Adding support for GetFruRecordTableMetadata FRU command type in pldmtool.

./pldmtool -h
PLDM requester tool for OpenBMC
Usage: ./pldmtool [OPTIONS] SUBCOMMAND

Options:
  -h,--help                   Print this help message and exit

Subcommands:
  raw                         send a raw request and print response
  base                        base type command
  fru                         fru type command
root@wspooncap07a-Y110UF8B9009:/tmp# ./pldmtool fru -h
fru type command
Usage: ./pldmtool fru [OPTIONS] SUBCOMMAND

Options:
  -h,--help                   Print this help message and exit

Subcommands:
  GetFruRecordTableMetadata   get fru record table metadata

./pldmtool fru -h
fru type command
Usage: ./pldmtool fru [OPTIONS] SUBCOMMAND

Options:
  -h,--help                   Print this help message and exit

Subcommands:
  GetFruRecordTableMetadata   get fru record table metadata

./pldmtool fru GetFruRecordTableMetadata
Encode request successfully
Request Message:
08 01 80 04 01
Success in creating the socket : RC = 3
Success in connecting to socket : RC = 0
Success in sending message type as pldm to mctp : RC = 0
Write to socket successful : RC = 5
Total length:5
Loopback response message:
08 01 80 04 01
On first recv(),response == request : RC = 0
Total length: 24
Shutdown Socket successful :  RC = 0
Response Message:
08 01 00 04 01 00 01 00 ff ff ff ff 3c 00 00 00 01 00 01 00 a7 c3 c7 98
Parsed Response Msg :
FRUDATAMajorVersion : 1
FRUDATAMinorVersion : 0
FRUTableMaximumSize : 4294967295
FRUTableLength : 60
Total number of Record Set Identifiers in table : 1
Total number of records in table :  1
FRU DATAStructureTableIntegrityChecksum :  2563228583

Signed-off-by: Sridevi Ramesh <sridevra@in.ibm.com>
Change-Id: I4396ff72418730bb8c0920f5f20688a28544b4cc
diff --git a/tool/pldm_fru_cmd.cpp b/tool/pldm_fru_cmd.cpp
new file mode 100644
index 0000000..e1cf800
--- /dev/null
+++ b/tool/pldm_fru_cmd.cpp
@@ -0,0 +1,90 @@
+#include "pldm_fru_cmd.hpp"
+
+#include "pldm_cmd_helper.hpp"
+
+namespace pldmtool
+{
+
+namespace fru
+{
+
+namespace
+{
+
+using namespace pldmtool::helper;
+
+std::vector<std::unique_ptr<CommandInterface>> commands;
+
+} // namespace
+
+class GetFruRecordTableMetadata : public CommandInterface
+{
+  public:
+    ~GetFruRecordTableMetadata() = default;
+    GetFruRecordTableMetadata() = delete;
+    GetFruRecordTableMetadata(const GetFruRecordTableMetadata&) = delete;
+    GetFruRecordTableMetadata(GetFruRecordTableMetadata&&) = default;
+    GetFruRecordTableMetadata&
+        operator=(const GetFruRecordTableMetadata&) = delete;
+    GetFruRecordTableMetadata& operator=(GetFruRecordTableMetadata&&) = default;
+
+    using CommandInterface::CommandInterface;
+
+    std::pair<int, std::vector<uint8_t>> createRequestMsg() override
+    {
+        std::vector<uint8_t> requestMsg(sizeof(pldm_msg_hdr));
+        auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
+
+        auto rc = encode_get_fru_record_table_metadata_req(
+            PLDM_LOCAL_INSTANCE_ID, request);
+        return {rc, requestMsg};
+    }
+
+    void parseResponseMsg(pldm_msg* responsePtr, size_t payloadLength) override
+    {
+        uint8_t cc = 0;
+        uint8_t fru_data_major_version, fru_data_minor_version;
+        uint32_t fru_table_maximum_size, fru_table_length;
+        uint16_t total_record_set_identifiers, total_table_records;
+        uint32_t checksum;
+
+        auto rc = decode_get_fru_record_table_metadata_resp(
+            responsePtr, payloadLength, &cc, &fru_data_major_version,
+            &fru_data_minor_version, &fru_table_maximum_size, &fru_table_length,
+            &total_record_set_identifiers, &total_table_records, &checksum);
+        if (rc != PLDM_SUCCESS || cc != PLDM_SUCCESS)
+        {
+            std::cerr << "Response Message Error: "
+                      << "rc=" << rc << ",cc=" << (int)cc << std::endl;
+            return;
+        }
+        std::cout << "Parsed Response Msg : " << std::endl;
+        std::cout << "FRUDATAMajorVersion : "
+                  << static_cast<uint32_t>(fru_data_major_version) << std::endl;
+        std::cout << "FRUDATAMinorVersion : "
+                  << static_cast<uint32_t>(fru_data_minor_version) << std::endl;
+        std::cout << "FRUTableMaximumSize : " << fru_table_maximum_size
+                  << std::endl;
+        std::cout << "FRUTableLength : " << fru_table_length << std::endl;
+        std::cout << "Total number of Record Set Identifiers in table : "
+                  << total_record_set_identifiers << std::endl;
+        std::cout << "Total number of records in table :  "
+                  << total_table_records << std::endl;
+        std::cout << "FRU DATAStructureTableIntegrityChecksum :  " << checksum
+                  << std::endl;
+    }
+};
+
+void registerCommand(CLI::App& app)
+{
+    auto fru = app.add_subcommand("fru", "FRU type command");
+    fru->require_subcommand(1);
+    auto getFruRecordTableMetadata = fru->add_subcommand(
+        "GetFruRecordTableMetadata", "get FRU record table metadata");
+    commands.push_back(std::make_unique<GetFruRecordTableMetadata>(
+        "fru", "GetFruRecordTableMetadata", getFruRecordTableMetadata));
+}
+
+} // namespace fru
+
+} // namespace pldmtool