summaryrefslogtreecommitdiff
path: root/usr.sbin/snmpd/util.c
diff options
context:
space:
mode:
authorMartijn van Duren <martijn@cvs.openbsd.org>2020-06-30 17:11:50 +0000
committerMartijn van Duren <martijn@cvs.openbsd.org>2020-06-30 17:11:50 +0000
commitd22f77e554dc90e2671789cc39465575294a3e52 (patch)
tree85eb5e6060c829bfd8def925576fdfda6ac6e270 /usr.sbin/snmpd/util.c
parent8e9a1f4a984e391d34de7c154c8caebff78ac414 (diff)
Remove agentx and control socket support.
snmpctl has been removed two releases ago, which makes the control interface obsolete. agentx support has always been quirky at best, but got completely broken with the BER_MAX_OID_LEN increase in ber.h. This change resulted in the oid length on the snmp side being left uninitialized because of size difference, resulting in weird behaviour. No one reported the breakage, even after 6.7 was released. This change requires users to remove the socket keyword from their snmpd.conf. OK denis@
Diffstat (limited to 'usr.sbin/snmpd/util.c')
-rw-r--r--usr.sbin/snmpd/util.c124
1 files changed, 1 insertions, 123 deletions
diff --git a/usr.sbin/snmpd/util.c b/usr.sbin/snmpd/util.c
index 9944fafc840..26a83bec459 100644
--- a/usr.sbin/snmpd/util.c
+++ b/usr.sbin/snmpd/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.9 2019/10/24 12:39:27 tb Exp $ */
+/* $OpenBSD: util.c,v 1.10 2020/06/30 17:11:49 martijn Exp $ */
/*
* Copyright (c) 2014 Bret Stephen Lambert <blambert@openbsd.org>
*
@@ -30,128 +30,6 @@
#include "snmp.h"
#include "snmpd.h"
-/*
- * Convert variable bindings from AgentX to SNMP dialect.
- */
-int
-varbind_convert(struct agentx_pdu *pdu, struct agentx_varbind_hdr *vbhdr,
- struct ber_element **varbind, struct ber_element **iter)
-{
- struct ber_oid oid;
- u_int32_t d;
- u_int64_t l;
- int slen;
- char *str;
- struct ber_element *a;
- int ret = AGENTX_ERR_NONE;
-
- if (snmp_agentx_read_oid(pdu, (struct snmp_oid *)&oid) == -1) {
- ret = AGENTX_ERR_PARSE_ERROR;
- goto done;
- }
-
- *iter = ober_add_sequence(*iter);
- if (*varbind == NULL)
- *varbind = *iter;
-
- a = ober_add_oid(*iter, &oid);
-
- switch (vbhdr->type) {
- case AGENTX_NO_SUCH_OBJECT:
- case AGENTX_NO_SUCH_INSTANCE:
- case AGENTX_END_OF_MIB_VIEW:
- case AGENTX_NULL:
- a = ober_add_null(a);
- break;
-
- case AGENTX_IP_ADDRESS:
- case AGENTX_OPAQUE:
- case AGENTX_OCTET_STRING:
- str = snmp_agentx_read_octetstr(pdu, &slen);
- if (str == NULL) {
- ret = AGENTX_ERR_PARSE_ERROR;
- goto done;
- }
- a = ober_add_nstring(a, str, slen);
- break;
-
- case AGENTX_OBJECT_IDENTIFIER:
- if (snmp_agentx_read_oid(pdu,
- (struct snmp_oid *)&oid) == -1) {
- ret = AGENTX_ERR_PARSE_ERROR;
- goto done;
- }
- a = ober_add_oid(a, &oid);
- break;
-
- case AGENTX_INTEGER:
- case AGENTX_COUNTER32:
- case AGENTX_GAUGE32:
- case AGENTX_TIME_TICKS:
- if (snmp_agentx_read_int(pdu, &d) == -1) {
- ret = AGENTX_ERR_PARSE_ERROR;
- goto done;
- }
- a = ober_add_integer(a, d);
- break;
-
- case AGENTX_COUNTER64:
- if (snmp_agentx_read_int64(pdu, &l) == -1) {
- ret = AGENTX_ERR_PARSE_ERROR;
- goto done;
- }
- a = ober_add_integer(a, l);
- break;
-
- default:
- log_debug("unknown data type '%i'", vbhdr->type);
- ret = AGENTX_ERR_PARSE_ERROR;
- goto done;
- }
-
- /* AgentX types correspond to BER types */
- switch (vbhdr->type) {
- case BER_TYPE_INTEGER:
- case BER_TYPE_BITSTRING:
- case BER_TYPE_OCTETSTRING:
- case BER_TYPE_NULL:
- case BER_TYPE_OBJECT:
- /* universal types */
- break;
-
- /* Convert AgentX error types to SNMP error types */
- case AGENTX_NO_SUCH_OBJECT:
- ober_set_header(a, BER_CLASS_CONTEXT, 0);
- break;
- case AGENTX_NO_SUCH_INSTANCE:
- ober_set_header(a, BER_CLASS_CONTEXT, 1);
- break;
-
- case AGENTX_COUNTER32:
- ober_set_header(a, BER_CLASS_APPLICATION, SNMP_COUNTER32);
- break;
-
- case AGENTX_GAUGE32:
- ober_set_header(a, BER_CLASS_APPLICATION, SNMP_GAUGE32);
- break;
-
- case AGENTX_COUNTER64:
- ober_set_header(a, BER_CLASS_APPLICATION, SNMP_COUNTER64);
- break;
-
- case AGENTX_IP_ADDRESS:
- /* application 0 implicit 4-byte octet string per SNMPv2-SMI */
- break;
-
- default:
- /* application-specific types */
- ober_set_header(a, BER_CLASS_APPLICATION, vbhdr->type);
- break;
- }
- done:
- return (ret);
-}
-
ssize_t
sendtofrom(int s, void *buf, size_t len, int flags, struct sockaddr *to,
socklen_t tolen, struct sockaddr *from, socklen_t fromlen)