RE: Infinitly looping call to get_first_data_point function

Steve Stetka <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
What happens when you register your getFirst as your getNext?  An infinite loop.  So I have overcome the infinite loop :) but I guess my question still stands...is my implementation of getFirst valid?  I've also included my implementation of getNext...
 
netsnmp_variable_list* PresetDataTableHandler::getNext(
        void **my_loop_context,
        void **my_data_context,
        netsnmp_variable_list *put_index_data,
        netsnmp_iterator_info *mydata) {
    
printf("%s:%d %s\n", __FUNCTION__, __LINE__, "Entered.");

    netsnmp_variable_list *idx = put_index_data;
    netsnmp_variable_list *ret = NULL;
    
    
     const long maxPresets =
             SubAgent::getInstance().getDBReader()->getNumPresets();
    
    
    if (PresetDataTableHandler::iterIdx < maxPresets - 1){

        PresetDataTableHandler::iterIdx++;
        
        snmp_set_var_typed_integer(
                idx,
                ASN_INTEGER,
                PresetDataTableHandler::iterIdx );

        ret = idx;

        idx = idx->next_variable;
    }

printf("%s:%d %s\n", __FUNCTION__, __LINE__, "Exit.");

    return ret;
}

 
In my get and set processing I use the following to get my index that I set:
 
long entryIdx = *(table_info->indexes->val.integer);
 
is this correct?  Below is my get processing...
 
int PresetDataTableHandler::processGetRequest(
        netsnmp_mib_handler*          handler,
        netsnmp_handler_registration* reginfo,
        netsnmp_agent_request_info*   reqinfo,
        netsnmp_request_info*         requests) {
    
printf("%s:%d %s\n", __FUNCTION__, __LINE__, "Entered.");

    netsnmp_request_info       *request;
    netsnmp_table_request_info *table_info;
 
    for (request=requests; request; request=request->next) {
        
        PresetDataTableEntry entry; 
        
        table_info = netsnmp_extract_table_info(request);
 
        long entryIdx = *(table_info->indexes->val.integer); // my index set in getNext?
 
        if(SubAgent::getInstance().getDBReader()->getPresetDataTableEntry(
                entryIdx, &entry)) {
        
            
            switch (table_info->colnum) {
            case COLUMN_INDEX:
                snmp_set_var_typed_integer(
                        request->requestvb,
                        ASN_INTEGER,
                        entry.getIndex());
                break;
            case COLUMN_VAL1:
                snmp_set_var_typed_integer(
                        request->requestvb,
                        ASN_INTEGER,
                        entry.getVAL1());
                break;
            case COLUMN_VAL2:
                snmp_set_var_typed_integer(
                        request->requestvb,
                        ASN_INTEGER,
                        entry.getVAL2());
                break;
            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_NOSUCHOBJECT);
                break;
            }
        } else {
            netsnmp_set_request_error(
                    reqinfo,
                    request,
                    SNMP_NOSUCHINSTANCE);
        }
    }
    
printf("%s:%d %s\n", __FUNCTION__, __LINE__, "Exit.");
    return SNMP_ERR_NOERROR;
}

 
 


----------------------------------------
> From: [email protected]
> To: [email protected]
> Subject: Infinitly looping call to get_first_data_point function
> Date: Mon, 2 Nov 2009 10:31:46 -0500
>
>
> When I use snmpget or snmpgetnext to access data in my table, I get a timeout. I put some printfs in my code and noticed that my get_first_data_point function (getFirst in my case) is infinitly being called. I am assuming I am not setting something correctly in the function. All I do is set idx (put_index_data) to the first index of my data array (0). Do I HAVE to set loop_context and data_context? My data is external to the subagent; and all I need is the index for snmpset and snmpget handling. Should I set the loop_context to the address of my static iterIdx variable below?
>
>
> netsnmp_variable_list* PresetDataTableHandler::getFirst(
> void **my_loop_context,
> void **my_data_context,
> netsnmp_variable_list *put_index_data,
> netsnmp_iterator_info *mydata) {
>
> printf("%s:%d %s\n", __FUNCTION__, __LINE__, "Entered.");
>
> netsnmp_variable_list *idx = put_index_data;
>
> PresetDataTableHandler::iterIdx = 0;
>
> snmp_set_var_typed_integer(
> idx,
> ASN_INTEGER,
> PresetDataTableHandler::iterIdx );
>
> idx = idx->next_variable;
>
> printf("%s:%d %s\n", __FUNCTION__, __LINE__, "Exit.");
>
> return put_index_data;
> }
>
>
> Thanks,
>
> Steve
> _________________________________________________________________
> Hotmail: Trusted email with powerful SPAM protection.
> http://clk.atdmt.com/GBL/go/177141665/direct/01/
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Net-snmp-users mailing list
> [email protected]
> Please see the following page to unsubscribe or change other options:
> https://lists.sourceforge.net/lists/listinfo/net-snmp-users 		 	   		  
_________________________________________________________________
Hotmail: Trusted email with Microsoft's powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141664/direct/01/
http://clk.atdmt.com/GBL/go/177141664/direct/01/

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.