Re: OID length

Olivier Miakinen <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Hello,

Le 22/01/2015 10:20, Chitrang Srivastava a écrit :
> 
> I am new to SNMP world, and trying to set(SNMPv2c) an OID , which is of
> type *DisplayString*,
> 
> If string is huge like 1300 bytes or so , I see length in OID is encoded as
> 1296 (0x0510)
> 
> Byte stream I see on wire shark is like *0x04 0x82 0x05 0x10*
> 
> Why is that ? Is this SNMP v2c limitation or something ASN.1 related?

I thing the answer is here :
<http://en.wikipedia.org/wiki/X.690#The_definite_form>.

<cit.>
In contrast to the short form, the long form length octets consist of an
initial octet and one or more subsequent octets. According to the X.690
standard [] the initial length octet shall be encoded as follows:

    bit 8 shall be one;
    bits 7 to 1 shall encode the number of subsequent octets in the
length octets, as an unsigned binary integer with bit 7 as the most
significant bit;
    the value 11111111 shall not be used.
</cit.>

After the 0x04 for OCTET STRING, you have 0x82 i.e. binary 10000010.
The bit 8 is one, the bits 7 to 1 have value 2, i.e. two octets for
the actual length.

<cit.>
All bits of the subsequent octets form the encoding of an unsigned
binary integer equal to the number of octets in the contents octets.
</cit.>

0x05 0x10, then 0x0510, i.e. 1296 decimal.

Regards,
-- 
Olivier Miakinen

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.