Patchwork [RFC,RESEND,v1,11/15] virtproxy: add vp_handle_packet()

login
register
mail settings
Submitter Michael Roth
Date Nov. 3, 2010, 3:28 p.m.
Message ID <1288798090-7127-12-git-send-email-mdroth@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/70022/
State New
Headers show

Comments

Michael Roth - Nov. 3, 2010, 3:28 p.m.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 virtproxy.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
Adam Litke - Nov. 4, 2010, 1:13 a.m.
Description please.

On Wed, 2010-11-03 at 10:28 -0500, Michael Roth wrote:
> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> ---
>  virtproxy.c |   23 +++++++++++++++++++++++
>  1 files changed, 23 insertions(+), 0 deletions(-)
> 
> diff --git a/virtproxy.c b/virtproxy.c
> index 4f56aba..5ec4e77 100644
> --- a/virtproxy.c
> +++ b/virtproxy.c
> @@ -431,6 +431,29 @@ static int vp_handle_data_packet(void *drv, const VPPacket *pkt)
>      return 0;
>  }
> 
> +static inline int vp_handle_packet(VPDriver *drv, const VPPacket *pkt)
> +{
> +    int ret;
> +
> +    TRACE("called with drv: %p", drv);
> +
> +    if (pkt->magic != VP_MAGIC) {
> +        LOG("invalid packet magic field");
> +        return -1;
> +    }
> +
> +    if (pkt->type == VP_PKT_CONTROL) {
> +        ret = vp_handle_control_packet(drv, pkt);
> +    } else if (pkt->type == VP_PKT_CLIENT || pkt->type == VP_PKT_SERVER) {
> +        ret = vp_handle_data_packet(drv, pkt);
> +    } else {
> +        LOG("invalid packet type");
> +        return -1;
> +    }
> +
> +    return ret;
> +}
> +
>  /* read handler for communication channel
>   *
>   * de-multiplexes data coming in over the channel. for control messages

Patch

diff --git a/virtproxy.c b/virtproxy.c
index 4f56aba..5ec4e77 100644
--- a/virtproxy.c
+++ b/virtproxy.c
@@ -431,6 +431,29 @@  static int vp_handle_data_packet(void *drv, const VPPacket *pkt)
     return 0;
 }
 
+static inline int vp_handle_packet(VPDriver *drv, const VPPacket *pkt)
+{
+    int ret;
+
+    TRACE("called with drv: %p", drv);
+
+    if (pkt->magic != VP_MAGIC) {
+        LOG("invalid packet magic field");
+        return -1;
+    }
+
+    if (pkt->type == VP_PKT_CONTROL) {
+        ret = vp_handle_control_packet(drv, pkt);
+    } else if (pkt->type == VP_PKT_CLIENT || pkt->type == VP_PKT_SERVER) {
+        ret = vp_handle_data_packet(drv, pkt);
+    } else {
+        LOG("invalid packet type");
+        return -1;
+    }
+
+    return ret;
+}
+
 /* read handler for communication channel
  *
  * de-multiplexes data coming in over the channel. for control messages