Re: 0-based or 1-based indexing

This is a discussion on Re: 0-based or 1-based indexing within the SNMP Coders forums, part of the Networking and Network Related category; HI, Let me be stronger in response than Dave Shield. See inline below. On Tue, 20 Jun 2006, Dave Shield ...


Go Back   Usenet Forums > Networking and Network Related > SNMP Coders

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-20-2006
David T. Perkins
 
Posts: n/a
Default Re: 0-based or 1-based indexing

HI,

Let me be stronger in response than Dave Shield.
See inline below.

On Tue, 20 Jun 2006, Dave Shield wrote:
> cnelson@nycap.rr.com wrote:


> > But are _all_ OIDs that end in
> >0 scalars? Is that just a convention or is it a contraint imposed by
> >SNMP or an unavoidable outcome of how OIDs are generated and handled?
> >
> >

> It's a convention.

The statement "It's a convention" is not correct.
The rules are the following for OIDs used to identify objects:
1) An Object type (an object class) that is a columnar or leaf
object is identified by an OID value (called it's name).
The last sub-identifier cannot be zero. (See RFC 2578,
last paragraph of section 7.10).
2) The SNMP protocol does not provide access to classes of
objects, but to instances of objects. An OID value
identifies (names) an instance of an object type.
Such an OID value is called an SNMP variable.
If the object type is a scalar, then the SNMP
variable is the OID value that is the OID value
for the object type with an additional sub-idenfier
of zero. For object types that are columnar,
RFC 2578 specifies in section 7.7 how to create
a sequence of sub-identifiers that are added
to the end of the OID value that identifies
the object type.

The result is that the variable (an OID value) that
identifies any instance of a scalar always ends with
a sub-identifier with a value of zero. However,
the OID value that identify an instance of a
columnar object type MAY have zero as the last
sub-identifier value.

Index values that are used to create the sequence
of sub-identifiers may be integers, strings, or
OID values. Dave Shield quotes below the
recommendation for use of integer values...

> There's nothing to say that you *can't* have a table index value of 0,
> though it's not recommended. From RFC 2578:
>
> 7.7. Mapping of the INDEX clause
>
> Instances identified by use of integer-valued objects should be
> numbered starting from one (i.e., not from zero). The use of zero as
> a value for an integer-valued index object should be avoided, except
> in special cases.
>

This recommendation is present because it was found that
in many cases a MIB designer needed an index value that
was used, for example in a reference, to mean that an
instance didn't exist. A value of, say, -1 would not
work. On the other hand, a value of zero ncould be used
to indicate a nonexisting item in a reference, just
like "NULL" is used for pointers in programming
languaged. However, the above says "should" and not
"must", so it is legal.

> >The reason I ask if that I need to create a MIB for something that looks
> >a lot like memory and it would be natural -- for my code and for the
> >user -- to start my table indices at 0 but I'm not sure I can.
> >
> >

>
> This is not forbidden, although it is discouraged.
> Only you can tell whether your situation is a legitimate "special case".
> The SNMP specifications don't try to dictate what this means.
>
> Dave


Regards,
/david t. perkins




_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/...et-snmp-coders
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:01 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0