[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 1/4] util: add qemu_ether_ntoa
From: |
Alexey Kardashevskiy |
Subject: |
[Qemu-devel] [PATCH v4 1/4] util: add qemu_ether_ntoa |
Date: |
Tue, 11 Mar 2014 10:42:26 +1100 |
This adds a helper to format ethernet MAC address.
Signed-off-by: Alexey Kardashevskiy <address@hidden>
---
include/qemu-common.h | 2 ++
util/cutils.c | 14 ++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/include/qemu-common.h b/include/qemu-common.h
index c8a58a8..a998e8d 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -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
diff --git a/util/cutils.c b/util/cutils.c
index 0116fcd..b337293 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -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;
+}
--
1.8.4.rc4