hi 
 I used "mib2c -c mib2c.iterate.conf  AdminUsrTable"  to generate  the 
following c code ,but when execution arrives at this line: 
     
/*******************************************************************************************************************************************************************/
    snmp_set_var_value(idx, (u_char *)entry->AdminPwd, 
strlen(entry->AdminPwd)); //when execution arrives at this line ,the agent will 
be shut down
     
/******************************************************************************************************************************************************************/

the agent will be shut down .Error message is "segment default"

netsnmp_variable_list *
AdminUsrTable_get_next_data_point(void **my_loop_context,
                                  void **my_data_context,
                                  netsnmp_variable_list * put_index_data,
                                  netsnmp_iterator_info *mydata)
{
    struct AdminUsrTable_entry *entry =
        (struct AdminUsrTable_entry *) *my_loop_context;
    netsnmp_variable_list *idx = put_index_data;
    if(entry == NULL)
        return NULL;

    DEBUGMSGTL(("AdminUsrTable", "AdminUser value : %s 
AdminUsrTable_get_next_data_point\n",entry->AdminUsr));

    DEBUGMSGTL(("AdminUsrTable", "AdminPwd value : %s 
AdminUsrTable_get_next_data_point\n",entry->AdminPwd));

    snmp_set_var_value(idx, (u_char *)entry->AdminUsr, strlen(entry->AdminUsr));




    idx = idx->next_variable;
    if(idx == NULL)
      DEBUGMSGTL(("AdminUsrTable", "here:AdminUsrTable_get_next_data_point\n"));

   
/***************************************************************************************************************************/
    snmp_set_var_value(idx, (u_char *)entry->AdminPwd, 
strlen(entry->AdminPwd)); //when execution arrive at this line ,the agent will 
be shut down
     
/*****************************************************************************************************************************************************/
    *my_data_context = (void *) entry;
    *my_loop_context = (void *) entry->next;
    DEBUGMSGTL(("AdminUsrTable", "end of AdminUsrTable_get_next_data_point\n"));
    return put_index_data;

}
int
AdminUsrTable_load(netsnmp_cache *cache, void *vmagic)
{

    struct AdminUsrTable_entry *entry;

    AdminUsrTable_free(cache, vmagic);

    entry = SNMP_MALLOC_TYPEDEF(struct AdminUsrTable_entry);
    if (!entry)
       return 1;
     // just for test
      strcpy(entry->AdminUsr,"hongjunli");
     strcpy(entry->AdminPwd,"hongjunli");

     entry->next = NULL;
     AdminUsrTable_head = entry;

    DEBUGMSGTL(("AdminUsrTable", "Loaded AdminUsr Table\n"));
    return 0;
}

void
AdminUsrTable_free(netsnmp_cache *cache, void *magic)
{
    struct AdminUsrTable_entry *p;
    while (AdminUsrTable_head) {
        p = AdminUsrTable_head;
        AdminUsrTable_head = AdminUsrTable_head->next;
        free(p);
    }

    AdminUsrTable_head  = NULL;

}
HW?)b彩h?+y烛N??v??y?'z?jwbv矾?,?n???!3搿?肚擘j?[???(疥?'!?顾l痘ナX??⒇^?^J肢斗?)??囤?l⑶gr?i?

Reply via email to