Add encode_tid_req() in PLDM base.
Signed-off-by: Sridevi Ramesh <sridevra@in.ibm.com>
Change-Id: I9f9815753a415f9c841a6113bc0ea54b1d5670ce
diff --git a/libpldm/base.c b/libpldm/base.c
index b34045c..0447112 100644
--- a/libpldm/base.c
+++ b/libpldm/base.c
@@ -323,6 +323,20 @@
return PLDM_SUCCESS;
}
+int encode_get_tid_req(uint8_t instance_id, struct pldm_msg *msg)
+{
+ if (msg == NULL) {
+ return PLDM_ERROR_INVALID_DATA;
+ }
+
+ struct pldm_header_info header = {0};
+ header.instance = instance_id;
+ header.msg_type = PLDM_REQUEST;
+ header.command = PLDM_GET_TID;
+ pack_pldm_header(&header, &(msg->hdr));
+
+ return PLDM_SUCCESS;
+}
int encode_get_tid_resp(uint8_t instance_id, uint8_t completion_code,
uint8_t tid, struct pldm_msg *msg)
{
diff --git a/libpldm/base.h b/libpldm/base.h
index 9d7961a..d0e917f 100644
--- a/libpldm/base.h
+++ b/libpldm/base.h
@@ -397,8 +397,20 @@
uint32_t *transfer_handle, uint8_t *transfer_opflag,
uint8_t *type);
+/* Requester */
+
/* GetTID */
+/** @brief Create a PLDM request message for GetTID
+ *
+ * @param[in] instance_id - Message's instance id
+ * @param[in,out] msg - Message will be written to this
+ * @return pldm_completion_codes
+ * @note Caller is responsible for memory alloc and dealloc of param
+ * 'msg.payload'
+ */
+int encode_get_tid_req(uint8_t instance_id, struct pldm_msg *msg);
+
/** @brief Create a PLDM response message for GetTID
*
* @param[in] instance_id - Message's instance id
diff --git a/test/libpldm_base_test.cpp b/test/libpldm_base_test.cpp
index af3a2af..ffa76de 100644
--- a/test/libpldm_base_test.cpp
+++ b/test/libpldm_base_test.cpp
@@ -439,6 +439,14 @@
ASSERT_EQ(versionOut.alpha, version.alpha);
}
+TEST(GetTID, testEncodeRequest)
+{
+ pldm_msg request{};
+
+ auto rc = encode_get_tid_req(0, &request);
+ ASSERT_EQ(rc, PLDM_SUCCESS);
+}
+
TEST(GetTID, testEncodeResponse)
{
uint8_t completionCode = 0;