oem/libpldm: platform: implement responder flow for GetAlertStatus

For the responder, need to encode responder data and send requester,
waiting for recive requester data to decode, so need to implement
encode/decode(Responder flow only) for GetAlertStatus.

The GetAlertStatus is a custom oem command to report enclosure ids of
system, alert status and flags, and config ID.

Request Data:
 Type - Request Data
  uint8 - Version of the command/response format. 0x0 for this format.

Response Data:
 Type - Response Data
  enum8 - completionCode.value{PLDM_BASE_CODES, UNSUPPORTED_FORMAT_VERSION=0x81}
  uint32 - Enclosure ID, AlertStatus, Flags, Config ID.(rack entry)
  uint32 - Enclosure ID, AlertStatus, Flags, Config ID.(pri cec node)

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I968056bbabf5cc724a3b6a9646dc271df4847ed2
diff --git a/oem/ibm/libpldm/host.c b/oem/ibm/libpldm/host.c
index 6628bd5..454f6c3 100644
--- a/oem/ibm/libpldm/host.c
+++ b/oem/ibm/libpldm/host.c
@@ -53,4 +53,50 @@
 	*pri_cec_node = le32toh(response->pri_cec_node);
 
 	return PLDM_SUCCESS;
-}
\ No newline at end of file
+}
+
+int decode_get_alert_status_req(const struct pldm_msg *msg,
+				size_t payload_length, uint8_t *version_id)
+{
+	if (msg == NULL || version_id == NULL) {
+		return PLDM_ERROR_INVALID_DATA;
+	}
+
+	if (payload_length != PLDM_GET_ALERT_STATUS_REQ_BYTES) {
+		return PLDM_ERROR_INVALID_LENGTH;
+	}
+
+	*version_id = msg->payload[0];
+
+	return PLDM_SUCCESS;
+}
+
+int encode_get_alert_status_resp(uint8_t instance_id, uint8_t completion_code,
+				 uint32_t rack_entry, uint32_t pri_cec_node,
+				 struct pldm_msg *msg, size_t payload_length)
+{
+	struct pldm_header_info header = {0};
+	int rc = PLDM_SUCCESS;
+
+	header.msg_type = PLDM_RESPONSE;
+	header.instance = instance_id;
+	header.pldm_type = PLDM_OEM;
+	header.command = PLDM_HOST_GET_ALERT_STATUS;
+
+	if ((rc = pack_pldm_header(&header, &(msg->hdr))) > PLDM_SUCCESS) {
+		return rc;
+	}
+
+	if (payload_length != PLDM_GET_ALERT_STATUS_RESP_BYTES) {
+		return PLDM_ERROR_INVALID_DATA;
+	}
+
+	struct pldm_get_alert_status_resp *response =
+	    (struct pldm_get_alert_status_resp *)msg->payload;
+
+	response->completion_code = completion_code;
+	response->rack_entry = htole32(rack_entry);
+	response->pri_cec_node = htole32(pri_cec_node);
+
+	return PLDM_SUCCESS;
+}