PEL: Add PELs from ESELs

When the OpenPower host firmware subsystem hostboot creates PELs, those
PELs get added to OpenBMC event logs in the ESEL entry of the
AdditionalData property.  (Eventually hostboot will update their code to
use PLDM to send down PELs.)

This commit looks for that ESEL keyword on incoming event logs, extracts
the PEL data, and adds it to the PEL repository with all of the other
PELs.

It extracts the PEL data by converting the string value to a vector of
uint8_ts starting after the IPMI data fields contained in that string.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I2b7f2915dceb9c306466b8181cae05a3ddd65057
diff --git a/extensions/openpower-pels/manager.hpp b/extensions/openpower-pels/manager.hpp
index bec67ca..86030d4 100644
--- a/extensions/openpower-pels/manager.hpp
+++ b/extensions/openpower-pels/manager.hpp
@@ -161,6 +161,20 @@
      */
     void hostReject(uint32_t pelID, RejectionReason reason) override;
 
+    /**
+     * @brief Converts the ESEL field in an OpenBMC event log to a
+     *        vector of uint8_ts that just contains the PEL data.
+     *
+     * That data string looks like: "50 48 00 ab ..."
+     *
+     * Throws an exception on any failures.
+     *
+     * @param[in] esel - The ESEL string
+     *
+     * @return std::vector<uint8_t> - The contained PEL data
+     */
+    static std::vector<uint8_t> eselToRawData(const std::string& esel);
+
   private:
     /**
      * @brief Adds a received raw PEL to the PEL repository
@@ -208,6 +222,23 @@
     void closeFD(int fd, sdeventplus::source::EventBase& source);
 
     /**
+     * @brief Adds a PEL to the repository given its data
+     *
+     * @param[in] pelData - The PEL to add as a vector of uint8_ts
+     * @param[in] obmcLogID - the OpenBMC event log ID
+     */
+    void addPEL(std::vector<uint8_t>& pelData, uint32_t obmcLogID);
+
+    /**
+     * @brief Adds the PEL stored in the ESEL field of the AdditionalData
+     *        property of an OpenBMC event log to the repository.
+     *
+     * @param[in] esel - The ESEL AdditionalData contents
+     * @param[in] obmcLogID - The OpenBMC event log ID
+     */
+    void addESELPEL(const std::string& esel, uint32_t obmcLogID);
+
+    /**
      * @brief Reference to phosphor-logging's Manager class
      */
     phosphor::logging::internal::Manager& _logManager;