I have a working SNMP table where my code initializes a table with a dataset
and then creates initial rows with:
netsnmp_create_table_data_row()
The code sets columns in each row, and adds each row to the table.
With just that code in place and an empty table handler, everything works as
expected.
I then modify the handler to override the values present in the table by
calling an external function that looks up the data efficiently by index value.
My question is as follows.
I would like to be able to do one of the following:
(1) create a dataset and then override the normal GET and ACTION to use
external function calls.
(2) not create the dataset at all, and implement GET and ACTION that do not use
an unsorted linked list in the manner of the mib2c output, but rather use
external code that requires the lookup index to be specified.
To accomplish this, how would I determine the lookup index in the SNMP GET/SET?
There is only 1 index in the table.
Example handler code:
int
myTable_handler(
netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests) {
/* perform anything here that you need to do. The requests have
already been processed by the master table_dataset handler, but
this gives you chance to act on the request in some other way
if need be. */
netsnmp_request_info *request;
netsnmp_table_request_info *table_info;
MY_ENTRY* table_entry;
int index;
switch (reqinfo->mode) {
/*
* Read-support (also covers GetNext requests)
*/
case MODE_GET:
for (request=requests; request; request=request->next) {
index = request->index;
table_entry = myExternalDataGetEntry(index);
if (NULL == table_entry)
{
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
table_info = netsnmp_extract_table_info(request);
snmp_set_var_typed_integer(request->requestvb, ASN_UNSIGNED,
table_entry->myValue);
}
break;
default:
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHOBJECT);
break;
}
return SNMP_ERR_NOERROR;
}
________________________________
CONFIDENTIALITY : This e-mail and any attachments are confidential and may be
privileged. If you are not a named recipient, please notify the sender
immediately and do not disclose the contents to another person, use it for any
purpose or store or copy the information in any medium.
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
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