diff options
author | Alexander Amelkin <alexander@amelkin.msk.ru> | 2018-07-26 19:40:44 +0300 |
---|---|---|
committer | Alexander Amelkin <alexander@amelkin.msk.ru> | 2018-11-07 18:11:58 +0300 |
commit | f0d5c17ea7b2b5b815f24b101d35ddda1a88d8a4 (patch) | |
tree | e4e79eba9b70161f8242638e539acf3ad211005b /lib/ipmi_chassis.c | |
parent | a4ac8ce4ab9a013ff0a12f0ea604eaf09af7d8bf (diff) | |
download | ipmitool-f0d5c17ea7b2b5b815f24b101d35ddda1a88d8a4.tar.gz |
Refactor timestamp handling
Handle all date/time stamps uniformly, taking in account the host
endianness. Respect the local time zone and the '-Z' option for
all ipmitool commands. Unify the date and time formatting.
Add correct handling of IPMI timestamps 'since system startup'
and for 'unspecified' timestamps.
Partially resolves ipmitool/ipmitool#23
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Diffstat (limited to 'lib/ipmi_chassis.c')
-rw-r--r-- | lib/ipmi_chassis.c | 33 |
1 files changed, 4 insertions, 29 deletions
diff --git a/lib/ipmi_chassis.c b/lib/ipmi_chassis.c index c251cfc..fba6b0b 100644 --- a/lib/ipmi_chassis.c +++ b/lib/ipmi_chassis.c @@ -42,6 +42,7 @@ #include <ipmitool/ipmi_intf.h> #include <ipmitool/ipmi_strings.h> #include <ipmitool/ipmi_chassis.h> +#include <ipmitool/ipmi_time.h> extern int verbose; @@ -699,45 +700,19 @@ ipmi_chassis_get_bootparam(struct ipmi_intf * intf, char * arg) case 6: { unsigned long session_id; - unsigned long timestamp; - char time_buf[40]; - time_t out_time; - struct tm *strtm; + uint32_t timestamp; session_id = ((unsigned long) rsp->data[3]); session_id |= (((unsigned long) rsp->data[4])<<8); session_id |= (((unsigned long) rsp->data[5])<<16); session_id |= (((unsigned long) rsp->data[6])<<24); - timestamp = ((unsigned long) rsp->data[7]); - timestamp |= (((unsigned long) rsp->data[8])<<8); - timestamp |= (((unsigned long) rsp->data[9])<<16); - timestamp |= (((unsigned long) rsp->data[10])<<24); - - memset(time_buf, 0, 40); - if(time_in_utc) - strtm = gmtime(&out_time); - else - strtm = localtime(&out_time); - - strftime( - time_buf, - sizeof(time_buf), - "%m/%d/%Y %H:%M:%S", strtm - ); + timestamp = ipmi32toh(&rsp->data[7]); printf(" Boot Initiator Info :\n"); printf(" Channel Number : %d\n", (rsp->data[2] & 0x0f)); printf(" Session Id : %08lXh\n",session_id); - if(timestamp != 0) - { - printf(" Timestamp : %08lXh, %s\n",timestamp,time_buf); - } - else - { - printf(" Timestamp : %08lXh, undefined\n",timestamp); - } - + printf(" Timestamp : %s\n", ipmi_timestamp_numeric(timestamp)); } break; case 7: |