Hi MF,

While testing further in detail I found below behaviour in netsnmp:

When I send trap below for the integer value = 2^31 i.e 2147483648 for the
first time:



snmptrap -c public -v 2c vl-pun-sms-dv01 '' 1.3.6.1.4.1.20006.1.0.5
     1.3.6.1.4.1.12345.1
i 2147483648



I see below in snmp logs:



Received 93 bytes from UDP: [10.129.157.150]:40991->[10.129.55.4]

0000: 30 5B 02 01  01 04 06 70  75 62 6C 69  63 A7 4E 02    0[.....public.N.

0016: 04 1B 5D D3  52 02 01 00  02 01 00 30  40 30 10 06    ..].R......0@0..

0032: 08 2B 06 01  02 01 01 03  00 43 04 28  93 DC 04 30    .+.......C.(...0

0048: 19 06 0A 2B  06 01 06 03  01 01 04 01  00 06 0B 2B    ...+...........+

0064: 06 01 04 01  81 9C 26 01  00 05 30 11  06 08 2B 06    ......&...0...+.

0080: 01 04 01 E0  39 01 02 05  00 80 00 00  00             ....9........



dumpx_recv:02 01 01

dumpv_recv:  Integer:   1 (0x01)

trace: _snmp_parse(): ../../snmplib/snmp_api.c, 4857:

snmp_api: Parsing SNMPv2 message...

trace: _snmp_parse(): ../../snmplib/snmp_api.c, 4867:

dumph_recv: SNMPv2c message



trace: snmp_comstr_parse(): ../../snmplib/snmp_auth.c, 135:

dumph_recv:   SNMP version

dumpx_recv:    02 01 01

dumpv_recv:      Integer:               1 (0x01)

trace: snmp_comstr_parse(): ../../snmplib/snmp_auth.c, 147:

dumph_recv:   community string

dumpx_recv:    04 06 70 75 62 6C 69 63

dumpv_recv:      String:  public

trace: _snmp_parse(): ../../snmplib/snmp_api.c, 4913:

dumph_recv:   PDU

trace: snmp_pdu_parse(): ../../snmplib/snmp_api.c, 5133:

dumpv_recv:     Command TRAP2

trace: snmp_pdu_parse(): ../../snmplib/snmp_api.c, 5214:

dumph_recv:     request_id

dumpx_recv:      02 04 1B 5D D3 52

dumpv_recv:        Integer:             459133778 (0x1B5DD352)

trace: snmp_pdu_parse(): ../../snmplib/snmp_api.c, 5225:

dumph_recv:     error status

dumpx_recv:      02 01 00

dumpv_recv:        Integer:             0 (0x00)

trace: snmp_pdu_parse(): ../../snmplib/snmp_api.c, 5236:

dumph_recv:     error index

dumpx_recv:      02 01 00

dumpv_recv:        Integer:             0 (0x00)





here first time it gives the integer value as 0.



Next time when I send the same trap I get below:

Received 93 bytes from UDP: [10.129.157.150]:38601->[10.129.55.4]

0000: 30 5B 02 01  01 04 06 70  75 62 6C 69  63 A7 4E 02    0[.....public.N.

0016: 04 06 86 87  26 02 01 00  02 01 00 30  40 30 10 06    ....&......0@0..

0032: 08 2B 06 01  02 01 01 03  00 43 04 28  94 43 E9 30    .+.......C.(.C.0

0048: 19 06 0A 2B  06 01 06 03  01 01 04 01  00 06 0B 2B    ...+...........+

0064: 06 01 04 01  81 9C 26 01  00 05 30 11  06 08 2B 06    ......&...0...+.

0080: 01 04 01 E0  39 01 02 05  00 80 00 00  00             ....9........



dumpx_recv:02 01 01

dumpv_recv:  Integer:   1 (0x01)

trace: _snmp_parse(): ../../snmplib/snmp_api.c, 4857:

snmp_api: Parsing SNMPv2 message...

trace: _snmp_parse(): ../../snmplib/snmp_api.c, 4867:

dumph_recv: SNMPv2c message



trace: snmp_comstr_parse(): ../../snmplib/snmp_auth.c, 135:

dumph_recv:   SNMP version

dumpx_recv:    02 01 01

dumpv_recv:      Integer:               1 (0x01)

trace: snmp_comstr_parse(): ../../snmplib/snmp_auth.c, 147:

dumph_recv:   community string

dumpx_recv:    04 06 70 75 62 6C 69 63

dumpv_recv:      String:  public

trace: _snmp_parse(): ../../snmplib/snmp_api.c, 4913:

dumph_recv:   PDU

trace: snmp_pdu_parse(): ../../snmplib/snmp_api.c, 5133:

dumpv_recv:     Command TRAP2

trace: snmp_pdu_parse(): ../../snmplib/snmp_api.c, 5214:

dumph_recv:     request_id

dumpx_recv:      02 04 06 86 87 26

dumpv_recv:        Integer:             109479718 (0x6868726)

trace: snmp_pdu_parse(): ../../snmplib/snmp_api.c, 5225:

dumph_recv:     error status

dumpx_recv:      02 01 00

dumpv_recv:        Integer:             0 (0x00)

trace: snmp_pdu_parse(): ../../snmplib/snmp_api.c, 5236:

dumph_recv:     error index

dumpx_recv:      02 01 00

dumpv_recv:        Integer:             0 (0x00)

trace: snmp_pdu_parse(): ../../snmplib/snmp_api.c, 5254:

dumph_recv:     VarBindList

trace: snmp_pdu_parse(): ../../snmplib/snmp_api.c, 5284:

dumph_recv:       VarBind

trace: snmp_parse_var_op(): ../../snmplib/snmp.c, 166:

dumph_recv:         Name

dumpx_recv:          06 08 2B 06 01 02 01 01 03 00

dumpv_recv:            ObjID: SNMPv2-MIB::sysUpTime.0

trace: snmp_pdu_parse(): ../../snmplib/snmp_api.c, 5293:

dumph_recv:         Value

dumpx_recv:          43 04 28 94 43 E9

dumpv_recv:            UInteger:     680805353 (0x289443E9)





all above are wrong values. Also in case of integer it fails for negative
values as below:

snmptrap -c public -v 2c vl-pun-sms-dv01 '' 1.3.6.1.4.1.20006.1.0.5
     1.3.6.1.4.1.12345.1
i -12345



trace: snmp_parse_var_op(): ../../snmplib/snmp.c, 166:

dumph_recv:         Name

dumpx_recv:          06 08 2B 06 01 04 01 E0 39 01

dumpv_recv:            ObjID: SNMPv2-SMI::enterprises.12345.1

trace: snmp_pdu_parse(): ../../snmplib/snmp_api.c, 5293:

dumph_recv:         Value

dumpx_recv:          02 02 CF C7

dumpv_recv:            Integer:         -12345 (0xFFFFCFC7)



I think in snmpapi.c its not converting it properly for negative values and
on my adapter I get below 4294954951 value for -12345





Output =
1;-1;0;167;public;6;1.3.6.1.4.1.20006.1;8;6;645809393;10.129.157.150;<null>;0;5;<null>;<null>;0;<null>;0;0;0;0;0;<null>;0;1;2;<null>;0;<null>;0;7;680839629;7;0x87d5310;20;1.3.6.1.4.1.20006.1.0.5|1.3.6.1.4.1.12345.1||4294954951|...





Whats wrong in snmpapi.c ?



Thanks,

Ashwini


On 3 February 2015 at 13:02, Ashwini Pagade <ashwinipag...@gmail.com> wrote:

> Hi MF,
>
> Thank you for your response. Changing %ld to %lu worked for me.
>
> Thank you!!
>
> Ashwini
>
> On 1 February 2015 at 23:37, Magnus Fromreide <ma...@lysator.liu.se>
> wrote:
>
>> On Sun, Feb 01, 2015 at 07:58:12PM +0530, Ashwini Pagade wrote:
>> > Hi,
>> >
>> > I am using snmpV3 adapter and passing V2 traps to it by using commands
>> as
>> > below. It looks like the range for type *u* (i.e. unsigned) is upto
>> (2^31)
>> > - 1 (i.e. 2147483647). I was expecting it to be (2^32) - 1 (i.e.
>> > 4294967295).
>> >
>> > snmptrap -c public -v 2c clm-pun-009642 '' 1.3.6.1.4.1.20006.1.0.5
>> > 1.3.6.1.4.1.12345.1 u 2147483647
>> >
>> > Above command generates following log:
>> > trace:  ..\..\snmplib\snmp_api.c, 5293:
>> > dumph_recv:             Value
>> > dumpx_recv:              42 04 7F FF FF FF
>> > dumpv_recv:                UInteger:    2147483647 (0x7FFFFFFF)
>> >
>> >
>> > snmptrap -c public -v 2c clm-pun-009642 '' 1.3.6.1.4.1.20006.1.0.5
>> > 1.3.6.1.4.1.12345.1 u 2147483648
>> >
>> > Above command generates following log:
>> > trace:  ..\..\snmplib\snmp_api.c, 5293:
>> > dumph_recv:             Value
>> > dumpx_recv:              42 05 00 80 00 00 00
>> > dumpv_recv:                UInteger:    -2147483648 (0x80000000)
>> >
>> > Refer to:
>> > http://www.net-snmp.org/docs/man/snmptrap.html
>> >
>> > I am using net-snmp v5.5.
>> >
>> > I think below line in function asn_parse_unsigned_int() in file asn1.c
>> is
>> > printing the incorrect value:
>> > DEBUGMSG(("dumpv_recv", "  UInteger:\t%ld (0x%.2lX)\n", value, value));
>> >
>> > However I think it is not just the dump/log error and incorrect value is
>> > propagated further down the line. I have an snmpV3 adapter which
>> receives
>> > the value. This adapter too gets the incorrect value.
>>
>> I have now looked at the code and it seems to be a pure log error.
>> In your dumps above you see that the values are 42 04 7F FF FF FF and
>> 42 05 00 80 00 00 00 and those two are correct.
>>
>> > I am not sure how this could be fixed. Data type of 'value' looks
>> correct
>> > which is u_long.
>> >
>> > How could we fix this? Any pointers/help in fixing this?
>>
>> Changing %ld to %lu should do the trick.
>>
>> /MF
>>
>
>
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to