util: enhance MAC address parsing
Current ether_aton does not support the MAC string without colons.
Add extra conversion when string length equal to 12.
Test log:
1/7 config_parser OK 0.01s
2/7 neighbor OK 0.01s
3/7 netlink OK 0.01s
4/7 util OK 0.01s
5/7 network_manager OK 0.01s
6/7 ethernet_interface OK 0.01s
7/7 vlan_interface OK 0.01s
Ok: 7
Expected Fail: 0
Fail: 0
Unexpected Pass: 0
Skipped: 0
Timeout: 0
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Change-Id: Id2125af85f1c3d75424ff6ea0980c1460614f14e
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/src/util.hpp b/src/util.hpp
index 804d492..b1d27c4 100644
--- a/src/util.hpp
+++ b/src/util.hpp
@@ -44,11 +44,7 @@
* @returns A mac address in network byte order
* @throws std::runtime_error for bad mac
*/
-ether_addr fromString(const char* str);
-inline ether_addr fromString(const std::string& str)
-{
- return fromString(str.c_str());
-}
+ether_addr fromString(std::string_view str);
/** @brief Converts the given mac address bytes into a string
* @param[in] mac - The mac address