aboutsummaryrefslogtreecommitdiffstats
path: root/libglouglou/libglouglou.c
diff options
context:
space:
mode:
authorLaurent Ghigonis <laurent@p1sec.com>2012-11-29 04:26:01 +0100
committerLaurent Ghigonis <laurent@p1sec.com>2012-11-29 04:26:01 +0100
commiteb2cd11aac7d9ee2756f1851063a4ba463701cdb (patch)
tree6701b40a46b6d1e8ceba1dbceedc07ead96a30ae /libglouglou/libglouglou.c
parentfix errors count in unit tests run (diff)
downloadglouglou-eb2cd11aac7d9ee2756f1851063a4ba463701cdb.tar.xz
glouglou-eb2cd11aac7d9ee2756f1851063a4ba463701cdb.zip
implement callbacks when server receives a connect, and test it in unit test
Diffstat (limited to 'libglouglou/libglouglou.c')
-rw-r--r--libglouglou/libglouglou.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libglouglou/libglouglou.c b/libglouglou/libglouglou.c
index bffb2e4..27144e4 100644
--- a/libglouglou/libglouglou.c
+++ b/libglouglou/libglouglou.c
@@ -39,6 +39,8 @@ gg_server_start(struct event_base *ev_base, char *ip, int port,
srv = xcalloc(1, sizeof(struct gg_server));
srv->ip = ip;
srv->port = port;
+ srv->handle_conn = handle_conn;
+ srv->handle_packet = handle_packet;
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s < 0)
goto err;
@@ -91,7 +93,12 @@ gg_server_stop(struct gg_server *srv)
void cb_srv_receive(evutil_socket_t fd, short what, void *arg)
{
+ struct gg_server *srv;
+
+ srv = arg;
printf("srv: Incoming data !\n");
+ if (srv->handle_conn)
+ srv->handle_conn(srv, 0, NULL); // XXX IN PROGRESS
}
/*
@@ -116,6 +123,8 @@ gg_client_connect(struct event_base *ev_base, char *ip, int port,
cli = xmalloc(sizeof(struct gg_client));
cli->ip = ip;
cli->port = port;
+ cli->handle_conn = handle_conn;
+ cli->handle_packet = handle_packet;
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s < 0)
goto err;