netsnmp_register_scalar vs netsnmp_register_instance for registering

This is a discussion on netsnmp_register_scalar vs netsnmp_register_instance for registering within the SNMP Users forums, part of the Networking and Network Related category; Hi There, I'm using watchers in my MIB code, for both integers and strings. I had been using "...


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

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-14-2006
Raffles
 
Posts: n/a
Default netsnmp_register_scalar vs netsnmp_register_instance for registering

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_registra tion *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_registrati on *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=...486&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/...net-snmp-users
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 02:16 PM.


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