general: Add array_byteswap() to helper

Make unconditional array byte swapping publicly available

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
This commit is contained in:
Alexander Amelkin 2018-08-01 15:56:42 +03:00
parent 7747d86cc4
commit 29e7d26edb
No known key found for this signature in database
GPG Key ID: E893587B5B74178D
2 changed files with 4 additions and 3 deletions

View File

@ -165,6 +165,7 @@ static inline void htoipmi32(uint32_t h, uint8_t *ipmi)
ipmi[3] = (h >> 24) & 0xFF; /* MSB */ 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_ntoh(uint8_t *buffer, size_t length);
uint8_t *array_letoh(uint8_t *buffer, size_t length); uint8_t *array_letoh(uint8_t *buffer, size_t length);

View File

@ -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 * 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; size_t i;
uint8_t temp; uint8_t temp;
@ -254,7 +254,7 @@ uint8_t *array_ntoh(uint8_t *buffer, size_t length)
return buffer; return buffer;
#else #else
/* Little-endian host needs conversion from big-endian network */ /* Little-endian host needs conversion from big-endian network */
return _ipmi_byteswap(buffer, length); return array_byteswap(buffer, length);
#endif #endif
} }
@ -263,7 +263,7 @@ uint8_t *array_letoh(uint8_t *buffer, size_t length)
{ {
#if WORDS_BIGENDIAN #if WORDS_BIGENDIAN
/* Big-endian host needs conversion from little-endian IPMI */ /* Big-endian host needs conversion from little-endian IPMI */
return _ipmi_byteswap(buffer, length); return array_byteswap(buffer, length);
#else #else
/* Little-endian host doesn't need conversion from little-endian IPMI */ /* Little-endian host doesn't need conversion from little-endian IPMI */
return buffer; return buffer;