From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=60536 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PIAAM-0006Xe-Ou for qemu-devel@nongnu.org; Mon, 15 Nov 2010 20:17:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PIAAL-0006ug-Is for qemu-devel@nongnu.org; Mon, 15 Nov 2010 20:16:58 -0500 Received: from e3.ny.us.ibm.com ([32.97.182.143]:57465) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PIAAL-0006uZ-G9 for qemu-devel@nongnu.org; Mon, 15 Nov 2010 20:16:57 -0500 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by e3.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id oAG0xUlG018101 for ; Mon, 15 Nov 2010 19:59:30 -0500 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oAG1GvqC399938 for ; Mon, 15 Nov 2010 20:16:57 -0500 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 oAG1Gu9u027997 for ; Mon, 15 Nov 2010 20:16:57 -0500 From: Michael Roth Date: Mon, 15 Nov 2010 19:15:58 -0600 Message-Id: <1289870175-14880-5-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1289870175-14880-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1289870175-14880-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC][PATCH v3 04/21] 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: agl@linux.vnet.ibm.com, abeekhof@redhat.com, mdroth@linux.vnet.ibm.com, aliguori@linux.vnet.ibm.com, ryanh@us.ibm.com, amit.shah@redhat.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 3686c77..2cfd905 100644 --- a/virtproxy.c +++ b/virtproxy.c @@ -151,3 +151,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