Hello list, when playing around with bitstrings, I found a small bug in net-snmp-5.7.1/snmplib/mib.c in function sprint_realloc_bitstring: ---------8<---------- for (; enums; enums = enums->next) { if (enums->value == (len * 8) + bit) { enum_string = enums->label; break; } } ---------8<----------
The snippet above assumes that all bits are enumerated in an ascending order. But, Cisco has a mib (CISCO-QOS-PIB-MIB) that enumerates QosInterfaceTypeCapabilities in a random order: ---------8<---------- QosInterfaceTypeCapabilities ::= TEXTUAL-CONVENTION STATUS current DESCRIPTION "An enumeration of interface capabilities. Used by the PDP to select policies and configuration to push to the PEP." SYNTAX BITS { unspecified (0), -- Classification support inputL2Classification (1), inputIpClassification (2), outputL2Classification (3), outputIpClassification (4), inputPortClassification (19), outputPortClassification (20), -- Policing support inputUflowPolicing (5), inputAggregatePolicing (6), outputUflowPolicing (7), outputAggregatePolicing (8), policeByMarkingDown (9), policeByDropping (10), inputUflowShaping (21), inputAggregateShaping (22), outputUflowShaping (23), outputAggregateShaping (24), -- Supported scheduling mechanisms fifo (11), wrr (12), wfq (13), cq (14), pq (15), cbwfq (16), pqWrr (25), pqCbwfq (26), -- Supported congestion control mechanisms tailDrop (17), wred (18) } ---------8<---------- When I run my little program that prints out all bits using snmp_varlist_add_variable and snprint_variable: ---------8<---------- /* val is a pointer to an u_char string */ snmp_varlist_add_variable (&vars, name, name_length, ASN_BIT_STR, (u_char *)val, val_size); snprint_variable (n, sizeof (n), name, name_length, vars); printf ("test vars: %s\n", n); snmp_free_varbind(vars); ---------8<---------- It outputs: $ ./snmpt test vars: CISCO-QOS-PIB-MIB::qosInterfaceTypeCapabilities = BITS: FF FF FF E0 00 unspecified(0) inputL2Classification(1) inputIpClassification(2) outputL2Classification(3) outputIpClassification(4) inputUflowPolicing(5) inputAggregatePolicing(6) outputUflowPolicing(7) outputAggregatePolicing(8) policeByMarkingDown(9) policeByDropping(10) fifo(11) wrr(12) wfq(13) cq(14) pq(15) cbwfq(16) tailDrop(17) wred(18) 19 20 21 22 23 24 25 26 When I put these bits in ascending order in the MIB, it outputs the following: $ ./snmpt test vars: CISCO-QOS-PIB-MIB::qosInterfaceTypeCapabilities = BITS: FF FF FF E0 00 unspecified(0) inputL2Classification(1) inputIpClassification(2) outputL2Classification(3) outputIpClassification(4) inputUflowPolicing(5) inputAggregatePolicing(6) outputUflowPolicing(7) outputAggregatePolicing(8) policeByMarkingDown(9) policeByDropping(10) fifo(11) wrr(12) wfq(13) cq(14) pq(15) cbwfq(16) tailDrop(17) wred(18) inputPortClassification(19) outputPortClassification(20) inputUflowShaping(21) inputAggregateShaping(22) outputUflowShaping(23) outputAggregateShaping(24) pqWrr(25) pqCbwfq(26) Which is correct and should be the output for both situations of course... T ------------------------------------------------------------------------------ LogMeIn Central: Instant, anywhere, Remote PC access and management. Stay in control, update software, and manage PCs from one command center Diagnose problems and improve visibility into emerging IT issues Automate, monitor and manage. Do more in less time with Central http://p.sf.net/sfu/logmein12331_d2d _______________________________________________ Net-snmp-users mailing list Net-snmp-users@lists.sourceforge.net Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users