Lines Matching +full:smi +full:- +full:based
47 # (W-7405-ENG-36) by Los Alamos National Laboratory, which is
63 #include "netdissect-stdinc.h"
70 #include <smi.h>
73 #include "netdissect-ctype.h"
83 * (we only care about the tag values for those allowed in the Internet SMI)
86 "U-0",
98 "U-8","U-9","U-10","U-11", /* 8-11 */
99 "U-12","U-13","U-14","U-15", /* 12-15 */
106 * Application-wide ASN.1 types from the Internet SMI and their tags
119 "C-5",
125 * Context-specific ASN.1 types for the SNMP PDUs and their tags
155 * Context-specific ASN.1 types for the SNMP Exceptions and their tags
168 * The Internet SMI does not specify any
171 "P-0"
175 * error-status values for any SNMP PDU
204 * generic-trap values in the SNMP Trap-PDU
226 #define defineCLASS(x) { "x", x, sizeof(x)/sizeof(x[0]) } /* not ANSI-C */
255 * A structure for the OID tree for the compiled-in MIB.
256 * This is stored as a general-order tree.
260 u_char oid; /* sub-id following parent */
267 * RFC-1156 format files into "makemib". "mib.h" MUST define at least
330 if ((o) == objp->oid) \
332 } while ((objp = objp->next) != NULL); \
335 ND_PRINT(suppressdot?"%s":".%s", objp->desc); \
336 objp = objp->child; \
342 * This is the definition for the Any-Data-Type storage used purely for
413 * (and of real-length "len") and stores the intermediate data in the
416 * This returns -l if it fails (i.e., the ASN.1 stream is not valid).
426 elem->asnlen = 0; in asn1_parse()
427 elem->type = BE_ANY; in asn1_parse()
430 return -1; in asn1_parse()
435 * +---+---+---+---+---+---+---+---+ in asn1_parse()
437 * +---+---+---+---+---+---+---+---+ in asn1_parse()
440 id = GET_U_1(p) & ASN_ID_BITS; /* lower 5 bits, range 00-1f */ in asn1_parse()
443 class = form >> 1; /* bits 7&6 -> bits 1&0, range 0-3 */ in asn1_parse()
444 form &= 0x1; /* bit 5 -> bit 0, range 0-1 */ in asn1_parse()
449 elem->form = form; in asn1_parse()
450 elem->class = class; in asn1_parse()
451 elem->id = id; in asn1_parse()
452 p++; len--; hdr = 1; in asn1_parse()
462 * bit set. XXX - this doesn't handle a value in asn1_parse()
469 return -1; in asn1_parse()
472 len--; in asn1_parse()
478 return -1; in asn1_parse()
480 elem->id = id = (id << 7) | GET_U_1(p); in asn1_parse()
481 --len; in asn1_parse()
487 return -1; in asn1_parse()
489 elem->asnlen = GET_U_1(p); in asn1_parse()
490 p++; len--; hdr++; in asn1_parse()
491 if (elem->asnlen & ASN_BIT8) { in asn1_parse()
492 uint32_t noct = elem->asnlen % ASN_BIT8; in asn1_parse()
493 elem->asnlen = 0; in asn1_parse()
496 return -1; in asn1_parse()
499 for (; noct != 0; len--, hdr++, noct--) { in asn1_parse()
500 elem->asnlen = (elem->asnlen << ASN_SHIFT8) | GET_U_1(p); in asn1_parse()
504 if (len < elem->asnlen) { in asn1_parse()
505 ND_PRINT("[len%d<asnlen%u]", len, elem->asnlen); in asn1_parse()
506 return -1; in asn1_parse()
510 return -1; in asn1_parse()
514 return -1; in asn1_parse()
518 return -1; in asn1_parse()
520 ND_TCHECK_LEN(p, elem->asnlen); in asn1_parse()
528 elem->type = BE_STR; in asn1_parse()
529 elem->data.str = p; in asn1_parse()
534 elem->type = BE_INT; in asn1_parse()
537 if (elem->asnlen == 0) { in asn1_parse()
539 return -1; in asn1_parse()
543 for (i = elem->asnlen; i != 0; p++, i--) in asn1_parse()
545 elem->data.integer = data; in asn1_parse()
550 elem->type = BE_OID; in asn1_parse()
551 elem->data.raw = (const uint8_t *)p; in asn1_parse()
555 elem->type = BE_NULL; in asn1_parse()
556 elem->data.raw = NULL; in asn1_parse()
560 elem->type = BE_OCTET; in asn1_parse()
561 elem->data.raw = (const uint8_t *)p; in asn1_parse()
570 elem->type = BE_INETADDR; in asn1_parse()
571 elem->data.raw = (const uint8_t *)p; in asn1_parse()
578 elem->type = BE_UNS; in asn1_parse()
580 for (i = elem->asnlen; i != 0; p++, i--) in asn1_parse()
582 elem->data.uns = data; in asn1_parse()
588 elem->type = BE_UNS64; in asn1_parse()
590 for (i = elem->asnlen; i != 0; p++, i--) in asn1_parse()
592 elem->data.uns64 = data64; in asn1_parse()
597 elem->type = BE_OCTET; in asn1_parse()
598 elem->data.raw = (const uint8_t *)p; in asn1_parse()
608 elem->type = BE_NOSUCHOBJECT; in asn1_parse()
609 elem->data.raw = NULL; in asn1_parse()
613 elem->type = BE_NOSUCHINST; in asn1_parse()
614 elem->data.raw = NULL; in asn1_parse()
618 elem->type = BE_ENDOFMIBVIEW; in asn1_parse()
619 elem->data.raw = NULL; in asn1_parse()
626 elem->type = BE_OCTET; in asn1_parse()
627 elem->data.raw = (const uint8_t *)p; in asn1_parse()
637 elem->type = BE_SEQ; in asn1_parse()
638 elem->data.raw = (const uint8_t *)p; in asn1_parse()
642 elem->type = BE_OCTET; in asn1_parse()
643 elem->data.raw = (const uint8_t *)p; in asn1_parse()
650 elem->type = BE_PDU; in asn1_parse()
651 elem->data.raw = (const uint8_t *)p; in asn1_parse()
655 elem->type = BE_OCTET; in asn1_parse()
656 elem->data.raw = (const uint8_t *)p; in asn1_parse()
662 p += elem->asnlen; in asn1_parse()
663 len -= elem->asnlen; in asn1_parse()
664 return elem->asnlen + hdr; in asn1_parse()
668 return -1; in asn1_parse()
674 const u_char *p = (const u_char *)elem->data.raw; in asn1_print_octets()
675 uint32_t asnlen = elem->asnlen; in asn1_print_octets()
679 for (i = asnlen; i != 0; p++, i--) in asn1_print_octets()
685 return -1; in asn1_print_octets()
693 uint32_t asnlen = elem->asnlen; in asn1_print_string()
696 p = elem->data.str; in asn1_print_string()
698 for (i = asnlen; printable && i != 0; p++, i--) in asn1_print_string()
700 p = elem->data.str; in asn1_print_string()
703 if (nd_printn(ndo, p, asnlen, ndo->ndo_snapend)) { in asn1_print_string()
709 for (i = asnlen; i != 0; p++, i--) { in asn1_print_string()
718 return -1; in asn1_print_string()
731 uint32_t asnlen = elem->asnlen; in asn1_print()
734 switch (elem->type) { in asn1_print()
737 if (asn1_print_octets(ndo, elem) == -1) in asn1_print()
738 return -1; in asn1_print()
745 int first = -1; in asn1_print()
748 p = (const u_char *)elem->data.raw; in asn1_print()
750 if (!ndo->ndo_nflag && asnlen > 2) { in asn1_print()
752 for (; a->node; a++) { in asn1_print()
753 if (i < a->oid_len) in asn1_print()
755 if (!ND_TTEST_LEN(p, a->oid_len)) in asn1_print()
757 if (memcmp(a->oid, p, a->oid_len) == 0) { in asn1_print()
758 objp = a->node->child; in asn1_print()
759 i -= a->oid_len; in asn1_print()
760 p += a->oid_len; in asn1_print()
761 ND_PRINT("%s", a->prefix); in asn1_print()
768 for (; i != 0; p++, i--) { in asn1_print()
780 if (!ndo->ndo_nflag) in asn1_print()
786 o -= s * OIDMUX; in asn1_print()
789 if (--first < 0) in asn1_print()
797 ND_PRINT("%d", elem->data.integer); in asn1_print()
801 ND_PRINT("%u", elem->data.uns); in asn1_print()
805 ND_PRINT("%" PRIu64, elem->data.uns64); in asn1_print()
809 if (asn1_print_string(ndo, elem) == -1) in asn1_print()
810 return -1; in asn1_print()
814 ND_PRINT("Seq(%u)", elem->asnlen); in asn1_print()
820 p = (const u_char *)elem->data.raw; in asn1_print()
822 for (i = asnlen; i != 0; p++, i--) { in asn1_print()
830 ND_PRINT("[%s]", Class[EXCEPTIONS].Id[elem->id]); in asn1_print()
834 ND_PRINT("%s(%u)", Class[CONTEXT].Id[elem->id], elem->asnlen); in asn1_print()
849 return -1; in asn1_print()
858 * Rose-Normal-Form.
879 length -= i; in asn1_decode()
914 const u_char *p = (const u_char *)elem->data.raw; in smi_decode_oid()
915 uint32_t asnlen = elem->asnlen; in smi_decode_oid()
917 int o = 0, first = -1; in smi_decode_oid()
920 for (*oidlen = 0; i != 0; p++, i--) { in smi_decode_oid()
933 o -= firstval * OIDMUX; in smi_decode_oid()
964 switch (smiType->basetype) { in smi_check_a_range()
967 if (smiRange->minValue.value.unsigned32 in smi_check_a_range()
968 == smiRange->maxValue.value.unsigned32) { in smi_check_a_range()
969 ok = (elem->asnlen == smiRange->minValue.value.unsigned32); in smi_check_a_range()
971 ok = (elem->asnlen >= smiRange->minValue.value.unsigned32 in smi_check_a_range()
972 && elem->asnlen <= smiRange->maxValue.value.unsigned32); in smi_check_a_range()
977 ok = (elem->data.integer >= smiRange->minValue.value.integer32 in smi_check_a_range()
978 && elem->data.integer <= smiRange->maxValue.value.integer32); in smi_check_a_range()
982 ok = (elem->data.uns >= smiRange->minValue.value.unsigned32 in smi_check_a_range()
983 && elem->data.uns <= smiRange->maxValue.value.unsigned32); in smi_check_a_range()
1057 if (ndo->ndo_vflag) { in smi_print_variable()
1058 ND_PRINT("%s::", smiGetNodeModule(smiNode)->name); in smi_print_variable()
1060 ND_PRINT("%s", smiNode->name); in smi_print_variable()
1061 if (smiNode->oidlen < oidlen) { in smi_print_variable()
1062 for (i = smiNode->oidlen; i < oidlen; i++) { in smi_print_variable()
1079 if (! smiNode || ! (smiNode->nodekind in smi_print_value()
1084 if (elem->type == BE_NOSUCHOBJECT in smi_print_value()
1085 || elem->type == BE_NOSUCHINST in smi_print_value()
1086 || elem->type == BE_ENDOFMIBVIEW) { in smi_print_value()
1090 if (NOTIFY_CLASS(pduid) && smiNode->access < SMI_ACCESS_NOTIFY) { in smi_print_value()
1094 if (READ_CLASS(pduid) && smiNode->access < SMI_ACCESS_READ_ONLY) { in smi_print_value()
1098 if (WRITE_CLASS(pduid) && smiNode->access < SMI_ACCESS_READ_WRITE) { in smi_print_value()
1103 && smiNode->access == SMI_ACCESS_NOT_ACCESSIBLE) { in smi_print_value()
1112 if (! smi_check_type(smiType->basetype, elem->type)) { in smi_print_value()
1128 switch (elem->type) { in smi_print_value()
1130 if (smiType->basetype == SMI_BASETYPE_BITS) { in smi_print_value()
1139 if (ndo->ndo_vflag) { in smi_print_value()
1140 ND_PRINT("%s::", smiGetNodeModule(smiNode)->name); in smi_print_value()
1142 ND_PRINT("%s", smiNode->name); in smi_print_value()
1143 if (smiNode->oidlen < oidlen) { in smi_print_value()
1144 for (i = smiNode->oidlen; in smi_print_value()
1156 if (smiType->basetype == SMI_BASETYPE_ENUM) { in smi_print_value()
1160 if (nn->value.value.integer32 in smi_print_value()
1161 == elem->data.integer) { in smi_print_value()
1162 ND_PRINT("%s", nn->name); in smi_print_value()
1163 ND_PRINT("(%d)", elem->data.integer); in smi_print_value()
1182 * version INTEGER {version-1(0)},
1184 * data ANY -- PDUs
1188 * request-id INTEGER,
1189 * error-status INTEGER,
1190 * error-index INTEGER,
1200 * agent-addr NetworkAddress,
1201 * generic-trap INTEGER,
1202 * specific-trap INTEGER,
1203 * time-stamp TimeTicks,
1235 ND_PRINT("[%d extra after SEQ of varbind]", length - count); in varbind_print()
1255 vblength = length - count; in varbind_print()
1275 length -= count; in varbind_print()
1327 if (ndo->ndo_vflag) in snmppdu_print()
1329 length -= count; in snmppdu_print()
1354 length -= count; in snmppdu_print()
1379 length -= count; in snmppdu_print()
1407 length -= count; in trappdu_print()
1412 /* agent-addr (inetaddr) */ in trappdu_print()
1416 ND_PRINT("[agent-addr!=INETADDR]"); in trappdu_print()
1422 length -= count; in trappdu_print()
1425 /* generic-trap (Integer) */ in trappdu_print()
1429 ND_PRINT("[generic-trap!=INT]"); in trappdu_print()
1438 length -= count; in trappdu_print()
1441 /* specific-trap (Integer) */ in trappdu_print()
1445 ND_PRINT("[specific-trap!=INT]"); in trappdu_print()
1451 ND_PRINT("[specific-trap(%d)!=0]", elem.data.integer); in trappdu_print()
1454 length -= count; in trappdu_print()
1459 /* time-stamp (TimeTicks) */ in trappdu_print()
1463 ND_PRINT("[time-stamp!=TIMETICKS]"); in trappdu_print()
1469 length -= count; in trappdu_print()
1493 ND_PRINT("[%d extra after PDU]", length - count); in pdu_print()
1494 if (ndo->ndo_vflag) { in pdu_print()
1532 if (ndo->ndo_vflag) { in pdu_print()
1566 length -= count; in scopedpdu_print()
1570 if (asn1_print_octets(ndo, &elem) == -1) in scopedpdu_print()
1582 length -= count; in scopedpdu_print()
1586 if (asn1_print_string(ndo, &elem) == -1) in scopedpdu_print()
1612 if (!(elem.asnlen == sizeof(DEF_COMMUNITY) - 1 && in community_print()
1614 sizeof(DEF_COMMUNITY) - 1) == 0)) { in community_print()
1617 if (asn1_print_string(ndo, &elem) == -1) in community_print()
1621 length -= count; in community_print()
1628 * Decode SNMPv3 User-based Security Message Header (SNMPv3)
1656 length -= count; in usm_print()
1667 if (ndo->ndo_vflag) in usm_print()
1669 length -= count; in usm_print()
1680 if (ndo->ndo_vflag) in usm_print()
1682 length -= count; in usm_print()
1693 length -= count; in usm_print()
1697 if (asn1_print_string(ndo, &elem) == -1) in usm_print()
1709 length -= count; in usm_print()
1720 length -= count; in usm_print()
1724 ND_PRINT("[%d extra after usm SEQ]", length - count); in usm_print()
1752 if (ndo->ndo_vflag) { in v3msg_print()
1764 length -= count; in v3msg_print()
1775 length -= count; in v3msg_print()
1796 length -= count; in v3msg_print()
1813 length -= count; in v3msg_print()
1817 ND_PRINT("[%d extra after message SEQ]", length - count); in v3msg_print()
1819 if (ndo->ndo_vflag) { in v3msg_print()
1824 if (ndo->ndo_vflag) { in v3msg_print()
1832 np = xnp + (np - xnp); in v3msg_print()
1833 length = xlength - (np - xnp); in v3msg_print()
1843 length -= count; in v3msg_print()
1848 if (ndo->ndo_vflag) { in v3msg_print()
1853 if (ndo->ndo_vflag) { in v3msg_print()
1859 if (ndo->ndo_vflag) { in v3msg_print()
1875 ndo->ndo_protocol = "snmp"; in snmp_print()
1887 ND_PRINT("[%d extra after iSEQ]", length - count); in snmp_print()
1905 if (ndo->ndo_vflag) in snmp_print()
1913 length -= count; in snmp_print()
1929 if (ndo->ndo_vflag) { in snmp_print()