red_channel: add on_input callback for tracing incoming bytes

The callback will be used in the next patch.
This commit is contained in:
Yonit Halperin 2013-08-14 09:38:12 -04:00
parent c1c08c2898
commit d1e7142a0f
2 changed files with 9 additions and 0 deletions

View File

@ -251,6 +251,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) {
@ -278,6 +279,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;
@ -390,6 +392,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);
@ -935,6 +941,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;

View File

@ -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 {