oemcommands: move GetLedStatus to new API
Rewrite "GetLedStatus" command to use the newly introduced IPMI
provider API.
Tested:
verified using ipmitool raw commands.
Command: ipmitool raw 0x30 0xB0 //get led status
Response: 10
Signed-off-by: NITIN SHARMA <nitin1x.sharma@intel.com>
Signed-off-by: jayaprakash Mutyala <mutyalax.jayaprakash@intel.com>
Change-Id: I7dcdc794f03ed585c51331c3117a7828a3030690
diff --git a/src/oemcommands.cpp b/src/oemcommands.cpp
index b87a2ab..7adb36a 100644
--- a/src/oemcommands.cpp
+++ b/src/oemcommands.cpp
@@ -1232,48 +1232,24 @@
return 0;
}
-ipmi_ret_t ipmiOEMGetLEDStatus(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
- ipmi_request_t request, ipmi_response_t response,
- ipmi_data_len_t dataLen, ipmi_context_t context)
+ipmi::RspType<uint8_t> ipmiOEMGetLEDStatus()
{
- uint8_t* resp = reinterpret_cast<uint8_t*>(response);
- // LED Status
- //[1:0] = Reserved
- //[3:2] = Status(Amber)
- //[5:4] = Status(Green)
- //[7:6] = System Identify
- // Status definitions:
- // 00b = Off
- // 01b = Blink
- // 10b = On
- // 11b = invalid
- if (*dataLen != 0)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "oem_get_led_status: invalid input len!");
- *dataLen = 0;
- return IPMI_CC_REQ_DATA_LEN_INVALID;
- }
-
+ uint8_t ledstate = 0;
phosphor::logging::log<phosphor::logging::level::DEBUG>("GET led status");
- *resp = 0;
- *dataLen = 0;
std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
for (auto it = ledAction::offsetObjPath.begin();
it != ledAction::offsetObjPath.end(); ++it)
{
uint8_t state = 0;
- if (-1 == getLEDState(*dbus, ledIntf, it->second, state))
+ if (getLEDState(*dbus, ledIntf, it->second, state) == -1)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"oem_get_led_status: fail to get ID LED status!");
- return IPMI_CC_UNSPECIFIED_ERROR;
+ return ipmi::responseUnspecifiedError();
}
- *resp |= state << it->first;
+ ledstate |= state << it->first;
}
-
- *dataLen = sizeof(*resp);
- return IPMI_CC_OK;
+ return ipmi::responseSuccess(ledstate);
}
ipmi_ret_t ipmiOEMCfgHostSerialPortSpeed(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
@@ -3655,8 +3631,9 @@
intel::general::cmdSetSecurityMode, Privilege::Admin,
ipmiSetSecurityMode);
- ipmiPrintAndRegister(intel::netFnGeneral, intel::general::cmdGetLEDStatus,
- NULL, ipmiOEMGetLEDStatus, PRIVILEGE_ADMIN);
+ registerHandler(prioOemBase, intel::netFnGeneral,
+ intel::general::cmdGetLEDStatus, Privilege::Admin,
+ ipmiOEMGetLEDStatus);
ipmiPrintAndRegister(ipmi::intel::netFnPlatform,
ipmi::intel::platform::cmdCfgHostSerialPortSpeed, NULL,