The code which handles getNext is as below...... 

//Call back function registered in each OID
extern "C" u_char* MibThreadGet(struct variable *vp, oid * name,
                                    size_t * length, int exact, size_t *
var_len,
                                    WriteMethod ** write_method)
{

*write_method = RunSet;

    if (exact)
    {
        std::cout<<"MIBTHREADGET FUNCTION RUNGET CALLED"<<std::endl;
        return RunGet(vp, name, length, var_len);
    }
    else
    {
        std::cout<<"MIBTHREADGET FUNCTION RUNGETNEXT CALLED"<<std::endl;
        return RunGetNext(vp, name, length, var_len);
    }
}



//GetNext supporting function
static u_char* RunGetNext( struct variable *vp, oid * name, size_t *
length, size_t * var_len )
{

size_t instlen = *length - vp->namelen;
netsnmp_oid2str(strOID, name, *length);


    bool bRequestSuccess = false;
    std::string strNewOID = "";
    std::string strNewInstance = "";
    std::string strNewValue = "";

//Pass the OID to Application which holds the value and get it.
bRequestSuccess = gGlobals.m_ICCClient.sendGetNextMessage(SerializedMsg,
                      "OAMICC",
                      1,
                      strNewValue,
                      strNewInstance,
                      strNewOID);


if (bRequestSuccess)
{
strTotalOID = strTotalOID + std::string(".") + strNewInstance;
std::vector<long> vectOID;
vectOID.clear();
vectOID = convertToOid(strTotalOID, 0);

unsigned int iCount = 0;
    for (; iCount < vectOID.size(); ++iCount)
    {
        name[(unsigned int)iCount] = vectOID[iCount];
        vp->name[(unsigned int)iCount] = vectOID[iCount];
    }

    *length = (long) iCount;
    vp->namelen = *length;

//Get the type of new OID returned.
snmpCounterType eCounterType = gGlobals.getTypeForOID(strNewOID);
vp->type = (char)eCounterType;

switch (eCounterType)
 {

case snmp_Type_Integer32 :
    case snmp_Type_CompInteger32 :
    case snmp_Type_TimeTicks :
    case snmp_Type_Counter32 :
    case snmp_Type_Gauge32 :
    case snmp_Type_UInteger32 :
    case snmp_Type_Counter64 :
    {
        long_ret = atol(strRetValue.c_str());
        std::cout<<"Returning Int Value : "<<long_ret<<std::endl;
        *var_len = sizeof(long_ret);
        return (u_char *) &long_ret;
    }

  case snmp_Type_IpAddress :
    {
        *var_len = 4;
        if (!strRetValue.empty ())
        {
            hp = gethostbyname(strRetValue.c_str());
if ( hp )
            return (u_char *)hp->h_addr_list[0];
        }
        return (u_char *)strRetValue.c_str();
    }

case snmp_Type_ObjectId :
    {
        vp->type = snmp_Type_ObjectId;
                if (!strRetValue.empty ())
        {
        *var_len = (int) 14;
        return (u_char *)strRetValue.c_str();
        }
            std::cout <<"I am never here" << std::endl;
                *var_len = (int) 1;
             return (u_char *)strRetValue.c_str();      
}

  case snmp_Type_BitString :
    {
        u_char* x;
        vp->type = snmp_Type_OctetString;
        *var_len =2;
        std::cout<<"Returning Value : "<<strRetValue<<std::endl;
        x=getBits(strRetValue);
        return (u_char *) x;
    }
    default :
    {
        std::cout<<"Returning NULL Value...."<<std::endl;
        return NULL;
    }
    }
}
}









-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Dave Shield
Sent: Friday, February 27, 2009 2:57 PM
To: Ragesh V
Cc: [email protected]
Subject: Re: SNMP Agent response time

2009/2/27 Ragesh V <[email protected]>:
> It's for processing the getnext request.

I didn't ask for a description what your code does.
I asked what it looked like.

Please post the *actual* code.

Dave

DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachment(s) are confidential and intended 
for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. 
Any views or opinions presented in 
this email are solely those of the author and may not necessarily reflect the 
opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, 
distribution and / or publication of 
this message without the prior written consent of the author of this e-mail is 
strictly prohibited. If you have 
received this email in error please delete it and notify the sender 
immediately. Before opening any mail and 
attachments please check them for viruses and defect.

-----------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
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

Reply via email to