libpldmresponder: FRU: construct PDRs

Construct FRU record set and entity association PDRs for the FRUs for
which the BMC collects VPD (FRU information off of an EEPROM).

These PDRs are structured as per PLDM spec DSP0248 v1.2.0.

Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Change-Id: I2c72d74dad449561b26c74482e00d1606546c5a2
diff --git a/libpldmresponder/fru.hpp b/libpldmresponder/fru.hpp
index ae3ef0e..d4a647a 100644
--- a/libpldmresponder/fru.hpp
+++ b/libpldmresponder/fru.hpp
@@ -12,6 +12,7 @@
 #include <vector>
 
 #include "libpldm/fru.h"
+#include "libpldm/pdr.h"
 
 namespace pldm
 {
@@ -28,6 +29,7 @@
 using PropertyMap = std::map<Property, Value>;
 using InterfaceMap = std::map<Interface, PropertyMap>;
 using ObjectValueTree = std::map<sdbusplus::message::object_path, InterfaceMap>;
+using ObjectPath = std::string;
 
 } // namespace dbus
 
@@ -53,7 +55,8 @@
      *  @param[in] configPath - path to the directory containing config files
      * for PLDM FRU
      */
-    FruImpl(const std::string& configPath);
+    FruImpl(const std::string& configPath, pldm_pdr* pdrRepo,
+            pldm_entity_association_tree* entityTree);
 
     /** @brief Total length of the FRU table in bytes, this excludes the pad
      *         bytes and the checksum.
@@ -110,15 +113,22 @@
     std::vector<uint8_t> table;
     uint32_t checksum = 0;
 
+    pldm_pdr* pdrRepo;
+    pldm_entity_association_tree* entityTree;
+
+    std::map<dbus::ObjectPath, pldm_entity_node*> objToEntityNode{};
+
     /** @brief populateRecord builds the FRU records for an instance of FRU and
      *         updates the FRU table with the FRU records.
      *
      *  @param[in] interfaces - D-Bus interfaces and the associated property
      *                          values for the FRU
      *  @param[in] recordInfos - FRU record info to build the FRU records
+     *  @param[in/out] entity - PLDM entity corresponding to FRU instance
      */
     void populateRecords(const pldm::responder::dbus::InterfaceMap& interfaces,
-                         const fru_parser::FruRecordInfos& recordInfos);
+                         const fru_parser::FruRecordInfos& recordInfos,
+                         const pldm_entity& entity);
 };
 
 namespace fru
@@ -128,7 +138,9 @@
 {
 
   public:
-    Handler(const std::string& configPath) : impl(configPath)
+    Handler(const std::string& configPath, pldm_pdr* pdrRepo,
+            pldm_entity_association_tree* entityTree) :
+        impl(configPath, pdrRepo, entityTree)
     {
         handlers.emplace(PLDM_GET_FRU_RECORD_TABLE_METADATA,
                          [this](const pldm_msg* request, size_t payloadLength) {
@@ -143,8 +155,6 @@
                          });
     }
 
-    FruImpl impl;
-
     /** @brief Handler for Get FRURecordTableMetadata
      *
      *  @param[in] request - Request message payload
@@ -163,6 +173,9 @@
      *  @return PLDM response message
      */
     Response getFRURecordTable(const pldm_msg* request, size_t payloadLength);
+
+  private:
+    FruImpl impl;
 };
 
 } // namespace fru