libpldm: Add API to decode package header info
This patch provides API to decode the firmware update package header
information and also do basic validation.
The API works with DSP0267_1.1.0, DSP0267_1.0.1 and DSP0267_1.0.0.
Tested: Unit tests passed
Signed-off-by: Tom Joseph <rushtotom@gmail.com>
Change-Id: I208a219cd4b9c9b9869eb3e286259b2f51206487
diff --git a/libpldm/firmware_update.h b/libpldm/firmware_update.h
index 97a13fb..a14bfb5 100644
--- a/libpldm/firmware_update.h
+++ b/libpldm/firmware_update.h
@@ -7,6 +7,7 @@
#include "base.h"
#include "utils.h"
+#define PLDM_FWUP_COMPONENT_BITMAP_MULTIPLE 8
#define PLDM_QUERY_DEVICE_IDENTIFIERS_REQ_BYTES 0
/** @brief Minimum length of device descriptor, 2 bytes for descriptor type,
* 2 bytes for descriptor length and atleast 1 byte of descriptor data
@@ -77,6 +78,20 @@
PLDM_FWUP_UBM_CONTROLLER_DEVICE_CODE_LENGTH = 4
};
+/** @struct pldm_package_header_information
+ *
+ * Structure representing fixed part of package header information
+ */
+struct pldm_package_header_information {
+ uint8_t uuid[PLDM_FWUP_UUID_LENGTH];
+ uint8_t package_header_format_version;
+ uint16_t package_header_size;
+ uint8_t timestamp104[PLDM_TIMESTAMP104_SIZE];
+ uint16_t component_bitmap_bit_length;
+ uint8_t package_version_string_type;
+ uint8_t package_version_string_length;
+} __attribute__((packed));
+
/** @struct pldm_descriptor_tlv
*
* Structure representing descriptor type, length and value
@@ -141,6 +156,21 @@
bitfield32_t capabilities_during_update;
} __attribute__((packed));
+/** @brief Decode the PLDM package header information
+ *
+ * @param[in] data - pointer to package header information
+ * @param[in] length - available length in the firmware update package
+ * @param[out] package_header_info - pointer to fixed part of PLDM package
+ * header information
+ * @param[out] package_version_str - pointer to package version string
+ *
+ * @return pldm_completion_codes
+ */
+int decode_pldm_package_header_info(
+ const uint8_t *data, size_t length,
+ struct pldm_package_header_information *package_header_info,
+ struct variable_field *package_version_str);
+
/** @brief Decode the record descriptor entries in the firmware update package
* and the Descriptors in the QueryDeviceIDentifiers command
*