Message ID | 1288798090-7127-5-git-send-email-mdroth@linux.vnet.ibm.com |
---|---|
State | New |
Headers | show |
You should describe your changes a little bit more on the top here. Looks good otherwise. On Wed, 2010-11-03 at 10:27 -0500, Michael Roth wrote: > Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> > --- > 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; > +}
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; +}
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> --- virtproxy.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-)