108{
109 int retval = -1;
110 struct rte_ether_addr mac_addr;
111 retval = rte_eth_macaddr_get(iface, &mac_addr);
112 if (retval != 0) {
113 TLOG() <<
"Failed to get MAC address of interface! Err id: " << retval;
114 return std::string("");
115 } else {
116 std::ostringstream ostrs;
117 hex_digits_to_stream(ostrs, (int)mac_addr.addr_bytes[0], ':');
118 hex_digits_to_stream(ostrs, (int)mac_addr.addr_bytes[1], ':');
119 hex_digits_to_stream(ostrs, (int)mac_addr.addr_bytes[2], ':');
120 hex_digits_to_stream(ostrs, (int)mac_addr.addr_bytes[3], ':');
121 hex_digits_to_stream(ostrs, (int)mac_addr.addr_bytes[4], ':');
122 hex_digits_to_stream(ostrs, (int)mac_addr.addr_bytes[5]);
123 std::string mac_str = ostrs.str();
124 mac_str.erase(std::remove(mac_str.begin(), mac_str.end(), ' '), mac_str.end());
125 return mac_str;
126 }
127}