[ First - *please* don't mail me privately, without copying
any responses to the mailing list. I don't have the time
or inclination to offer private, unpaid, SNMP consultancy.
Keep discussions to the list, where others can both learn
and offer advice. Thanks. ]
> Is there a way to generate code automatically for DisplayString
> as is done for int in mib2c
What do you mean by that?
There are a number of different approaches that mib2c can generate
code for, so it's not really clear what you're referring to.
> or there exist a net_snmp_register_displaystring?
The 'watcher' helper can be used to implement watched scalar
objects of *any* type - not just integers.
Try:
netsnmp_handler_registration *reg =
netsnmp_create_handler_registration(
"myObject", NULL,
myObjectOID, OID_LENGTH(myObjectOID),
HANDLER_CAN_RONLY);
netsnmp_watcher_info *winfo =
netsnmp_create_watcher_info(
&myObject, sizeof(myObject),
ASN_WHATEVER, WATCHER_FIXED_SIZE);
netsnmp_register_watched_scalar( reg, winfo );
That should work for strings as well as integers.
(It also handles requests for invalid scalar instances correctly,
which the 'netsnmp_register_*_instance' calls don't)
You can implement a writeable integer by changing "RONLY" to "RWRITE".
A writeable string (assuming a fixed character buffer) would need
WATCHER_MAX_SIZE as well, plus
winfo->data_size = strlen(myObject);
before registering it.
Dave
PS: Please, no HTML mail. Thanks
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Net-snmp-coders mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders