/* \summary: Simple Network Management Protocol (SNMP) printer */
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include "netdissect-stdinc.h"
#include <stdio.h>
#include <string.h>
+#include <limits.h>
#ifdef USE_LIBSMI
#include <smi.h>
#endif
+#include "netdissect-ctype.h"
+
#include "netdissect.h"
#include "extract.h"
#define DECODE_ErrorStatus(e) \
( e >= 0 && (size_t)e < sizeof(ErrorStatus)/sizeof(ErrorStatus[0]) \
? ErrorStatus[e] \
- : (nd_snprintf(errbuf, sizeof(errbuf), "err=%u", e), errbuf))
+ : (snprintf(errbuf, sizeof(errbuf), "err=%u", e), errbuf))
/*
* generic-trap values in the SNMP Trap-PDU
#define DECODE_GenericTrap(t) \
( t >= 0 && (size_t)t < sizeof(GenericTrap)/sizeof(GenericTrap[0]) \
? GenericTrap[t] \
- : (nd_snprintf(buf, sizeof(buf), "gt=%d", t), buf))
+ : (snprintf(buf, sizeof(buf), "gt=%d", t), buf))
/*
* ASN.1 type class table
ND_PRINT("[nothing to parse]");
return -1;
}
- ND_TCHECK_1(p);
/*
* it would be nice to use a bit field, but you can't depend on them.
* that won't fit in 32 bits.
*/
id = 0;
- ND_TCHECK_1(p);
while (GET_U_1(p) & ASN_BIT8) {
if (len < 1) {
ND_PRINT("[Xtagfield?]");
len--;
hdr++;
p++;
- ND_TCHECK_1(p);
}
if (len < 1) {
ND_PRINT("[Xtagfield?]");
return -1;
}
- ND_TCHECK_1(p);
elem->id = id = (id << 7) | GET_U_1(p);
--len;
++hdr;
ND_PRINT("[no asnlen]");
return -1;
}
- ND_TCHECK_1(p);
elem->asnlen = GET_U_1(p);
p++; len--; hdr++;
if (elem->asnlen & ASN_BIT8) {
break;
case INTEGER: {
- int32_t data;
+ uint32_t data;
elem->type = BE_INT;
data = 0;
return -1;
}
if (GET_U_1(p) & ASN_BIT8) /* negative */
- data = -1;
+ data = UINT_MAX;
for (i = elem->asnlen; i != 0; p++, i--)
data = (data << ASN_SHIFT8) | GET_U_1(p);
elem->data.integer = data;
p = elem->data.str;
ND_TCHECK_LEN(p, asnlen);
for (i = asnlen; printable && i != 0; p++, i--)
- printable = ND_ISPRINT(GET_U_1(p));
+ printable = ND_ASCII_ISPRINT(GET_U_1(p));
p = elem->data.str;
if (printable) {
ND_PRINT("\"");
break;
case BE_OID: {
- int o = 0, first = -1;
+ int first = -1;
+ uint32_t o = 0;
p = (const u_char *)elem->data.raw;
i = asnlen;
}
for (; i != 0; p++, i--) {
- ND_TCHECK_1(p);
o = (o << ASN_SHIFT7) + (GET_U_1(p) & ~ASN_BIT8);
if (GET_U_1(p) & ASN_LONGLEN)
continue;
unsigned int firstval;
for (*oidlen = 0; i != 0; p++, i--) {
- ND_TCHECK_1(p);
o = (o << ASN_SHIFT7) + (GET_U_1(p) & ~ASN_BIT8);
if (GET_U_1(p) & ASN_LONGLEN)
continue;
o = 0;
}
return 0;
-
-trunc:
- nd_print_trunc(ndo);
- return -1;
}
static int smi_check_type(SmiBasetype basetype, int be)
}
if (NOTIFY_CLASS(pduid) && smiNode->access < SMI_ACCESS_NOTIFY) {
- ND_PRINT("[notNotifyable]");
+ ND_PRINT("[notNotifiable]");
}
if (READ_CLASS(pduid) && smiNode->access < SMI_ACCESS_READ_ONLY) {
u_short pduid, const u_char *np, u_int length)
{
struct be elem;
- int count = 0, ind;
+ int count = 0;
#ifdef USE_LIBSMI
SmiNode *smiNode = NULL;
#endif
length = elem.asnlen;
np = (const u_char *)elem.data.raw;
- for (ind = 1; length > 0; ind++) {
+ while (length) {
const u_char *vbend;
u_int vblength;
np += count;
varbind_print(ndo, pduid, np, length);
- return;
}
/*
np += count;
varbind_print(ndo, TRAP, np, length);
- return;
}
/*