send PLDM event msg when state sensor changes

Add the D-Bus to event handler interface to listen all of the state
sensor PDRs and pldm should be able to send up a PLDM event msg when a
D-Bus property changes. the PlatformEventMessage command format is
defined in Table 15 in DSP0248 v1.2.0.

Tested: test with JSON
https://gist.github.com/lxwinspur/6a40abea7330c25e4d49826e890c4be9
The sendEventMsg method is successfully called and the corresponding
message is successfully sent when the D-Bus property value of the sensor
status changes.
print requestMsg Data: 80 02 0a 01 00 00 01 00 01 00 00 00(when calling
sendEventMsg method)

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I9b6d5c1403bfcaa00dbbf478f7d797cc4a40f20d
diff --git a/host-bmc/dbus_to_event_handler.cpp b/host-bmc/dbus_to_event_handler.cpp
new file mode 100644
index 0000000..7b2d207
--- /dev/null
+++ b/host-bmc/dbus_to_event_handler.cpp
@@ -0,0 +1,161 @@
+#include "dbus_to_event_handler.hpp"
+
+#include "libpldm/requester/pldm.h"
+
+#include "libpldmresponder/pdr.hpp"
+
+namespace pldm
+{
+
+using namespace pldm::responder::pdr;
+using namespace pldm::utils;
+using namespace sdbusplus::bus::match::rules;
+
+namespace state_sensor
+{
+const std::vector<uint8_t> pdrTypes{PLDM_STATE_SENSOR_PDR};
+
+DbusToPLDMEvent::DbusToPLDMEvent(int mctp_fd, uint8_t mctp_eid,
+                                 Requester& requester) :
+    mctp_fd(mctp_fd),
+    mctp_eid(mctp_eid), requester(requester)
+{}
+
+void DbusToPLDMEvent::sendEventMsg(uint8_t eventType,
+                                   const std::vector<uint8_t>& eventDataVec)
+{
+    auto instanceId = requester.getInstanceId(mctp_eid);
+    std::vector<uint8_t> requestMsg(sizeof(pldm_msg_hdr) +
+                                    PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES +
+                                    eventDataVec.size());
+    auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
+
+    auto rc = encode_platform_event_message_req(
+        instanceId, 1 /*formatVersion*/, 0 /*tId*/, eventType,
+        eventDataVec.data(), eventDataVec.size(), request,
+        eventDataVec.size() + PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES);
+    if (rc != PLDM_SUCCESS)
+    {
+        requester.markFree(mctp_eid, instanceId);
+        std::cerr << "Failed to encode_platform_event_message_req, rc = " << rc
+                  << std::endl;
+        return;
+    }
+
+    uint8_t* responseMsg = nullptr;
+    size_t responseMsgSize{};
+
+    auto requesterRc =
+        pldm_send_recv(mctp_eid, mctp_fd, requestMsg.data(), requestMsg.size(),
+                       &responseMsg, &responseMsgSize);
+    std::unique_ptr<uint8_t, decltype(std::free)*> responseMsgPtr{responseMsg,
+                                                                  std::free};
+
+    requester.markFree(mctp_eid, instanceId);
+    if (requesterRc != PLDM_REQUESTER_SUCCESS)
+    {
+        std::cerr
+            << "Failed to send msg to report state sensor event changes, rc = "
+            << requesterRc << std::endl;
+        return;
+    }
+    uint8_t completionCode{};
+    uint8_t status{};
+    auto responsePtr = reinterpret_cast<struct pldm_msg*>(responseMsgPtr.get());
+    rc = decode_platform_event_message_resp(
+        responsePtr, responseMsgSize - sizeof(pldm_msg_hdr), &completionCode,
+        &status);
+
+    if (rc != PLDM_SUCCESS || completionCode != PLDM_SUCCESS)
+    {
+        std::cerr << "Failed to decode_platform_event_message_resp: "
+                  << "rc=" << rc
+                  << ", cc=" << static_cast<unsigned>(completionCode)
+                  << std::endl;
+    }
+}
+
+void DbusToPLDMEvent::sendStateSensorEvent(SensorId sensorId,
+                                           const DbusObjMaps& dbusMaps)
+{
+    // Encode PLDM platform event msg to indicate a state sensor change.
+    // DSP0248_1.2.0 Table 19
+    size_t sensorEventSize = PLDM_SENSOR_EVENT_DATA_MIN_LENGTH + 1;
+    const auto& [dbusMappings, dbusValMaps] = dbusMaps.at(sensorId);
+    for (uint8_t offset = 0; offset < dbusMappings.size(); ++offset)
+    {
+        std::vector<uint8_t> sensorEventDataVec{};
+        sensorEventDataVec.resize(sensorEventSize);
+        auto eventData = reinterpret_cast<struct pldm_sensor_event_data*>(
+            sensorEventDataVec.data());
+        eventData->sensor_id = sensorId;
+        eventData->sensor_event_class_type = PLDM_STATE_SENSOR_STATE;
+        eventData->event_class[0] = offset;
+        eventData->event_class[1] = PLDM_SENSOR_UNKNOWN;
+        eventData->event_class[2] = PLDM_SENSOR_UNKNOWN;
+
+        const auto& dbusMapping = dbusMappings[offset];
+        const auto& dbusValueMapping = dbusValMaps[offset];
+        auto stateSensorMatch = std::make_unique<sdbusplus::bus::match::match>(
+            pldm::utils::DBusHandler::getBus(),
+            propertiesChanged(dbusMapping.objectPath.c_str(),
+                              dbusMapping.interface.c_str()),
+            [this, sensorEventDataVec, dbusValueMapping](auto& msg) mutable {
+                DbusChangedProps props{};
+                std::string intf;
+                msg.read(intf, props);
+                const auto& first = props.begin();
+                for (const auto& itr : dbusValueMapping)
+                {
+                    if (itr.second == first->second)
+                    {
+                        auto eventData =
+                            reinterpret_cast<struct pldm_sensor_event_data*>(
+                                sensorEventDataVec.data());
+                        eventData->event_class[1] = itr.first;
+                        eventData->event_class[2] = itr.first;
+                        this->sendEventMsg(PLDM_SENSOR_EVENT,
+                                           sensorEventDataVec);
+                    }
+                }
+            });
+        stateSensorMatchs.emplace_back(std::move(stateSensorMatch));
+    }
+}
+
+void DbusToPLDMEvent::listenSensorEvent(const pdr_utils::Repo& repo,
+                                        const DbusObjMaps& dbusMaps)
+{
+    const std::map<Type, sensorEvent> sensorHandlers = {
+        {PLDM_STATE_SENSOR_PDR,
+         [this](SensorId sensorId, const DbusObjMaps& dbusMaps) {
+             this->sendStateSensorEvent(sensorId, dbusMaps);
+         }}};
+
+    pldm_state_sensor_pdr* pdr = nullptr;
+    std::unique_ptr<pldm_pdr, decltype(&pldm_pdr_destroy)> sensorPdrRepo(
+        pldm_pdr_init(), pldm_pdr_destroy);
+
+    for (auto pdrType : pdrTypes)
+    {
+        Repo sensorPDRs(sensorPdrRepo.get());
+        getRepoByType(repo, sensorPDRs, pdrType);
+        if (sensorPDRs.empty())
+        {
+            return;
+        }
+
+        PdrEntry pdrEntry{};
+        auto pdrRecord = sensorPDRs.getFirstRecord(pdrEntry);
+        while (pdrRecord)
+        {
+            pdr = reinterpret_cast<pldm_state_sensor_pdr*>(pdrEntry.data);
+            SensorId sensorId = LE16TOH(pdr->sensor_id);
+            sensorHandlers.at(pdrType)(sensorId, dbusMaps);
+            pdrRecord = sensorPDRs.getNextRecord(pdrRecord, pdrEntry);
+        }
+    }
+}
+
+} // namespace state_sensor
+} // namespace pldm
diff --git a/host-bmc/dbus_to_event_handler.hpp b/host-bmc/dbus_to_event_handler.hpp
new file mode 100644
index 0000000..add5c2d
--- /dev/null
+++ b/host-bmc/dbus_to_event_handler.hpp
@@ -0,0 +1,85 @@
+#pragma once
+
+#include "libpldm/platform.h"
+
+#include "libpldmresponder/pdr_utils.hpp"
+#include "pldmd/dbus_impl_requester.hpp"
+
+#include <map>
+
+using namespace pldm::dbus_api;
+using namespace pldm::responder;
+
+namespace pldm
+{
+
+using SensorId = uint16_t;
+using DbusObjMaps =
+    std::map<SensorId,
+             std::tuple<pdr_utils::DbusMappings, pdr_utils::DbusValMaps>>;
+using sensorEvent =
+    std::function<void(SensorId sensorId, const DbusObjMaps& dbusMaps)>;
+
+namespace state_sensor
+{
+/** @class DbusToPLDMEvent
+ *  @brief This class can listen to the state sensor PDRs and send PLDM event
+ *         msg when a D-Bus property changes
+ */
+class DbusToPLDMEvent
+{
+  public:
+    DbusToPLDMEvent() = delete;
+    DbusToPLDMEvent(const DbusToPLDMEvent&) = delete;
+    DbusToPLDMEvent(DbusToPLDMEvent&&) = delete;
+    DbusToPLDMEvent& operator=(const DbusToPLDMEvent&) = delete;
+    DbusToPLDMEvent& operator=(DbusToPLDMEvent&&) = delete;
+    ~DbusToPLDMEvent() = default;
+
+    /** @brief Constructor
+     *  @param[in] mctp_fd - fd of MCTP communications socket
+     *  @param[in] mctp_eid - MCTP EID of host firmware
+     *  @param[in] requester - reference to Requester object
+     */
+    explicit DbusToPLDMEvent(int mctp_fd, uint8_t mctp_eid,
+                             Requester& requester);
+
+  public:
+    /** @brief Listen all of the state sensor PDRs
+     *  @param[in] repo - pdr utils repo object
+     *  @param[in] dbusMaps - The map of D-Bus mapping and value
+     */
+    void listenSensorEvent(const pdr_utils::Repo& repo,
+                           const DbusObjMaps& dbusMaps);
+
+  private:
+    /** @brief Send state sensor event msg when a D-Bus property changes
+     *  @param[in] sensorId - sensor id
+     */
+    void sendStateSensorEvent(SensorId sensorId, const DbusObjMaps& dbusMaps);
+
+    /** @brief Send all of sensor event
+     *  @param[in] eventType - PLDM Event types
+     *  @param[in] eventDataVec - std::vector, contains send event data
+     */
+    void sendEventMsg(uint8_t eventType,
+                      const std::vector<uint8_t>& eventDataVec);
+
+    /** @brief fd of MCTP communications socket */
+    int mctp_fd;
+
+    /** @brief MCTP EID of host firmware */
+    uint8_t mctp_eid;
+
+    /** @brief reference to Requester object, primarily used to access API to
+     *  obtain PLDM instance id.
+     */
+    Requester& requester;
+
+    /** @brief D-Bus property changed signal match */
+    std::vector<std::unique_ptr<sdbusplus::bus::match::match>>
+        stateSensorMatchs;
+};
+
+} // namespace state_sensor
+} // namespace pldm
diff --git a/libpldm/base.h b/libpldm/base.h
index 5109c34..7f87971 100644
--- a/libpldm/base.h
+++ b/libpldm/base.h
@@ -113,6 +113,8 @@
 // Macros for byte-swapping variables in-place
 #define HTOLE32(X) (X = htole32(X))
 #define HTOLE16(X) (X = htole16(X))
