Dear Friends,

Greetings to all,
Thanks for your help to solve the lot of issues related to my applications.

Here, i have a mib table indexed by internal index, generated by mib2c iterator 
config, net-snmp style of code.The snmp agent got values by other external 
subsystems.I have used the position count style loop context.So presently,i 
fixed the index range as 20. But i need the indexing should not be fixed.


Here with i have given my code of get{first,next}hooks and my index api also.
 

/* New Definition */
typedef struct alarmHisTable_entry 
{
    /* Index values */
    long alarmSerNo;

    /* Column values */
    long alarmID;
    long alarmType;
    char alarmName;
    long alarmSeverity;
    long alarmStatus;
    char alarmTimeStamp;
}alarmHisTableEntry;

alarmHisTableEntry *AlarmHisEntry;
static oid alarmHisTable_oid[] = { 1,3,6,1,4,1,8723,1,1,1,1,9,4 };
static oid alarmHisIndex_oid[] = { 1,3,6,1,4,1,8723,1,1,1,1,9,4,1};

.
.
.
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)
{
    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);
   /* 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;
    }
Is there alternate for this to make the index varying...


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

Reply via email to