Re: about the hex-string

"Dave Shield" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
2008/5/27  <[email protected]>:
>  Good all.
>
> I am a new expolder in net-snmp;
>
> I wirte a test mib and registered in the net-snmp lib,but where i run
> snmpwalk command,there are some problem:
>
> #snmpwalk -v 2c -c public localhost 1.3.6.1.4.1

   [snip]

> In the handle functions they are ASN_OCTET_STR type.

An "Octet String" is simply a string of octets.
These could be printable characters, or binary data.
The same ASN.1 type is used for both.

The MIB file would normally include a DISPLAY HINT,
to indicate how this value should be printed.

In the absence of such a hint, the Net-SNMP library attempts
to guess whether this is a printable string, or a binary value,
based on the value returned.


> Please tell me how could the happen ?

Looking at the value returned:

> iso.3.6.1.4.1.55555.1.1.1.10.1.2.1 = Hex-STRING: 4E 55 4C 4C 00 00 00 00 00
> 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

This contains four printable characters ("NULL"),
followed by a large number of 0-valued octets, which
are not printable.  So the library has decided that this
is a binary string value, and displayed it as such.

It looks as if the code implementing this particular
object has returned the full buffer holding the value,
rather than just the printable value itself.
I.e.

   snmp_set_var_typed_value(
         request->requestvb, ASN_OCTET_STR,
         myRow->myColumn,  sizeof(myRow->myColumn));

instead of

   snmp_set_var_typed_value(
         request->requestvb, ASN_OCTET_STR,
         myRow->myColumn,  strlen(myRow->myColumn));


If you use strlen, things should be OK.

Dave

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
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.