storagehandler: move get FRU area info to new API

Rewritten "Get FRU inventory area info" command to use
the newly introduced IPMI provider API.

Tested:
Unable to verify as command was returning error
earlier too.

Change-Id: I535e1d5c41a1e0dc253148bc52df5f22b70b4330
Signed-off-by: Pradeep Kumar <pradeep1x.kumar@intel.com>
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
diff --git a/storagehandler.cpp b/storagehandler.cpp
index 95a72e4..6f20835 100644
--- a/storagehandler.cpp
+++ b/storagehandler.cpp
@@ -651,43 +651,35 @@
     return rc;
 }
 
-// Read FRU info area
-ipmi_ret_t ipmi_storage_get_fru_inv_area_info(
-    ipmi_netfn_t netfn, ipmi_cmd_t cmd, ipmi_request_t request,
-    ipmi_response_t response, ipmi_data_len_t data_len, ipmi_context_t context)
+/** @brief implements the get FRU Inventory Area Info command
+ *
+ *  @returns IPMI completion code plus response data
+ *   - FRU Inventory area size in bytes,
+ *   - access bit
+ **/
+ipmi::RspType<uint16_t, // FRU Inventory area size in bytes,
+              uint8_t   // access size (bytes / words)
+              >
+    ipmiStorageGetFruInvAreaInfo(uint8_t fruID)
 {
-    ipmi_ret_t rc = IPMI_CC_OK;
-    const FruInvenAreaInfoRequest* reqptr =
-        reinterpret_cast<const FruInvenAreaInfoRequest*>(request);
 
-    auto iter = frus.find(reqptr->fruID);
+    auto iter = frus.find(fruID);
     if (iter == frus.end())
     {
-        *data_len = 0;
-        return IPMI_CC_SENSOR_INVALID;
+        return ipmi::responseSensorInvalid();
     }
 
     try
     {
-        const auto& fruArea = getFruAreaData(reqptr->fruID);
-        auto size = static_cast<uint16_t>(fruArea.size());
-        FruInvenAreaInfoResponse resp;
-        resp.sizems = size >> 8;
-        resp.sizels = size;
-        resp.access = static_cast<uint8_t>(AccessMode::bytes);
-
-        *data_len = sizeof(resp);
-
-        // Pack the actual response
-        std::memcpy(response, &resp, *data_len);
+        return ipmi::responseSuccess(
+            static_cast<uint16_t>(getFruAreaData(fruID).size()),
+            static_cast<uint8_t>(AccessMode::bytes));
     }
     catch (const InternalFailure& e)
     {
-        rc = IPMI_CC_UNSPECIFIED_ERROR;
-        *data_len = 0;
         log<level::ERR>(e.what());
+        return ipmi::responseUnspecifiedError();
     }
-    return rc;
 }
 
 // Read FRU data
@@ -810,9 +802,9 @@
                           clearSEL);
 
     // <Get FRU Inventory Area Info>
-    ipmi_register_callback(NETFUN_STORAGE, IPMI_CMD_GET_FRU_INV_AREA_INFO, NULL,
-                           ipmi_storage_get_fru_inv_area_info,
-                           PRIVILEGE_OPERATOR);
+    ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnStorage,
+                          ipmi::storage::cmdGetFruInventoryAreaInfo,
+                          ipmi::Privilege::User, ipmiStorageGetFruInvAreaInfo);
 
     // <Add READ FRU Data
     ipmi_register_callback(NETFUN_STORAGE, IPMI_CMD_READ_FRU_DATA, NULL,
diff --git a/storagehandler.hpp b/storagehandler.hpp
index bcc6c7d..4754bf6 100644
--- a/storagehandler.hpp
+++ b/storagehandler.hpp
@@ -57,24 +57,6 @@
 } __attribute__((packed));
 
 /**
- * @struct Get FRU inventory area info command request data
- */
-struct FruInvenAreaInfoRequest
-{
-    uint8_t fruID; ///< FRU Device ID. FFH = reserved.
-} __attribute__((packed));
-
-/**
- * @struct Get FRU inventory area info command response
- */
-struct FruInvenAreaInfoResponse
-{
-    uint8_t sizels; ///< Fru Inventory area size in bytes, LS Byte
-    uint8_t sizems; ///< Fru Inventory are size in bytes, MS Byte
-    uint8_t access; ///< 0b Devices is accessed by bytes, 1b - by words
-} __attribute__((packed));
-
-/**
  * @struct Get Repository info command response
  */
 struct GetRepositoryInfoResponse