+#define LE32TOH(X) (X = le32toh(X))
+#define LE16TOH(X) (X = le16toh(X))
 
 /** @struct pldm_msg
  *
diff --git a/libpldmresponder/meson.build b/libpldmresponder/meson.build
index a4a8b67..481c82b 100644
--- a/libpldmresponder/meson.build
+++ b/libpldmresponder/meson.build
@@ -21,6 +21,7 @@
   'fru_parser.cpp',
   'fru.cpp',
   '../host-bmc/host_pdr_handler.cpp',
+  '../host-bmc/dbus_to_event_handler.cpp',
   'event_parser.cpp'
 ]
 
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index c017486..dff2352 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -172,6 +172,12 @@
         generateTerminusLocatorPDR(pdrRepo);
         generate(*dBusIntf, pdrJsonsDir, pdrRepo);
         pdrCreated = true;
+
+        if (dbusToPLDMEventHandler)
+        {
+            dbusToPLDMEventHandler->listenSensorEvent(pdrRepo,
+                                                      sensorDbusObjMaps);
+        }
     }
 
     // Build FRU table if not built, since entity association PDR's are built
diff --git a/libpldmresponder/platform.hpp b/libpldmresponder/platform.hpp
index 6d6fd95..a4d3991 100644
--- a/libpldmresponder/platform.hpp
+++ b/libpldmresponder/platform.hpp
@@ -2,12 +2,14 @@
 
 #include "config.h"
 
+#include "libpldm/pdr.h"
 #include "libpldm/platform.h"
 #include "libpldm/states.h"
 
 #include "common/utils.hpp"
 #include "event_parser.hpp"
 #include "fru.hpp"
+#include "host-bmc/dbus_to_event_handler.hpp"
 #include "host-bmc/host_pdr_handler.hpp"
 #include "libpldmresponder/pdr.hpp"
 #include "libpldmresponder/pdr_utils.hpp"
@@ -26,6 +28,7 @@
 
 using namespace pldm::utils;
 using namespace pldm::responder::pdr_utils;
+using namespace pldm::state_sensor;
 
 using generatePDR =
     std::function<void(const pldm::utils::DBusHandler& dBusIntf,
@@ -59,12 +62,13 @@
     Handler(const pldm::utils::DBusHandler* dBusIntf,
             const std::string& pdrJsonsDir, const std::string& eventsJsonsDir,
             pldm_pdr* repo, HostPDRHandler* hostPDRHandler,
-            fru::Handler* fruHandler, bool buildPDRLazily = false,
+            DbusToPLDMEvent* dbusToPLDMEventHandler, fru::Handler* fruHandler,
+            bool buildPDRLazily = false,
             const std::optional<EventMap>& addOnHandlersMap = std::nullopt) :
         pdrRepo(repo),
         hostPDRHandler(hostPDRHandler), stateSensorHandler(eventsJsonsDir),
-        fruHandler(fruHandler), dBusIntf(dBusIntf), pdrJsonsDir(pdrJsonsDir),
-        pdrCreated(false)
+        dbusToPLDMEventHandler(dbusToPLDMEventHandler), fruHandler(fruHandler),
+        dBusIntf(dBusIntf), pdrJsonsDir(pdrJsonsDir), pdrCreated(false)
     {
         if (!buildPDRLazily)
         {
@@ -440,6 +444,7 @@
     DbusObjMaps sensorDbusObjMaps{};
     HostPDRHandler* hostPDRHandler;
     events::StateSensorHandler stateSensorHandler;
+    DbusToPLDMEvent* dbusToPLDMEventHandler;
     fru::Handler* fruHandler;
     const pldm::utils::DBusHandler* dBusIntf;
     std::string pdrJsonsDir;
diff --git a/pldmd/pldmd.cpp b/pldmd/pldmd.cpp
index 192112e..e4a865b 100644
--- a/pldmd/pldmd.cpp
+++ b/pldmd/pldmd.cpp
@@ -6,6 +6,7 @@
 #include "common/utils.hpp"
 #include "dbus_impl_pdr.hpp"
 #include "dbus_impl_requester.hpp"
+#include "host-bmc/dbus_to_event_handler.hpp"
 #include "host-bmc/dbus_to_host_effecters.hpp"
 #include "host-bmc/host_pdr_handler.hpp"
 #include "invoker.hpp"
@@ -49,6 +50,7 @@
 using namespace pldm;
 using namespace sdeventplus;
 using namespace sdeventplus::source;
+using namespace pldm::state_sensor;
 
 static Response processRxMsg(const std::vector<uint8_t>& requestMsg,
                              Invoker& invoker, dbus_api::Requester& requester)
@@ -174,6 +176,7 @@
     std::unique_ptr<HostPDRHandler> hostPDRHandler;
     std::unique_ptr<pldm::host_effecters::HostEffecterParser>
         hostEffecterParser;
+    std::unique_ptr<DbusToPLDMEvent> dbusToPLDMEventHandler;
     auto dbusHandler = std::make_unique<DBusHandler>();
     auto hostEID = pldm::utils::readHostEID();
     if (hostEID)
@@ -185,6 +188,8 @@
             std::make_unique<pldm::host_effecters::HostEffecterParser>(
                 &dbusImplReq, sockfd, pdrRepo.get(), dbusHandler.get(),
                 HOST_JSONS_DIR, verbose);
+        dbusToPLDMEventHandler =
+            std::make_unique<DbusToPLDMEvent>(sockfd, hostEID, dbusImplReq);
     }
 
     Invoker invoker{};
@@ -195,11 +200,12 @@
     // FRU table is built lazily when a FRU command or Get PDR command is
     // handled. To enable building FRU table, the FRU handler is passed to the
     // Platform handler.
-    invoker.registerHandler(PLDM_PLATFORM,
-                            std::make_unique<platform::Handler>(
-                                dbusHandler.get(), PDR_JSONS_DIR,
-                                EVENTS_JSONS_DIR, pdrRepo.get(),
-                                hostPDRHandler.get(), fruHandler.get(), true));
+    invoker.registerHandler(PLDM_PLATFORM, std::make_unique<platform::Handler>(
+                                               dbusHandler.get(), PDR_JSONS_DIR,
+                                               EVENTS_JSONS_DIR, pdrRepo.get(),
+                                               hostPDRHandler.get(),
+                                               dbusToPLDMEventHandler.get(),
+                                               fruHandler.get(), true));
     invoker.registerHandler(PLDM_FRU, std::move(fruHandler));
 
 #ifdef OEM_IBM
diff --git a/test/libpldmresponder_pdr_effecter_test.cpp b/test/libpldmresponder_pdr_effecter_test.cpp
index 390db58..7c8d29d 100644
--- a/test/libpldmresponder_pdr_effecter_test.cpp
+++ b/test/libpldmresponder_pdr_effecter_test.cpp
@@ -28,7 +28,7 @@
     auto outPDRRepo = pldm_pdr_init();
     Repo outRepo(outPDRRepo);
     Handler handler(&mockedUtils, "./pdr_jsons/state_effecter/good",
-                    "./event_jsons/good", inPDRRepo, nullptr, nullptr);
+                    "./event_jsons/good", inPDRRepo, nullptr, nullptr, nullptr);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_STATE_EFFECTER_PDR);
 
@@ -127,7 +127,7 @@
     auto outPDRRepo = pldm_pdr_init();
     Repo outRepo(outPDRRepo);
     Handler handler(&mockedUtils, "./pdr_jsons/state_effecter/good", "",
-                    inPDRRepo, nullptr, nullptr);
+                    inPDRRepo, nullptr, nullptr, nullptr);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_NUMERIC_EFFECTER_PDR);
 
@@ -173,7 +173,7 @@
     auto outPDRRepo = pldm_pdr_init();
     Repo outRepo(outPDRRepo);
     Handler handler(&mockedUtils, "./pdr_jsons/state_effecter/good",
-                    "./event_jsons/good", inPDRRepo, nullptr, nullptr);
+                    "./event_jsons/good", inPDRRepo, nullptr, nullptr, nullptr);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_STATE_EFFECTER_PDR);
 
@@ -194,7 +194,7 @@
 
     auto inPDRRepo = pldm_pdr_init();
     Handler handler(&mockedUtils, "./pdr_jsons/state_effecter/good", "",
-                    inPDRRepo, nullptr, nullptr);
+                    inPDRRepo, nullptr, nullptr, nullptr);
     uint16_t entityType = 33;
     uint16_t entityInstance = 0;
     uint16_t containerId = 0;
@@ -207,4 +207,4 @@
                                      containerId, stateSetId, true);
     ASSERT_EQ(effecterId, PLDM_INVALID_EFFECTER_ID);
     pldm_pdr_destroy(inPDRRepo);
-}
\ No newline at end of file
+}
diff --git a/test/libpldmresponder_pdr_sensor_test.cpp b/test/libpldmresponder_pdr_sensor_test.cpp
index bda9293..946720a 100644
--- a/test/libpldmresponder_pdr_sensor_test.cpp
+++ b/test/libpldmresponder_pdr_sensor_test.cpp
@@ -33,7 +33,7 @@
     auto outPDRRepo = pldm_pdr_init();
     Repo outRepo(outPDRRepo);
     Handler handler(&mockedUtils, "./pdr_jsons/state_sensor/good", "",
-                    inPDRRepo, nullptr, nullptr);
+                    inPDRRepo, nullptr, nullptr, nullptr);
     handler.getPDR(req, requestPayloadLength);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_STATE_SENSOR_PDR);
@@ -83,7 +83,7 @@
     auto outPDRRepo = pldm_pdr_init();
     Repo outRepo(outPDRRepo);
     Handler handler(&mockedUtils, "./pdr_jsons/state_sensor/good", "",
-                    inPDRRepo, nullptr, nullptr);
+                    inPDRRepo, nullptr, nullptr, nullptr);
     handler.getPDR(req, requestPayloadLength);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_STATE_SENSOR_PDR);
diff --git a/test/libpldmresponder_platform_test.cpp b/test/libpldmresponder_platform_test.cpp
index 61a823f..28dd1e0 100644
--- a/test/libpldmresponder_platform_test.cpp
+++ b/test/libpldmresponder_platform_test.cpp
@@ -40,7 +40,7 @@
 
     auto pdrRepo = pldm_pdr_init();
     Handler handler(&mockedUtils, "./pdr_jsons/state_effecter/good",
-                    "./event_jsons/good", pdrRepo, nullptr, nullptr);
+                    "./event_jsons/good", pdrRepo, nullptr, nullptr, nullptr);
     Repo repo(pdrRepo);
     ASSERT_EQ(repo.empty(), false);
     auto response = handler.getPDR(req, requestPayloadLength);
@@ -77,7 +77,7 @@
 
     auto pdrRepo = pldm_pdr_init();
     Handler handler(&mockedUtils, "./pdr_jsons/state_effecter/good",
-                    "./event_jsons/good", pdrRepo, nullptr, nullptr);
+                    "./event_jsons/good", pdrRepo, nullptr, nullptr, nullptr);
     Repo repo(pdrRepo);
     ASSERT_EQ(repo.empty(), false);
     auto response = handler.getPDR(req, requestPayloadLength);
@@ -108,7 +108,7 @@
 
     auto pdrRepo = pldm_pdr_init();
     Handler handler(&mockedUtils, "./pdr_jsons/state_effecter/good",
-                    "./event_jsons/good", pdrRepo, nullptr, nullptr);
+                    "./event_jsons/good", pdrRepo, nullptr, nullptr, nullptr);
     Repo repo(pdrRepo);
     ASSERT_EQ(repo.empty(), false);
     auto response = handler.getPDR(req, requestPayloadLength);
@@ -137,7 +137,7 @@
 
     auto pdrRepo = pldm_pdr_init();
     Handler handler(&mockedUtils, "./pdr_jsons/state_effecter/good",
-                    "./event_jsons/good", pdrRepo, nullptr, nullptr);
+                    "./event_jsons/good", pdrRepo, nullptr, nullptr, nullptr);
     Repo repo(pdrRepo);
     ASSERT_EQ(repo.empty(), false);
     auto response = handler.getPDR(req, requestPayloadLength);
@@ -168,7 +168,7 @@
 
     auto pdrRepo = pldm_pdr_init();
     Handler handler(&mockedUtils, "./pdr_jsons/state_effecter/good",
-                    "./event_jsons/good", pdrRepo, nullptr, nullptr);
+                    "./event_jsons/good", pdrRepo, nullptr, nullptr, nullptr);
     Repo repo(pdrRepo);
     ASSERT_EQ(repo.empty(), false);
     auto response = handler.getPDR(req, requestPayloadLength);
@@ -230,7 +230,7 @@
     auto outPDRRepo = pldm_pdr_init();
     Repo outRepo(outPDRRepo);
     Handler handler(&mockedUtils, "./pdr_jsons/state_effecter/good",
-                    "./event_jsons/good", inPDRRepo, nullptr, nullptr);
+                    "./event_jsons/good", inPDRRepo, nullptr, nullptr, nullptr);
     handler.getPDR(req, requestPayloadLength);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_STATE_EFFECTER_PDR);
@@ -276,7 +276,7 @@
     auto outPDRRepo = pldm_pdr_init();
     Repo outRepo(outPDRRepo);
     Handler handler(&mockedUtils, "./pdr_jsons/state_effecter/good",
-                    "./event_jsons/good", inPDRRepo, nullptr, nullptr);
+                    "./event_jsons/good", inPDRRepo, nullptr, nullptr, nullptr);
     handler.getPDR(req, requestPayloadLength);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_STATE_EFFECTER_PDR);
@@ -321,7 +321,7 @@
     auto numericEffecterPdrRepo = pldm_pdr_init();
     Repo numericEffecterPDRs(numericEffecterPdrRepo);
     Handler handler(&mockedUtils, "./pdr_jsons/state_effecter/good", "",
-                    inPDRRepo, nullptr, nullptr);
+                    inPDRRepo, nullptr, nullptr, nullptr);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, numericEffecterPDRs, PLDM_NUMERIC_EFFECTER_PDR);
 
@@ -363,7 +363,7 @@
     auto numericEffecterPdrRepo = pldm_pdr_init();
     Repo numericEffecterPDRs(numericEffecterPdrRepo);
     Handler handler(&mockedUtils, "./pdr_jsons/state_effecter/good", "",
-                    inPDRRepo, nullptr, nullptr);
+                    inPDRRepo, nullptr, nullptr, nullptr);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, numericEffecterPDRs, PLDM_NUMERIC_EFFECTER_PDR);
 
@@ -540,7 +540,7 @@
     auto outPDRRepo = pldm_pdr_init();
     Repo outRepo(outPDRRepo);
     MockdBusHandler mockedUtils;
-    Handler handler(&mockedUtils, "", "", inPDRRepo, nullptr, nullptr);
+    Handler handler(&mockedUtils, "", "", inPDRRepo, nullptr, nullptr, nullptr);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_TERMINUS_LOCATOR_PDR);
 
@@ -584,7 +584,7 @@
     auto outPDRRepo = pldm_pdr_init();
     Repo outRepo(outPDRRepo);
     Handler handler(&mockedUtils, "./pdr_jsons/state_sensor/good", "",
-                    inPDRRepo, nullptr, nullptr);
+                    inPDRRepo, nullptr, nullptr, nullptr);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_STATE_SENSOR_PDR);
     pdr_utils::PdrEntry e;
@@ -630,7 +630,7 @@
     auto outPDRRepo = pldm_pdr_init();
     Repo outRepo(outPDRRepo);
     Handler handler(&mockedUtils, "./pdr_jsons/state_sensor/good", "",
-                    inPDRRepo, nullptr, nullptr);
+                    inPDRRepo, nullptr, nullptr, nullptr);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_STATE_SENSOR_PDR);
     pdr_utils::PdrEntry e;