X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/a03ba28e199692fa339e17f73cbd94a07d2d09de..ce1fc8263da72437c1df54b8b3ee682413d9e6ed:/print-snmp.c diff --git a/print-snmp.c b/print-snmp.c index 60ba4d22..6f57c2f1 100644 --- a/print-snmp.c +++ b/print-snmp.c @@ -56,11 +56,6 @@ # @(#)snmp.awk.x 1.1 (LANL) 1/15/90 */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.63 2005-04-18 00:07:31 guy Exp $ (LBL)"; -#endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -75,15 +70,16 @@ static const char rcsid[] _U_ = #endif #include "interface.h" -#include "addrtoname.h" #undef OPAQUE /* defined in */ +static const char tstr[] = "[|snmp]"; + /* * Universal ASN.1 types * (we only care about the tag values for those allowed in the Internet SMI) */ -const char *Universal[] = { +static const char *Universal[] = { "U-0", "Boolean", "Integer", @@ -106,7 +102,7 @@ const char *Universal[] = { /* * Application-wide ASN.1 types from the Internet SMI and their tags */ -const char *Application[] = { +static const char *Application[] = { "IpAddress", #define IPADDR 0 "Counter", @@ -125,7 +121,7 @@ const char *Application[] = { /* * Context-specific ASN.1 types for the SNMP PDUs and their tags */ -const char *Context[] = { +static const char *Context[] = { "GetRequest", #define GETREQ 0 "GetNextRequest", @@ -155,7 +151,7 @@ const char *Context[] = { /* * Context-specific ASN.1 types for the SNMP Exceptions and their tags */ -const char *Exceptions[] = { +static const char *Exceptions[] = { "noSuchObject", #define NOSUCHOBJECT 0 "noSuchInstance", @@ -168,14 +164,14 @@ const char *Exceptions[] = { * Private ASN.1 types * The Internet SMI does not specify any */ -const char *Private[] = { +static const char *Private[] = { "P-0" }; /* * error-status values for any SNMP PDU */ -const char *ErrorStatus[] = { +static const char *ErrorStatus[] = { "noError", "tooBig", "noSuchName", @@ -204,7 +200,7 @@ const char *ErrorStatus[] = { /* * generic-trap values in the SNMP Trap-PDU */ -const char *GenericTrap[] = { +static const char *GenericTrap[] = { "coldStart", "warmStart", "linkDown", @@ -225,7 +221,7 @@ const char *GenericTrap[] = { * type definitions. */ #define defineCLASS(x) { "x", x, sizeof(x)/sizeof(x[0]) } /* not ANSI-C */ -struct { +static const struct { const char *name; const char **Id; int numIDs; @@ -245,7 +241,7 @@ struct { /* * defined forms for ASN.1 types */ -const char *Form[] = { +static const char *Form[] = { "Primitive", #define PRIMITIVE 0 "Constructed", @@ -278,7 +274,7 @@ struct obj { * Currently, this includes the prefixes for the Internet MIB, the * private enterprises tree, and the experimental tree. */ -struct obj_abrev { +static const struct obj_abrev { const char *prefix; /* prefix for this abrev */ struct obj *node; /* pointer into object table */ const char *oid; /* ASN.1 encoded OID */ @@ -360,7 +356,7 @@ struct be { /* * SNMP versions recognized by this module */ -const char *SnmpVersion[] = { +static const char *SnmpVersion[] = { "SNMPv1", #define SNMP_VERSION_1 0 "SNMPv2c", @@ -653,7 +649,7 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem) return elem->asnlen + hdr; trunc: - fputs("[|snmp]", stdout); + printf("%s", tstr); return -1; } @@ -684,7 +680,7 @@ asn1_print(struct be *elem) int o = 0, first = -1, i = asnlen; if (!sflag && !nflag && asnlen > 2) { - struct obj_abrev *a = &obj_abrev_list[0]; + const struct obj_abrev *a = &obj_abrev_list[0]; size_t a_len = strlen(a->oid); for (; a->node; a++) { TCHECK2(*p, a_len); @@ -782,11 +778,14 @@ asn1_print(struct be *elem) const u_char *p = elem->data.str; TCHECK2(*p, asnlen); for (i = asnlen; printable && i-- > 0; p++) - printable = isprint(*p) || isspace(*p); + printable = ND_ISPRINT(*p); p = elem->data.str; if (printable) { putchar('"'); - (void)fn_print(p, p + asnlen); + if (fn_printn(p, asnlen, snapend)) { + putchar('"'); + goto trunc; + } putchar('"'); } else for (i = asnlen; i-- > 0; p++) { @@ -831,7 +830,7 @@ asn1_print(struct be *elem) return 0; trunc: - fputs("[|snmp]", stdout); + printf("%s", tstr); return -1; } @@ -876,7 +875,7 @@ struct smi2be { int be; }; -static struct smi2be smi2betab[] = { +static const struct smi2be smi2betab[] = { { SMI_BASETYPE_INTEGER32, BE_INT }, { SMI_BASETYPE_OCTETSTRING, BE_STR }, { SMI_BASETYPE_OCTETSTRING, BE_INETADDR }, @@ -927,7 +926,7 @@ smi_decode_oid(struct be *elem, unsigned int *oid, return 0; trunc: - fputs("[|snmp]", stdout); + printf("%s", tstr); return -1; }