libpldm: Add encode API for ApplyComplete response

After firmware verification is successful, the FD transitions
into the APPLY state and begins transferring the component image into
the storage location where the object resides. After the FD finishes
applying the component successfully, it issues an ApplyComplete
command indicating success and the FD transitions to the READY XFER
state to be ready for the next component transfer. This implementation
works with DSP0267_1.1.0, DSP0267_1.0.1 and DSP0267_1.0.0.

Tested: Unit tests passed

Signed-off-by: gokulsanker <gokul.sanker.v.g@intel.com>
Change-Id: Ia1471e03863ad343416c1d26083a2db5ed2cb525
diff --git a/libpldm/firmware_update.c b/libpldm/firmware_update.c
index 2dfa721..8dd09d2 100644
--- a/libpldm/firmware_update.c
+++ b/libpldm/firmware_update.c
@@ -1151,3 +1151,29 @@
 

 	return PLDM_SUCCESS;

 }

+

+int encode_apply_complete_resp(uint8_t instance_id, uint8_t completion_code,

+			       struct pldm_msg *msg, size_t payload_length)

+{

+	if (msg == NULL) {

+		return PLDM_ERROR_INVALID_DATA;

+	}

+

+	if (payload_length != sizeof(completion_code)) {

+		return PLDM_ERROR_INVALID_LENGTH;

+	}

+

+	struct pldm_header_info header = {0};

+	header.instance = instance_id;

+	header.msg_type = PLDM_RESPONSE;

+	header.pldm_type = PLDM_FWUP;

+	header.command = PLDM_APPLY_COMPLETE;

+	uint8_t rc = pack_pldm_header(&header, &(msg->hdr));

+	if (rc) {

+		return rc;

+	}

+

+	msg->payload[0] = completion_code;

+

+	return PLDM_SUCCESS;

+}