sensorcommands: move get SDR alloc info & res dev SDR repo to new API

Rewrite "Get SDR allocinfo & resdevSDR repo" cmd to new IPMI prov API.

Tested:
1. verified ipmitool get SDR allocation info is same both before and
after the changes
2. verfied the reserve device SDR repo command
3. verified the reserve SDR command

Signed-off-by: jayaprakash Mutyala <mutyalax.jayaprakash@intel.com>
Change-Id: Ic933ef56117e502a6d65433e407a2d0f0b01288f
diff --git a/src/sensorcommands.cpp b/src/sensorcommands.cpp
index c8fef9c..b24ac7e 100644
--- a/src/sensorcommands.cpp
+++ b/src/sensorcommands.cpp
@@ -1101,65 +1101,48 @@
     return IPMI_CC_OK;
 }
 
-ipmi_ret_t ipmiStorageGetSDRAllocationInfo(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)
+/** @brief implements the get SDR allocation info command
+ *
+ *  @returns IPMI completion code plus response data
+ *   - allocUnits    - Number of possible allocation units
+ *   - allocUnitSize - Allocation unit size in bytes.
+ *   - allocUnitFree - Number of free allocation units
+ *   - allocUnitLargestFree - Largest free block in allocation units
+ *   - maxRecordSize    - Maximum record size in allocation units.
+ */
+ipmi::RspType<uint16_t, // allocUnits
+              uint16_t, // allocUnitSize
+              uint16_t, // allocUnitFree
+              uint16_t, // allocUnitLargestFree
+              uint8_t   // maxRecordSize
+              >
+    ipmiStorageGetSDRAllocationInfo()
 {
-    if (*dataLen)
-    {
-        *dataLen = 0;
-        return IPMI_CC_REQ_DATA_LEN_INVALID;
-    }
-    *dataLen = 0; // default to 0 in case of an error
-    GetAllocInfoResp *resp = static_cast<GetAllocInfoResp *>(response);
-
     // 0000h unspecified number of alloc units
-    resp->allocUnitsLSB = 0;
-    resp->allocUnitsMSB = 0;
+    constexpr uint16_t allocUnits = 0;
 
-    // max unit size is size of max record
-    resp->allocUnitSizeLSB = maxSDRTotalSize & 0xFF;
-    resp->allocUnitSizeMSB = maxSDRTotalSize >> 8;
-    // read only sdr, no free alloc blocks
-    resp->allocUnitFreeLSB = 0;
-    resp->allocUnitFreeMSB = 0;
-    resp->allocUnitLargestFreeLSB = 0;
-    resp->allocUnitLargestFreeMSB = 0;
+    constexpr uint16_t allocUnitFree = 0;
+    constexpr uint16_t allocUnitLargestFree = 0;
     // only allow one block at a time
-    resp->maxRecordSize = 1;
+    constexpr uint8_t maxRecordSize = 1;
 
-    *dataLen = sizeof(GetAllocInfoResp);
-
-    return IPMI_CC_OK;
+    return ipmi::responseSuccess(allocUnits, maxSDRTotalSize, allocUnitFree,
+                                 allocUnitLargestFree, maxRecordSize);
 }
 
-ipmi_ret_t ipmiStorageReserveSDR(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)
+/** @brief implements the reserve SDR command
+ *  @returns IPMI completion code plus response data
+ *   - sdrReservationID
+ */
+ipmi::RspType<uint16_t> ipmiStorageReserveSDR()
 {
-    printCommand(+netfn, +cmd);
-
-    if (*dataLen)
-    {
-        *dataLen = 0;
-        return IPMI_CC_REQ_DATA_LEN_INVALID;
-    }
-    *dataLen = 0; // default to 0 in case of an error
     sdrReservationID++;
     if (sdrReservationID == 0)
     {
         sdrReservationID++;
     }
-    *dataLen = 2;
-    auto resp = static_cast<uint8_t *>(response);
-    resp[0] = sdrReservationID & 0xFF;
-    resp[1] = sdrReservationID >> 8;
 
-    return IPMI_CC_OK;
+    return ipmi::responseSuccess(sdrReservationID);
 }
 
 ipmi::RspType<uint16_t,            // next record ID
@@ -1514,22 +1497,22 @@
         nullptr, ipmiStorageGetSDRRepositoryInfo, PRIVILEGE_USER);
 
     // <Get SDR Allocation Info>
-    ipmiPrintAndRegister(NETFUN_STORAGE,
-                         static_cast<ipmi_cmd_t>(
-                             IPMINetfnStorageCmds::ipmiCmdGetSDRAllocationInfo),
-                         nullptr, ipmiStorageGetSDRAllocationInfo,
-                         PRIVILEGE_USER);
+    ipmi::registerHandler(
+        ipmi::prioOemBase, NETFUN_STORAGE,
+        static_cast<ipmi::Cmd>(
+            IPMINetfnStorageCmds::ipmiCmdGetSDRAllocationInfo),
+        ipmi::Privilege::User, ipmiStorageGetSDRAllocationInfo);
 
     // <Reserve SDR Repo>
-    ipmiPrintAndRegister(NETFUN_SENSOR,
-                         static_cast<ipmi_cmd_t>(
-                             IPMINetfnSensorCmds::ipmiCmdReserveDeviceSDRRepo),
-                         nullptr, ipmiStorageReserveSDR, PRIVILEGE_USER);
+    ipmi::registerHandler(ipmi::prioOemBase, NETFUN_SENSOR,
+                          static_cast<ipmi::Cmd>(
+                              IPMINetfnSensorCmds::ipmiCmdReserveDeviceSDRRepo),
+                          ipmi::Privilege::User, ipmiStorageReserveSDR);
 
-    ipmiPrintAndRegister(
-        NETFUN_STORAGE,
-        static_cast<ipmi_cmd_t>(IPMINetfnStorageCmds::ipmiCmdReserveSDR),
-        nullptr, ipmiStorageReserveSDR, PRIVILEGE_USER);
+    ipmi::registerHandler(
+        ipmi::prioOemBase, NETFUN_STORAGE,
+        static_cast<ipmi::Cmd>(IPMINetfnStorageCmds::ipmiCmdReserveSDR),
+        ipmi::Privilege::User, ipmiStorageReserveSDR);
 
     // <Get Sdr>
     ipmi::registerHandler(