dmi_entity_info

Synopsis

#include <opendmi/entity.h>

void *dmi_entity_info(const dmi_entity_t *entity, const dmi_type_t *type);

Description

The dmi_entity_info function returns a pointer to the decoded structure descriptor for the given entity. The entity type is verified against the expected type parameter before returning the data.

The returned pointer should be cast to the appropriate type-specific structure (e.g., dmi_cooling_device_t * for cooling device entities). The entity must have been previously decoded with dmi_entity_decode.

The type is the structure type of the specification the structure is decoded by, see dmi_type, rather than the number the structure is found at. Some vendors place structures defined by others at type numbers of their own, e.g. Dell moves Intel reference code structures 16 types down, and such a structure is still of the type of its original specification, since its data is laid out as that type expects, while dmi_entity_type_id returns the type number found in the table. Structures of different types sharing a type number, e.g. Intel vPro information and Lenovo ThinkVantage Technologies enablement, are told apart, so the pointer returned is always of the C type of type.

Parameters

entity

Entity descriptor.

type

Expected structure type, e.g. DMI_TYPE(cooling_device). If the entity is not of this type, the function returns nullptr and raises an error. Pass DMI_TYPE_ANY to skip type checking.

Return value

Returns a pointer to the decoded structure descriptor. Returns nullptr if entity is nullptr, the entity has not been decoded, or the entity type does not match type.

Errors

DMI_ERROR_ENTITY_TYPE_INVALID

Structure is not of type type.

Examples

dmi_entity_t *entity;
dmi_cooling_device_t *info;

info = dmi_entity_info(entity, DMI_TYPE(cooling_device));
if (info != nullptr) {
    printf("type: %s\n", dmi_cooling_device_type_name(info->type));
    printf("status: %s\n", dmi_status_name(info->status));
}