Dear Friends,

Greetings to all.

I have been using net-snmp 5.3.1 in my project.Regarding my project ,the 
subagent get the data from other system not its own. I am using mib2c iterator 
conf for my mib tables.I have used the position count as my loop context


Regarding this position style loop context,the index of the table generated by 
me . Pls any one ,help us , how to generate the simple index other than 
position style loop context.

for your reference i have given my sample code..

netsnmp_variable_list *
MyTable_get_first_data_point(void **my_loop_context,
                          void **my_data_context,
                          netsnmp_variable_list *put_index_data,
                          netsnmp_iterator_info *mydata)
{
     
    netsnmp_variable_list *vptr;
    MyTableEntry* myEntry;
        
    /* We use the positinonal count as our loop context */
    int *position = (int*)malloc(sizeof(int));
    *position = 0;


    *my_loop_context = position /** XXX */ ;

    myEntry = getMyIndex();

    *my_data_context = (void *)&myEntry[*position] /** XXX */ ;

    vptr = put_index_data;

    snmp_set_var_value(vptr, (u_char *)&myEntry[*position].ontID,
                      sizeof(&myEntry[*position].ontID));
        
    vptr = vptr->next_variable;

    return put_index_data;
}

netsnmp_variable_list *
MyTable_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;
   ontEqpmtTableEntry *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);
    /* Are we beyond the end? */
    if (*position >= 0) 
   {
        /* End of routes.  stop here by returning NULL */
        SNMP_FREE(position);
        *my_loop_context = NULL;
        *my_data_context = NULL;
        free(Eqpmtentry);
        return NULL;
    }

    *my_loop_context = position /** XXX */ ;

      myEntry = MyTableIndex();

    *my_data_context = (void *)&myEntry[*position] /** XXX */ ;

      vptr = put_index_data;

      snmp_set_var_value(vptr, (u_char *)&myEntry[*position].ontID,
                      sizeof(&myEntry[*position].ontID));
          
    vptr = vptr->next_variable;

    return put_index_data;
}


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
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to