Template:FAQ:Applications 15b

From Net-SNMP Wiki
Jump to: navigation, search

There's one other aspect of string-indexed tables that can cause problems - the difference between implicit- and explicit-length strings, and how to represent these when making an SNMP query.

The most common style of string index uses an explicit length, followed by the individual ASCII character values:

     "dave"  =  4.'d'.'a'.'v'.'e' 

(as shown in the previous entry).

However if the string index is defined in the MIB file as IMPLIED (or if it has a fixed length, such as a physical ethernet address), then the length subidentifier is omitted, and the index simply consists of the character values:

     "dave"  =  'd'.'a'.'v'.'e'

Note that IMPLIED index objects can only appear as the *last* index for a table.

The Net-SNMP library uses double quotes (i.e. "dave") to indicate an explicit length string index value, and single quotes (i.e. 'dave') to indicate an implicit length one. If you use the wrong style of quotes, then the resulting OID will be incorrect, and you'll get confusing results to your query.