> I want to have a single handler called once for two separately registered
> variables examples.1.0 and examples.3.0
Yes - that's easy enough.
Something like:
oid example1_oid[] = { ...., 1 };
oid example3_oid[] = { ...., 3 };
netsnmp_handler_registration *reg =
netsnmp_create_handler_registration( "example1",
shared_handler,
example1_oid, OID_LENGTH(example1_oid), HANDLER_CAN_RONLY);
netsnmp_register_scalar( reg );
netsnmp_handler_registration *reg =
netsnmp_create_handler_registration( "example3",
shared_handler,
example3_oid, OID_LENGTH(example3_oid), HANDLER_CAN_RONLY);
netsnmp_register_scalar( reg );
(assuming these are scalar objects - otherwise you could include the
final 0 in the OID array, and use 'netsnmp_register_instance' instead)
> but the twist is that the value of
> the variables are computed from a common source that is costly to access.
OK - so the 'shared_handler' routine caches this value in some way,
and uses that cached value to service incoming requests, only recomputing
it when the cached value gets "too old" (however you want to define this).
That would deal with requests for both objects in the same request,
two separate requests for the two objects (in either order) in rapid
succession, and even repeated requests for the same object.
You should be able to use the 'cache' helper to implement this.
It was originally designed to slot into the handler chain and be
invoked automatically, but I believe Robert has done some work to
make it useable "standalone".
> It is also sadly impossible for me to register a single handler for example.
Sorry - I'm not sure what you mean by that.
>
> Now I have been looking into handlers and it seems that the first
> splitting is done on the target variable level.
or that.
> Is it possible to do what I want using net-snmp handlers?
Unless I've completely misunderstood you, then sure.
Dave
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Net-snmp-coders mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders