Okay. 
I am not sure what went wrong here.
Can you please go through the below code snippet and try to find out
what could be the issue?

int   forward_handler( netsnmp_pdu           *pdu,
                       netsnmp_transport     *transport,
                       netsnmp_trapd_handler *handler)
{
    netsnmp_session session, *ss;
    netsnmp_pdu *clone_v2_pdu;
        int             oldquick;
    char buf[BUFSIZ], *cp;

        DEBUGMSGTL(( "snmptrapd", "forward_handler (%s)\n",
handler->token));
        
#if 1 // MODIFICATION..  Converted SNMP v1 trap to V2 trap

        netsnmp_pdu    *v2_pdu = NULL;
        if (pdu->command == SNMP_MSG_TRAP)
            v2_pdu = convert_v1pdu_to_v2(pdu);
        else
            v2_pdu = pdu;
        oldquick = snmp_get_quick_print();
        snmp_set_quick_print(1);
#endif

        snmp_sess_init( &session );
        if (strchr( handler->token, ':') == NULL) {
        snprintf( buf, BUFSIZ, "%s:%d", handler->token, SNMP_TRAP_PORT);
        cp = buf;
    } else {
        cp = handler->token;
    }
    session.peername = cp;
   //session.version  = pdu->version; //ORIG.. commented for testing
    session.version  = v2_pdu->version; //Try 1
  //session.version  = SNMP_VERSION_2c; // Try 2
        ss = snmp_open( &session );
    if (!ss)
        return NETSNMPTRAPD_HANDLER_FAIL;

    /* XXX: wjh we should be caching sessions here and not always
       reopening a session.  It's very ineffecient, especially with v3
       INFORMS which may require engineID probing */

    clone_v2_pdu = snmp_clone_pdu(v2_pdu);
    if (clone_v2_pdu->transport_data) {
        free(clone_v2_pdu->transport_data);
        clone_v2_pdu->transport_data        = NULL;
        clone_v2_pdu->transport_data_length = 0;
    }

        if (!snmp_send( ss, clone_v2_pdu )) {
        snmp_sess_perror("Forward failed", ss);
        snmp_free_pdu(clone_v2_pdu);
        snmp_free_pdu(v2_pdu);
    }
    snmp_close( ss );
    return NETSNMPTRAPD_HANDLER_OK;
}

thank you
renjith

-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Dave Shield
Sent: Tuesday, October 19, 2010 6:58 PM
To: Renjith R. V.
Cc: [email protected]
Subject: Re: how to identify variable 'type' and 'value' from pdu
structure

On 19 October 2010 14:20, Renjith R. V. <[email protected]>
wrote:
> I haven't created any new session.
> The session related code in forward_handler() is attached below.
> I have updated session.version with the version available in v2_pdu
> which is created using convert_v1pdu_to_v2().

Yes - that should work.

The error you were getting before probably came from the earlier code

        session.version  = pdu->version;

(since the original pdu was v1)

Dave
***** Confidentiality Statement/Disclaimer *****

This message and any attachments is intended for the sole use of the intended 
recipient. It may contain confidential information. Any unauthorized use, 
dissemination or modification is strictly prohibited. If you are not the 
intended recipient, please notify the sender immediately then delete it from 
all your systems, and do not copy, use or print. Internet communications are 
not secure and it is the responsibility of the recipient to make sure that it 
is virus/malicious code exempt.
The company/sender cannot be responsible for any unauthorized alterations or 
modifications made to the contents. If you require any form of confirmation of 
the contents, please contact the company/sender. The company/sender is not 
liable for any errors or omissions in the content of this message.

------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to