mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 10:37:22 +00:00
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:
parent
7747d86cc4
commit
29e7d26edb
@ -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);
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user