[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC][PATCH v2 10/19] virtproxy: add handler for data packe
From: |
Michael Roth |
Subject: |
[Qemu-devel] [RFC][PATCH v2 10/19] virtproxy: add handler for data packets |
Date: |
Wed, 10 Nov 2010 16:28:06 -0600 |
Process VPPackets coming in from channel and send them to the
appropriate server/client connections.
Signed-off-by: Michael Roth <address@hidden>
---
virtproxy.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/virtproxy.c b/virtproxy.c
index f189e2c..a0bbe7f 100644
--- a/virtproxy.c
+++ b/virtproxy.c
@@ -268,6 +268,48 @@ static void vp_channel_accept(void *opaque)
vp_set_fd_handler(drv->listen_fd, NULL, NULL, NULL);
}
+/* handle data packets
+ *
+ * process VPPackets containing data and send them to the corresponding
+ * FDs
+ */
+static int vp_handle_data_packet(void *drv, const VPPacket *pkt)
+{
+ int fd, ret;
+
+ TRACE("called with drv: %p", drv);
+
+ if (pkt->type == VP_PKT_CLIENT) {
+ TRACE("recieved client packet, client fd: %d, server fd: %d",
+ pkt->payload.proxied.client_fd, pkt->payload.proxied.server_fd);
+ fd = pkt->payload.proxied.server_fd;
+ } else if (pkt->type == VP_PKT_SERVER) {
+ TRACE("recieved server packet, client fd: %d, server fd: %d",
+ pkt->payload.proxied.client_fd, pkt->payload.proxied.server_fd);
+ fd = pkt->payload.proxied.client_fd;
+ } else {
+ TRACE("unknown packet type");
+ return -1;
+ }
+
+ /* TODO: proxied in non-blocking mode can causes us to spin here
+ * for slow servers/clients. need to use write()'s and maintain
+ * a per-conn write queue that we clear out before sending any
+ * more data to the fd
+ */
+ ret = vp_send_all(fd, (void *)pkt->payload.proxied.data,
+ pkt->payload.proxied.bytes);
+ if (ret == -1) {
+ LOG("error sending data over channel");
+ return -1;
+ } else if (ret != pkt->payload.proxied.bytes) {
+ TRACE("buffer full?");
+ return -1;
+ }
+
+ return 0;
+}
+
/* process a stream of packets coming in from the channel */
int vp_handle_packet_buf(VPDriver *drv, const void *buf, int count)
{
--
1.7.0.4
- [Qemu-devel] [RFC][PATCH v2 15/19] virtproxy: add virtproxy-builtin.c for compat defs, (continued)
- [Qemu-devel] [RFC][PATCH v2 15/19] virtproxy: add virtproxy-builtin.c for compat defs, Michael Roth, 2010/11/10
- [Qemu-devel] [RFC][PATCH v2 16/19] virtproxy: qemu integration, add virtproxy chardev, Michael Roth, 2010/11/10
- [Qemu-devel] [RFC][PATCH v2 14/19] virtproxy: add read handler for proxied connections, Michael Roth, 2010/11/10
- [Qemu-devel] [RFC][PATCH v2 13/19] virtproxy: interfaces to set/remove VPIForwards, Michael Roth, 2010/11/10
- [Qemu-devel] [RFC][PATCH v2 09/19] virtproxy: interfaces to set/remove/handle VPOForwards, Michael Roth, 2010/11/10
- [Qemu-devel] [RFC][PATCH v2 11/19] virtproxy: add handler for control packet, Michael Roth, 2010/11/10
- [Qemu-devel] [RFC][PATCH v2 08/19] virtproxy: add vp_new() VPDriver constructor, Michael Roth, 2010/11/10
- [Qemu-devel] [RFC][PATCH v2 06/19] virtproxy: add accept handler for communication channel, Michael Roth, 2010/11/10
- [Qemu-devel] [RFC][PATCH v2 07/19] virtproxy: add read handler for communication channel, Michael Roth, 2010/11/10
- [Qemu-devel] [RFC][PATCH v2 05/19] virtproxy, add vp_channel_send_all, Michael Roth, 2010/11/10
- [Qemu-devel] [RFC][PATCH v2 10/19] virtproxy: add handler for data packets,
Michael Roth <=
- [Qemu-devel] [RFC][PATCH v2 03/19] virtproxy: add debug functions for virtproxy core, Michael Roth, 2010/11/10
- [Qemu-devel] [RFC][PATCH v2 04/19] virtproxy: list look-up functions conns/oforwards/iforwards, Michael Roth, 2010/11/10
- [Qemu-devel] [RFC][PATCH v2 01/19] virtproxy: base data structures and constants, Michael Roth, 2010/11/10
- [Qemu-devel] [RFC][PATCH v2 02/19] virtproxy: qemu-vp, standalone daemon skeleton, Michael Roth, 2010/11/10
- [Qemu-devel] [RFC][PATCH v2 12/19] virtproxy: add vp_handle_packet(), Michael Roth, 2010/11/10
- Re: [Qemu-devel] [RFC][PATCH v2 00/19] virtproxy: host/guest communication layer, Michael Roth, 2010/11/10