fru: Add support to insert hot-plug PDRs into repository

This API helps to insert PDRs that are added or modified
during concurrent maintenance operations into the PDR repository.
The function assigns a new record handle (based on the last
BMC side PDR handle) and appends the provided PDR entry to the
repository.

Tested By: Tested and it successfully builds with -Doem-ibm=disabled

Change-Id: I4981caa7700b5022159056819b875e47240798a0
Signed-off-by: Pavithra Barithaya <pavithrabarithaya07@gmail.com>
diff --git a/libpldmresponder/fru.cpp b/libpldmresponder/fru.cpp
index ff6643a..7fe1b7c 100644
--- a/libpldmresponder/fru.cpp
+++ b/libpldmresponder/fru.cpp
@@ -504,6 +504,25 @@
     return PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
 }
 
+uint32_t FruImpl::addHotPlugRecord(
+    pldm::responder::pdr_utils::PdrEntry pdrEntry)
+{
+    uint32_t lastHandle = 0;
+    uint32_t recordHandle = 0;
+
+    if (oemPlatformHandler)
+    {
+        auto lastLocalRecord = oemPlatformHandler->fetchLastBMCRecord(pdrRepo);
+        lastHandle = pldm_pdr_get_record_handle(pdrRepo, lastLocalRecord);
+    }
+
+    pdrEntry.handle.recordHandle = lastHandle + 1;
+    pldm_pdr_add(pdrRepo, pdrEntry.data, pdrEntry.size, false,
+                 pdrEntry.handle.recordHandle, &recordHandle);
+
+    return recordHandle;
+}
+
 namespace fru
 {
 Response Handler::getFRURecordTableMetadata(const pldm_msg* request,