summaryrefslogtreecommitdiff
path: root/usr.sbin/relayd/snmp.c
diff options
context:
space:
mode:
authorPierre-Yves Ritschard <pyr@cvs.openbsd.org>2009-06-05 00:04:02 +0000
committerPierre-Yves Ritschard <pyr@cvs.openbsd.org>2009-06-05 00:04:02 +0000
commit24ee8a36b7e45716d783580adea8ac7467d5bcfc (patch)
treeebf9a990991c7294e7580d1b33350cdf4e8ed91a /usr.sbin/relayd/snmp.c
parent0f6af33b31a5abc284575ed55bde36e0edfa00f9 (diff)
Make imsg completely async model agnostic by not requiring an
imsg_event_add function to be provided (which ended up being a named callback). Instead provide a wrapper in the daemon and call that everywhere. Previsously discussed with the usual suspects, ok eric@ though not too happy about the function name (imsg_compose_event).
Diffstat (limited to 'usr.sbin/relayd/snmp.c')
-rw-r--r--usr.sbin/relayd/snmp.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/usr.sbin/relayd/snmp.c b/usr.sbin/relayd/snmp.c
index 2e92955a7f9..983dd1ac10b 100644
--- a/usr.sbin/relayd/snmp.c
+++ b/usr.sbin/relayd/snmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: snmp.c,v 1.3 2009/06/03 20:20:09 eric Exp $ */
+/* $OpenBSD: snmp.c,v 1.4 2009/06/05 00:04:01 pyr Exp $ */
/*
* Copyright (c) 2008 Reyk Floeter <reyk@openbsd.org>
@@ -94,9 +94,9 @@ snmp_sendsock(struct imsgbuf *ibuf)
/* enable restricted snmp socket mode */
bzero(&tmpibuf, sizeof(tmpibuf));
imsg_init(&tmpibuf, s, NULL);
- imsg_compose(&tmpibuf, IMSG_SNMP_LOCK, 0, 0, -1, NULL, 0);
+ imsg_compose_event(&tmpibuf, IMSG_SNMP_LOCK, 0, 0, -1, NULL, 0);
- imsg_compose(ibuf, IMSG_SNMPSOCK, 0, 0, s, NULL, 0);
+ imsg_compose_event(ibuf, IMSG_SNMPSOCK, 0, 0, s, NULL, 0);
imsg_flush(ibuf); /* need to send the socket now */
close(s);
return (0);
@@ -104,7 +104,7 @@ snmp_sendsock(struct imsgbuf *ibuf)
fail:
if (s != -1)
close(s);
- imsg_compose(ibuf, IMSG_NONE, 0, 0, -1, NULL, 0);
+ imsg_compose_event(ibuf, IMSG_NONE, 0, 0, -1, NULL, 0);
return (-1);
}
@@ -114,7 +114,7 @@ snmp_getsock(struct imsgbuf *ibuf)
struct imsg imsg;
int n, s = -1, done = 0;
- imsg_compose(ibuf, IMSG_SNMPSOCK, 0, 0, -1, NULL, 0);
+ imsg_compose_event(ibuf, IMSG_SNMPSOCK, 0, 0, -1, NULL, 0);
imsg_flush(ibuf);
while (!done) {
@@ -237,6 +237,7 @@ snmp_element(const char *oid, enum snmp_type type, void *buf, int64_t val)
if (imsg_composev(ibuf_snmp, IMSG_SNMP_ELEMENT, 0, 0, -1,
iov, iovcnt) == -1)
return (-1);
+ imsg_event_add(ibuf_snmp);
return (0);
}
@@ -256,7 +257,7 @@ snmp_hosttrap(struct table *table, struct host *host)
* XXX The trap format needs some tweaks and other OIDs
*/
- imsg_compose(ibuf_snmp, IMSG_SNMP_TRAP, 0, 0, -1, NULL, 0);
+ imsg_compose_event(ibuf_snmp, IMSG_SNMP_TRAP, 0, 0, -1, NULL, 0);
SNMP_ELEMENT(".1", SNMP_NULL, NULL, 0);
SNMP_ELEMENT(".1.1", SNMP_OCTETSTRING, host->conf.name, 0);
@@ -272,5 +273,5 @@ snmp_hosttrap(struct table *table, struct host *host)
SNMP_ELEMENT(".1.9", SNMP_INTEGER32, NULL, host->retry_cnt);
done:
- imsg_compose(ibuf_snmp, IMSG_SNMP_END, 0, 0, -1, NULL, 0);
+ imsg_compose_event(ibuf_snmp, IMSG_SNMP_END, 0, 0, -1, NULL, 0);
}