From patchwork Wed Nov 25 18:49:31 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark McLoughlin X-Patchwork-Id: 39439 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C79461007D1 for ; Thu, 26 Nov 2009 06:42:59 +1100 (EST) Received: from localhost ([127.0.0.1]:37838 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDNlQ-0003Zv-93 for incoming@patchwork.ozlabs.org; Wed, 25 Nov 2009 14:42:56 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NDMyn-0007Ry-5c for qemu-devel@nongnu.org; Wed, 25 Nov 2009 13:52:41 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NDMya-0007JV-Qg for qemu-devel@nongnu.org; Wed, 25 Nov 2009 13:52:37 -0500 Received: from [199.232.76.173] (port=49011 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDMyZ-0007Im-O9 for qemu-devel@nongnu.org; Wed, 25 Nov 2009 13:52:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:12138) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NDMyZ-0000FF-3G for qemu-devel@nongnu.org; Wed, 25 Nov 2009 13:52:27 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nAPIqQ1O001623 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 25 Nov 2009 13:52:26 -0500 Received: from blaa.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nAPIqNvg000340; Wed, 25 Nov 2009 13:52:25 -0500 Received: by blaa.localdomain (Postfix, from userid 500) id 323CCB07D; Wed, 25 Nov 2009 18:49:43 +0000 (GMT) From: Mark McLoughlin To: qemu-devel@nongnu.org Date: Wed, 25 Nov 2009 18:49:31 +0000 Message-Id: <1259174977-26212-39-git-send-email-markmc@redhat.com> In-Reply-To: <1259174977-26212-1-git-send-email-markmc@redhat.com> References: <1259174977-26212-1-git-send-email-markmc@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Mark McLoughlin Subject: [Qemu-devel] [PATCH 38/44] net: add qemu_foreach_nic() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Mark McLoughlin --- net.c | 20 ++++++++++++++++++++ net.h | 2 ++ 2 files changed, 22 insertions(+), 0 deletions(-) diff --git a/net.c b/net.c index a1ec243..c71699d 100644 --- a/net.c +++ b/net.c @@ -326,6 +326,26 @@ qemu_find_vlan_client_by_name(Monitor *mon, int vlan_id, return vc; } +void qemu_foreach_nic(qemu_nic_foreach func, void *opaque) +{ + VLANClientState *nc; + VLANState *vlan; + + QTAILQ_FOREACH(nc, &non_vlan_clients, next) { + if (nc->info->type == NET_CLIENT_TYPE_NIC) { + func(DO_UPCAST(NICState, nc, nc), opaque); + } + } + + QTAILQ_FOREACH(vlan, &vlans, next) { + QTAILQ_FOREACH(nc, &vlan->clients, next) { + if (nc->info->type == NET_CLIENT_TYPE_NIC) { + func(DO_UPCAST(NICState, nc, nc), opaque); + } + } + } +} + int qemu_can_send_packet(VLANClientState *sender) { VLANState *vlan = sender->vlan; diff --git a/net.h b/net.h index 497a737..d583d59 100644 --- a/net.h +++ b/net.h @@ -95,6 +95,8 @@ NICState *qemu_new_nic(NetClientInfo *info, void qemu_del_vlan_client(VLANClientState *vc); VLANClientState *qemu_find_vlan_client_by_name(Monitor *mon, int vlan_id, const char *client_str); +typedef void (*qemu_nic_foreach)(NICState *nic, void *opaque); +void qemu_foreach_nic(qemu_nic_foreach func, void *opaque); int qemu_can_send_packet(VLANClientState *vc); ssize_t qemu_sendv_packet(VLANClientState *vc, const struct iovec *iov, int iovcnt);