diff options
author | Laurent Ghigonis <laurent@p1sec.com> | 2012-07-22 01:08:34 +0200 |
---|---|---|
committer | Laurent Ghigonis <laurent@p1sec.com> | 2012-07-22 01:08:34 +0200 |
commit | d6d5ea47494b569882c032432dde23ec2505c631 (patch) | |
tree | 574e96066540b86f2c58dbaf1bd5bc9d073366a2 /glougloud | |
parent | fix imcompatibility between imsg and imsgev ! (diff) | |
download | glouglou-d6d5ea47494b569882c032432dde23ec2505c631.tar.xz glouglou-d6d5ea47494b569882c032432dde23ec2505c631.zip |
follow imsgev changes
Diffstat (limited to 'glougloud')
-rw-r--r-- | glougloud/glougloud.c | 17 | ||||
-rw-r--r-- | glougloud/server.c | 11 | ||||
-rw-r--r-- | glougloud/user.c | 10 |
3 files changed, 32 insertions, 6 deletions
diff --git a/glougloud/glougloud.c b/glougloud/glougloud.c index 6c1960d..4d2f211 100644 --- a/glougloud/glougloud.c +++ b/glougloud/glougloud.c @@ -50,6 +50,8 @@ struct user { static void imsgev_server(struct imsgev *, int, struct imsg *); static void imsgev_user(struct imsgev *, int, struct imsg *); +static void imsgev_server_needfd(struct imsgev *); +static void imsgev_user_needfd(struct imsgev *); struct server_proc *srv_proc; struct user_proc *usr_proc; @@ -256,7 +258,7 @@ main(int argc, char **argv) socketpair_prepare(srv_proc->fd); srv_proc->pid = server_init(srv_proc->fd); close(srv_proc->fd[1]); - imsgev_init(&srv_proc->iev, srv_proc->fd[0], NULL, imsgev_server); + imsgev_init(&srv_proc->iev, srv_proc->fd[0], NULL, imsgev_server, imsgev_server_needfd); pcap = my_pcap_open_live(PCAP_INTERFACE, PCAP_SNAPLEN, 1, PCAP_TO, errbuf, -1, 0); if (pcap == NULL) @@ -274,7 +276,7 @@ main(int argc, char **argv) socketpair_prepare(usr_proc->fd); usr_proc->pid = user_init(usr_proc->fd, pcap); close(usr_proc->fd[1]); - imsgev_init(&usr_proc->iev, usr_proc->fd[0], NULL, imsgev_user); + imsgev_init(&usr_proc->iev, usr_proc->fd[0], NULL, imsgev_user, imsgev_user_needfd); signal_set(&ev_sigint, SIGINT, sig_handler, NULL); signal_set(&ev_sigterm, SIGTERM, sig_handler, NULL); @@ -472,3 +474,14 @@ imsgev_user(struct imsgev *iev, int code, struct imsg *imsg) } } +static void +imsgev_server_needfd(struct imsgev *iev) +{ + fatal("imsgev_server_needfd"); +} + +static void +imsgev_user_needfd(struct imsgev *iev) +{ + fatal("imsgev_user_needfd"); +} diff --git a/glougloud/server.c b/glougloud/server.c index c275234..3446f6e 100644 --- a/glougloud/server.c +++ b/glougloud/server.c @@ -38,6 +38,7 @@ struct user { }; static void imsgev_main(struct imsgev *, int, struct imsg *); +static void imsgev_main_needfd(struct imsgev *); static void receive(int, short, void *); static void ev_usrtimer(int, short, void *); @@ -79,7 +80,7 @@ server_init(int fd[2]) signal(SIGPIPE, SIG_IGN); srv = xmalloc(sizeof(struct server)); - imsgev_init(&srv->iev, fd[1], NULL, &imsgev_main); + imsgev_init(&srv->iev, fd[1], NULL, imsgev_main, imsgev_main_needfd); srv->time = time(NULL); event_set(&srv->ev, net_socket, EV_READ|EV_PERSIST, receive, NULL); @@ -150,7 +151,7 @@ imsgev_main(struct imsgev *iev, int code, struct imsg *imsg) case IMSGEV_EREAD: case IMSGEV_EWRITE: case IMSGEV_EIMSG: - fatal("imsgev read/write error"); + fatal("server: imsgev read/write error (%d)", code); /* NOTREACHED */ break; case IMSGEV_DONE: @@ -161,6 +162,12 @@ imsgev_main(struct imsgev *iev, int code, struct imsg *imsg) } static void +imsgev_main_needfd(struct imsgev *iev) +{ + fatal("server: imsgev_main_needfd"); +} + +static void receive(int fd, short why, void *data) { struct sockaddr_in remote; diff --git a/glougloud/user.c b/glougloud/user.c index 644e092..38caae7 100644 --- a/glougloud/user.c +++ b/glougloud/user.c @@ -121,6 +121,7 @@ static void ev_timer(int, short, void *); static void usrconn(struct imsgev *, struct imsg *); static void imsgev_main(struct imsgev *, int, struct imsg *); +static void imsgev_main_needfd(struct imsgev *); static struct phandler phandlers[] = { { phandler_ether, DLT_EN10MB }, @@ -168,7 +169,7 @@ user_init(int fd[2], pcap_t *pcap) cap = xcalloc(1, sizeof(struct capture)); cap->fd = fd[1]; - imsgev_init(&cap->iev, cap->fd, NULL, &imsgev_main); + imsgev_init(&cap->iev, cap->fd, NULL, imsgev_main, imsgev_main_needfd); for (i=0; i<CONN_FREEIDS_COUNT-1; i++) cap->conn_freeids[i] = i; cap->time = time(NULL); @@ -785,7 +786,7 @@ imsgev_main(struct imsgev *iev, int code, struct imsg *imsg) case IMSGEV_EREAD: case IMSGEV_EWRITE: case IMSGEV_EIMSG: - fatal("imsgev read/write error"); + fatal("user: imsgev read/write error"); /* NOTREACHED */ break; case IMSGEV_DONE: @@ -795,3 +796,8 @@ imsgev_main(struct imsgev *iev, int code, struct imsg *imsg) } } +static void +imsgev_main_needfd(struct imsgev *iev) +{ + fatal("server: imsgev_main_needfd"); +} |