diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2009-06-06 09:02:47 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2009-06-06 09:02:47 +0000 |
commit | 43b3ccb7b66fe7ac8ef51712e09e4d04777fb3c0 (patch) | |
tree | f7a3ed200a44161068d03ed37714ff75bd226535 /usr.sbin/ospf6d/control.c | |
parent | 13bd723f39459bc3835159e553a7c494c498c93b (diff) |
make ospf6ctl/ospf6d imsg-in-a-lib ready too.
ospf6ctl is already broken in tree (not connected to build).
ok pyr@
Diffstat (limited to 'usr.sbin/ospf6d/control.c')
-rw-r--r-- | usr.sbin/ospf6d/control.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/usr.sbin/ospf6d/control.c b/usr.sbin/ospf6d/control.c index 3fd4a91ca52..7ecdd792aa3 100644 --- a/usr.sbin/ospf6d/control.c +++ b/usr.sbin/ospf6d/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.9 2009/05/31 20:29:56 jacekm Exp $ */ +/* $OpenBSD: control.c,v 1.10 2009/06/06 09:02:46 eric Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -131,11 +131,12 @@ control_accept(int listenfd, short event, void *bula) return; } - imsg_init(&c->ibuf, connfd, control_dispatch_imsg); - c->ibuf.events = EV_READ; - event_set(&c->ibuf.ev, c->ibuf.fd, c->ibuf.events, - c->ibuf.handler, &c->ibuf); - event_add(&c->ibuf.ev, NULL); + imsg_init(&c->iev.ibuf, connfd); + c->iev.handler = control_dispatch_imsg; + c->iev.events = EV_READ; + event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events, + c->iev.handler, &c->iev); + event_add(&c->iev.ev, NULL); TAILQ_INSERT_TAIL(&ctl_conns, c, entry); } @@ -145,7 +146,7 @@ control_connbyfd(int fd) { struct ctl_conn *c; - for (c = TAILQ_FIRST(&ctl_conns); c != NULL && c->ibuf.fd != fd; + for (c = TAILQ_FIRST(&ctl_conns); c != NULL && c->iev.ibuf.fd != fd; c = TAILQ_NEXT(c, entry)) ; /* nothing */ @@ -157,7 +158,7 @@ control_connbypid(pid_t pid) { struct ctl_conn *c; - for (c = TAILQ_FIRST(&ctl_conns); c != NULL && c->ibuf.pid != pid; + for (c = TAILQ_FIRST(&ctl_conns); c != NULL && c->iev.ibuf.pid != pid; c = TAILQ_NEXT(c, entry)) ; /* nothing */ @@ -174,11 +175,11 @@ control_close(int fd) return; } - msgbuf_clear(&c->ibuf.w); + msgbuf_clear(&c->iev.ibuf.w); TAILQ_REMOVE(&ctl_conns, c, entry); - event_del(&c->ibuf.ev); - close(c->ibuf.fd); + event_del(&c->iev.ev); + close(c->iev.ibuf.fd); free(c); } @@ -197,20 +198,20 @@ control_dispatch_imsg(int fd, short event, void *bula) } if (event & EV_READ) { - if ((n = imsg_read(&c->ibuf)) == -1 || n == 0) { + if ((n = imsg_read(&c->iev.ibuf)) == -1 || n == 0) { control_close(fd); return; } } if (event & EV_WRITE) { - if (msgbuf_write(&c->ibuf.w) == -1) { + if (msgbuf_write(&c->iev.ibuf.w) == -1) { control_close(fd); return; } } for (;;) { - if ((n = imsg_get(&c->ibuf, &imsg)) == -1) { + if ((n = imsg_get(&c->iev.ibuf, &imsg)) == -1) { control_close(fd); return; } @@ -224,12 +225,12 @@ control_dispatch_imsg(int fd, short event, void *bula) ospfe_fib_update(imsg.hdr.type); /* FALLTHROUGH */ case IMSG_CTL_RELOAD: - c->ibuf.pid = imsg.hdr.pid; + c->iev.ibuf.pid = imsg.hdr.pid; ospfe_imsg_compose_parent(imsg.hdr.type, 0, NULL, 0); break; case IMSG_CTL_KROUTE: case IMSG_CTL_KROUTE_ADDR: - c->ibuf.pid = imsg.hdr.pid; + c->iev.ibuf.pid = imsg.hdr.pid; ospfe_imsg_compose_parent(imsg.hdr.type, imsg.hdr.pid, imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); @@ -239,8 +240,8 @@ control_dispatch_imsg(int fd, short event, void *bula) sizeof(ifidx)) { memcpy(&ifidx, imsg.data, sizeof(ifidx)); ospfe_iface_ctl(c, ifidx); - imsg_compose(&c->ibuf, IMSG_CTL_END, 0, - 0, NULL, 0); + imsg_compose(&c->iev.ibuf, IMSG_CTL_END, 0, + 0, -1, NULL, 0); } break; case IMSG_CTL_SHOW_DATABASE: @@ -254,7 +255,7 @@ control_dispatch_imsg(int fd, short event, void *bula) case IMSG_CTL_SHOW_DB_ASBR: case IMSG_CTL_SHOW_RIB: case IMSG_CTL_SHOW_SUM: - c->ibuf.pid = imsg.hdr.pid; + c->iev.ibuf.pid = imsg.hdr.pid; ospfe_imsg_compose_rde(imsg.hdr.type, 0, imsg.hdr.pid, imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); break; @@ -269,7 +270,7 @@ control_dispatch_imsg(int fd, short event, void *bula) imsg_free(&imsg); } - imsg_event_add(&c->ibuf); + imsg_event_add(&c->iev); } int @@ -280,8 +281,8 @@ control_imsg_relay(struct imsg *imsg) if ((c = control_connbypid(imsg->hdr.pid)) == NULL) return (0); - return (imsg_compose(&c->ibuf, imsg->hdr.type, 0, imsg->hdr.pid, - imsg->data, imsg->hdr.len - IMSG_HEADER_SIZE)); + return (imsg_compose_event(&c->iev, imsg->hdr.type, 0, imsg->hdr.pid, + -1, imsg->data, imsg->hdr.len - IMSG_HEADER_SIZE)); } void |