From patchwork Thu Jan 22 08:03:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Feldman X-Patchwork-Id: 431698 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 33366140216 for ; Thu, 22 Jan 2015 19:07:10 +1100 (AEDT) Received: from localhost ([::1]:51567 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YECnE-0006rt-99 for incoming@patchwork.ozlabs.org; Thu, 22 Jan 2015 03:07:08 -0500 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=CJnB5ybhBuYVWaQ08c/QaPO0tZlUyd2aBYioTr931Fc=; b=0Uk/SfIMJ/YdQanCMkAYiNOPRTGUzBzjYIBAaK8lxEAO3VPlPX6tEb6PjiS43jYbdH Gp4JwDubZDPezSFhK3VikqoE1fWi5Kt0dMbErjl69wykNIv20C8Aj+XSFArCZ3r2ut+w knrgweP/YCKHni9+3S6BwjMYk+qxWWEkNjvGmUH0YOlvpTYs19EiNlnk7WjpkRQiiy7p 3KOQaLAaQdtq9XW9yPvRc7TDUOzTdC94At3H1XXeaaoR9tsNMmIIHzSaA09LQKXkR492 RYsQi2o0YGIqujiXiqYjgGnEbbfc9349vQ65Y6QTt4fRthB55KH+psXF1ers15t861R/ Iw6w== X-Received: by 10.66.55.41 with SMTP id o9mr206969pap.80.1421913766029; Thu, 22 Jan 2015 00:02:46 -0800 (PST) Received: from rocker1.home (static-50-53-122-54.bvtn.or.frontiernet.net. [50.53.122.54]) by mx.google.com with ESMTPSA id le6sm8368368pab.33.2015.01.22.00.02.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jan 2015 00:02:45 -0800 (PST) From: sfeldma@gmail.com 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 Date: Thu, 22 Jan 2015 00:03:50 -0800 Message-Id: <1421913839-22448-2-git-send-email-sfeldma@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1421913839-22448-1-git-send-email-sfeldma@gmail.com> References: <1421913839-22448-1-git-send-email-sfeldma@gmail.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::22a Subject: [Qemu-devel] [PATCH v5 01/10] net: add MAC address string printer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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),