I've got a loop that adds a 36 null vars to an get request PDU but after waiting for 
synchronous processing of that request, I get only one value back.  I copied this code 
from elsewhere in my application where it works fine and I see nothing in the 
adaptations that would cause it to fail here.  This I what I've got:

    ...
    size_t s;

    struct snmp_pdu *pdu;
    struct snmp_pdu *response;
            
    struct variable_list *vars;
    int status;
    int count;

    int retval;

    // Base for speed, adminStatus, operStatus
    oid ifoid[] = { 1, 3, 6, 1, 4, 1, 20540, 2, 1, 1, 1 };
    // duplexStatus
    oid dot3oid[] = { 1, 3, 6, 1, 2, 1, 10, 7, 2, 1, 19, 1 };

    size_t oidSize;

    pdu = snmp_pdu_create(SNMP_MSG_GET);

    for (s = 0; s < numPort; ++s) {
        oidSize = OID_LENGTH(ifoid);
        
        ifoid[oidSize-1] = ports[s];

        ifoid[oidSize-2] = 5;// Speed
        snmp_add_null_var(pdu, ifoid, oidSize);
    
        ifoid[oidSize-2] = 7;// AdminStatus
        snmp_add_null_var(pdu, ifoid, oidSize);
    
        ifoid[oidSize-2] = 8;// OperStatus
        snmp_add_null_var(pdu, ifoid, oidSize);
        
        oidSize = OID_LENGTH(dot3oid);
        dot3oid[oidSize-1] = ports[s];
        snmp_add_null_var(pdu, dot3oid, oidSize);
    }

    status = snmp_synch_response(ss, pdu, &response);
    
    if (status == STAT_SUCCESS && response->errstat == SNMP_ERR_NOERROR) {
        /*
         * SUCCESS: Print the result variables
         */

        /* manipuate the information ourselves */
        for(count = 0, vars = response->variables;
            vars;
            ++count, vars = vars->next_variable) {
            snmp_log(LOG_ERR,
                     "Handling variable %d, rec %d, index %d, type %d\n",
                     count, count / 4, count % 4, vars->type);
            
            ...

But the last for loop only executes once.  It appears that the response->variables 
list is only one node long.  Is there something clearly wrong in my code?  I need 
fresh eyes and no one else here knows SNMP at all.  Thanks.



-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
>From Windows to Linux, servers to mobile, InstallShield X is the one
installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
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