On Fri, 2005-04-29 at 06:12, ericyosho wrote: > maybe have to explain: > take scalar mplsTunnelNotificationMaxRate for example. > > mplsTunnelNotificationMaxRate OBJECT-TYPE > SYNTAX Unsigned32 > MAX-ACCESS read-write > ...... > i will first use mib2c.scalar.conf to generate a code > template containing two functions. > > but i will also define a static unsigned variable in > front of > all the functions(here maybe > static unsigned mplsTunnelNotificationMaxRate
Well, that's probably not a valid declaration, but I get the general idea. > i guess it's the way of thinking of the > mib2c.int_watch.conf ?). Please bear in mind that the scalar helper provides an equivalent mechanism to the basic instance helper (i.e. netsnmp_register_instance). It does *not* correspond to the more specific netsnmp_register_*_instance() calls. That's where the "watched_scalar" comes in. (See yesterday's message). > when registering it as a scalar, i have to do the > coding > with SET_RESERVE1 SET_RESERVE2 ...... > while registering it as an instance,i have got > everything > done after the initial function. i can just comment > out all > the 'MODE_GET' or 'MODE_SET_......'. > and it works well. You're not really giving enough detail to be clear about exactly what you're doing. But I don't believe that commenting out the SET or GET code in a handler registered using "netsnmp_register_instance()" will continue work. netsnmp_register_*_instance() perhaps, but not the basic instance helper. > > What are you passing to this routine, and how have > > you declared the relevant variable? > just the same example > i defined an unsigned mplsTunnelNotificationMaxRate. But unsigned *what*? Unsigned int, unsigned long, unsigned aardvark, what? > when i went with > netsnmp_register_int_instance("mplsTunnelN...", > mplsTunnelN..._oid, > OID_LENGTH > (mplsTunnelN..._oid), > &mplsTunnelN..., > NULL); > nothing went wrong; Which would imply that 'mplsTunnelN' was probably declared as an "int" variable. > but when i used > netsnmp_register_ulong_instance() > leaving all the args unchanged,it warned me about the > fourth arg. Not surprising. The fourth argument of netsnmp_register_int_instance is "int *it" The fourth argument of netsnmp_register_ulong_instance is "u_long * it" Whichever API call you're using, you've got to declare the variable being watched using the correct type (or conversely, given a particular variable, you've got to use the matching API call). So when using netsnmp_register_int_instance, you'd declare static int my_int_var; When using netsnmp_register_int_instance, you'd declare static ulong my_ulong_var; The two types are not (or not necessarily) interchangeable. That's one of the differences between the ns_register_*_instance approach, and the watched_scalar helper. The instance-based APIs provide a selection of calls, and you've got to choose the appropriate one. The watched_scalar helper provides a single call, and you specify the (SNMP) type involved. 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-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