Code is similar to below........
void
initialize_table_XXXTable(void)
{
static u_long XXXTable_oid[] = { 1, 3, 6, 1, 4, 1, 38070, 3, 1, 24, 4
};
netsnmp_table_registration_info *table_info;
netsnmp_handler_registration *my_handler;
netsnmp_variable_list *index_vb;
table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
my_handler =
netsnmp_create_handler_registration("XXXTable",
XXXTable_handler,
XXXTable_oid,
OID_LENGTH
(XXXTable_oid),
HANDLER_CAN_RWRITE);
if (!my_handler || !table_info /* || !iinfo */ ) {
snmp_log(LOG_ERR,
"malloc failed in initialize_table_XXXTable");
return;
}
netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER,
0);
index_vb = table_info->indexes;
index_vb = index_vb->next_variable;
table_info->min_column = 1;
table_info->max_column = 6;
netsnmp_register_table(my_handler, table_info);
}
int
XXXTable_handler(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
netsnmp_request_info *request;
netsnmp_table_request_info *table_info;
netsnmp_variable_list *var;
struct commitInfo *ci = NULL;
void *data_context = NULL;
u_long *suffix;
size_t suffix_len;
struct XXXTable_entry *entry = NULL;
suffix = requests->requestvb->name + reginfo->rootoid_len + 1;
suffix_len = requests->requestvb->name_length -
(reginfo->rootoid_len + 1);
for (request = requests; request; request = request->next) {
var = request->requestvb;
if (request->processed != 0)
continue;
ci = netsnmp_oid_stash_get_data(commitStorage,
suffix + 1, suffix_len - 1);
table_info = netsnmp_extract_table_info(request);
if (table_info == NULL) {
continue;
}
switch (reqinfo->mode) {
case MODE_GET:
case MODE_GETNEXT:
{
entry = get_XXXTable_row(reqinfo->mode,
table_info->indexes);
switch (table_info->colnum) {
case COLUMN1:
{
------------
------------
xxx_get_oid(var, table_info->indexes, "column1",
entry_val);
snmp_set_var_typed_value(var, ASN_INTEGER,
(const u_char *)
&entry_val->
XXXType,
sizeof(entry_val->
XXXType));
}
break;
case COLUMN2:
{
------------
------------
xxx_get_oid(var, table_info->indexes, "column2",
entry_val);
snmp_set_var_typed_value(var, ASN_INTEGER,
(const u_char *)
&entry_val->
XXXValue,
sizeof(entry_val->
XXXValue));
}
break;
default:
snmp_log(LOG_ERR,
"problem encountered in xxxTable_handler: unsupported
mode\n");
}
}
return SNMP_ERR_NOERROR;
}
Thanks...........
On Thu, Oct 20, 2011 at 12:41 PM, Dave Shield <[email protected]>wrote:
> On 20 October 2011 08:07, Ravi Kumar <[email protected]> wrote:
> > I have registered my table with netsnmp_register_table to implement
> > my own getnext.
> > Every thing seems to be working fine except snmpgetnext request with
> > multiple oid returns only first oid and its value in response PDU.
> > Any guesses ?
>
> I'm sorry - I don't have the time to try and guess what might be
> wrong with code that I've never seen.
>
>
> > my code loops over
> >
> > for (request = requests; request; request = request->next) {
>
> Well that's a good start.
> The problem ismost likely to lie with the code that follows.
>
> But I can't tell, since I've no idea what this code looks like.
>
>
> Dave
>
------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Ciosco Self-Assessment and learn
about Cisco certifications, training, and career opportunities.
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders