libpldm: Add decode API for RequestUpdate cmd response
RequestUpdate command is the command to initiate a firmware update
for a firmware device. 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: Id1c684aa17f140b318d587bd14116e03be2b4f20
diff --git a/libpldm/firmware_update.c b/libpldm/firmware_update.c
index 11007a7..b5b1162 100644
--- a/libpldm/firmware_update.c
+++ b/libpldm/firmware_update.c
@@ -670,4 +670,33 @@
comp_img_set_ver_str->ptr, comp_img_set_ver_str->length);
return PLDM_SUCCESS;
+}
+
+int decode_request_update_resp(const struct pldm_msg *msg,
+ size_t payload_length, uint8_t *completion_code,
+ uint16_t *fd_meta_data_len,
+ uint8_t *fd_will_send_pkg_data)
+{
+ if (msg == NULL || completion_code == NULL ||
+ fd_meta_data_len == NULL || fd_will_send_pkg_data == NULL ||
+ !payload_length) {
+ return PLDM_ERROR_INVALID_DATA;
+ }
+
+ *completion_code = msg->payload[0];
+ if (*completion_code != PLDM_SUCCESS) {
+ return PLDM_SUCCESS;
+ }
+
+ if (payload_length != sizeof(struct pldm_request_update_resp)) {
+ return PLDM_ERROR_INVALID_LENGTH;
+ }
+
+ struct pldm_request_update_resp *response =
+ (struct pldm_request_update_resp *)msg->payload;
+
+ *fd_meta_data_len = le16toh(response->fd_meta_data_len);
+ *fd_will_send_pkg_data = response->fd_will_send_pkg_data;
+
+ return PLDM_SUCCESS;
}
\ No newline at end of file