libpldm : add encode/decode APIs for SetStateEffecterStates

This commit implements the encode request and decode
response APIs for the SetStateEffecterStates command.
This enables BMC requester apps to send this command and
process the received response.

Change-Id: I1436c8730553b5a1aed8cda1fa90b8742e5be228
Signed-off-by: vkaverap <vkaverap@in.ibm.com>
diff --git a/libpldm/platform.c b/libpldm/platform.c
index 8bdd406..9d3a427 100644
--- a/libpldm/platform.c
+++ b/libpldm/platform.c
@@ -22,6 +22,52 @@
 	return rc;
 }
 
+int encode_set_state_effecter_states_req(uint8_t instance_id,
+					 uint16_t effecter_id,
+					 uint8_t comp_effecter_count,
+					 set_effecter_state_field *field,
+					 struct pldm_msg *msg)
+{
+	struct pldm_header_info header = {0};
+	int rc = PLDM_SUCCESS;
+
+	header.msg_type = PLDM_REQUEST;
+	header.instance = instance_id;
+	header.pldm_type = PLDM_PLATFORM;
+	header.command = PLDM_SET_STATE_EFFECTER_STATES;
+
+	if ((rc = pack_pldm_header(&header, &(msg->hdr))) > PLDM_SUCCESS) {
+		return rc;
+	}
+
+	if (comp_effecter_count < 0x1 || comp_effecter_count > 0x8) {
+		return PLDM_ERROR_INVALID_DATA;
+	}
+
+	uint8_t *encoded_msg = msg->body.payload;
+	effecter_id = htole16(effecter_id);
+	memcpy(encoded_msg, &effecter_id, sizeof(effecter_id));
+	encoded_msg += sizeof(effecter_id);
+	memcpy(encoded_msg, &comp_effecter_count, sizeof(comp_effecter_count));
+	encoded_msg += sizeof(comp_effecter_count);
+	memcpy(encoded_msg, field,
+	       (sizeof(set_effecter_state_field) * comp_effecter_count));
+
+	return PLDM_SUCCESS;
+}
+
+int decode_set_state_effecter_states_resp(const struct pldm_msg_payload *msg,
+					  uint8_t *completion_code)
+{
+	if (msg == NULL || completion_code == NULL) {
+		return PLDM_ERROR_INVALID_DATA;
+	}
+
+	*completion_code = *(uint8_t *)msg->payload;
+
+	return PLDM_SUCCESS;
+}
+
 int decode_set_state_effecter_states_req(const struct pldm_msg_payload *msg,
 					 uint16_t *effecter_id,
 					 uint8_t *comp_effecter_count,