types: Remove custom MacAddr type
The standard library has an ether_addr type that does the same job.
Change-Id: I98685b0b60dd07453ae2362adb33e0a7c9c3132c
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/util.cpp b/util.cpp
index 6bc1497..91030c8 100644
--- a/util.cpp
+++ b/util.cpp
@@ -603,30 +603,9 @@
return sdbusplus::message::variant_ns::get<std::string>(value);
}
-MacAddr fromBuf(std::string_view buf)
+std::string toString(const ether_addr& mac)
{
- MacAddr ret;
- if (buf.size() != ret.size())
- {
- throw std::runtime_error("Invalid MacAddr size");
- }
- memcpy(ret.data(), buf.data(), ret.size());
- return ret;
-}
-
-std::string toString(const MacAddr& mac)
-{
- std::string str;
- str.reserve(mac.size() * 3);
- for (size_t i = 0; i < mac.size(); ++i)
- {
- str.push_back(internal::toHex(mac[i] >> 4));
- str.push_back(internal::toHex(mac[i]));
- str.push_back(':');
- }
- // Remove trailing semicolon
- str.pop_back();
- return str;
+ return ether_ntoa(&mac);
}
} // namespace mac_address