base: GetTID responder implementation

A pldm terminus is defined as the point of communication termination
for PLDM messages and the PLDM functions associated with those messages.

The Terminus ID(TID) is a value that identifies a PLDM terminus.

This commit assignes 1 to the BMC as the TID.

Signed-off-by: John Wang <wangzqbj@inspur.com>
Change-Id: I7adb0e1274f326fe6cf148771f230f530c9a567c
diff --git a/libpldm/base.c b/libpldm/base.c
index 36df1b0..5927ba1 100644
--- a/libpldm/base.c
+++ b/libpldm/base.c
@@ -322,3 +322,48 @@
 
 	return PLDM_SUCCESS;
 }
+
+int encode_get_tid_resp(uint8_t instance_id, uint8_t completion_code,
+			uint8_t tid, struct pldm_msg *msg)
+{
+	if (msg == NULL) {
+		return PLDM_ERROR_INVALID_DATA;
+	}
+
+	struct pldm_get_tid_resp *response =
+	    (struct pldm_get_tid_resp *)msg->payload;
+
+	response->completion_code = completion_code;
+	struct pldm_header_info header = {0};
+	header.instance = instance_id;
+	header.msg_type = PLDM_RESPONSE;
+	header.command = PLDM_GET_TID;
+	pack_pldm_header(&header, &(msg->hdr));
+
+	response->tid = tid;
+
+	return PLDM_SUCCESS;
+}
+
+int decode_get_tid_resp(const struct pldm_msg *msg, size_t payload_length,
+			uint8_t *completion_code, uint8_t *tid)
+{
+	if (msg == NULL || tid == NULL || completion_code == NULL) {
+		return PLDM_ERROR_INVALID_DATA;
+	}
+
+	if (payload_length != PLDM_GET_TID_RESP_BYTES) {
+		return PLDM_ERROR_INVALID_LENGTH;
+	}
+
+	struct pldm_get_tid_resp *response =
+	    (struct pldm_get_tid_resp *)msg->payload;
+	*completion_code = response->completion_code;
+	if (PLDM_SUCCESS != *completion_code) {
+		return PLDM_SUCCESS;
+	};
+
+	*tid = response->tid;
+
+	return PLDM_SUCCESS;
+}