diff options
author | Laurent Ghigonis <laurent@p1sec.com> | 2012-11-29 04:26:01 +0100 |
---|---|---|
committer | Laurent Ghigonis <laurent@p1sec.com> | 2012-11-29 04:26:01 +0100 |
commit | eb2cd11aac7d9ee2756f1851063a4ba463701cdb (patch) | |
tree | 6701b40a46b6d1e8ceba1dbceedc07ead96a30ae /libglouglou/libglouglou.h | |
parent | fix errors count in unit tests run (diff) | |
download | glouglou-eb2cd11aac7d9ee2756f1851063a4ba463701cdb.tar.xz glouglou-eb2cd11aac7d9ee2756f1851063a4ba463701cdb.zip |
implement callbacks when server receives a connect, and test it in unit test
Diffstat (limited to 'libglouglou/libglouglou.h')
-rw-r--r-- | libglouglou/libglouglou.h | 33 |
1 files changed, 19 insertions, 14 deletions
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 *)); |