diff options
author | Alexey Kardashevskiy <aik@ozlabs.ru> | 2014-03-11 10:42:26 +1100 |
---|---|---|
committer | Amit Shah <amit.shah@redhat.com> | 2014-03-27 15:18:45 +0530 |
commit | 4297c8ee6f0ef70e5a71e3387a0fccaa20b04f94 (patch) | |
tree | 0f112bd18364728886a78a2d67b1156e8933a21c /util | |
parent | db237e33c08a279f0179f8f5128a6d10d9adc38a (diff) | |
download | hqemu-4297c8ee6f0ef70e5a71e3387a0fccaa20b04f94.zip hqemu-4297c8ee6f0ef70e5a71e3387a0fccaa20b04f94.tar.gz |
util: add qemu_ether_ntoa
This adds a helper to format ethernet MAC address.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Diffstat (limited to 'util')
-rw-r--r-- | util/cutils.c | 14 |
1 files changed, 14 insertions, 0 deletions
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; +} |