From 29e7d26edbeb1c4e44effa1de2422c8c4380b05e Mon Sep 17 00:00:00 2001 From: Alexander Amelkin Date: Wed, 1 Aug 2018 15:56:42 +0300 Subject: [PATCH] general: Add array_byteswap() to helper Make unconditional array byte swapping publicly available Signed-off-by: Alexander Amelkin --- include/ipmitool/helper.h | 1 + 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;