PEL: Add APIs to read the FW versions

Add methods to the DataInterface class to read the BMC and server
firmware versions.  The server firmware version represents the version
of all firmware images that are in the flash image, not just the BMC.
There is nowhere to get that version yet, so this commit just has a
placeholder.

These will be used by the ExtendedUserHeader section.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I47389714c987337cb96c72b6bf2b270c78003357
diff --git a/extensions/openpower-pels/data_interface.cpp b/extensions/openpower-pels/data_interface.cpp
index 66442c5..7342dc0 100644
--- a/extensions/openpower-pels/data_interface.cpp
+++ b/extensions/openpower-pels/data_interface.cpp
@@ -13,8 +13,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#include "config.h"
+
 #include "data_interface.hpp"
 
+#include <fstream>
 #include <xyz/openbmc_project/State/OperatingSystem/Status/server.hpp>
 
 namespace openpower
@@ -48,6 +51,8 @@
 {
     readMTMS();
     readHostState();
+    readBMCFWVersion();
+    readServerFWVersion();
 }
 
 void DataInterface::readMTMS()
@@ -217,5 +222,27 @@
     }
 }
 
+void DataInterface::readBMCFWVersion()
+{
+    std::ifstream versionFile{BMC_VERSION_FILE};
+    std::string line;
+    static const auto versionID = "VERSION=";
+
+    while (std::getline(versionFile, line))
+    {
+        if (line.find(versionID) != std::string::npos)
+        {
+            auto pos = line.find_first_of('"') + 1;
+            _bmcFWVersion = line.substr(pos, line.find_last_of('"') - pos);
+            break;
+        }
+    }
+}
+
+void DataInterface::readServerFWVersion()
+{
+    // Not available yet
+}
+
 } // namespace pels
 } // namespace openpower