From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NDMyi-0007Nr-6Q for qemu-devel@nongnu.org; Wed, 25 Nov 2009 13:52:36 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NDMyY-0007Hf-KJ for qemu-devel@nongnu.org; Wed, 25 Nov 2009 13:52:32 -0500 Received: from [199.232.76.173] (port=49000 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDMyY-0007HC-9y for qemu-devel@nongnu.org; Wed, 25 Nov 2009 13:52:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39169) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NDMyX-0000ET-LP for qemu-devel@nongnu.org; Wed, 25 Nov 2009 13:52:26 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nAPIqOfe015245 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 25 Nov 2009 13:52:24 -0500 From: Mark McLoughlin Date: Wed, 25 Nov 2009 18:49:10 +0000 Message-Id: <1259174977-26212-18-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> Subject: [Qemu-devel] [PATCH 17/44] net: introduce NICState and qemu_new_nic() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Mark McLoughlin Common state for all NICs. The opaque member will replace the opaque member in VLANClientState since only NICs need it. The conf member will allow us to iterate over NICs, access the MAC addr for the NIC and send a packet from each NIC in qemu_announce_self(). Signed-off-by: Mark McLoughlin --- net.c | 21 +++++++++++++++++++++ net.h | 11 +++++++++++ 2 files changed, 32 insertions(+), 0 deletions(-) diff --git a/net.c b/net.c index 355eb87..7195827 100644 --- a/net.c +++ b/net.c @@ -293,6 +293,27 @@ VLANClientState *qemu_new_net_client(NetClientInfo *info, return vc; } +NICState *qemu_new_nic(NetClientInfo *info, + NICConf *conf, + const char *model, + const char *name, + void *opaque) +{ + VLANClientState *nc; + NICState *nic; + + assert(info->type == NET_CLIENT_TYPE_NIC); + assert(info->size >= sizeof(NICState)); + + nc = qemu_new_net_client(info, conf->vlan, conf->peer, model, name); + + nic = DO_UPCAST(NICState, nc, nc); + nic->conf = conf; + nic->opaque = opaque; + + return nic; +} + VLANClientState *qemu_new_vlan_client(net_client_type type, VLANState *vlan, VLANClientState *peer, diff --git a/net.h b/net.h index 71a9a44..4de20de 100644 --- a/net.h +++ b/net.h @@ -75,6 +75,12 @@ struct VLANClientState { unsigned receive_disabled : 1; }; +typedef struct NICState { + VLANClientState nc; + NICConf *conf; + void *opaque; +} NICState; + struct VLANState { int id; QTAILQ_HEAD(, VLANClientState) clients; @@ -90,6 +96,11 @@ VLANClientState *qemu_new_net_client(NetClientInfo *info, VLANClientState *peer, const char *model, const char *name); +NICState *qemu_new_nic(NetClientInfo *info, + NICConf *conf, + const char *model, + const char *name, + void *opaque); VLANClientState *qemu_new_vlan_client(net_client_type type, VLANState *vlan, VLANClientState *peer, -- 1.6.5.2