Skip to contentSkip to conversation

net: add MAC address string printer

PATCH Superseded [email protected] 1 participant 1 message Dec 30, 2014 Networking

v1 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH 2/10 net: add MAC address string printer

From: Scott Feldman <[email protected]>

We can use this in virtio-net code as well as new Rocker driver code, so up-level this.

---
 include/net/net.h |    1 +
 net/net.c         |    7 +++++++
 2 files changed, 8 insertions(+)
include/net/net.h +1 -0
index 008d610..90742f0 100644
@@ -97,6 +97,7 @@ typedef struct NICState {
     bool peer_deleted;
 } NICState;
 
+char *qemu_mac_strdup_printf(const uint8_t *macaddr);
 NetClientState *qemu_find_netdev(const char *id);
 int qemu_find_net_clients_except(const char *id, NetClientState **ncs,
                                  NetClientOptionsKind type, int max);
net/net.c +7 -0
index 7acc162..2387616 100644
@@ -151,6 +151,13 @@ int parse_host_port(struct sockaddr_in *saddr, const char *str)
     return 0;
 }
 
+char *qemu_mac_strdup_printf(const uint8_t *macaddr)
+{
+    return g_strdup_printf("%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
+                           macaddr[0], macaddr[1], macaddr[2],
+                           macaddr[3], macaddr[4], macaddr[5]);
+}
+
 void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6])
 {
     snprintf(nc->info_str, sizeof(nc->info_str),
Signature · 1 line
1.7.10.4