dmi_checksum_calc
Synopsis
#include <opendmi/utils.h>
bool dmi_checksum_calc(const void *data, size_t length, uint8_t *pchecksum);
bool dmi_checksum_test(const void *data, size_t length);
Description
SMBIOS protects its entry points with an 8-bit checksum: the bytes of the data, the checksum byte included, add up to zero modulo 256.
The dmi_checksum_calc function computes the checksum of the length bytes
at data, that is the value which brings their sum to zero modulo 256, and
stores it in the variable pchecksum points to. The
checksum byte within the data is counted as any other byte, so it is set to
zero before the checksum is computed.
The dmi_checksum_test function tells whether the length bytes at data
add up to zero modulo 256, i.e. whether the checksum they hold is valid.
Return value
The dmi_checksum_calc function returns true if the checksum has been
computed, and false if data or pchecksum is nullptr, in which case
the variable is left as it is. The checksum of zero bytes is zero.
The dmi_checksum_test function returns true if the bytes add up to zero,
which they do when length is zero, and false otherwise, or if data is
nullptr.
Errors
DMI_ERROR_ARGUMENT_NULL-
Raised if
dataorpchecksumisnullptr. The functions take no context, so the error reaches no error queue.