*snmp_client.c::snmp_sess_synch_response(*) code is erroneous.
snmpget request must sent a query for discovering snmpEngineID which the
following code is sending.
After this it is supposed to send the actual SNMP get request for a MIB
variable say sysContact.0

When it does context probing it invokes this method and times out even if a
response is received.
Ideally when response is received. It is supposed to send a new request
with variable binding sysContact.0

In the following code, it loops infinitely on 1.
In an infinite loop when there is no socket event it will have count 0,
which is hitting session timeout.
Only when there are more than 0 bytes read, it will process. This is
correct. After processing it is supposed to send snmp request with the
received value in the previous response with the required MIB variable say
sysContact.0
It not not doing so.
Till the timer expires it is retransmitting the same request for discovery
of snmpEngineID but not sending request for sysContact.0
I'm using NET-SNMP 5.6.2.1. Is the following bug fixed later ? or what is
the issue

*snmp_client.c*
int
snmp_sess_synch_response(void *sessp,
                         netsnmp_pdu *pdu, netsnmp_pdu **response)
{
    netsnmp_session *ss;
    struct synch_state lstate, *state;
    snmp_callback   cbsav;
    void           *cbmagsav;
    int             numfds, count;
    fd_set          fdset;
    struct timeval  timeout, *tvp;
    int             block;

    ss = snmp_sess_session(sessp);
    if (ss == NULL) {
        return STAT_ERROR;
snmp_log(LOG_WARNING,"ss NULL");
    }

    memset((void *) &lstate, 0, sizeof(lstate));
    state = &lstate;
    cbsav = ss->callback;
    cbmagsav = ss->callback_magic;
    ss->callback = snmp_synch_input;
    ss->callback_magic = (void *) state;

    if ((state->reqid = snmp_sess_send(sessp, pdu)) == 0) {
        snmp_free_pdu(pdu);
        state->status = STAT_ERROR;
snmp_log(LOG_WARNING,"req ID 0");
    } else
        state->waiting = 1;

    while (state->waiting) {
 numfds = 0;
        FD_ZERO(&fdset);
        block = NETSNMP_SNMPBLOCK;
        tvp = &timeout;
        timerclear(tvp);
        snmp_sess_select_info_flags(sessp, &numfds, &fdset, tvp, &block,
                                    NETSNMP_SELECT_NOALARMS);
        if (block == 1)
            tvp = NULL;         /* block without timeout */
        count = select(numfds, &fdset, NULL, NULL, tvp);
        if (count > 0) {
            snmp_sess_read(sessp, &fdset);
    snmp_log(LOG_WARNING,"count >0");
        } else
            switch (count) {
            case 0:
                snmp_sess_timeout(sessp);
  snmp_log(LOG_WARNING,"count 0 session timeout");
break;
            case -1:
                if (errno == EINTR) {
                    continue;
                } else {
                    snmp_errno = SNMPERR_GENERR;    /*MTCRITICAL_RESOURCE */
                    /*
                     * CAUTION! if another thread closed the socket(s)
                     * waited on here, the session structure was freed.
                     * It would be nice, but we can't rely on the pointer.
                     * ss->s_snmp_errno = SNMPERR_GENERR;
                     * ss->s_errno = errno;
                     */
                    snmp_set_detail(strerror(errno));
                }
                /*
                 * FALLTHRU
                 */
            default:
                state->status = STAT_ERROR;
                state->waiting = 0;
snmp_log(LOG_WARNING,"count -1");
            }
    }
    *response = state->pdu;
    ss->callback = cbsav;
    ss->callback_magic = cbmagsav;
    return state->status;
}


On Tue, Nov 18, 2014 at 6:31 PM, sandhya reddy <sr8...@gmail.com> wrote:

> I have installed net-snmp 5.6.2.1 and sent out snmp get request using
> snmpget command. This is a SNMPv3 request over TLS that i'm sending.
>
> snmpget request sends out two get request
> 1) Read operation for snmpEngineID.0
> 2) Actual get request querying for a MIB variable say sysContact.0
>
> From the tool 1st request is going out for which a response is received in
> net-snmp.
> After that it is sending the same request two more times
> Finally it gives error
> Failed 5343 contextEngineID probing
>
> Please help with the mistake i'm doing
> Why is this error coming inspite of receiving response
>
> Thanks
> Sandhya
>
>
>
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to