Hi,
I implemented a table using iterator, and I can do snmpwalk on the table. But 
snmpget gave the Index out of range error. Table index starts from 1. Here is 
related the code piece, can anyone point out where I did wrong?
int myTable_load(netsnmp_cache * cache, void *vmagic)
{
    struct myTable_entry *this;
    u_long i;
    int state = 1;
    for (i = 0; i < num_entries; i++) {
        
        this = SNMP_MALLOC_TYPEDEF(struct myTable_entry);
        if (this == NULL) {
           return SNMP_ERR_GENERR;
        }
        /* MIB index should start from 1 */
        this->Index = i+1; 
                this->status = state;
                
        this->next = myTable_head;
        myTable_head = this;    
    }
    
    return SNMP_ERR_NOERROR;
}


void myTable_free(netsnmp_cache * cache, void *vmagic)
{
    struct myTable_entry *this, *that;
    
    for (this = myTable_head; this; this = that) {
        that = this->next;
        SNMP_FREE(this);        
    }
    myTable_head = NULL;
}


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)
{
    *my_loop_context = myTable_head;
    *my_data_context = myTable_head;


    snmp_set_var_typed_value(put_index_data, ASN_UNSIGNED ,     
                            (u_char *)&(myTable_head->Index),      
                                        sizeof(myTable_head->Index));


    return myTable_get_next_data_point(my_loop_context,
                                               my_data_context,
                                               put_index_data, 
                                   mydata);
}


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)
{
    struct myTable_entry *entry =
        (struct myTable_entry *) *my_loop_context;
    netsnmp_variable_list *idx = put_index_data;
    
    if (entry) {
        snmp_set_var_typed_value(idx, ASN_UNSIGNED ,     (u_char 
*)&(entry->Index),   sizeof(entry->Index));
       idx = idx->next_variable;
        *my_data_context = (void *) entry;
        *my_loop_context = (void *) entry->next;
        return put_index_data;
    } else {
        return NULL;
    }
}




int myTable_handler(netsnmp_mib_handler *handler,
                            netsnmp_handler_registration *reginfo,
                            netsnmp_agent_request_info *reqinfo,
                            netsnmp_request_info *requests)
{
    
    netsnmp_request_info *request;
    netsnmp_table_request_info *table_info;
    struct myTable_entry *table_entry;
    
    switch (reqinfo->mode) {
        /*
         * SNMP GET support (also covers GetNext requests)
         */
        case MODE_GET:
            for (request = requests; request; request = request->next) {
                table_entry = (struct myTable_entry *)
                    netsnmp_extract_iterator_context(request);
                table_info = netsnmp_extract_table_info(request);
                
                switch (table_info->colnum) {
                    case COLUMN_STATUS:
…………….

Thanks
From: b...@live.com
To: d.t.shi...@liverpool.ac.uk
CC: net-snmp-users@lists.sourceforge.net
Subject: Strange behavior on linkUpDownNotifications‏
Date: Mon, 29 Mar 2010 11:39:35 -0400








Hi,
I finally can receive link up/down traps. But here is the strange behavior:
1. link up/down traps only sent after the snmpd is restarted.  If I don't 
restart snmpd, there were no link up/down traps sent. 
2. There were too many link up/down traps after snmpd is restarted. I usually 
saw 3 link up traps and 6 link down traps even if I only brought down and up 
the interface once.
3. There were only one coldStart trap and one nsShutdown trap as expected.
Does anyone know the reason? I search the email archives and seems that other 
people had the same issue before, and one response to the problem was that's 
expected behavior. I don't quite understand why the above behavior happened? 
Does anyone know how to make link up/down traps work?
ThanksXuan 
                                          
Hotmail: Trusted email with powerful SPAM protection. Sign up now.              
                          
_________________________________________________________________
Hotmail is redefining busy with tools for the New Busy. Get more from your 
inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID27925::T:WLMTAGL:ON:WL:en-US:WM_HMP:032010_2
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to