RFC2578 section 7.1.1:
The INTEGER type (but not the Integer32 type) may also be used to
represent integer-valued information as named-number enumerations.
RFC3416 section 2.5:
A BITS value is encoded as an OCTET STRING
So these two can go.
There's still plenty opportunity for cleanup here, but that's for
another time.
OK?
martijn@
Index: usr.bin/snmp/smi.c
===================================================================
RCS file: /cvs/src/usr.bin/snmp/smi.c,v
retrieving revision 1.15
diff -u -p -r1.15 smi.c
--- usr.bin/snmp/smi.c 21 Oct 2021 08:17:34 -0000 1.15
+++ usr.bin/snmp/smi.c 23 Oct 2021 20:25:37 -0000
@@ -247,7 +247,7 @@ smi_print_element(struct ber_oid *oid, s
struct oid okey;
struct oid *object = NULL;
struct textconv tckey;
- size_t len, i, slen;
+ size_t len, i;
long long v, ticks;
int is_hex = 0, ret;
struct ber_oid o;
@@ -271,7 +271,6 @@ smi_print_element(struct ber_oid *oid, s
switch (root->be_encoding) {
case BER_TYPE_INTEGER:
- case BER_TYPE_ENUMERATED:
if (ober_get_integer(root, &v) == -1)
goto fail;
if (root->be_class == BER_CLASS_APPLICATION &&
@@ -344,22 +343,6 @@ smi_print_element(struct ber_oid *oid, s
}
if (asprintf(&str, "%s%lld", print_hint ? hint : "", v) == -1)
goto fail;
- break;
- case BER_TYPE_BITSTRING:
- if (ober_get_bitstring(root, (void *)&buf, &len) == -1)
- goto fail;
- slen = len * 2 + 1 + sizeof("BITS: ");
- if ((str = calloc(1, slen)) == NULL)
- goto fail;
- p = str;
- if (print_hint) {
- strlcpy(str, "BITS: ", slen);
- p += sizeof("BITS: ");
- }
- for (i = 0; i < len; i++) {
- snprintf(p, 3, "%02x", buf[i]);
- p += 2;
- }
break;
case BER_TYPE_OBJECT:
if (ober_get_oid(root, &o) == -1)
Index: usr.sbin/snmpd/smi.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/smi.c,v
retrieving revision 1.30
diff -u -p -r1.30 smi.c
--- usr.sbin/snmpd/smi.c 21 Oct 2021 15:08:15 -0000 1.30
+++ usr.sbin/snmpd/smi.c 23 Oct 2021 20:25:37 -0000
@@ -472,21 +472,10 @@ smi_print_element(struct ber_element *ro
switch (root->be_encoding) {
case BER_TYPE_INTEGER:
- case BER_TYPE_ENUMERATED:
if (ober_get_integer(root, &v) == -1)
goto fail;
if (asprintf(&str, "%lld", v) == -1)
goto fail;
- break;
- case BER_TYPE_BITSTRING:
- if (ober_get_bitstring(root, (void *)&buf, &len) == -1)
- goto fail;
- if ((str = calloc(1, len * 2 + 1)) == NULL)
- goto fail;
- for (p = str, i = 0; i < len; i++) {
- snprintf(p, 3, "%02x", buf[i]);
- p += 2;
- }
break;
case BER_TYPE_OBJECT:
if (ober_get_oid(root, &o) == -1)