On Tue, 2005-04-26 at 21:52, Robert Story wrote:
> DS> Compare with scalar vs instance helpers.  The scalar helper
> DS> is basically just a wrapper round the instance helper.
> DS> That works fine, IMO.
> 
> Easy for you to say, you wrote them!

Actually, the instance helper is one of Wes'.
I wrote the scalar helper to address the limitations of using
the instance helper to implement scalar objects.

>  Coincidentally, this came up on IRC the
> other day. Someone asked me the difference between the scalar and instance
> helpers, and my response was "I have no idea." Maybe you can enlighten me for
> future reference...

Sure.

The instance helper is concerned with a single instance OID.
This can be anywhere within the OID tree - a scalar instance
or one within a MIB table.  It's *just* concerned with that
one OID - anything else is "none of my business, squire"

The scalar helper is concerned with a scalar MIB object.
Not just the (sole) valid instance of that object, but also
all the related (invalid) OIDs.  It's responsible for the
*whole* of the MIB subtree rooted at the registration point.


To see the difference, consider two "scalar" registrations.
One for 'sysLocation.0' (implemented using the instance helper)
and one for 'sysContact' (using the scalar helper).

If you do a GET for sysLocation.0 or sysContact.0, the two
helpers work in much the same way, and return the appropriate
value.  Similarly for a GETNEXT on sysLocation/sysContact
(returning the same value) or a GETNEXT on
sysLocation.0/sysContact.0 (skipping on to the next handler).


But consider a (SNMPv2) GET on 'sysLocation' and 'sysContact'
The instance helper looks at the OID (sysLocation), decides it's
not interested (since this is not the same as sysLocation.0)
and declines to process the request.   The main agent driving
code can't find anything else to answer it either, so returns
a 'noSuchObject' exception.

The scalar helper looks at the OID (sysContact), and recognises
it as relevant.   It passes the request to the instance helper,
but this isn't interested.  The scalar helper therefore return
a 'noSuchInstance' exception.

The same holds true for GET requests for sys{Contact,Location}.1
or sys{Contact,Location}.0.99, etc, etc.   In each case, an
implementation using the instance handler would return the
wrong exception ('noSuchObject'), while the scalar handler
would return the correct exception ('noSuchInstance').


Does that make things clearer?

Dave



-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start!  http://www.idcswdc.com/cgi-bin/survey?id=105hix
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to