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/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;
}