pldm: Convert to using libpldm transport APIs

A significant amount of logic can be removed by exploiting the new
transport APIs provided by libpldm. Switch the pldm repository over to
use these by introducing an RAII wrapper for the APIs. The current
stance is to continue using the legacy mctp-demux transport
implementation, but we also provide a build option to switch to the
AF_MCTP transport.

We don't currently have the infrastructure in place to get the correct
TIDs, so to keep everything working as before use the EID as the TID in
the EID-to-TID mapping.

Change-Id: I366f079082b102cfc0e90db0f62208581eb8693e
Signed-off-by: Rashmica Gupta <rashmica@linux.ibm.com>
Signed-off-by: Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
diff --git a/requester/handler.hpp b/requester/handler.hpp
index 9e5d8d1..6987b16 100644
--- a/requester/handler.hpp
+++ b/requester/handler.hpp
@@ -1,11 +1,11 @@
 #pragma once
 
 #include "common/instance_id.hpp"
+#include "common/transport.hpp"
 #include "common/types.hpp"
 #include "request.hpp"
 
 #include <libpldm/base.h>
-#include <libpldm/pldm.h>
 #include <sys/socket.h>
 
 #include <phosphor-logging/lg2.hpp>
@@ -87,26 +87,24 @@
 
     /** @brief Constructor
      *
-     *  @param[in] fd - fd of MCTP communications socket
+     *  @param[in] pldm_transport - PLDM requester
      *  @param[in] event - reference to PLDM daemon's main event loop
      *  @param[in] instanceIdDb - reference to an InstanceIdDb
-     *  @param[in] currentSendbuffSize - current send buffer size
      *  @param[in] verbose - verbose tracing flag
      *  @param[in] instanceIdExpiryInterval - instance ID expiration interval
      *  @param[in] numRetries - number of request retries
      *  @param[in] responseTimeOut - time to wait between each retry
      */
     explicit Handler(
-        int fd, sdeventplus::Event& event, pldm::InstanceIdDb& instanceIdDb,
-        int currentSendbuffSize, bool verbose,
+        PldmTransport* pldmTransport, sdeventplus::Event& event,
+        pldm::InstanceIdDb& instanceIdDb, bool verbose,
         std::chrono::seconds instanceIdExpiryInterval =
             std::chrono::seconds(INSTANCE_ID_EXPIRATION_INTERVAL),
         uint8_t numRetries = static_cast<uint8_t>(NUMBER_OF_REQUEST_RETRIES),
         std::chrono::milliseconds responseTimeOut =
             std::chrono::milliseconds(RESPONSE_TIME_OUT)) :
-        fd(fd),
-        event(event), instanceIdDb(instanceIdDb),
-        currentSendbuffSize(currentSendbuffSize), verbose(verbose),
+        pldmTransport(pldmTransport),
+        event(event), instanceIdDb(instanceIdDb), verbose(verbose),
         instanceIdExpiryInterval(instanceIdExpiryInterval),
         numRetries(numRetries), responseTimeOut(responseTimeOut)
     {}
@@ -171,8 +169,8 @@
         }
 
         auto request = std::make_unique<RequestInterface>(
-            fd, eid, event, std::move(requestMsg), numRetries, responseTimeOut,
-            currentSendbuffSize, verbose);
+            pldmTransport, eid, event, std::move(requestMsg), numRetries,
+            responseTimeOut, verbose);
         auto timer = std::make_unique<phosphor::Timer>(
             event.get(), instanceIdExpiryCallBack);
 
@@ -243,10 +241,9 @@
     }
 
   private:
-    int fd; //!< file descriptor of MCTP communications socket
+    PldmTransport* pldmTransport; //!< PLDM transport object
     sdeventplus::Event& event; //!< reference to PLDM daemon's main event loop
     pldm::InstanceIdDb& instanceIdDb; //!< reference to an InstanceIdDb
-    int currentSendbuffSize;          //!< current Send Buffer size
     bool verbose;                     //!< verbose tracing flag
     std::chrono::seconds
         instanceIdExpiryInterval;     //!< Instance ID expiration interval