fw-update: Firmware discovery of MCTP endpoints

Tested:

a) Verified MCTP endpoints are discovered by PLDM and fetching the firmware
   inventory commands.
b) PLDM firmware update successful after uploading the package, which depends
   on the firmware inventory commands.
c) Verified MCTP endpoints are discovered irrespective of the startup order
   with the MCTP control application.

Signed-off-by: Tom Joseph <rushtotom@gmail.com>
Change-Id: I7ee9aed40433a8e5a4ebb8e61f917ec82dde9c35
diff --git a/requester/mctp_endpoint_discovery.hpp b/requester/mctp_endpoint_discovery.hpp
new file mode 100644
index 0000000..b09a2e9
--- /dev/null
+++ b/requester/mctp_endpoint_discovery.hpp
@@ -0,0 +1,46 @@
+#pragma once
+
+#include "fw-update/manager.hpp"
+
+#include <sdbusplus/bus/match.hpp>
+
+namespace pldm
+{
+
+class MctpDiscovery
+{
+  public:
+    MctpDiscovery() = delete;
+    MctpDiscovery(const MctpDiscovery&) = delete;
+    MctpDiscovery(MctpDiscovery&&) = delete;
+    MctpDiscovery& operator=(const MctpDiscovery&) = delete;
+    MctpDiscovery& operator=(MctpDiscovery&&) = delete;
+    ~MctpDiscovery() = default;
+
+    /** @brief Constructs the MCTP Discovery object to handle discovery of
+     *         MCTP enabled devices
+     *
+     *  @param[in] bus - reference to systemd bus
+     *  @param[in] fwManager - pointer to the firmware manager
+     */
+    explicit MctpDiscovery(sdbusplus::bus::bus& bus,
+                           fw_update::Manager* fwManager);
+
+  private:
+    /** @brief reference to the systemd bus */
+    sdbusplus::bus::bus& bus;
+
+    fw_update::Manager* fwManager;
+
+    /** @brief Used to watch for new MCTP endpoints */
+    sdbusplus::bus::match_t mctpEndpointSignal;
+
+    void dicoverEndpoints(sdbusplus::message::message& msg);
+
+    static constexpr uint8_t mctpTypePLDM = 1;
+
+    static constexpr std::string_view mctpEndpointIntfName{
+        "xyz.openbmc_project.MCTP.Endpoint"};
+};
+
+} // namespace pldm
\ No newline at end of file