From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=58438 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P9MbB-00075A-Jd for qemu-devel@nongnu.org; Fri, 22 Oct 2010 14:44:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P9Mb8-0001r9-6a for qemu-devel@nongnu.org; Fri, 22 Oct 2010 14:44:16 -0400 Received: from e5.ny.us.ibm.com ([32.97.182.145]:53177) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P9Mb7-0001kb-Sj for qemu-devel@nongnu.org; Fri, 22 Oct 2010 14:44:14 -0400 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by e5.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id o9MIN72B021039 for ; Fri, 22 Oct 2010 14:23:07 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o9MIhsKv2347110 for ; Fri, 22 Oct 2010 14:43:54 -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 o9MIhsSf014846 for ; Fri, 22 Oct 2010 14:43:54 -0400 From: Michael Roth Date: Fri, 22 Oct 2010 13:43:20 -0500 Message-Id: <1287773011-24726-5-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1287773011-24726-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1287773011-24726-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC][PATCH 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: aliguori@linux.vnet.ibm.com, ryanh@us.ibm.com, agl@linux.vnet.ibm.com, mdroth@linux.vnet.ibm.com, abeekhof@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 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