From c9510635d777c6d231dbca91af527bd3afdafdd7 Mon Sep 17 00:00:00 2001 From: Alexander Amelkin Date: Mon, 27 May 2019 20:07:58 +0300 Subject: [PATCH] Add a helper htoipmi24() function The function converts a host 32-bit integer into an IPMI 24-bit value (LSB first). Signed-off-by: Alexander Amelkin --- include/ipmitool/helper.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/ipmitool/helper.h b/include/ipmitool/helper.h index ccb538c..1da83fb 100644 --- a/include/ipmitool/helper.h +++ b/include/ipmitool/helper.h @@ -169,6 +169,13 @@ static inline uint32_t ipmi24toh(void *ipmi24) return h; } +static inline void htoipmi24(uint32_t h, uint8_t *ipmi) +{ + ipmi[0] = h & 0xFF; /* LSB */ + ipmi[1] = (h >> 8) & 0xFF; + ipmi[2] = (h >> 16) & 0xFF; /* MSB */ +} + static inline uint32_t ipmi32toh(void *ipmi32) { uint8_t *ipmi = ipmi32;