libfru 3.0.2.gb79b203
FRU Manupulation Library
|
Header for FRU information helper functions. More...
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
Go to the source code of this file.
Data Structures | |
struct | fru_field_t |
A generic input (decoded) field structure. More... | |
struct | fru_chassis_t |
The exploded representation of chassis info area. More... | |
struct | fru_board_t |
The exploded representation of board info area. More... | |
struct | fru_product_t |
The exploded representation of product info area. More... | |
struct | fru_t |
Exploded/decoded FRU data structure. More... | |
struct | fru_mr_rec_t |
MultiRecord area record type. More... | |
Macros | |
#define | LIBFRU_MAJOR |
Major component of the library version. | |
#define | LIBFRU_MINOR |
Minor component of the library version. | |
#define | LIBFRU_SUBMINOR |
Subminor component of the library version. | |
#define | LIBFRU_VERSION |
Integer representation of the library version. | |
#define | FRU_MAX(a, b) |
Return the maximum of a and b. | |
#define | FRU_MIN(a, b) |
Return the minimum of a and b. | |
#define | FRU_FIELDMAXARRAY |
For C-string allocation. | |
#define | FRU_INFO_AREAS |
Number of standard 'info' areas. | |
#define | FRU_FIRST_INFO_AREA |
Index of the first 'info' area. | |
#define | FRU_LAST_INFO_AREA |
Index of the first 'info' area. | |
#define | FRU_IS_INFO_AREA(atype) |
Check if atype is an information area type. | |
#define | FRU_ATYPE_TO_INFOIDX(atype) |
Convert an area type atype into an information area index or to -1 if atype is not an info area type. | |
#define | FRU_INFOIDX_TO_ATYPE(idx) |
Convert an info area index idx into a full-range area type or to (fru_area_type_t)(-1) if idx was invalid. | |
#define | FRU_INFOIDX(a) |
Get the info area index from an area type enum name. | |
#define | FRU_FOREACH_INFOIDX(it) |
Iterate through all info area indices using it as an iterator. | |
#define | FRU_REAL_FE(t) |
Convert a fru_field_enc_t value to an index to a FRU_FE_REALCOUNT-sized array. | |
#define | FRU_FE_FROMREAL(t) |
Convert an index to a FRU_FE_REALCOUNT-sized array to a fru_field_enc_t value. | |
#define | FRU_FE_IS_REAL(t) |
Check if t is a 'real' encoding type? (One that is defined by FRU specification) | |
#define | FRU_FIELD_IS_REAL_ENC(f) |
Check if field f is non-NULL and has a real encoding. | |
#define | FRU_FIELD_IS_AUTO_ENC(f) |
Check if field f is non-NULL and has an auto encoding. | |
#define | FRU_MAX_FIELD_COUNT |
Max mandatory field count among all info areas. | |
#define | FRU_IS_VALID_AREA(atype) |
Check if atype is any valid area type. | |
#define | FRU_FOREACH_AREA(it) |
Iterate through all area types using it as an iterator. | |
#define | FRU_ATYPE_HAS_TYPE(atype) |
Check if the area has a 'type' field. | |
#define | FRU_ATYPE_HAS_LANG(atype) |
Check if the area has a 'lang' field. | |
#define | FRU_ARRAY_SZ(a) |
A convenience macro to get the size of an array in elements. | |
#define | FRU_LIST_HEAD |
Add entry at the head of the list, used by fru_add_mr() and alike. | |
#define | FRU_LIST_TAIL |
Add entry at the end of the list, used by fru_add_mr() and alike. | |
#define | FRU_IS_APOS_VALID(pos) |
#define | fru_free(fru) |
Deallocate a dynamically allocated fru structure. | |
#define | FRU_MR_IS_VALID_TYPE(t) |
The FRU_MR_RAW is not considered a valid type, must be checked separately. | |
#define | FRU_MR_OEM_COUNT |
The total number of possible OEM types to Multirecord area records. | |
#define | FRU_MR_OEM(n) |
An OEM Multirecord area type, make sure that n is less than FRU_MR_OEM_COUNT. | |
#define | FRU_MRR_OEM_MAXDATA |
Maximum length of OEM MR record data in decoded form (NUL-terminated hex string) | |
#define | FRU_MRR_RAW_MAXDATA |
Maximum length of Custom/Raw MR record data in decoded form (NUL-terminated hex string) | |
#define | FRU_MR_MGMT_IS_SUBTYPE_VALID(mt) |
Is the MR management access record subtype mt valid? | |
#define | FRU_MR_MGMT_SUBTYPE_TO_IDX(mt) |
Convert a valid MR Management Access Record subtype into a 0-based index or into -1 if mt is not a valid subtype. | |
#define | FRU_MR_MGMT_IDX_TO_SUBTYPE(i) |
Convert a valid 0-based index into an MR Management Access Record subtype or to FRU_MR_MGMT_INVALID if the result would not be a valid subtype. | |
#define | FRU_MR_MGMT_MAXDATA |
Maximum length of data in MR Management Access record. | |
Typedefs | |
typedef void * | fru_custom_t |
A list of custom fields of an info area. | |
typedef void * | fru_mr_t |
A pointer to multi-record area descriptor. | |
Functions | |
bool | fru_setfield (fru_field_t *field, fru_field_enc_t encoding, const char *string) |
Copy string to the given field, perform length check according to selected encoding, truncate if needed. | |
bool | fru_setfield_binary (fru_field_t *field, const void *buf, size_t size) |
Copy a binary input buffer into the given field, perform length check, truncate if needed. | |
fru_field_t * | fru_getfield (const fru_t *fru, fru_area_type_t atype, size_t index) |
Get a pointer to a mandatory field in the info area of the given type in the given fru structure. | |
fru_field_t * | fru_add_custom (fru_t *fru, fru_area_type_t atype, size_t index, fru_field_enc_t encoding, const char *string) |
Add a custom field to the given area type in the given fru structure. | |
fru_field_t * | fru_get_custom (const fru_t *fru, fru_area_type_t atype, size_t index) |
Get a pointer to a custom data field in the area of the given type in the given fru structure. | |
bool | fru_delete_custom (fru_t *fru, fru_area_type_t atype, size_t index) |
Delete a custom data field in the area of the given type in the given fru structure. | |
int16_t | fru_hex2byte (const char *hex) |
Convert 2 first bytes of hex string into a binary byte. | |
fru_t * | fru_init (fru_t *fru) |
Initialize/allocate a fru structure. | |
fru_t * | fru_loadfile (fru_t *fru, const char *filename, fru_flags_t flags) |
Load FRU information from a binary file. | |
fru_t * | fru_loadbuffer (fru_t *fru, const void *buf, size_t size, fru_flags_t flags) |
Load FRU information from a binary file. | |
void | fru_wipe (fru_t *fru) |
Wipe the contents of a fru_t structure. | |
bool | fru_enable_area (fru_t *fru, fru_area_type_t area, fru_area_position_t after) |
Enable a previously disabled / non-present area. | |
bool | fru_disable_area (fru_t *fru, fru_area_type_t atype) |
Disable a previously enabled / present area. | |
bool | fru_move_area (fru_t *fru, fru_area_type_t area, fru_area_position_t after) |
Move an enabled/present area. | |
bool | fru_savebuffer (void **bufptr, size_t *size, const fru_t *fru) |
Encode a FRU info structure into a binary buffer. | |
bool | fru_savefile (const char *fname, const fru_t *fru) |
Encode a FRU info structure into a binary file. | |
fru_mr_rec_t * | fru_add_mr (fru_t *fru, size_t index, fru_mr_rec_t *rec) |
Add a multirecord area record. | |
fru_mr_rec_t * | fru_get_mr (const fru_t *fru, size_t index) |
Get a multirecord area record at the given index. | |
fru_mr_rec_t * | fru_find_mr (const fru_t *fru, fru_mr_type_t type, size_t *index) |
Find a multirecord area record of the given type or at the given index. | |
bool | fru_replace_mr (fru_t *fru, size_t index, fru_mr_rec_t *rec) |
Replace a multirecord area record at the given index. | |
bool | fru_delete_mr (fru_t *fru, size_t index) |
Delete a multirecord area record at the given index. | |
bool | fru_set_internal_binary (fru_t *fru, const void *buffer, size_t size) |
Set internal use area from binary buffer. | |
bool | fru_set_internal_hexstring (fru_t *fru, const void *hexstr) |
Set internal use area from a hex string. | |
bool | fru_delete_internal (fru_t *fru) |
Delete internal use area from FRU structure. | |
Header for FRU information helper functions.
SPDX-License-Identifier: GPL-2.0-or-later OR Apache-2.0
#define FRU_FIELDMAXARRAY |
For C-string allocation.
You probably don't need to directly use this, prefer using fru_field_t
type:
Better yet, use fru_set_field() that performs the required checks itself.
#define FRU_MAX | ( | a, | |
b | |||
) |
Return the maximum of a and b.
#define FRU_MIN | ( | a, | |
b | |||
) |
Return the minimum of a and b.