diff options
Diffstat (limited to 'usr.sbin/ripd/ripe.c')
-rw-r--r-- | usr.sbin/ripd/ripe.c | 73 |
1 files changed, 39 insertions, 34 deletions
diff --git a/usr.sbin/ripd/ripe.c b/usr.sbin/ripd/ripe.c index 1094c50cc97..2d6f4f584c3 100644 --- a/usr.sbin/ripd/ripe.c +++ b/usr.sbin/ripd/ripe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ripe.c,v 1.11 2009/05/31 20:30:15 jacekm Exp $ */ +/* $OpenBSD: ripe.c,v 1.12 2009/06/06 08:20:55 eric Exp $ */ /* * Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it> @@ -47,8 +47,8 @@ void ripe_sig_handler(int, short, void *); void ripe_shutdown(void); struct ripd_conf *oeconf = NULL; -struct imsgbuf *ibuf_main; -struct imsgbuf *ibuf_rde; +struct imsgev *iev_main; +struct imsgev *iev_rde; /* ARGSUSED */ void @@ -151,22 +151,24 @@ ripe(struct ripd_conf *xconf, int pipe_parent2ripe[2], int pipe_ripe2rde[2], close(pipe_parent2rde[0]); close(pipe_parent2rde[1]); - if ((ibuf_rde = malloc(sizeof(struct imsgbuf))) == NULL || - (ibuf_main = malloc(sizeof(struct imsgbuf))) == NULL) + if ((iev_rde = malloc(sizeof(struct imsgev))) == NULL || + (iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsg_init(ibuf_rde, pipe_ripe2rde[0], ripe_dispatch_rde); - imsg_init(ibuf_main, pipe_parent2ripe[1], ripe_dispatch_main); + imsg_init(&iev_rde->ibuf, pipe_ripe2rde[0]); + iev_rde->handler = ripe_dispatch_rde; + imsg_init(&iev_main->ibuf, pipe_parent2ripe[1]); + iev_main->handler = ripe_dispatch_main; /* setup event handler */ - ibuf_rde->events = EV_READ; - event_set(&ibuf_rde->ev, ibuf_rde->fd, ibuf_rde->events, - ibuf_rde->handler, ibuf_rde); - event_add(&ibuf_rde->ev, NULL); + iev_rde->events = EV_READ; + event_set(&iev_rde->ev, iev_rde->ibuf.fd, iev_rde->events, + iev_rde->handler, iev_rde); + event_add(&iev_rde->ev, NULL); - ibuf_main->events = EV_READ; - event_set(&ibuf_main->ev, ibuf_main->fd, ibuf_main->events, - ibuf_main->handler, ibuf_main); - event_add(&ibuf_main->ev, NULL); + iev_main->events = EV_READ; + event_set(&iev_main->ev, iev_main->ibuf.fd, iev_main->events, + iev_main->handler, iev_main); + event_add(&iev_main->ev, NULL); event_set(&oeconf->ev, oeconf->rip_socket, EV_READ|EV_PERSIST, recv_packet, oeconf); @@ -208,14 +210,15 @@ ripe(struct ripd_conf *xconf, int pipe_parent2ripe[2], int pipe_ripe2rde[2], int ripe_imsg_compose_parent(int type, pid_t pid, void *data, u_int16_t datalen) { - return (imsg_compose(ibuf_main, type, 0, pid, data, datalen)); + return (imsg_compose_event(iev_main, type, 0, pid, -1, data, datalen)); } int ripe_imsg_compose_rde(int type, u_int32_t peerid, pid_t pid, void *data, u_int16_t datalen) { - return (imsg_compose(ibuf_rde, type, peerid, pid, data, datalen)); + return (imsg_compose_event(iev_rde, type, peerid, pid, -1, + data, datalen)); } /* ARGSUSED */ @@ -223,7 +226,8 @@ void ripe_dispatch_main(int fd, short event, void *bula) { struct imsg imsg; - struct imsgbuf *ibuf = bula; + struct imsgev *iev = bula; + struct imsgbuf *ibuf = &iev->ibuf; struct kif *kif; struct iface *iface; ssize_t n; @@ -288,10 +292,10 @@ ripe_dispatch_main(int fd, short event, void *bula) imsg_free(&imsg); } if (!shut) - imsg_event_add(ibuf); + imsg_event_add(iev); else { /* this pipe is dead, so remove the event handler */ - event_del(&ibuf->ev); + event_del(&iev->ev); event_loopexit(NULL); } } @@ -302,7 +306,8 @@ ripe_dispatch_rde(int fd, short event, void *bula) { struct rip_route *rr; struct imsg imsg; - struct imsgbuf *ibuf = bula; + struct imsgev *iev = bula; + struct imsgbuf *ibuf = &iev->ibuf; struct iface *iface; struct nbr *nbr; ssize_t n; @@ -434,10 +439,10 @@ ripe_dispatch_rde(int fd, short event, void *bula) imsg_free(&imsg); } if (!shut) - imsg_event_add(ibuf); + imsg_event_add(iev); else { /* this pipe is dead, so remove the event handler */ - event_del(&ibuf->ev); + event_del(&iev->ev); event_loopexit(NULL); } } @@ -461,12 +466,12 @@ ripe_shutdown(void) close(oeconf->rip_socket); /* clean up */ - msgbuf_write(&ibuf_rde->w); - msgbuf_clear(&ibuf_rde->w); - free(ibuf_rde); - msgbuf_write(&ibuf_main->w); - msgbuf_clear(&ibuf_main->w); - free(ibuf_main); + msgbuf_write(&iev_rde->ibuf.w); + msgbuf_clear(&iev_rde->ibuf.w); + free(iev_rde); + msgbuf_write(&iev_main->ibuf.w); + msgbuf_clear(&iev_main->ibuf.w); + free(iev_main); free(oeconf); free(pkt_ptr); @@ -483,8 +488,8 @@ ripe_iface_ctl(struct ctl_conn *c, unsigned int idx) LIST_FOREACH(iface, &oeconf->iface_list, entry) { if (idx == 0 || idx == iface->ifindex) { ictl = if_to_ctl(iface); - imsg_compose(&c->ibuf, IMSG_CTL_SHOW_IFACE, - 0, 0, ictl, sizeof(struct ctl_iface)); + imsg_compose_event(&c->iev, IMSG_CTL_SHOW_IFACE, + 0, 0, -1, ictl, sizeof(struct ctl_iface)); } } } @@ -499,12 +504,12 @@ ripe_nbr_ctl(struct ctl_conn *c) LIST_FOREACH(iface, &oeconf->iface_list, entry) LIST_FOREACH(nbr, &iface->nbr_list, entry) { nctl = nbr_to_ctl(nbr); - imsg_compose(&c->ibuf, - IMSG_CTL_SHOW_NBR, 0, 0, nctl, + imsg_compose_event(&c->iev, + IMSG_CTL_SHOW_NBR, 0, 0, -1, nctl, sizeof(struct ctl_nbr)); } - imsg_compose(&c->ibuf, IMSG_CTL_END, 0, 0, NULL, 0); + imsg_compose_event(&c->iev, IMSG_CTL_END, 0, 0, -1, NULL, 0); } void |