Menu

#2560 OCTECT STRING encoding issues with Python bindings

linux
closed
nobody
5
2014-07-24
2014-07-23
No

For several OCTECT STRING (SIZE 8) and OCTECT STRING (SIZE(1|8)) the python bindings are encoding the hexidecimal characters as ascii instead of binary.

Here is a simplified wireshark capture which displays the issue:
Expected Output: 0x00, getting 30 30 instead
XXxx XX XX 30 30 XX XX XX Xx Xx XX XX XX XX XX xX XX

Expected Output 0xFFFFFFFFFFFFFFFF, getting ascii encoded F (46) instead.
XXxX XX 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46
XXxX 46 XX XX XX Xx Xx XX XX XX XX XX xX XX XX

Discussion

  • Bill Fenner

    Bill Fenner - 2014-07-23

    Can you share sample code? With:

    >>> s.set( [ netsnmp.client.Varbind( 'BRIDGE-MIB::dot1dStpPortDesignatedRoot', '42', '\x01\x02\x03\x04\x05\x06\x07\x08' ) ] )
    

    I got:

    dumph_send:   SNMPv3 Message
    dumph_send:     SET
    dumph_send:       VarBind
    dumph_send:         Value
    dumpx_send:          04 08 01 02 03 04 05 06 07 08
    dumpv_send:            String:  ........
    dumph_send:         Name
    dumpx_send:          06 0B 2B 06 01 02 01 11 02 0F 01 06 2A
    dumpv_send:            ObjID: dot1dStpPortDesignatedRoot.42
    

    and while it's obviously a ridiculous set request, it is a well-formed message. It works with FF too.

    >>> s.set( [ netsnmp.client.Varbind( 'BRIDGE-MIB::dot1dStpPortDesignatedRoot', '42', '\xff\xff\xff\xff\xff\xff\xff\xff' ) ] )
    dumph_send:   SNMPv3 Message
    dumph_send:     SET
    dumph_send:       VarBind
    dumph_send:         Value
    dumpx_send:          04 08 FF FF FF FF FF FF FF FF
    dumpv_send:            String:  ........
    dumph_send:         Name
    dumpx_send:          06 0B 2B 06 01 02 01 11 02 0F 01 06 2A
    dumpv_send:            ObjID: dot1dStpPortDesignatedRoot.42
    
     

    Last edit: Bill Fenner 2014-07-23
  • Bill Fenner

    Bill Fenner - 2014-07-24

    By the way, the way to get the tracing is to put the following in /etc/snmp/python.conf:

    [snmp] doDebugging 1
    [snmp] debugTokens dump
    

    (Obviously this is system-wide so be careful leaving this configured)

     
  • Kurt Frederiksen

    Did a bit more investigation with this new information. Looks like there was a bug in our code which was using the net-snmp python bindings. Thanks for the help debugging, now we can continue to test and hopefully find and resolve more bugs.

    This bug can be closed.

     
  • Bill Fenner

    Bill Fenner - 2014-07-24
    • status: open --> closed
     

Log in to post a comment.