event: Handling pldmPDRRepositoryChgEvent

Added a handler to react to the "pldmPDRRepositoryChgEvent" event and
extract the data. If the eventDataFormat is "formatIsPDRHandles" then
the changeRecords are further extracted. If the eventDataOperation is
"recordAdded" then the PDRHandles are extracted from the changeEntry
data and stored in the "pdrRecordHandle" vector.

"decode_pldm_pdr_repository_chg_event_data" function will extract the
eventData and changeRecord from the pldmPDRRepositoryChgEvent class
while the "decode_pldm_pdr_repository_change_record_data" will extract
the changeEntries data from the changeRecord. Unit tests for the above
decode functions have been added.

Extracted PDR handles are used to fetch PDRs corresponding to the same
from the host.

Signed-off-by: Zahed Hossain <zahzahed@in.ibm.com>
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Change-Id: I32e8745e04ac82393e067c0f0ab48802809495a6
diff --git a/libpldmresponder/platform.hpp b/libpldmresponder/platform.hpp
index 893a709..94c7c14 100644
--- a/libpldmresponder/platform.hpp
+++ b/libpldmresponder/platform.hpp
@@ -83,6 +83,13 @@
                 return this->sensorEvent(request, payloadLength, formatVersion,
                                          tid, eventDataOffset);
             });
+        eventHandlers[PLDM_PDR_REPOSITORY_CHG_EVENT].emplace_back(
+            [this](const pldm_msg* request, size_t payloadLength,
+                   uint8_t formatVersion, uint8_t tid, size_t eventDataOffset) {
+                return this->pldmPDRRepositoryChgEvent(request, payloadLength,
+                                                       formatVersion, tid,
+                                                       eventDataOffset);
+            });
 
         // Additional OEM event handlers for PLDM events, append it to the
         // standard handlers
@@ -198,6 +205,35 @@
     int sensorEvent(const pldm_msg* request, size_t payloadLength,
                     uint8_t formatVersion, uint8_t tid, size_t eventDataOffset);
 
+    /** @brief Handler for pldmPDRRepositoryChgEvent
+     *
+     *  @param[in] request - Request message
+     *  @param[in] payloadLength - Request payload length
+     *  @param[in] formatVersion - Version of the event format
+     *  @param[in] tid - Terminus ID of the event's originator
+     *  @param[in] eventDataOffset - Offset of the event data in the request
+     *                               message
+     *  @return PLDM completion code
+     */
+    int pldmPDRRepositoryChgEvent(const pldm_msg* request, size_t payloadLength,
+                                  uint8_t formatVersion, uint8_t tid,
+                                  size_t eventDataOffset);
+
+    /** @brief Handler for extracting the PDR handles from changeEntries
+     *
+     *  @param[in] changeEntryData - ChangeEntry data from changeRecord
+     *  @param[in] changeEntryDataSize - total size of changeEntryData
+     *  @param[in] numberOfChangeEntries - total number of changeEntries to
+     *                                     extract
+     *  @param[out] pdrRecordHandles - std::vector where the extracted PDR
+     *                                 handles are placed
+     *  @return PLDM completion code
+     */
+    int getPDRRecordHandles(const ChangeEntry* changeEntryData,
+                            size_t changeEntryDataSize,
+                            size_t numberOfChangeEntries,
+                            PDRRecordHandles& pdrRecordHandles);
+
     /** @brief Handler for setting Sensor event data
      *
      *  @param[in] sensorId - sensorID value of the sensor