libpldm : Add decode API for QueryDeviceIdentifiers cmd

QueryDeviceIdentifiers command is used by update agent to obtain the
firmware identifiers for the firmware device and its defined in DSP0267
Version 1.1.0 sec:10.1.

Tested: Unit tests passed

Signed-off-by: gokulsanker <gokul.sanker.v.g@intel.com>
Change-Id: I9ef81ce75aaedaae2fff9f5632ce16aa952cda17
diff --git a/libpldm/tests/libpldm_firmware_update_test.cpp b/libpldm/tests/libpldm_firmware_update_test.cpp
index 8387b77..489be16 100644
--- a/libpldm/tests/libpldm_firmware_update_test.cpp
+++ b/libpldm/tests/libpldm_firmware_update_test.cpp
@@ -20,3 +20,45 @@
     EXPECT_EQ(requestPtr->hdr.type, PLDM_FWUP);

     EXPECT_EQ(requestPtr->hdr.command, PLDM_QUERY_DEVICE_IDENTIFIERS);

 }

+

+TEST(QueryDeviceIdentifiers, goodPathDecodeResponse)

+{

+    // descriptorDataLen is not fixed here taking it as 6

+    constexpr uint8_t descriptorDataLen = 6;

+    std::array<uint8_t, hdrSize +

+                            sizeof(struct pldm_query_device_identifiers_resp) +

+                            descriptorDataLen>

+        responseMsg{};

+    auto inResp = reinterpret_cast<struct pldm_query_device_identifiers_resp*>(

+        responseMsg.data() + hdrSize);

+

+    inResp->completion_code = PLDM_SUCCESS;

+    inResp->device_identifiers_len = htole32(descriptorDataLen);

+    inResp->descriptor_count = 1;

+

+    // filling descriptor data

+    std::fill_n(responseMsg.data() + hdrSize +

+                    sizeof(struct pldm_query_device_identifiers_resp),

+                descriptorDataLen, 0xFF);

+

+    auto response = reinterpret_cast<pldm_msg*>(responseMsg.data());

+    uint8_t completionCode = PLDM_SUCCESS;

+    uint32_t deviceIdentifiersLen = 0;

+    uint8_t descriptorCount = 0;

+    uint8_t* outDescriptorData = nullptr;

+

+    auto rc = decode_query_device_identifiers_resp(

+        response, responseMsg.size() - hdrSize, &completionCode,

+        &deviceIdentifiersLen, &descriptorCount, &outDescriptorData);

+

+    EXPECT_EQ(rc, PLDM_SUCCESS);

+    EXPECT_EQ(completionCode, PLDM_SUCCESS);

+    EXPECT_EQ(deviceIdentifiersLen, inResp->device_identifiers_len);

+    EXPECT_EQ(descriptorCount, inResp->descriptor_count);

+    EXPECT_EQ(true,

+              std::equal(outDescriptorData,

+                         outDescriptorData + deviceIdentifiersLen,

+                         responseMsg.begin() + hdrSize +

+                             sizeof(struct pldm_query_device_identifiers_resp),

+                         responseMsg.end()));

+}