From eb2cd11aac7d9ee2756f1851063a4ba463701cdb Mon Sep 17 00:00:00 2001 From: Laurent Ghigonis Date: Thu, 29 Nov 2012 04:26:01 +0100 Subject: implement callbacks when server receives a connect, and test it in unit test --- libglouglou/libglouglou.h | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'libglouglou/libglouglou.h') diff --git a/libglouglou/libglouglou.h b/libglouglou/libglouglou.h index 74712d7..2a7e1c7 100644 --- a/libglouglou/libglouglou.h +++ b/libglouglou/libglouglou.h @@ -3,20 +3,6 @@ #define PACKET_VERSION 1 #define DNSNAME_MAX 20 -struct gg_server { - const char *ip; - int port; - struct event *ev; - int sock; -}; - -struct gg_client { - const char *ip; - int port; - struct event *ev; - int sock; -}; - struct gg_packet { u_int8_t ver; u_int8_t type; @@ -64,6 +50,25 @@ struct gg_packet { #define name_fqdn pdat.name.fqdn }; +struct gg_server { + const char *ip; + int port; + struct event *ev; + int sock; + int (*handle_conn)(struct gg_server *, int, struct sockaddr_in *); + int (*handle_packet)(struct gg_server *, struct gg_packet *); +}; + +struct gg_client { + const char *ip; + int port; + struct event *ev; + int sock; + int (*handle_conn)(struct gg_client *, int); + int (*handle_packet)(struct gg_client *, struct gg_packet *); +}; + + struct gg_server *gg_server_start(struct event_base *, char *, int, int (*handle_conn)(struct gg_server *, int, struct sockaddr_in *), int (*handle_packet)(struct gg_server *, struct gg_packet *)); -- cgit v1.2.3-59-g8ed1b