Allow decoding MAC addresses in some FRUs
Some motherboards store their mac address in a zlib compressed chunk at
a known location in the FRU.  Decode that section, and pull the mac
address into the appropriate field.
This requires some refactoring so that the indexing can now have the
indexes passed through the various parse functions.
To use this functionality requires the use of libxml and zlib, which are
added as new dependencies.
Change-Id: Icb5c2e46e2a08ca83b3559892169ee2b3f319b2e
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/src/fru_device/fru_utils.hpp b/src/fru_device/fru_utils.hpp
index 0491b30..d689d5c 100644
--- a/src/fru_device/fru_utils.hpp
+++ b/src/fru_device/fru_utils.hpp
@@ -126,6 +126,14 @@
 
 ssize_t getFieldLength(uint8_t fruFieldTypeLenValue);
 
+struct FruSections
+{
+    off_t IpmiFruOffset = 0;
+    std::array<uint8_t, I2C_SMBUS_BLOCK_MAX> ipmiFruBlock;
+
+    off_t GigabyteXmlOffset = 0;
+};
+
 /// \brief Find a FRU header.
 /// \param reader the FRUReader to read via
 /// \param errorHelp and a helper string for failures
@@ -134,9 +142,8 @@
 ///        set to 0 to perform search;
 ///        returns the offset at which a header was found
 /// \return whether a header was found
-bool findFRUHeader(FRUReader& reader, const std::string& errorHelp,
-                   std::array<uint8_t, I2C_SMBUS_BLOCK_MAX>& blockData,
-                   off_t& baseOffset);
+std::optional<FruSections> findFRUHeader(
+    FRUReader& reader, const std::string& errorHelp, off_t offset);
 
 /// \brief Read and validate FRU contents.
 /// \param reader the FRUReader to read via
@@ -229,4 +236,6 @@
 
 bool updateAddProperty(const std::string& propertyValue,
                        const std::string& propertyName,
-                       std::vector<uint8_t>& data);
+                       std::vector<uint8_t>& fruData);
+
+std::string parseMacFromGzipXmlHeader(FRUReader& reader, off_t offset);