Skip to content

Commit

Permalink
util: add qemu_ether_ntoa
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
aik authored and Amit Shah committed Mar 27, 2014
1 parent db237e3 commit 4297c8e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/qemu-common.h
Expand Up @@ -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
14 changes: 14 additions & 0 deletions util/cutils.c
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}

0 comments on commit 4297c8e

Please sign in to comment.