From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=51610 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PDfGb-0001JW-Na for qemu-devel@nongnu.org; Wed, 03 Nov 2010 11:28:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PDfGa-00072x-7c for qemu-devel@nongnu.org; Wed, 03 Nov 2010 11:28:49 -0400 Received: from e2.ny.us.ibm.com ([32.97.182.142]:47262) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PDfGa-00072q-3z for qemu-devel@nongnu.org; Wed, 03 Nov 2010 11:28:48 -0400 Received: from d01relay03.pok.ibm.com (d01relay03.pok.ibm.com [9.56.227.235]) by e2.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id oA3FCu1t017821 for ; Wed, 3 Nov 2010 11:12:56 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oA3FSk8S098466 for ; Wed, 3 Nov 2010 11:28:46 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id oA3FSjo5007430 for ; Wed, 3 Nov 2010 11:28:46 -0400 From: Michael Roth Date: Wed, 3 Nov 2010 10:27:59 -0500 Message-Id: <1288798090-7127-5-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1288798090-7127-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1288798090-7127-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC][RESEND][PATCH v1 04/15] virtproxy: list look-up functions conns/oforwards/iforwards List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: abeekhof@redhat.com, agl@linux.vnet.ibm.com, mdroth@linux.vnet.ibm.com, aliguori@linux.vnet.ibm.com Signed-off-by: Michael Roth --- virtproxy.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-) diff --git a/virtproxy.c b/virtproxy.c index 2f8996c..fa17722 100644 --- a/virtproxy.c +++ b/virtproxy.c @@ -149,3 +149,47 @@ static QemuOptsList vp_socket_opts = { { /* end if list */ } }, }; + +/* get VPConn by fd, "client" denotes whether to look for client or server */ +static VPConn *get_conn(const VPDriver *drv, int fd, bool client) +{ + VPConn *c = NULL; + int cur_fd; + + QLIST_FOREACH(c, &drv->conns, next) { + cur_fd = client ? c->client_fd : c->server_fd; + if (cur_fd == fd) { + return c; + } + } + + return NULL; +} + +/* get VPOForward by service_id */ +static VPOForward *get_oforward(const VPDriver *drv, const char *service_id) +{ + VPOForward *f = NULL; + + QLIST_FOREACH(f, &drv->oforwards, next) { + if (strncmp(f->service_id, service_id, VP_SERVICE_ID_LEN) == 0) { + return f; + } + } + + return NULL; +} + +/* get VPIForward by service_id */ +static VPIForward *get_iforward(const VPDriver *drv, const char *service_id) +{ + VPIForward *f = NULL; + + QLIST_FOREACH(f, &drv->iforwards, next) { + if (strncmp(f->service_id, service_id, VP_SERVICE_ID_LEN) == 0) { + return f; + } + } + + return NULL; +} -- 1.7.0.4