Hi,
I have generated the code using the net-snmp style for a table in linux environment.
The below is the one generated for the get and set routines( addl. code added to store
and retrieve it from a structure).
getXXX()
{
xxxTable_info *info = (xxxTable_info *) data_context;
*ret_len = info->data_len;
return (char *) info->data;
}
set_XXX (void *data_context, char *val,
size_t val_len)
{
int error_val = SNMPERR_SUCCESS;
xxxTable_info *info = (xxxTable_info *) data_context;
strcpy(info->data, val);
info->data_len = val_len;
return error_val;
}
In the above code,
1. for get routine, I am allocating static memory for "info->data" as per the comment
given in the generated code saying, use static or persistent data. But, I want to use
dynamic memory since static data will increase the memory size in runtime. If I want
to use dynamic memory then I need to allocate the "info->data" inside the get routine
and free it somewhere later once the response has been sent. Is there any way to free
the data after building the response packet and send it back to the manager? Or
net-snmp api code you take care freeing the variables allocated inside this routine
after sending the response??
2. For the set routine, I am storing the input value stored in the variable "val" in
my
info->data variable. Also, I am seeing the comment in the generated code saying that
the freeing the allocated memory for the variable "val" is not taken care by the
net-snmp api. in this case, is it manadatory to free the allocate data for "val" to
get freed by us inside the set routine once we assign it to the "info->data" variable??
Please clarify on the above queries.
Thanks & Regards,
Karthik. N
--
______________________________________________
IndiaInfo Mail - the free e-mail service with a difference! www.indiainfo.com
Check out our value-added Premium features, such as an extra 20MB for mail storage,
POP3, e-mail forwarding, and ads-free mailboxes!
Powered by Outblaze
-------------------------------------------------------
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