mirror of
https://github.com/ipmitool/ipmitool.git
synced 2026-06-03 20:51:36 +00:00
lanplus: Make byteswapping generic
Get rid of lanplus-specific yet very generic in nature lanplus_swap() function that unconditionally swaps bytes in an arbitrary byte array. Move it to helper module and add two conditionally working interfaces to it: - array_ntoh() for network (BE) to host conversion, and - array_letoh() for ipmi (LE) to host conversion. The added functions will only perform byte swapping if the target architecture differs in endianness from the data source. array_ntoh() will only do swap on LE machines, while array_letoh() will only do it on BE ones. These functions are introduced for future use in other places of ipmitool. Partially resolves ipmitool/ipmitool#26 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
This commit is contained in:
@@ -165,6 +165,9 @@ static inline void htoipmi32(uint32_t h, uint8_t *ipmi)
|
||||
ipmi[3] = (h >> 24) & 0xFF; /* MSB */
|
||||
}
|
||||
|
||||
uint8_t *array_ntoh(uint8_t *buffer, size_t length);
|
||||
uint8_t *array_letoh(uint8_t *buffer, size_t length);
|
||||
|
||||
#define ipmi_open_file_read(file) ipmi_open_file(file, 0)
|
||||
#define ipmi_open_file_write(file) ipmi_open_file(file, 1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user