From 50937afbf87c7a25c6d7815f15c94df30da5c3ef Mon Sep 17 00:00:00 2001 From: Heikki Hannikainen Date: Tue, 2 Jul 2013 08:49:27 +0300 Subject: [PATCH] Make a c->write_packet method to support packet transmission for IS2 --- src/aprsis2.c | 4 ++++ src/aprsis2.h | 2 ++ src/outgoing.c | 2 +- src/worker.c | 11 +++++++---- src/worker.h | 1 + 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/aprsis2.c b/src/aprsis2.c index c1e3c83..75720af 100644 --- a/src/aprsis2.c +++ b/src/aprsis2.c @@ -524,3 +524,7 @@ int is2_deframe_input(struct worker_t *self, struct client_t *c, int start_at) return i; } +int is2_write_packet(struct worker_t *self, struct client_t *c, char *p, int len) +{ + return 0; +} diff --git a/src/aprsis2.h b/src/aprsis2.h index 6697662..12cd0f6 100644 --- a/src/aprsis2.h +++ b/src/aprsis2.h @@ -11,6 +11,8 @@ extern int is2_input_handler(struct worker_t *self, struct client_t *c, IS2Messa extern int is2_out_server_signature(struct worker_t *self, struct client_t *c); extern int is2_deframe_input(struct worker_t *self, struct client_t *c, int start_at); +extern int is2_write_packet(struct worker_t *self, struct client_t *c, char *p, int len); + extern int is2_out_ping(struct worker_t *self, struct client_t *c); #endif diff --git a/src/outgoing.c b/src/outgoing.c index f304c0e..74260b1 100644 --- a/src/outgoing.c +++ b/src/outgoing.c @@ -35,7 +35,7 @@ static inline void send_single(struct worker_t *self, struct client_t *c, char * else clientaccount_add( c, c->ai_protocol, 0, 0, 0, 1, 0, 0); - c->write(self, c, data, len); + c->write_packet(self, c, data, len); } static void process_outgoing_single(struct worker_t *self, struct pbuf_t *pb) diff --git a/src/worker.c b/src/worker.c index 5938880..6bce361 100644 --- a/src/worker.c +++ b/src/worker.c @@ -1522,7 +1522,7 @@ static void collect_new_clients(struct worker_t *self) } c->handler_client_readable = &handle_corepeer_readable; - c->write = &udp_client_write; + c->write_packet = c->write = &udp_client_write; continue; } @@ -1557,11 +1557,14 @@ static void collect_new_clients(struct worker_t *self) c->write = &tcp_client_write; } - if (c->flags & CLFLAGS_IS2) + if (c->flags & CLFLAGS_IS2) { c->handler_consume_input = &is2_deframe_input; - else + c->write_packet = &is2_write_packet; + } else { c->handler_consume_input = &deframe_aprsis_input_lines; - + c->write_packet = c->write; + } + /* The new client may end up destroyed right away, never mind it here. * We will notice it later and discard the client. */ diff --git a/src/worker.h b/src/worker.h index 8548ac8..96d034c 100644 --- a/src/worker.h +++ b/src/worker.h @@ -360,6 +360,7 @@ struct client_t { int (*is2_input_handler) (struct worker_t *self, struct client_t *c, IS2Message *message); int (*handler_consume_input) (struct worker_t *self, struct client_t *c, int start_at); int (*write) (struct worker_t *self, struct client_t *c, char *p, int len); + int (*write_packet) (struct worker_t *self, struct client_t *c, char *p, int len); int (*handler_client_readable) (struct worker_t *self, struct client_t *c); int (*handler_client_writable) (struct worker_t *self, struct client_t *c);