> > I´ve analysed and found that the hooks
> > (if table is empty the firts else the next hook) return and the error
> > apears before the handler function be called.
> 
> You're using the iterator handler then?

  Yes.

> What is the code for your MIB?
> In particular, the initialisation code (where the table is 
> registered) and the get_first/next hook routines.

  The initialisation code used is the one generated by the script
mib2c.iterate.conf. The hooks are:

/**********************BEGINING OF GET_FIRST**********************/
netsnmp_variable_list *
mobileAgentTable_get_first_data_point(void **my_loop_context, void
**my_data_context,
                          netsnmp_variable_list *put_index_data,
                          netsnmp_iterator_info *mydata)
{
    marca*      ptMarcaTemp = NULL;
    netsnmp_variable_list *vptr;

    printf("Searching registry(first line) ...\n");
    
    //Get the first node (line) of the structure (linked list)
    ptMarcaTemp = primeiro_no();
    
    //The last element is a sentinel, so if the pointer points to there,
return end of the structure.
    if( strcmp(ptMarcaTemp->info->nome, "ULTIMO") == 0)
    {
        printf("End of the table reached and the index was not found !\n");
        return NULL;
    }
    
    //Refresh loop_context and data_context
    *my_loop_context = ptMarcaTemp;
    *my_data_context = ptMarcaTemp;
    
    vptr = put_index_data;
    
    snmp_set_var_value(vptr, (u_char *) &ptMarcaTemp->indice, sizeof(
ptMarcaTemp->indice ));
    
    vptr = vptr->next_variable;

    return put_index_data;
}
/**********************END OF GET_FIRST**********************/

/**********************BEGINING OF GET_NEXT**********************/
netsnmp_variable_list *
mobileAgentTable_get_next_data_point(void **my_loop_context, void
**my_data_context,
                         netsnmp_variable_list *put_index_data,
                         netsnmp_iterator_info *mydata)
{

    marca*      ptMarcaTemp;

    printf("Searching registry ...\n");
    
    //Adjust pointers to walk throught the table
    ptMarcaTemp = *my_loop_context;
    ptMarcaTemp = ptMarcaTemp->prox;
    
    //End of the linked list(table) reached
    if( strcpy(ptMarcaTemp->info->nome, "ULTIMO") == 0)
    {
        printf("End of the table reached and the index was not found !\n");
        return NULL;
    }
        
    netsnmp_variable_list *vptr;

    vptr = put_index_data;
    
    snmp_set_var_value(vptr, (u_char *) &ptMarcaTemp->indice, sizeof(
ptMarcaTemp->indice ));
    vptr = vptr->next_variable;
    
    //refresh loop_context and data_context
    *my_loop_context = ptMarcaTemp;
    *my_data_context = ptMarcaTemp;
    
    return put_index_data;
}
/**********************END OF GET_NEXT**********************/
The problem is: segmentation fault error apears when one of the hooks return
NULL and the table is empty. In a previous table(cod for just one table), I
used the same return(NULL) and the code worked perfectly.

Other problem is when I get one column of the table. The result is displayed
in HEX-STRING but I didn´t do any modification of the data type.

Best regards, Jordan


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to