]> Git Repo - qemu.git/commitdiff
util: add qemu_ether_ntoa
authorAlexey Kardashevskiy <[email protected]>
Mon, 10 Mar 2014 23:42:26 +0000 (10:42 +1100)
committerAmit Shah <[email protected]>
Thu, 27 Mar 2014 09:48:45 +0000 (15:18 +0530)
This adds a helper to format ethernet MAC address.

Signed-off-by: Alexey Kardashevskiy <[email protected]>
Reviewed-by: Juan Quintela <[email protected]>
Signed-off-by: Amit Shah <[email protected]>
include/qemu-common.h
util/cutils.c

index c8a58a873a3b9f323c60e805bd42cf02d4112f1b..a998e8d36c85c2f0f33d1a60d8fc166f2ac510e5 100644 (file)
@@ -472,4 +472,6 @@ size_t buffer_find_nonzero_offset(const void *buf, size_t len);
  */
 int parse_debug_env(const char *name, int max, int initial);
 
+const char *qemu_ether_ntoa(const MACAddr *mac);
+
 #endif
index 0116fcde74f197f0d41b2f393c9fd7ae4c9de073..b3372932390564e5f665e39c6ea09dc0a3dfbef8 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "qemu/sockets.h"
 #include "qemu/iov.h"
+#include "net/net.h"
 
 void strpadcpy(char *buf, int buf_size, const char *str, char pad)
 {
@@ -530,3 +531,16 @@ int parse_debug_env(const char *name, int max, int initial)
     }
     return debug;
 }
+
+/*
+ * Helper to print ethernet mac address
+ */
+const char *qemu_ether_ntoa(const MACAddr *mac)
+{
+    static char ret[18];
+
+    snprintf(ret, sizeof(ret), "%02x:%02x:%02x:%02x:%02x:%02x",
+             mac->a[0], mac->a[1], mac->a[2], mac->a[3], mac->a[4], mac->a[5]);
+
+    return ret;
+}
This page took 0.029829 seconds and 4 git commands to generate.