Hi There,

I'm using watchers in my MIB code, for both integers and strings. I had
been using "netsnmp_register_watched_scalar" for both. However today I reread
the watcher.c example on the website
(http://www.net-snmp.com/dev/agent/examples.html). This uses
"netsnmp_register_watched_instance". However I'm slightly suspicious of this
since 1. this example is missing from the doxygen examples page which I
generated locally (might be because I'm using 5.2.2 source - is
watcher.c a new example?) and also because having looked at the source
code, the netsnmp_register_instance doesn't add a zero onto the end of
the OID before registering it, but requires that it be present in the OID
which is passed to it, which seemed to make for an inconsistent API.
Can anybody advise which call is the correct one (and what difference it
will make)?

My concern is that if I use the wrong one I'll end up with array bounds
overwrites at some point, which will most likely cause a bug not obviously
related to me making the wrong call. If I don't hear, I'll assume that the
example in Watcher.c see is the way to go.

In a similar vein, is "netsnmp_register_watched_scalar" still the right
call to make to register my watched integers, or to put it another way,
is there any reason not to use "netsnmp_register_watched_instance" for
them too (it would be nice my OIDs either all had zeros or not, rather
than being mixed).

For reference I've pasted below the code for the plain "register" functions,
which the "register_watched" functions call. If I've understood correctly, the
only difference apart from the ".0" is the registration of a scalar handler?
1. Does that assume a fixed size (the strings are not fixed size) 2. Is it
required for integers to be handled correctly?

Apologies for the length of this post.

Thanks

Raffles

instance.c
00070 int
00071 netsnmp_register_instance(netsnmp_handler_registration *reginfo)
00072 {
00073     netsnmp_inject_handler(reginfo, netsnmp_get_instance_handler());
00074     return netsnmp_register_serialize(reginfo);
00075 }

scalar.c
00078 int
00079 netsnmp_register_scalar(netsnmp_handler_registration *reginfo)
00080 {
00081     /*
00082      * Extend the registered OID with space for the instance subid
00083      * (but don't extend the length just yet!)
00084      */
00085     reginfo->rootoid = realloc(reginfo->rootoid,
00086                               (reginfo->rootoid_len+1) * sizeof(oid) );
00087     reginfo->rootoid[ reginfo->rootoid_len ] = 0;
00088
00089     netsnmp_inject_handler(reginfo, netsnmp_get_instance_handler());
00090     netsnmp_inject_handler(reginfo, netsnmp_get_scalar_handler());
00091     return netsnmp_register_serialize(reginfo);
00092 }

--

Visit our website at www.roke.co.uk

Roke Manor Research Ltd, Roke Manor, Romsey, Hampshire SO51 0ZN, UK.

The information contained in this e-mail and any attachments is proprietary to
Roke Manor Research Ltd and must not be passed to any third party without
permission. This communication is for information only and shall not create or
change any contractual relationship.



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to