Dave> Have a look at "netsnmp_register_watched_scalar"
Dave> Not only does this cope with string values as well as integer ones,
Dave> it also handles scalar objects correctly (which netsnmp_register_instance
Dave> doesn't - in particular requests for an invalid instance)
Robert> If I'm not mistaken, it does have a quirk or two related to strings.
Robert> I can't remember exactly, but I want to say that it doesn't handle
Robert> variable length strings very well.
It needs both the current and maximum string lengths, yes.
And because the 'netsnmp_create_watcher_info' call only takes a
single size parameter, specifying this is a little cumbersome.
But one of:
winfo = netsnmp_create_watcher_info(
myStringObject, strlen(myStringObject),
ASN_OCTET_STR, WATCHER_MAX_SIZE);
winfo->max_size = sizeof( myStringObject );
or:
winfo = netsnmp_create_watcher_info(
myStringObject, sizeof(myStringObject),
ASN_OCTET_STR, WATCHER_MAX_SIZE);
winfo->data_size = strlen( myStringObject );
should work correctly.
Robert> I've seen you post this before, so I assume you have a template.
Robert> Can you update your template, and add one line:
Robert> static char myStringObject[128];
Noted.
In fact, the example program that I'm pasting this from does include
such a line already, but it's a file-scoped variable (for consistency
with the other non-watched examples), so this doesn't appear next to
the registration call.
But I'll try to remember to mention that this buffer must be persistent.
Dave
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
Net-snmp-users mailing list
[EMAIL PROTECTED]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users