From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJGJx-0001wN-WF for qemu-devel@nongnu.org; Thu, 05 Feb 2015 01:53:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJGJq-0006sw-FB for qemu-devel@nongnu.org; Thu, 05 Feb 2015 01:53:49 -0500 Received: from mail-pd0-f169.google.com ([209.85.192.169]:40892) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJGJi-0006qO-RU for qemu-devel@nongnu.org; Thu, 05 Feb 2015 01:53:42 -0500 Received: by pdjy10 with SMTP id y10so5912783pdj.7 for ; Wed, 04 Feb 2015 22:53:34 -0800 (PST) From: sfeldma@gmail.com Date: Wed, 4 Feb 2015 22:54:12 -0800 Message-Id: <1423119261-60904-2-git-send-email-sfeldma@gmail.com> In-Reply-To: <1423119261-60904-1-git-send-email-sfeldma@gmail.com> References: <1423119261-60904-1-git-send-email-sfeldma@gmail.com> Subject: [Qemu-devel] [PATCH v6 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 Reviewed-by: Eric Blake --- 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