summaryrefslogtreecommitdiffstats
path: root/server/red_channel.h
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2010-11-01 17:40:46 +0200
committerAlon Levy <alevy@redhat.com>2010-12-07 21:32:33 +0200
commit23db8c093c043127310e41874fd428e4b24b2d9d (patch)
tree0b45eaf2a8855e5cdac3f732cdb26e9e6c6aaca2 /server/red_channel.h
parent5ada644f3037ad768a54eef2c5b38dd2d7c590d8 (diff)
downloadspice-23db8c093c043127310e41874fd428e4b24b2d9d.tar.gz
spice-23db8c093c043127310e41874fd428e4b24b2d9d.tar.xz
spice-23db8c093c043127310e41874fd428e4b24b2d9d.zip
server: red_channel: add optional parser and separate incoming/outgoing error handlers for later inputs/main channel usage
Diffstat (limited to 'server/red_channel.h')
-rw-r--r--server/red_channel.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/server/red_channel.h b/server/red_channel.h
index 509da775..24f969b9 100644
--- a/server/red_channel.h
+++ b/server/red_channel.h
@@ -26,6 +26,7 @@
#include "reds.h"
#include "spice.h"
#include "ring.h"
+#include "server/demarshallers.h"
#define MAX_SEND_BUFS 1000
#define MAX_SEND_VEC 50
@@ -37,6 +38,7 @@
typedef int (*handle_message_proc)(void *opaque,
SpiceDataHeader *header, uint8_t *msg);
+typedef int (*handle_parsed_proc)(void *opaque, size_t size, uint32_t type, void *message);
typedef uint8_t *(*alloc_msg_recv_buf_proc)(void *opaque, SpiceDataHeader *msg_header);
typedef void (*release_msg_recv_buf_proc)(void *opaque,
SpiceDataHeader *msg_header, uint8_t *msg);
@@ -52,6 +54,10 @@ typedef struct IncomingHandler {
alloc_msg_recv_buf_proc alloc_msg_buf;
on_incoming_error_proc on_error; // recv error or handle_message error
release_msg_recv_buf_proc release_msg_buf; // for errors
+ // The following is an optional alternative to handle_message, used if not null
+ spice_parse_channel_func_t parser;
+ handle_parsed_proc handle_parsed;
+ int shut; // came here from inputs_channel. Not sure if it is really required or can be removed. XXX
} IncomingHandler;
typedef int (*get_outgoing_msg_size_proc)(void *opaque);
@@ -89,6 +95,8 @@ typedef struct RedChannel RedChannel;
typedef uint8_t *(*channel_alloc_msg_recv_buf_proc)(RedChannel *channel,
SpiceDataHeader *msg_header);
+typedef int (*channel_handle_parsed_proc)(RedChannel *channel, size_t size, uint32_t type,
+ void *message);
typedef int (*channel_handle_message_proc)(RedChannel *channel,
SpiceDataHeader *header, uint8_t *msg);
typedef void (*channel_release_msg_recv_buf_proc)(RedChannel *channel,
@@ -98,6 +106,8 @@ typedef int (*channel_configure_socket_proc)(RedChannel *channel);
typedef void (*channel_send_pipe_item_proc)(RedChannel *channel, PipeItem *item);
typedef void (*channel_release_pipe_item_proc)(RedChannel *channel,
PipeItem *item, int item_pushed);
+typedef void (*channel_on_incoming_error_proc)(RedChannel *channel);
+typedef void (*channel_on_outgoing_error_proc)(RedChannel *channel);
struct RedChannel {
RedsStreamContext *peer;
@@ -137,6 +147,11 @@ struct RedChannel {
channel_release_pipe_item_proc release_item;
int during_send;
+ /* Stuff below added for Main and Inputs channels switch to RedChannel
+ * (might be removed later) */
+ channel_on_incoming_error_proc on_incoming_error; /* alternative to disconnect */
+ channel_on_outgoing_error_proc on_outgoing_error;
+ int shut; /* signal channel is to be closed */
};
/* if one of the callbacks should cause disconnect, use red_channel_shutdown and don't
@@ -152,6 +167,21 @@ RedChannel *red_channel_create(int size, RedsStreamContext *peer,
channel_send_pipe_item_proc send_item,
channel_release_pipe_item_proc release_item);
+/* alternative constructor, meant for marshaller based (inputs,main) channels,
+ * will become default eventually */
+RedChannel *red_channel_create_parser(int size, RedsStreamContext *peer,
+ SpiceCoreInterface *core,
+ int migrate, int handle_acks,
+ channel_configure_socket_proc config_socket,
+ spice_parse_channel_func_t parser,
+ channel_handle_parsed_proc handle_parsed,
+ channel_alloc_msg_recv_buf_proc alloc_recv_buf,
+ channel_release_msg_recv_buf_proc release_recv_buf,
+ channel_send_pipe_item_proc send_item,
+ channel_release_pipe_item_proc release_item,
+ channel_on_incoming_error_proc incoming_error,
+ channel_on_outgoing_error_proc outgoing_error);
+
void red_channel_destroy(RedChannel *channel);
void red_channel_shutdown(RedChannel *channel);