diff options
| author | Alexander Amelkin <alexander@amelkin.msk.ru> | 2018-08-01 15:56:42 +0300 |
|---|---|---|
| committer | Alexander Amelkin <alexander@amelkin.msk.ru> | 2018-08-01 15:57:37 +0300 |
| commit | 29e7d26edbeb1c4e44effa1de2422c8c4380b05e (patch) | |
| tree | 7fbf9db25f580bb1e75f35d1b5a4de97cf237f69 | |
| parent | 7747d86cc4f717cd860075657018633089293481 (diff) | |
| download | ipmitool-29e7d26edbeb1c4e44effa1de2422c8c4380b05e.tar.gz | |
general: Add array_byteswap() to helper
Make unconditional array byte swapping publicly available
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
| -rw-r--r-- | include/ipmitool/helper.h | 1 | ||||
| -rw-r--r-- | lib/helper.c | 6 |
2 files changed, 4 insertions, 3 deletions
diff --git a/include/ipmitool/helper.h b/include/ipmitool/helper.h index 4eb5499..1f3ee3e 100644 --- a/include/ipmitool/helper.h +++ b/include/ipmitool/helper.h @@ -165,6 +165,7 @@ static inline void htoipmi32(uint32_t h, uint8_t *ipmi) ipmi[3] = (h >> 24) & 0xFF; /* MSB */ } +uint8_t *array_byteswap(uint8_t *buffer, size_t length); uint8_t *array_ntoh(uint8_t *buffer, size_t length); uint8_t *array_letoh(uint8_t *buffer, size_t length); diff --git a/lib/helper.c b/lib/helper.c index b932cd1..18acd47 100644 --- a/lib/helper.c +++ b/lib/helper.c @@ -231,7 +231,7 @@ void printbuf(const uint8_t * buf, int len, const char * desc) /* * Unconditionally reverse the order of arbitrarily long strings of bytes */ -static uint8_t *_ipmi_byteswap(uint8_t *buffer, size_t length) +uint8_t *array_byteswap(uint8_t *buffer, size_t length) { size_t i; uint8_t temp; @@ -254,7 +254,7 @@ uint8_t *array_ntoh(uint8_t *buffer, size_t length) return buffer; #else /* Little-endian host needs conversion from big-endian network */ - return _ipmi_byteswap(buffer, length); + return array_byteswap(buffer, length); #endif } @@ -263,7 +263,7 @@ uint8_t *array_letoh(uint8_t *buffer, size_t length) { #if WORDS_BIGENDIAN /* Big-endian host needs conversion from little-endian IPMI */ - return _ipmi_byteswap(buffer, length); + return array_byteswap(buffer, length); #else /* Little-endian host doesn't need conversion from little-endian IPMI */ return buffer; |
