From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YECj5-00089B-EE for qemu-devel@nongnu.org; Thu, 22 Jan 2015 03:02:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YECj1-0005XI-0l for qemu-devel@nongnu.org; Thu, 22 Jan 2015 03:02:51 -0500 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]:46603) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YECj0-0005X8-Pl for qemu-devel@nongnu.org; Thu, 22 Jan 2015 03:02:46 -0500 Received: by mail-pa0-f42.google.com with SMTP id et14so282373pad.1 for ; Thu, 22 Jan 2015 00:02:46 -0800 (PST) From: sfeldma@gmail.com Date: Thu, 22 Jan 2015 00:03:50 -0800 Message-Id: <1421913839-22448-2-git-send-email-sfeldma@gmail.com> In-Reply-To: <1421913839-22448-1-git-send-email-sfeldma@gmail.com> References: <1421913839-22448-1-git-send-email-sfeldma@gmail.com> Subject: [Qemu-devel] [PATCH v5 01/10] net: add MAC address string printer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, jiri@resnulli.us, roopa@cumulusnetworks.com, john.fastabend@gmail.com, eblake@redhat.com, pbonzini@redhat.com, stefanha@gmail.com, dsahern@gmail.com, jasowang@redhat.com From: Scott Feldman We can use this in virtio-net code as well as new Rocker driver code, so up-level this. Signed-off-by: Scott Feldman --- include/net/net.h | 1 + net/net.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index 008d610..90742f0 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -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); diff --git a/net/net.c b/net/net.c index 7acc162..2387616 100644 --- a/net/net.c +++ b/net/net.c @@ -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), -- 1.7.10.4