summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexander Amelkin <alexander@amelkin.msk.ru>2018-07-30 16:08:47 +0300
committerAlexander Amelkin <alexander@amelkin.msk.ru>2018-08-21 17:30:25 +0300
commitb44ec2fb65dfb115fc5485ea9eb7f0281cdb6a05 (patch)
treea308516cc9cc6b899f2737f03fd3560941723c75 /lib
parente9716e216d970b2c84eff5bde5802a05c202cacb (diff)
downloadipmitool-b44ec2fb65dfb115fc5485ea9eb7f0281cdb6a05.tar.gz
mc: guid: Fix byte ordering to follow IPMI spec
Before this commit the bytes for the GUID 'node' part were displayed in reverse order as if they were reported by BMC according to SMBIOS specification, not accordint to IPMI. The field order in guid_t was also specified according to RFC4122/SMBIOS, which is the reverse of IPMI specification. It has now been fixed. The time_low field of GUID was taken directly, without taking in account the ipmitool host endianness. It is now properly converted from IPMI little-endian to host byte order. Other GUID fields are also properly converted now. As of now, ipmitool does not generally work properly when built for a big-endian target, but that's out of scope of this commit. Please note that this commit most probably breaks the output of `ipmitool mc guid` with most existing BMC implementations, but that's just an indication of them being broken. A follow-up commit will re-add support for the broken behavior. Partially resolves ipmitool/ipmitool#25 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Diffstat (limited to 'lib')
-rw-r--r--lib/ipmi_mc.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/ipmi_mc.c b/lib/ipmi_mc.c
index ee75e95..34f9978 100644
--- a/lib/ipmi_mc.c
+++ b/lib/ipmi_mc.c
@@ -533,14 +533,21 @@ ipmi_mc_print_guid(struct ipmi_guid_t guid)
memset(tbuf, 0, 40);
struct tm *tm;
- /* Kipp - changed order of last field (node) to follow specification */
printf("System GUID : %08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x\n",
- guid.time_low, guid.time_mid, guid.time_hi_and_version,
- guid.clock_seq_hi_variant << 8 | guid.clock_seq_low,
- guid.node[0], guid.node[1], guid.node[2],
- guid.node[3], guid.node[4], guid.node[5]);
-
- s = (time_t)guid.time_low; /* Kipp - removed the BSWAP_32, it was not needed here */
+ /* We're displaying GUID as hex integers. Thus we need them to be
+ * in host byte order before we display them. However, according to
+ * IPMI 2.0, all GUID fields are in LSB first (Little Endian)
+ * format. Hence the ipmiXtoh() calls:
+ */
+ ipmi32toh(&guid.time_low),
+ ipmi16toh(&guid.time_mid),
+ ipmi16toh(&guid.time_hi_and_version),
+ ipmi16toh(&guid.clock_seq_variant),
+ /* The node part is shown as bytes, so no additional conversion */
+ guid.node[5], guid.node[4], guid.node[3],
+ guid.node[2], guid.node[1], guid.node[0]);
+
+ s = (time_t)ipmi32toh(&guid.time_low);
if(time_in_utc)
tm = gmtime(&s);
else