platform-mc: Terminus name handling
`PLDM-stack: Adding sensor monitoring section` design spec details that
the `Terminus name` is required to create the terminus's sensors,
states, effecters... D-Bus interfaces and `Terminus Name` can be
encoded in the Terminus's `Entity Auxiliary Names PDR` or in the MCTP
Entity-manager endpoint EID configuration file.
[1] https://gerrit.openbmc.org/c/openbmc/docs/+/47252/34/designs/pldm-stack.md#433
Section `28.18 Entity Auxiliary Names PDR` in DSP0248 V1.2.2 details
about the PDRs response for the name of one PLDM entity. When the
containerID is `0x0000` this entity is `Overall system` or `top most
containing entity`. The name of this entity will can be used as
`Terminus name`.
Support parsing `Entity Auxiliary Names PDR` and find the `Terminus
name` if it is reponsed in the terminus' PDRs. `Terminus Name` string
will be assigned to local variable and can be used as prefix for
sensors, state, effecters... names.
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Change-Id: I701537c48651b9de86de77941b752e30de112916
diff --git a/common/utils.cpp b/common/utils.cpp
index 60154be..1cd5a72 100644
--- a/common/utils.cpp
+++ b/common/utils.cpp
@@ -671,5 +671,15 @@
}
}
+std::string_view trimNameForDbus(std::string& name)
+{
+ std::replace(name.begin(), name.end(), ' ', '_');
+ auto nullTerminatorPos = name.find('\0');
+ if (nullTerminatorPos != std::string::npos)
+ {
+ name.erase(nullTerminatorPos);
+ }
+ return name;
+}
} // namespace utils
} // namespace pldm