/*
* Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
- * The Regents of the University of California. All rights reserved.
+ * John Robert LoVerso. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by John Robert LoVerso.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* This implementation has been influenced by the CMU SNMP release,
* by Steve Waldbusser. However, this shares no code with that system.
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.49 2001-06-15 21:06:59 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.53 2002-06-11 17:08:56 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
elem->type = BE_UNS64;
high = 0, low = 0;
for (i = elem->asnlen; i-- > 0; p++) {
- high = (high << 8) |
+ high = (high << 8) |
((low & 0xFF000000) >> 24);
low = (low << 8) | *p;
}
o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8);
if (*p & ASN_LONGLEN)
continue;
-
+
/*
* first subitem encodes two items with 1st*OIDMUX+2nd
+ * (see X.690:1997 clause 8.19 for the details)
*/
if (first < 0) {
+ int s;
if (!nflag)
objp = mibroot;
first = 0;
- OBJ_PRINT(o/OIDMUX, first);
- o %= OIDMUX;
+ s = o / OIDMUX;
+ if (s > 2) s = 2;
+ OBJ_PRINT(s, first);
+ o -= s * OIDMUX;
}
OBJ_PRINT(o, first);
if (--first < 0)
break;
}
d = elem->data.uns64.high * 4294967296.0; /* 2^32 */
- if (elem->data.uns64.high <= 0x1fffff) {
+ if (elem->data.uns64.high <= 0x1fffff) {
d += elem->data.uns64.low;
#if 0 /*is looks illegal, but what is the intention?*/
printf("%.f", d);
o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8);
if (*p & ASN_LONGLEN)
continue;
-
+
/*
* first subitem encodes two items with 1st*OIDMUX+2nd
+ * (see X.690:1997 clause 8.19 for the details)
*/
if (first < 0) {
first = 0;
if (*oidlen < oidsize) {
- oid[(*oidlen)++] = o/OIDMUX;
+ oid[*oidlen] = o / OIDMUX;
+ if (oid[*oidlen] > 2) oid[*oidlen] = 2;
}
- o %= OIDMUX;
+ o -= oid[*oidlen] * OIDMUX;
+ if (*oidlen < oidsize) (*oidlen)++;
}
if (*oidlen < oidsize) {
- oid[(*oidlen)++] = o;
+ oid[(*oidlen)++] = o;
}
o = 0;
}
struct be *elem)
{
int ok = 1;
-
+
switch (smiType->basetype) {
case SMI_BASETYPE_OBJECTIDENTIFIER:
case SMI_BASETYPE_OCTETSTRING:
ok = (elem->data.integer >= smiRange->minValue.value.integer32
&& elem->data.integer <= smiRange->maxValue.value.integer32);
break;
-
+
case SMI_BASETYPE_UNSIGNED32:
ok = (elem->data.uns >= smiRange->minValue.value.unsigned32
&& elem->data.uns <= smiRange->maxValue.value.unsigned32);
break;
-
+
case SMI_BASETYPE_UNSIGNED64:
/* XXX */
break;
/* apply display hints (integer, octetstring) */
/* convert instance identifier to index type values */
-
+
switch (elem->type) {
case BE_OID:
if (smiType->basetype == SMI_BASETYPE_BITS) {
}
fputs(smiNode->name, stdout);
if (smiNode->oidlen < oidlen) {
- for (i = smiNode->oidlen;
+ for (i = smiNode->oidlen;
i < oidlen; i++) {
printf(".%u", oid[i]);
}
np = (u_char *)pdu.data.raw;
if (version == SNMP_VERSION_1 &&
- (pdu.id == GETBULKREQ || pdu.id == INFORMREQ ||
+ (pdu.id == GETBULKREQ || pdu.id == INFORMREQ ||
pdu.id == V2TRAP || pdu.id == REPORT)) {
printf("[v2 PDU in v1 message]");
return;
}
if (vflag) {
- fputs("} ", stdout);
+ fputs(" } ", stdout);
}
}
asn1_print(&elem);
return;
}
- if (vflag)
+ if (vflag)
printf("B=%d ", elem.data.integer);
length -= count;
np += count;
asn1_print(&elem);
return;
}
- if (vflag)
+ if (vflag)
printf("T=%d ", elem.data.integer);
length -= count;
np += count;
return;
}
flags = elem.data.str[0];
- if (flags != 0x00 && flags != 0x01 && flags != 0x03
+ if (flags != 0x00 && flags != 0x01 && flags != 0x03
&& flags != 0x04 && flags != 0x05 && flags != 0x07) {
printf("[msgFlags=0x%02X]", flags);
return;