diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-12-07 09:50:52 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-12-07 09:50:52 +0000 |
commit | 31554520542dd5f92ce73cde2156304054423b5b (patch) | |
tree | dd1509803e5d3d2421be54c4f1225495648ddcd2 /usr.sbin/snmpd | |
parent | f88bca2dd82801eebb72c91e1370c419b83d5b4f (diff) |
add a new 'd' format to ber_printf_elements to pass ints instead of
long longs; you have to pass the right type with vargs. this finally
fixes the previous problem on i386.
discussed with claudio
Diffstat (limited to 'usr.sbin/snmpd')
-rw-r--r-- | usr.sbin/snmpd/ber.c | 6 | ||||
-rw-r--r-- | usr.sbin/snmpd/snmpd.h | 4 | ||||
-rw-r--r-- | usr.sbin/snmpd/snmpe.c | 20 |
3 files changed, 11 insertions, 19 deletions
diff --git a/usr.sbin/snmpd/ber.c b/usr.sbin/snmpd/ber.c index adb9979df75..4db46def32a 100644 --- a/usr.sbin/snmpd/ber.c +++ b/usr.sbin/snmpd/ber.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.c,v 1.2 2007/12/05 23:29:19 reyk Exp $ */ +/* $OpenBSD: ber.c,v 1.3 2007/12/07 09:50:51 reyk Exp $ */ /* * Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net> @@ -489,6 +489,10 @@ ber_printf_elements(struct ber_element *ber, char *fmt, ...) d = va_arg(ap, int); ber = ber_add_boolean(ber, d); break; + case 'd': + d = va_arg(ap, int); + ber = ber_add_integer(ber, d); + break; case 'e': e = va_arg(ap, struct ber_element *); ber_link_elements(ber, e); diff --git a/usr.sbin/snmpd/snmpd.h b/usr.sbin/snmpd/snmpd.h index 64ff3856988..c253b26af18 100644 --- a/usr.sbin/snmpd/snmpd.h +++ b/usr.sbin/snmpd/snmpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: snmpd.h,v 1.2 2007/12/05 22:52:50 reyk Exp $ */ +/* $OpenBSD: snmpd.h,v 1.3 2007/12/07 09:50:51 reyk Exp $ */ /* * Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net> @@ -243,7 +243,7 @@ struct oid { */ struct snmp_message { - u_int8_t sm_version; + u_int sm_version; char sm_community[SNMPD_MAXCOMMUNITYLEN]; u_int sm_context; diff --git a/usr.sbin/snmpd/snmpe.c b/usr.sbin/snmpd/snmpe.c index 0b5d7aabba9..c11fb327a41 100644 --- a/usr.sbin/snmpd/snmpe.c +++ b/usr.sbin/snmpd/snmpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: snmpe.c,v 1.2 2007/12/07 09:18:00 reyk Exp $ */ +/* $OpenBSD: snmpe.c,v 1.3 2007/12/07 09:50:51 reyk Exp $ */ /* * Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net> @@ -607,7 +607,7 @@ snmpe_parse(struct sockaddr_storage *ss, msg->sm_error = errval; msg->sm_errorindex = erridx; - log_debug("snmpe_parse: %s: SNMPv%d '%s' context %d request %d", + log_debug("snmpe_parse: %s: SNMPv%d '%s' context %d request %lld", log_host(ss, host, sizeof(host)), msg->sm_version + 1, msg->sm_community, msg->sm_context, msg->sm_request); @@ -725,7 +725,7 @@ snmpe_recvmsg(int fd, short sig, void *arg) socklen_t slen; ssize_t len; struct ber ber; - struct ber_element *req = NULL, *resp = NULL, *b, *c; + struct ber_element *req = NULL, *resp = NULL; struct snmp_message msg; slen = sizeof(ss); @@ -777,23 +777,11 @@ snmpe_recvmsg(int fd, short sig, void *arg) /* Create new SNMP packet */ resp = ber_add_sequence(NULL); -#ifdef notyet - ber_printf_elements(resp, "is{tiii{e}}.", + ber_printf_elements(resp, "ds{tiii{e}}.", msg.sm_version, msg.sm_community, BER_CLASS_CONTEXT, SNMP_T_GETRESP, msg.sm_request, msg.sm_error, msg.sm_errorindex, msg.sm_varbindresp); -#else - b = ber_add_integer(resp, msg.sm_version); - b = ber_add_string(b, msg.sm_community); - c = b = ber_add_sequence(b); - ber_set_header(b, BER_CLASS_CONTEXT, SNMP_T_GETRESP); - c = ber_add_integer(c, msg.sm_request); - c = ber_add_integer(c, msg.sm_error); - c = ber_add_integer(c, msg.sm_errorindex); - c = ber_add_sequence(c); - ber_link_elements(c, msg.sm_varbindresp); -#endif #ifdef DEBUG snmpe_debug_elements(resp); |