Add handling for FRU prefixes

There are some FRU eeproms in the wild that use the custom field to
represent the MAC address, but prefix the mac itself with "MAC:"

Detect this case, and expose this as a new field MAC_<Previous
fieldname>.  This allows Entity-Manager to properly parse the MAC
address to fill into EthernetInterface and set the MAC address.

Tested: Boot a platform with this type of fru (P3809)
Observe that the MAC address is set correctly.  Introspecting DBUS shows
the mac field was added correctly

Change-Id: I03dbeebc41c8e589d7992b91d589f40e9e11f5c5
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/configurations/nvidia_bmc_p3809.json b/configurations/nvidia_bmc_p3809.json
index 1f9b91f..65686ea 100644
--- a/configurations/nvidia_bmc_p3809.json
+++ b/configurations/nvidia_bmc_p3809.json
@@ -9,5 +9,8 @@
     ],
     "Name": "BMC",
     "Probe": "xyz.openbmc_project.FruDevice({'PRODUCT_MANUFACTURER': 'NVIDIA', 'PRODUCT_PRODUCT_NAME': 'P3809-BMC'})",
-    "Type": "Board"
+    "Type": "Board",
+    "xyz.openbmc_project.Inventory.Item.NetworkInterface": {
+        "MACAddress": "$MAC_BOARD_INFO_AM2"
+    }
 }
diff --git a/src/fru_utils.cpp b/src/fru_utils.cpp
index 0c5c2fc..0a1f583 100644
--- a/src/fru_utils.cpp
+++ b/src/fru_utils.cpp
@@ -384,6 +384,7 @@
     state = res.first;
     std::string value = res.second;
     std::string name;
+    bool isCustomField = false;
     if (fieldIndex < fruAreaFieldNames.size())
     {
         name = std::string(getFruAreaName(area)) + "_" +
@@ -391,6 +392,7 @@
     }
     else
     {
+        isCustomField = true;
         name = std::string(getFruAreaName(area)) + "_" + fruCustomFieldName +
                std::to_string(fieldIndex - fruAreaFieldNames.size() + 1);
     }
@@ -403,7 +405,16 @@
                          [](char ch) { return ((ch != 0) && (ch != ' ')); })
                 .base(),
             value.end());
-
+        if (isCustomField)
+        {
+            // Some MAC addresses are stored in a custom field, with
+            // "MAC:" prefixed on the value.  If we see that, create a
+            // new field with the decoded data
+            if (value.starts_with("MAC: "))
+            {
+                result["MAC_" + name] = value.substr(5);
+            }
+        }
         result[name] = std::move(value);
         ++fieldIndex;
     }
diff --git a/test/test_fru-utils.cpp b/test/test_fru-utils.cpp
index 19aff02..9d154f6 100644
--- a/test/test_fru-utils.cpp
+++ b/test/test_fru-utils.cpp
@@ -427,6 +427,7 @@
             Pair("BOARD_PRODUCT_NAME", "P3809"),
             Pair("BOARD_SERIAL_NUMBER", "1583324800150"),
             Pair("Common_Format_Version", "1"), Pair("PRODUCT_ASSET_TAG", ""),
+            Pair("MAC_BOARD_INFO_AM2", "3C:6D:66:14:C8:7A"),
             Pair("PRODUCT_FRU_VERSION_ID", "v0.1"),
             Pair("PRODUCT_LANGUAGE_CODE", "25"),
             Pair("PRODUCT_MANUFACTURER", "NVIDIA"),