Dear Friends
Greetings to all,
I have an issue with SNMP GET Request.
I have used net-snmp 5.1.2 and created the snmp subAgent, the values supplied
to the agent externally.
I have used mib2c iterator config to generate net-snmp style of code for my
alarm related history. I have modifed the skeleton code such a way that it will
contain 20 no of rows and using position count as loop context.
When i make the SNMP Get request on first columnar object for say ALARMID thro
adventnet MIbBrowser, it retrived
the 20 intances of that alarmID
alarmID.1:-->1234
alarmID.2:-->1234
alarmID.3:-->1234
.
.
.
alarmID.18:-->1234
alarmID.19:-->1234
alarmID.20:-->1234
But, from the agent side,it will make the SNMP Get Request on next columnar
object for say alarmType.
If i use the same for last columnar object in the table,it will return 20
intances of that object and handler called another mibtable for example to say
table2,same sceneraio, happen for GET-BULK request.
for your reference i have to provide the index code,first-get and get-next
hooks.
alarmHisTableEntry *getAlarmIndex()
{
uint32_t Index =0;
memset(AlarmHisEntry,0,((sizeof(alarmHisTableEntry)) * 20));
for(uint32_t iterate =0; iterate < 20 ;iterate++)
{
Index = iterate +1;
AlarmHisEntry[iterate].alarmSerNo = Index;
}
return AlarmHisEntry;
}
/* Example iterator hook routines - using 'get_next' to do most of the work */
netsnmp_variable_list *
alarmHisTable_get_first_data_point(void **my_loop_context,
void **my_data_context,
netsnmp_variable_list *put_index_data,
netsnmp_iterator_info *mydata)
{
/**my_loop_context = alarmHisTable_head;
return alarmHisTable_get_next_data_point(my_loop_context, my_data_context,
put_index_data, mydata );*/
netsnmp_variable_list *vptr;
alarmHisTableEntry *myEntry;
/* We use the positinonal count as our loop context */
int *position = (int*)malloc(sizeof(int));
*position = 0;
*my_loop_context = position /** XXX */ ;
myEntry = getAlarmIndex();
*my_data_context = (void *)&myEntry[*position] /** XXX */ ;
vptr = put_index_data;
snmp_set_var_value(vptr, (u_char *)&myEntry[*position].alarmSerNo,
sizeof(&myEntry[*position].alarmSerNo));
vptr = vptr->next_variable;
return put_index_data;
}
netsnmp_variable_list *
alarmHisTable_get_next_data_point(void **my_loop_context,
void **my_data_context,
netsnmp_variable_list *put_index_data,
netsnmp_iterator_info *mydata)
{
netsnmp_variable_list *vptr;
alarmHisTableEntry *myEntry;
int *position = (int *) *my_loop_context;
/* make sure we were called correctly */
if (!position)
return NULL;
/* go to the next route in the list */
(*position)++;
printf("Value of position = %d\n",*position);
/* change for no of rows.....*/
/* Are we beyond the end? */
if (*position >= 20 )
{
/* End of routes. stop here by returning NULL */
SNMP_FREE(position);
*my_loop_context = NULL;
*my_data_context = NULL;
return NULL;
}
*my_loop_context = position /** XXX */ ;
myEntry = getAlarmIndex();
*my_data_context = (void *)&myEntry[*position] /** XXX */ ;
vptr = put_index_data;
snmp_set_var_value(vptr, (u_char *)&myEntry[*position].alarmSerNo,
sizeof(&myEntry[*position].alarmSerNo));
vptr = vptr->next_variable;
return put_index_data;
}
Pls any of you help me to resolve this issue.
With thanks and Regards,
D.SenthilNathan
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders