Add Get SEL Time UTC Offset function
The current ipmi does not support the time zone acquisition command.
This command is a standard ipmi command. In the ipmi specification,
the corresponding NetFn=0x0A and Cmd=0x5C.
Returns the offset in minutes from UTC to SEL (local) time.
The offset is a 16 bit signed integer with two complements.
LS byte comes first.
(Range from - 1440 to 1440)
tested:
When the current time zone is East Zone 8,
ipmitool raw 0x0A 0x5C
e0 01
Signed-off-by: Xiaochao Ma <maxiaochao@inspur.com>
Change-Id: I74edfe4f18201bec801b021e69a88231e51473a5
diff --git a/host-ipmid-whitelist.conf b/host-ipmid-whitelist.conf
index 5397115..9dd1eb1 100644
--- a/host-ipmid-whitelist.conf
+++ b/host-ipmid-whitelist.conf
@@ -40,6 +40,7 @@
0x0A:0x44 //<Storage>:<Add SEL Entry>
0x0A:0x48 //<Storage>:<Get SEL Time>
0x0A:0x49 //<Storage>:<Set SEL Time>
+0x0A:0x5C //<Storage>:<Get SEL Time UTC Offset>
0x0C:0x02 //<Transport>:<Get LAN Configuration Parameters>
0x2C:0x00 //<Group Extension>:<Group Extension Command>
0x2C:0x01 //<Group Extension>:<Get DCMI Capabilities>
diff --git a/storagehandler.cpp b/storagehandler.cpp
index d12fb3b..cf5ef5e 100644
--- a/storagehandler.cpp
+++ b/storagehandler.cpp
@@ -629,6 +629,26 @@
return ipmi::responseSuccess();
}
+/** @brief implements the get SEL timezone command
+ * @returns IPMI completion code plus response data
+ * -current timezone
+ */
+ipmi::RspType<int16_t> ipmiStorageGetSelTimeUtcOffset()
+{
+ time_t timep;
+ struct tm* gmTime;
+ struct tm* localTime;
+
+ time(&timep);
+ localTime = localtime(&timep);
+ auto validLocalTime = mktime(localTime);
+ gmTime = gmtime(&timep);
+ auto validGmTime = mktime(gmTime);
+ auto timeEquation = (validLocalTime - validGmTime) / 60;
+
+ return ipmi::responseSuccess(timeEquation);
+}
+
/** @brief implements the reserve SEL command
* @returns IPMI completion code plus response data
* - SEL reservation ID.
@@ -878,6 +898,12 @@
ipmi::storage::cmdSetSelTime,
ipmi::Privilege::Operator, ipmiStorageSetSelTime);
+ // <Get SEL Timezone>
+ ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
+ ipmi::storage::cmdGetSelTimeUtcOffset,
+ ipmi::Privilege::User,
+ ipmiStorageGetSelTimeUtcOffset);
+
// <Get SEL Entry>
ipmi_register_callback(NETFUN_STORAGE, IPMI_CMD_GET_SEL_ENTRY, NULL,
getSELEntry, PRIVILEGE_USER);