From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Yonit Halperin Date: Wed, 14 Aug 2013 09:38:12 -0400 Subject: [PATCH] red_channel: add on_input callback for tracing incoming bytes The callback will be used in the next patch. https://bugzilla.redhat.com/show_bug.cgi?id=1016790 (cherry picked from commit d1e7142a0f90e2b977d2a73d26dc5b09d7771826) --- server/red_channel.c | 7 +++++++ server/red_channel.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/server/red_channel.c b/server/red_channel.c index 228669b..bc6ac8d 100644 --- a/server/red_channel.c +++ b/server/red_channel.c @@ -244,6 +244,7 @@ static void red_peer_handle_incoming(RedsStream *stream, IncomingHandler *handle handler->cb->on_error(handler->opaque); return; } + handler->cb->on_input(handler->opaque, bytes_read); handler->header_pos += bytes_read; if (handler->header_pos != handler->header.header_size) { @@ -271,6 +272,7 @@ static void red_peer_handle_incoming(RedsStream *stream, IncomingHandler *handle handler->cb->on_error(handler->opaque); return; } + handler->cb->on_input(handler->opaque, bytes_read); handler->msg_pos += bytes_read; if (handler->msg_pos != msg_size) { return; @@ -383,6 +385,10 @@ static void red_channel_client_on_output(void *opaque, int n) stat_inc_counter(rcc->channel->out_bytes_counter, n); } +static void red_channel_client_on_input(void *opaque, int n) +{ +} + static void red_channel_client_default_peer_on_error(RedChannelClient *rcc) { red_channel_client_disconnect(rcc); @@ -919,6 +925,7 @@ RedChannel *red_channel_create(int size, channel->incoming_cb.handle_message = (handle_message_proc)handle_message; channel->incoming_cb.on_error = (on_incoming_error_proc)red_channel_client_default_peer_on_error; + channel->incoming_cb.on_input = red_channel_client_on_input; channel->outgoing_cb.get_msg_size = red_channel_client_peer_get_out_msg_size; channel->outgoing_cb.prepare = red_channel_client_peer_prepare_out_msg; channel->outgoing_cb.on_block = red_channel_client_peer_on_out_block; diff --git a/server/red_channel.h b/server/red_channel.h index fa11505..64befff 100644 --- a/server/red_channel.h +++ b/server/red_channel.h @@ -74,6 +74,7 @@ typedef uint8_t *(*alloc_msg_recv_buf_proc)(void *opaque, uint16_t type, uint32_ typedef void (*release_msg_recv_buf_proc)(void *opaque, uint16_t type, uint32_t size, uint8_t *msg); typedef void (*on_incoming_error_proc)(void *opaque); +typedef void (*on_input_proc)(void *opaque, int n); typedef struct IncomingHandlerInterface { handle_message_proc handle_message; @@ -83,6 +84,7 @@ typedef struct IncomingHandlerInterface { // The following is an optional alternative to handle_message, used if not null spice_parse_channel_func_t parser; handle_parsed_proc handle_parsed; + on_input_proc on_input; } IncomingHandlerInterface; typedef struct IncomingHandler {