I'm trying to manipulate ifLinkUpDownTrapEnable values.  I used mib2c to create a 
ifXTable module and I can get and set values with snmpget and snmpset just fine.  Now 
I'm trying to write a utility routine to update all the values with one call.  I've 
got something like:

// IF-MIB::ifLinkUpDownTrapEnable (.1.3.6.1.2.1.31.1.1.1.14).
// 0 replaced by port number below.
static oid link_OID[] = { SNMP_OID_MIB2, 31, 1, 1, 1, 14, 0 };
static size_t link_OID_len = OID_LENGTH(link_OID);

  int SXSNMPSetTrapsEnabled(int auth, int links[])
  {
    struct snmp_pdu *pdu;
    struct snmp_pdu *response;

    size_t port;
    char value[20];

    int status;

    int retval;

    /*
     * Create the PDU for the data for our request.
     */
    pdu = snmp_pdu_create(SNMP_MSG_SET);

    sprintf(value, "%d", auth);
    snmp_add_var(pdu, auth_OID, auth_OID_len, 'i', value);
    
    for (port = 0; port < NUM_IF; ++port) {
        link_OID[link_OID_len-1] = port+1;
        sprintf(value, "%d", links[port]);
        
        snmp_add_var(pdu, link_OID, link_OID_len, 'i', value);
    }
    
    /*
     * Send the Request out.
     */
    status = snmp_synch_response(ss, pdu, &response);
    if (status == STAT_SUCCESS) {
        retval = SXSNMP_SUCCESS;
    } else {
        snmp_log(LOG_ERR, "Unable to set trap enable values\n");
        retval = SXSNMP_FAILURE;
    }

    if (response)
        snmp_free_pdu(response);
    
    return retval;
  }

and I've added tracing to my set_ifLinkUpDownTrapEnable function.  When I use snmpset 
to set individual objects, I get things like:

  set_ifLinkUpDownTrapEnable: port 8, value 1
  set_ifLinkUpDownTrapEnable: port 1, value 1
  set_ifLinkUpDownTrapEnable: port 3, value 1

but when I call the function above, the value column is correct but the port is 1 for 
all the invocations.  

I drilled down through snmp_add_var() and it copies the OID so I don't see a problem 
with using the same OID variable over and over, changing just the last element.  And 
I've printed out the OID in the loop that calls snmp_add_var() and I get the correct 
values there.

Any pointers or insights appreciated.  Thanks!



-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
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