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/test/request_test.cpp b/requester/test/request_test.cpp
index 2e3060d..51b337d 100644
--- a/requester/test/request_test.cpp
+++ b/requester/test/request_test.cpp
@@ -1,3 +1,4 @@
+#include "common/transport.hpp"
 #include "mock_request.hpp"
 
 #include <libpldm/base.h>
@@ -41,14 +42,15 @@
 
     int fd = 0;
     mctp_eid_t eid = 0;
+    PldmTransport* pldmTransport = nullptr;
     sdeventplus::Event event;
-    std::vector<uint8_t> requestMsg;
 };
 
 TEST_F(RequestIntfTest, 0Retries100msTimeout)
 {
-    MockRequest request(fd, eid, event, std::move(requestMsg), 0,
-                        milliseconds(100), 90000, false);
+    std::vector<uint8_t> requestMsg;
+    MockRequest request(pldmTransport, eid, event, std::move(requestMsg), 0,
+                        milliseconds(100), false);
     EXPECT_CALL(request, send())
         .Times(Exactly(1))
         .WillOnce(Return(PLDM_SUCCESS));
@@ -58,8 +60,9 @@
 
 TEST_F(RequestIntfTest, 2Retries100msTimeout)
 {
-    MockRequest request(fd, eid, event, std::move(requestMsg), 2,
-                        milliseconds(100), 90000, false);
+    std::vector<uint8_t> requestMsg;
+    MockRequest request(pldmTransport, eid, event, std::move(requestMsg), 2,
+                        milliseconds(100), false);
     // send() is called a total of 3 times, the original plus two retries
     EXPECT_CALL(request, send()).Times(3).WillRepeatedly(Return(PLDM_SUCCESS));
     auto rc = request.start();
@@ -69,8 +72,9 @@
 
 TEST_F(RequestIntfTest, 9Retries100msTimeoutRequestStoppedAfter1sec)
 {
-    MockRequest request(fd, eid, event, std::move(requestMsg), 9,
-                        milliseconds(100), 90000, false);
+    std::vector<uint8_t> requestMsg;
+    MockRequest request(pldmTransport, eid, event, std::move(requestMsg), 9,
+                        milliseconds(100), false);
     // send() will be called a total of 10 times, the original plus 9 retries.
     // In a ideal scenario send() would have been called 10 times in 1 sec (when
     // the timer is stopped) with a timeout of 100ms. Because there are delays
@@ -92,8 +96,9 @@
 
 TEST_F(RequestIntfTest, 2Retries100msTimeoutsendReturnsError)
 {
-    MockRequest request(fd, eid, event, std::move(requestMsg), 2,
-                        milliseconds(100), 90000, false);
+    std::vector<uint8_t> requestMsg;
+    MockRequest request(pldmTransport, eid, event, std::move(requestMsg), 2,
+                        milliseconds(100), false);
     EXPECT_CALL(request, send()).Times(Exactly(1)).WillOnce(Return(PLDM_ERROR));
     auto rc = request.start();
     EXPECT_EQ(rc, PLDM_ERROR);