Dave,

Sorry about missing the reply all button.

I have migrated to using net-snmp 5.3.0.1 as suggested, however I 
am still seeing the same memory growth.

There must be something that I am missing, something that I need to 
free?

I have changed my code to look something like the following to 
listen for traps on port 7878:

static int
pre_parse(netsnmp_session * session, netsnmp_transport *transport,
          void *transport_data, int transport_data_length)
{
    return 1;
}

static netsnmp_session *
snmptrapd_add_session(netsnmp_transport *t)
{
    netsnmp_session sess, *session = &sess, *rc = NULL;

    snmp_sess_init(session);
    session->peername = SNMP_DEFAULT_PEERNAME;
    session->version = SNMP_DEFAULT_VERSION;
    session->community_len = SNMP_DEFAULT_COMMUNITY_LEN;
    session->retries = SNMP_DEFAULT_RETRIES;
    session->timeout = SNMP_DEFAULT_TIMEOUT;
    session->callback = OnTrapRec;
    session->callback_magic = NULL;
    session->authenticator = NULL;
    sess.isAuthoritative = SNMP_SESS_UNKNOWNAUTH;

    rc = snmp_add(session, t, pre_parse, NULL);
    if (rc == NULL) {
        snmp_sess_perror("snmptrapd", session);
    }
    return rc;
}

void GetTraps(void* magic, int port)
{
    init_snmp("Test");

    netsnmp_session* ss = NULL;
    netsnmp_transport *transport = NULL;
    transport = netsnmp_tdomain_transport("udp:7878", 1, "udp");
    ss = snmptrapd_add_session(transport);

    if (ss)
    {
        int numfds = 0;
        fd_set fdset;
        FD_ZERO(&fdset);
        struct timeval timeout;
        timerclear(&timeout);
        int block = 1;

        for (;;)
        {
            snmp_select_info(&numfds, &fdset, &timeout, &block);
            int count = select(numfds, &fdset, 0, 0, 0);

            if (count > 0)
            {
                snmp_sess_read(&fdset);
                /* free something here? */
            }
        }
    }

    snmp_close(ss);
    snmp_shutdown("Test");
}

int OnTrapRec(int op, struct snmp_session *session, int reqid,
struct
snmp_pdu *pdu,void *magic)
{
    std::cout << "OnTrapRec" << std::endl;
    /* free something here? */
}





Concerned about your privacy? Instantly send FREE secure email, no account 
required
http://www.hushmail.com/send?l=480

Get the best prices on SSL certificates from Hushmail
https://www.hushssl.com?l=485



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
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