Example #1
0
/**
 * the *_extract_index routine
 *
 * This routine is called when a set request is received for an index
 * that was not found in the table container. Here, we parse the oid
 * in the the individual index components and copy those indexes to the
 * context. Then we make sure the indexes for the new row are valid.
 */
int
pwrTable_extract_index(pwrTable_context * ctx, netsnmp_index * hdr)
{
    /*
     * temporary local storage for extracting oid index
     *
     * extract index uses varbinds (netsnmp_variable_list) to parse
     * the index OID into the individual components for each index part.
     */
    netsnmp_variable_list var_pwrIndex;
    int             err;

    /*
     * copy index, if provided
     */
    if (hdr) {
        netsnmp_assert(ctx->index.oids == NULL);
        if (snmp_clone_mem((void *) &ctx->index.oids, hdr->oids,
                           hdr->len * sizeof(oid))) {
            return -1;
        }
        ctx->index.len = hdr->len;
    }

    /*
     * initialize variable that will hold each component of the index.
     * If there are multiple indexes for the table, the variable_lists
     * need to be linked together, in order.
     */
    memset(&var_pwrIndex, 0x00, sizeof(var_pwrIndex));
    var_pwrIndex.type = ASN_INTEGER;    /* type hint for parse_oid_indexes */
       /** TODO: link this index to the next, or NULL for the last one */
#ifdef TABLE_CONTAINER_TODO
    log_print(LOGN_CRI,
             "pwrTable_extract_index index list not implemented!\n");
    return 0;
#else
    //var_pwrIndex.next_variable = &var_XX;
    var_pwrIndex.next_variable = NULL;
#endif


    /*
     * parse the oid into the individual index components
     */
    err = parse_oid_indexes(hdr->oids, hdr->len, &var_pwrIndex);
    if (err == SNMP_ERR_NOERROR) {
        /*
         * copy index components into the context structure
         */
        ctx->pwrIndex = *var_pwrIndex.val.integer;


        /*
         * TODO: check index for valid values. For EXAMPLE:
         *
         * if ( *var_pwrIndex.val.integer != XXX ) {
         *    err = -1;
         * }
         */
    }

    /*
     * parsing may have allocated memory. free it.
     */
    snmp_reset_var_buffers(&var_pwrIndex);

    return err;
}
Example #2
0
/**********************************************************************
 **********************************************************************
 *                                                                    *
 *                                                                    *
 * GET procession functions                                           *
 *                                                                    *
 *                                                                    *
 **********************************************************************
 **********************************************************************/
NETSNMP_INLINE int
process_get_requests(netsnmp_handler_registration *reginfo,
                     netsnmp_agent_request_info *agtreq_info,
                     netsnmp_request_info *requests,
                     table_container_data * tad)
{
    int             rc = SNMP_ERR_NOERROR;
    netsnmp_request_info *current;
    netsnmp_index *row = NULL;
    netsnmp_table_request_info *tblreq_info;
    netsnmp_variable_list *var;

    netsnmp_assert(NULL != tad->table);

    /*
     * Loop through each of the requests, and
     * try to find the appropriate row from the container.
     */
    for (current = requests; current; current = current->next) {

        var = current->requestvb;
        DEBUGMSGTL(("table_array:get",
                    "  process_get_request oid:"));
        DEBUGMSGOID(("table_array:get", var->name,
                     var->name_length));
        DEBUGMSG(("table_array:get", "\n"));

        /*
         * skip anything that doesn't need processing.
         */
        if (current->processed != 0) {
            DEBUGMSGTL(("table_array:get", "already processed\n"));
            continue;
        }

        /*
         * Get pointer to the table information for this request. This
         * information was saved by table_helper_handler. When
         * debugging, we double check a few assumptions. For example,
         * the table_helper_handler should enforce column boundaries.
         */
        tblreq_info = netsnmp_extract_table_info(current);
        netsnmp_assert(tblreq_info->colnum <= tad->tblreg_info->max_column);

        if ((agtreq_info->mode == MODE_GETNEXT) ||
                (agtreq_info->mode == MODE_GETBULK)) {
            /*
             * find the row
             */
            row = find_next_row(tblreq_info, tad);
            if (!row) {
                /*
                 * no results found.
                 *
                 * xxx-rks: how do we skip this entry for the next handler,
                 * but still allow it a chance to hit another handler?
                 */
                DEBUGMSGTL(("table_array:get", "no row found\n"));
                continue;
            }

            /*
             * * if data was found, make sure it has the column we want
             */
            /* xxx-rks: add suport for sparse tables */

            /*
             * build new oid
             */
            build_new_oid(reginfo, tblreq_info, row, current);

        } /** GETNEXT/GETBULK */
        else {
            netsnmp_index index;
            index.oids = tblreq_info->index_oid;
            index.len = tblreq_info->index_oid_len;

            row = CONTAINER_FIND(tad->table, &index);
            if (!row) {
                DEBUGMSGTL(("table_array:get", "no row found\n"));
                netsnmp_set_request_error(agtreq_info, current,
                                          SNMP_NOSUCHINSTANCE);
                continue;
            }
        } /** GET */

        /*
         * get the data
         */
        rc = tad->cb->get_value(current, row, tblreq_info);

    } /** for ( ... requests ... ) */

    return rc;
}
/**
 * the *_extract_index routine
 *
 * This routine is called when a set request is received for an index
 * that was not found in the table container. Here, we parse the oid
 * in the the individual index components and copy those indexes to the
 * context. Then we make sure the indexes for the new row are valid.
 */
int
saHpiHotSwapEventTable_extract_index( saHpiHotSwapEventTable_context * ctx, netsnmp_index * hdr )
{
    /*
     * temporary local storage for extracting oid index
     *
     * extract index uses varbinds (netsnmp_variable_list) to parse
     * the index OID into the individual components for each index part.
     */
    /** TODO: add storage for external index(s)! */
    netsnmp_variable_list var_saHpiDomainId;
    netsnmp_variable_list var_saHpiResourceId;
    netsnmp_variable_list var_saHpiEventSeverity;
    netsnmp_variable_list var_saHpiHotSwapEventEntryId;
    int err;

    /*
     * copy index, if provided
     */
    if(hdr) {
        netsnmp_assert(ctx->index.oids == NULL);
        if(snmp_clone_mem( (void*)&ctx->index.oids, hdr->oids,
                           hdr->len * sizeof(oid) )) {
            return -1;
        }
        ctx->index.len = hdr->len;
    }

    /*
     * initialize variable that will hold each component of the index.
     * If there are multiple indexes for the table, the variable_lists
     * need to be linked together, in order.
     */
       /** TODO: add code for external index(s)! */
       memset( &var_saHpiDomainId, 0x00, sizeof(var_saHpiDomainId) );
       var_saHpiDomainId.type = ASN_UNSIGNED; /* type hint for parse_oid_indexes */
       /** TODO: link this index to the next, or NULL for the last one */
#ifdef TABLE_CONTAINER_TODO
    snmp_log(LOG_ERR, "saHpiHotSwapEventTable_extract_index index list not implemented!\n" );
    return 0;
#else
       var_saHpiDomainId.next_variable = &var_XX;
#endif

       memset( &var_saHpiResourceId, 0x00, sizeof(var_saHpiResourceId) );
       var_saHpiResourceId.type = ASN_UNSIGNED; /* type hint for parse_oid_indexes */
       /** TODO: link this index to the next, or NULL for the last one */
#ifdef TABLE_CONTAINER_TODO
    snmp_log(LOG_ERR, "saHpiHotSwapEventTable_extract_index index list not implemented!\n" );
    return 0;
#else
       var_saHpiResourceId.next_variable = &var_XX;
#endif

       memset( &var_saHpiEventSeverity, 0x00, sizeof(var_saHpiEventSeverity) );
       var_saHpiEventSeverity.type = ASN_INTEGER; /* type hint for parse_oid_indexes */
       /** TODO: link this index to the next, or NULL for the last one */
#ifdef TABLE_CONTAINER_TODO
    snmp_log(LOG_ERR, "saHpiHotSwapEventTable_extract_index index list not implemented!\n" );
    return 0;
#else
       var_saHpiEventSeverity.next_variable = &var_XX;
#endif

       memset( &var_saHpiHotSwapEventEntryId, 0x00, sizeof(var_saHpiHotSwapEventEntryId) );
       var_saHpiHotSwapEventEntryId.type = ASN_UNSIGNED; /* type hint for parse_oid_indexes */
       /** TODO: link this index to the next, or NULL for the last one */
#ifdef TABLE_CONTAINER_TODO
    snmp_log(LOG_ERR, "saHpiHotSwapEventTable_extract_index index list not implemented!\n" );
    return 0;
#else
       var_saHpiHotSwapEventEntryId.next_variable = &var_XX;
#endif


    /*
     * parse the oid into the individual index components
     */
    err = parse_oid_indexes( hdr->oids, hdr->len, &var_saHpiDomainId );
    if (err == SNMP_ERR_NOERROR) {
       /*
        * copy index components into the context structure
        */
              /** skipping external index saHpiDomainId */
   
              /** skipping external index saHpiResourceId */
   
              /** skipping external index saHpiEventSeverity */
   
                ctx->saHpiHotSwapEventEntryId = *var_saHpiHotSwapEventEntryId.val.integer;
   
   
           /*
            * TODO: check index for valid values. For EXAMPLE:
            *
              * if ( *var_saHpiDomainId.val.integer != XXX ) {
          *    err = -1;
          * }
          */
           /*
            * TODO: check index for valid values. For EXAMPLE:
            *
              * if ( *var_saHpiResourceId.val.integer != XXX ) {
          *    err = -1;
          * }
          */
           /*
            * TODO: check index for valid values. For EXAMPLE:
            *
              * if ( *var_saHpiEventSeverity.val.integer != XXX ) {
          *    err = -1;
          * }
          */
           /*
            * TODO: check index for valid values. For EXAMPLE:
            *
              * if ( *var_saHpiHotSwapEventEntryId.val.integer != XXX ) {
          *    err = -1;
          * }
          */
    }

    /*
     * parsing may have allocated memory. free it.
     */
    snmp_reset_var_buffers( &var_saHpiDomainId );

    return err;
}
Example #4
0
void
saHpiWatchdogTable_set_reserve2(netsnmp_request_group * rg)
{
  /*saHpiWatchdogTable_context *row_ctx =
        (saHpiWatchdogTable_context *) rg->existing_row;
     
    saHpiWatchdogTable_context *undo_ctx =
    (saHpiWatchdogTable_context *) rg->undo_info;*/
    netsnmp_request_group_item *current;
    netsnmp_variable_list *var;
    int             rc = SNMP_ERR_NOERROR;

    DEBUGMSGTL((AGENT,"saHpiWatchdogTable_set_reserve2. Entry\n"));
    rg->rg_void = rg->list->ri;
    
    for (current = rg->list; current; current = current->next) {

        var = current->ri->requestvb;
        rc = SNMP_ERR_NOERROR;

        switch (current->tri->colnum) {

        case COLUMN_SAHPIWATCHDOGLOG:
            /** TruthValue = ASN_INTEGER */
            rc = netsnmp_check_vb_truthvalue(current->ri->requestvb);
            break;

        case COLUMN_SAHPIWATCHDOGRUNNING:
            /** TruthValue = ASN_INTEGER */
            rc = netsnmp_check_vb_truthvalue(current->ri->requestvb);
            break;

        case COLUMN_SAHPIWATCHDOGTIMERUSE:
	  // HPI-MIB::saHpiWatchdogTimerUse 
	  if ( ((*var->val.integer < 0) || 
	       (*var->val.integer > 5)) &&
	       (*var->val.integer != 0x0F)) {
	    rc = SNMP_ERR_BADVALUE;
	  }
	  break;

        case COLUMN_SAHPIWATCHDOGTIMERACTION:
	  // HPI-MIB::saHpiWatchdogTimerAction
	  if ((*var->val.integer < 0) ||
	      (*var->val.integer > 3)) {
	    rc = SNMP_ERR_BADVALUE;
	  }
	  break;

        case COLUMN_SAHPIWATCHDOGPRETIMERINTERRUPT:
            /** INTEGER = ASN_INTEGER */
	  // HPI-MIB::saHpiWatchdogPretimerInterrupt
	   if ( ((*var->val.integer < 0) || 
	       (*var->val.integer > 3)) &&
	       (*var->val.integer != 0x0F)) {
	    rc = SNMP_ERR_BADVALUE;
	  }
	   break;

        case COLUMN_SAHPIWATCHDOGPRETIMEOUTINTERVAL:
	  // No restriction. 32-bit unsigned can be anything
            break;
	    
        case COLUMN_SAHPIWATCHDOGTIMERUSEEXPFLAGS:
	  if ((*var->val.integer < 0 ) ||
	      (*var->val.integer > 32)) {
	    rc = SNMP_ERR_BADVALUE;
	  }         
	  break;

        case COLUMN_SAHPIWATCHDOGTIMERINITIALCOUNT:
         
            break;

        case COLUMN_SAHPIWATCHDOGTIMERPRESENTCOUNT:
           
            break;


        default:/** We shouldn't get here */
            netsnmp_assert(0); /** why wasn't this caught in reserve1? */
        }

        if (rc)
            netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri,
                                           rc);
    }
    DEBUGMSGTL((AGENT,"saHpiWatchdogTable_set_reserve2. Exit (rc: %d)\n", rc));
    /*
     * done with all the columns. Could check row related
     * requirements here.
     */
}
Example #5
0
/************************************************************
 * If the ACTION phase does fail (for example due to an apparently
 * valid, but unacceptable value, or an unforeseen problem), then
 * the list of write routines are called again, with the UNDO
 * action. This requires the routine to reset the value that was
 * changed to its previous value (assuming it was actually changed),
 * and then to release any resources that had been allocated. As
 * with the FREE phase, the agent will then return an indication
 * of the error to the requesting application.
 *
 * BEFORE calling this routine, the agent will update the container
 * (remove any newly inserted row, re-insert any removed row).
 *
 * AFTER calling this routing, the agent will call row_copy
 * to restore the data in existing_row from the date in undo_info.
 * Then undo_info will be deleted (or existing row, if row_created
 * == 1).
 */
void
saHpiWatchdogTable_set_undo(netsnmp_request_group * rg)
{
    netsnmp_variable_list *var;  
    netsnmp_request_group_item *current;

    /*
     * loop through columns
     */
    for (current = rg->list; current; current = current->next) {

        var = current->ri->requestvb;

        switch (current->tri->colnum) {

        case COLUMN_SAHPIWATCHDOGLOG:
            /** TruthValue = ASN_INTEGER */
            break;

        case COLUMN_SAHPIWATCHDOGRUNNING:
            /** TruthValue = ASN_INTEGER */
            break;

        case COLUMN_SAHPIWATCHDOGTIMERUSE:
            /** INTEGER = ASN_INTEGER */
            break;

        case COLUMN_SAHPIWATCHDOGTIMERACTION:
            /** INTEGER = ASN_INTEGER */
            break;

        case COLUMN_SAHPIWATCHDOGPRETIMERINTERRUPT:
            /** INTEGER = ASN_INTEGER */
            break;

        case COLUMN_SAHPIWATCHDOGPRETIMEOUTINTERVAL:
            /** UNSIGNED32 = ASN_UNSIGNED */
            break;

        case COLUMN_SAHPIWATCHDOGTIMERUSEEXPFLAGS:
            /** UNSIGNED32 = ASN_UNSIGNED */
            break;

        case COLUMN_SAHPIWATCHDOGTIMERINITIALCOUNT:
            /** UNSIGNED32 = ASN_UNSIGNED */
            break;

        case COLUMN_SAHPIWATCHDOGTIMERPRESENTCOUNT:
            /** UNSIGNED32 = ASN_UNSIGNED */
            break;        

        default:/** We shouldn't get here */
            netsnmp_assert(0); /** why wasn't this caught in reserve1? */
	    break;
        }
    }

    /*
     * done with all the columns. Could check row related
     * requirements here.
     */
}
int
_load_v4(netsnmp_container *container, int idx_offset)
{
    FILE           *in;
    char            line[128];
    int             rc = 0;
    netsnmp_arp_entry *entry;
    char           arp[3*NETSNMP_ACCESS_ARP_PHYSADDR_BUF_SIZE+1];
    char           *arp_token;
    int             i;

    netsnmp_assert(NULL != container);

#define PROCFILE "/proc/net/arp"
    if (!(in = fopen(PROCFILE, "r"))) {
        snmp_log(LOG_DEBUG,"could not open " PROCFILE "\n");
        return -2;
    }

    /*
     * Get rid of the header line 
     */
    fgets(line, sizeof(line), in);

    /*
     * IP address | HW | Flag | HW address      | Mask | Device
     * 192.168.1.4  0x1  0x2   00:40:63:CC:1C:8C  *      eth0
     */
    while (fgets(line, sizeof(line), in)) {
        
        int             za, zb, zc, zd;
        unsigned int    tmp_flags;
        char            ifname[21];

        rc = sscanf(line,
                    "%d.%d.%d.%d 0x%*x 0x%x %96s %*[^ ] %20s\n",
                    &za, &zb, &zc, &zd, &tmp_flags, arp, ifname);
        if (7 != rc) {
            snmp_log(LOG_ERR, PROCFILE " data format error (%d!=12)\n", rc);
            snmp_log(LOG_ERR, " line ==|%s|\n", line);
            continue;
        }
        DEBUGMSGTL(("access:arp:container",
                    "ip addr %d.%d.%d.%d, flags 0x%X, hw addr "
                    "%s, name %s\n",
                    za,zb,zc,zd, tmp_flags, arp, ifname ));

        /*
         */
        entry = netsnmp_access_arp_entry_create();
        if(NULL == entry) {
            rc = -3;
            break;
        }

        /*
         * look up ifIndex
         */
        entry->if_index = netsnmp_access_interface_index_find(ifname);
        if(0 == entry->if_index) {
            snmp_log(LOG_ERR,"couldn't find ifIndex for '%s', skipping\n",
                     ifname);
            netsnmp_access_arp_entry_free(entry);
            continue;
        }

        /*
         * now that we've passed all the possible 'continue', assign
         * index offset.
         */
        entry->ns_arp_index = ++idx_offset;

        /*
         * parse ip addr
         */
        entry->arp_ipaddress[0] = za;
        entry->arp_ipaddress[1] = zb;
        entry->arp_ipaddress[2] = zc;
        entry->arp_ipaddress[3] = zd;
        entry->arp_ipaddress_len = 4;

        /*
         * parse hw addr
         */
        for (arp_token = strtok(arp, ":"), i=0; arp_token != NULL; arp_token = strtok(NULL, ":"), i++) {
            entry->arp_physaddress[i] = strtol(arp_token, NULL, 16);
        }
        entry->arp_physaddress_len = i;

        /*
         * what can we do with hw? from arp manpage:

         default  value  of  this  parameter is ether (i.e. hardware code
         0x01 for  IEEE  802.3  10Mbps  Ethernet).   Other  values  might
         include  network  technologies  such as ARCnet (arcnet) , PROnet
         (pronet) , AX.25 (ax25) and NET/ROM (netrom).
        */

        /*
         * parse mask
         */
        /* xxx-rks: what is mask? how to interpret '*'? */


        /*
         * process type
         */
        if(tmp_flags & ATF_PERM)
            entry->arp_type = INETNETTOMEDIATYPE_STATIC;
        else
            entry->arp_type = INETNETTOMEDIATYPE_DYNAMIC;

        /*
         * process status
         * if flags are 0, we can't tell the difference between
         * stale or incomplete.
         */
        if(tmp_flags & ATF_COM)
            entry->arp_state = INETNETTOMEDIASTATE_REACHABLE;
        else
            entry->arp_state = INETNETTOMEDIASTATE_UNKNOWN;

        /*
         * add entry to container
         */
        if (CONTAINER_INSERT(container, entry) < 0)
        {
            DEBUGMSGTL(("access:arp:container","error with arp_entry: insert into container failed.\n"));
            netsnmp_access_arp_entry_free(entry);
            continue;
        }
    }

    fclose(in);
    if( rc < 0 )
        return rc;

    return idx_offset;
}
static int
_load_ipv4(netsnmp_container* container, u_long *index )
{
    FILE           *in;
    char            line[256];
    netsnmp_route_entry *entry = NULL;
    char            name[16];
    int             fd;

    DEBUGMSGTL(("access:route:container",
                "route_container_arch_load ipv4\n"));

    netsnmp_assert(NULL != container);

    /*
     * fetch routes from the proc file-system:
     */
    if (!(in = fopen("/proc/net/route", "r"))) {
        snmp_log(LOG_ERR, "cannot open /proc/net/route\n");
        return -2;
    }

    /*
     * create socket for ioctls (see NOTE[1], below)
     */
    fd = socket(AF_INET, SOCK_DGRAM, 0);
    if(fd < 0) {
        snmp_log(LOG_ERR, "could not create socket\n");
        fclose(in);
        return -2;
    }

    fgets(line, sizeof(line), in); /* skip header */

    while (fgets(line, sizeof(line), in)) {
        char            rtent_name[32];
        int             refcnt, flags, rc;
        uint32_t        dest, nexthop, mask, tmp_mask;
        unsigned        use;

        entry = netsnmp_access_route_entry_create();

        /*
         * as with 1.99.14:
         *    Iface Dest     GW       Flags RefCnt Use Met Mask     MTU  Win IRTT
         * BE eth0  00000000 C0A80101 0003  0      0   0   FFFFFFFF 1500 0   0 
         * LE eth0  00000000 0101A8C0 0003  0      0   0   00FFFFFF    0 0   0  
         */
        rc = sscanf(line, "%s %x %x %x %u %d %d %x %*d %*d %*d\n",
                    rtent_name, &dest, &nexthop,
                    /*
                     * XXX: fix type of the args 
                     */
                    &flags, &refcnt, &use, &entry->rt_metric1,
                    &tmp_mask);
        DEBUGMSGTL(("9:access:route:container", "line |%s|\n", line));
        if (8 != rc) {
            snmp_log(LOG_ERR,
                     "/proc/net/route data format error (%d!=8), line ==|%s|",
                     rc, line);
            
            netsnmp_access_route_entry_free(entry);        
            continue;
        }

        /*
         * temporary null terminated name
         */
        strncpy(name, rtent_name, sizeof(name));
        name[ sizeof(name)-1 ] = 0;

        /*
         * don't bother to try and get the ifindex for routes with
         * no interface name.
         * NOTE[1]: normally we'd use netsnmp_access_interface_index_find,
         * but since that will open/close a socket, and we might
         * have a lot of routes, call the ioctl routine directly.
         */
        if ('*' != name[0])
            entry->if_index =
                netsnmp_access_interface_ioctl_ifindex_get(fd,name);

        /*
         * arbitrary index
         */
        entry->ns_rt_index = ++(*index);

        mask = htonl(tmp_mask);

#ifdef USING_IP_FORWARD_MIB_IPCIDRROUTETABLE_IPCIDRROUTETABLE_MODULE
        entry->rt_mask = mask;
        /** entry->rt_tos = XXX; */
        /** rt info ?? */
#endif
        /*
         * copy dest & next hop
         */
        entry->rt_dest_type = INETADDRESSTYPE_IPV4;
        entry->rt_dest_len = 4;
        memcpy(entry->rt_dest, &dest, 4);

        entry->rt_nexthop_type = INETADDRESSTYPE_IPV4;
        entry->rt_nexthop_len = 4;
        memcpy(entry->rt_nexthop, &nexthop, 4);

        /*
         * count bits in mask
         */
        entry->rt_pfx_len = netsnmp_ipaddress_ipv4_prefix_len(mask);

#ifdef USING_IP_FORWARD_MIB_INETCIDRROUTETABLE_INETCIDRROUTETABLE_MODULE
        /*
    inetCidrRoutePolicy OBJECT-TYPE 
        SYNTAX     OBJECT IDENTIFIER 
        MAX-ACCESS not-accessible 
        STATUS     current 
        DESCRIPTION 
               "This object is an opaque object without any defined 
                semantics.  Its purpose is to serve as an additional 
                index which may delineate between multiple entries to 
                the same destination.  The value { 0 0 } shall be used 
                as the default value for this object."
        */
        /*
         * on linux, default routes all look alike, and would have the same
         * indexed based on dest and next hop. So we use the if index
         * as the policy, to distinguise between them. Hopefully this is
         * unique.
         * xxx-rks: It should really only be for the duplicate case, but that
         *     would be more complicated thanI want to get into now. Fix later.
         */
        if (0 == nexthop) {
            entry->rt_policy = &entry->if_index;
            entry->rt_policy_len = 1;
            entry->flags |= NETSNMP_ACCESS_ROUTE_POLICY_STATIC;
        }
#endif

        /*
         * get protocol and type from flags
         */
        entry->rt_type = _type_from_flags(flags);
        
        entry->rt_proto = (flags & RTF_DYNAMIC)
            ? IANAIPROUTEPROTOCOL_ICMP : IANAIPROUTEPROTOCOL_LOCAL;

        /*
         * insert into container
         */
        if (CONTAINER_INSERT(container, entry) < 0)
        {
            DEBUGMSGTL(("access:route:container", "error with route_entry: insert into container failed.\n"));
            netsnmp_access_route_entry_free(entry);
            continue;
        }
    }

    fclose(in);
    close(fd);
    return 0;
}
Example #8
0
static void create_stdin_waiter_thread()
{
    netsnmp_assert(s_thread_handle == 0);
    s_thread_handle = (HANDLE)_beginthreadex(0, 0, wait_for_stdin, 0, 0, &s_threadid);
    netsnmp_assert(s_thread_handle != 0);
}
/**
 * commit new values.
 *
 * At this point, you should have done everything you can to ensure that
 * this commit will not fail.
 *
 * Should you need different behavior depending on which columns were
 * set, rowreq_ctx->column_set_flags will indicate which writeable columns were
 * set. The definitions for the COLUMN_*_FLAG bits can be found in
 * dot11ConfigIpGroupTable_oids.h.
 * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags.
 *
 * @param dot11ConfigIpGroupTable_rowreq_ctx
 *        Pointer to the users context.
 *
 * @retval MFD_SUCCESS : success
 * @retval MFD_ERROR   : error
 */
int
dot11ConfigIpGroupTable_commit( dot11ConfigIpGroupTable_rowreq_ctx *rowreq_ctx)
{
    int rc = MFD_SUCCESS;
    int             save_flags;

    DEBUGMSGTL(("verbose:dot11ConfigIpGroupTable:dot11ConfigIpGroupTable_commit","called\n"));

    /** we should have a non-NULL pointer */
    netsnmp_assert( NULL != rowreq_ctx );

    /*
     * save flags, then clear until we actually do something
     */
    save_flags = rowreq_ctx->column_set_flags;
    rowreq_ctx->column_set_flags = 0;

	if(RS_NOTREADY == rowreq_ctx->data.ConfigIpRowStatus) {
        rowreq_ctx->data.ConfigIpRowStatus = RS_NOTINSERVICE;
    }

    /*
     * commit dot11ConfigIpGroupTable data
     * 1) check the column's flag in save_flags to see if it was set.
     * 2) clear the flag when you handle that column
     * 3) set the column's flag in column_set_flags if it needs undo
     *    processing in case of a failure.
     */
    if (save_flags & COLUMN_IFCONFIGIPADDR_FLAG) {
       save_flags &= ~COLUMN_IFCONFIGIPADDR_FLAG; /* clear IfconfigIpAddr */
       /*
        * TODO:482:o: |-> commit column IfconfigIpAddr.
        */
       rc = MFD_SUCCESS;
       if(-1 == rc) {
           snmp_log(LOG_ERR,"dot11ConfigIpGroupTable column IfconfigIpAddr commit failed\n");
       }
       else {
            /*
             * set flag, in case we need to undo IfconfigIpAddr
             */
            rowreq_ctx->column_set_flags |= COLUMN_IFCONFIGIPADDR_FLAG;
       }
    }

    if (save_flags & COLUMN_IFCONFIGNETMASK_FLAG) {
       save_flags &= ~COLUMN_IFCONFIGNETMASK_FLAG; /* clear IfconfigNetmask */
       /*
        * TODO:482:o: |-> commit column IfconfigNetmask.
        */
       rc = MFD_SUCCESS;
       if(-1 == rc) {
           snmp_log(LOG_ERR,"dot11ConfigIpGroupTable column IfconfigNetmask commit failed\n");
       }
       else {
            /*
             * set flag, in case we need to undo IfconfigNetmask
             */
            rowreq_ctx->column_set_flags |= COLUMN_IFCONFIGNETMASK_FLAG;
       }
    }

    if (save_flags & COLUMN_CONFIGIPROWSTATUS_FLAG) {
       save_flags &= ~COLUMN_CONFIGIPROWSTATUS_FLAG; /* clear ConfigIpRowStatus */
	   
        switch(rowreq_ctx->data.ConfigIpRowStatus) {
            case RS_ACTIVE:
                break;

            case RS_CREATEANDWAIT:
                rowreq_ctx->data.ConfigIpRowStatus = RS_NOTREADY;
                rc = MFD_SUCCESS;
                break;
                
            case RS_DESTROY:  
                rowreq_ctx->rowreq_flags &= ~MFD_ROW_DELETED;
                break;
                
            default:
                break;
        }
          
       /*
        * TODO:482:o: |-> commit column ConfigIpRowStatus.
        */
       if(-1 == rc) {
           snmp_log(LOG_ERR,"dot11ConfigIpGroupTable column ConfigIpRowStatus commit failed\n");
       }
       else {
            /*
             * set flag, in case we need to undo ConfigIpRowStatus
             */
            rowreq_ctx->column_set_flags |= COLUMN_CONFIGIPROWSTATUS_FLAG;
       }
    }

    /*
     * if we successfully commited this row, set the dirty flag.
     */
    if (MFD_SUCCESS == rc) {
        rowreq_ctx->rowreq_flags |= MFD_ROW_DIRTY;
    }

    if (save_flags) {
       snmp_log(LOG_ERR, "unhandled columns (0x%x) in commit\n", save_flags);
       return MFD_ERROR;
    }

    return rc;
} /* dot11ConfigIpGroupTable_commit */
Example #10
0
/** @internal Implements the stash_to_next handler */
int
netsnmp_stash_to_next_helper(netsnmp_mib_handler *handler,
                            netsnmp_handler_registration *reginfo,
                            netsnmp_agent_request_info *reqinfo,
                            netsnmp_request_info *requests)
{

    int             ret = SNMP_ERR_NOERROR;
    int             namelen;
    int             finished = 0;
    netsnmp_oid_stash_node **cinfo;
    netsnmp_variable_list   *vb;
    netsnmp_request_info    *reqtmp;

    /*
     * this code depends on AUTO_NEXT being set
     */
    netsnmp_assert(handler->flags & MIB_HANDLER_AUTO_NEXT);

    /*
     * Don't do anything for any modes except GET_STASH. Just return,
     * and the agent will call the next handler (AUTO_NEXT).
     *
     * If the handler chain already supports GET_STASH, we don't
     * need to do anything here either.  Once again, we just return
     * and the agent will call the next handler (AUTO_NEXT).
     *
     * Otherwise, we munge the mode to GET_NEXT, and call the
     * next handler ourselves, repeatedly until we've retrieved the
     * full contents of the table or subtree.
     *   Then restore the mode and return to the calling handler 
     * (setting AUTO_NEXT_OVERRRIDE so the agent knows what we did).
     */
    if (MODE_GET_STASH == reqinfo->mode) {
        if ( reginfo->modes & HANDLER_CAN_STASH ) {
            return ret;
        }
        cinfo  = netsnmp_extract_stash_cache( reqinfo );
        reqtmp = SNMP_MALLOC_TYPEDEF(netsnmp_request_info);
        vb = reqtmp->requestvb = SNMP_MALLOC_TYPEDEF( netsnmp_variable_list );
        vb->type = ASN_NULL;
        snmp_set_var_objid( vb, reginfo->rootoid, reginfo->rootoid_len );

        reqinfo->mode = MODE_GETNEXT;
        while (!finished) {
            ret = netsnmp_call_next_handler(handler, reginfo, reqinfo, reqtmp);
            namelen = SNMP_MIN(vb->name_length, reginfo->rootoid_len);
            if ( !snmp_oid_compare( reginfo->rootoid, reginfo->rootoid_len,
                                   vb->name, namelen) &&
                 vb->type != ASN_NULL && vb->type != SNMP_ENDOFMIBVIEW ) {
                /*
                 * This result is relevant so save it, and prepare
                 * the request varbind for the next query.
                 */
                netsnmp_oid_stash_add_data( cinfo, vb->name, vb->name_length,
                                            snmp_clone_varbind( vb ));
                    /*
                     * Tidy up the response structure,
                     *  ready for retrieving the next entry
                     */
                netsnmp_free_all_list_data(reqtmp->parent_data);
                reqtmp->parent_data = NULL;
                reqtmp->processed = 0;
                vb->type = ASN_NULL;
            } else {
                finished = 1;
            }
        }
        reqinfo->mode = MODE_GET_STASH;

        /*
         * let the handler chain processing know that we've already
         * called the next handler
         */
        handler->flags |= MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE;
    }

    return ret;
}
/*
 * @internal
 * Retrieve the value for a particular column
 */
NETSNMP_STATIC_INLINE int
_dot11WtpWAPIPerformanceStatsTable_get_column( dot11WtpWAPIPerformanceStatsTable_rowreq_ctx *rowreq_ctx,
                       netsnmp_variable_list *var, int column )
{
    int rc = SNMPERR_SUCCESS;
    
    DEBUGMSGTL(("internal:dot11WtpWAPIPerformanceStatsTable:_mfd_dot11WtpWAPIPerformanceStatsTable_get_column","called\n"));


    netsnmp_assert(NULL != rowreq_ctx);

    switch(column) {

    /* (INDEX) staMacAddr(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */
    case COLUMN_STAMACADDR:
    var->type = ASN_OCTET_STR;
    /*
     * NOTE: val_len is in bytes, staMacAddr_len might not be (e.g. oids)
     */
        if (var->val_len < (rowreq_ctx->tbl_idx.staMacAddr_len *
                            sizeof(rowreq_ctx->tbl_idx.staMacAddr[0]))) {
           var->val.string = malloc(rowreq_ctx->tbl_idx.staMacAddr_len *
                                    sizeof(rowreq_ctx->tbl_idx.staMacAddr[0]));
        }
        var->val_len = rowreq_ctx->tbl_idx.staMacAddr_len * sizeof(rowreq_ctx->tbl_idx.staMacAddr[0]);
        memcpy( var->val.string, rowreq_ctx->tbl_idx.staMacAddr, var->val_len );
        break;

    /* wtpWapiVersion(2)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */
    case COLUMN_WTPWAPIVERSION:
    var->val_len = sizeof(long);
    var->type = ASN_INTEGER;
rc = wtpWapiVersion_get(rowreq_ctx, (long *)var->val.string );
        break;

    /* wtpWapiControlledPortStatus(3)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h */
    case COLUMN_WTPWAPICONTROLLEDPORTSTATUS:
    var->val_len = sizeof(u_long);
    var->type = ASN_INTEGER;
rc = wtpWapiControlledPortStatus_get(rowreq_ctx, (u_long *)var->val.string );
        break;

    /* wtpWapiSelectedUnicastCipher(4)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */
    case COLUMN_WTPWAPISELECTEDUNICASTCIPHER:
    var->type = ASN_OCTET_STR;
rc = wtpWapiSelectedUnicastCipher_get(rowreq_ctx, (char **)&var->val.string, &var->val_len );
        break;

    /* wtpWapiWPIReplayCounters(5)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h */
    case COLUMN_WTPWAPIWPIREPLAYCOUNTERS:
    var->val_len = sizeof(u_long);
    var->type = ASN_COUNTER;
rc = wtpWapiWPIReplayCounters_get(rowreq_ctx, (u_long *)var->val.string );
        break;

    /* wtpWapiWPIDecryptableErrors(6)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h */
    case COLUMN_WTPWAPIWPIDECRYPTABLEERRORS:
    var->val_len = sizeof(u_long);
    var->type = ASN_COUNTER;
rc = wtpWapiWPIDecryptableErrors_get(rowreq_ctx, (u_long *)var->val.string );
        break;

    /* wtpWapiWPIMICErrors(7)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h */
    case COLUMN_WTPWAPIWPIMICERRORS:
    var->val_len = sizeof(u_long);
    var->type = ASN_COUNTER;
rc = wtpWapiWPIMICErrors_get(rowreq_ctx, (u_long *)var->val.string );
        break;

    /* wtpWapiWAISignatureErrors(8)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h */
    case COLUMN_WTPWAPIWAISIGNATUREERRORS:
    var->val_len = sizeof(u_long);
    var->type = ASN_COUNTER;
rc = wtpWapiWAISignatureErrors_get(rowreq_ctx, (u_long *)var->val.string );
        break;

    /* wtpWapiWAIHMACErrors(9)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h */
    case COLUMN_WTPWAPIWAIHMACERRORS:
    var->val_len = sizeof(u_long);
    var->type = ASN_COUNTER;
rc = wtpWapiWAIHMACErrors_get(rowreq_ctx, (u_long *)var->val.string );
        break;

    /* wtpWapiWAIAuthResultFailures(10)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h */
    case COLUMN_WTPWAPIWAIAUTHRESULTFAILURES:
    var->val_len = sizeof(u_long);
    var->type = ASN_COUNTER;
rc = wtpWapiWAIAuthResultFailures_get(rowreq_ctx, (u_long *)var->val.string );
        break;

    /* wtpWapiWAIDiscardCounters(11)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h */
    case COLUMN_WTPWAPIWAIDISCARDCOUNTERS:
    var->val_len = sizeof(u_long);
    var->type = ASN_COUNTER;
rc = wtpWapiWAIDiscardCounters_get(rowreq_ctx, (u_long *)var->val.string );
        break;

    /* wtpWapiWAITimeoutCounters(12)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h */
    case COLUMN_WTPWAPIWAITIMEOUTCOUNTERS:
    var->val_len = sizeof(u_long);
    var->type = ASN_COUNTER;
rc = wtpWapiWAITimeoutCounters_get(rowreq_ctx, (u_long *)var->val.string );
        break;

    /* wtpWapiWAIFormatErrors(13)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h */
    case COLUMN_WTPWAPIWAIFORMATERRORS:
    var->val_len = sizeof(u_long);
    var->type = ASN_COUNTER;
rc = wtpWapiWAIFormatErrors_get(rowreq_ctx, (u_long *)var->val.string );
        break;

    /* wtpWapiWAICertificateHandshakeFailures(14)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h */
    case COLUMN_WTPWAPIWAICERTIFICATEHANDSHAKEFAILURES:
    var->val_len = sizeof(u_long);
    var->type = ASN_COUNTER;
rc = wtpWapiWAICertificateHandshakeFailures_get(rowreq_ctx, (u_long *)var->val.string );
        break;

    /* wtpWapiWAIUnicastHandshakeFailures(15)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h */
    case COLUMN_WTPWAPIWAIUNICASTHANDSHAKEFAILURES:
    var->val_len = sizeof(u_long);
    var->type = ASN_COUNTER;
rc = wtpWapiWAIUnicastHandshakeFailures_get(rowreq_ctx, (u_long *)var->val.string );
        break;

    /* wtpWapiWAIMulticastHandshakeFailures(16)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h */
    case COLUMN_WTPWAPIWAIMULTICASTHANDSHAKEFAILURES:
    var->val_len = sizeof(u_long);
    var->type = ASN_COUNTER;
rc = wtpWapiWAIMulticastHandshakeFailures_get(rowreq_ctx, (u_long *)var->val.string );
        break;

     default:
         snmp_log(LOG_ERR,"unknown column %d in _dot11WtpWAPIPerformanceStatsTable_get_column\n", column);
         break;
    }

    return rc;
} /* _dot11WtpWAPIPerformanceStatsTable_get_column */
/*
 * @internal
 * Retrieve the value for a particular column
 */
NETSNMP_STATIC_INLINE int
_pgsqlPgAmTable_get_column( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx,
                       netsnmp_variable_list *var, int column )
{
    int rc = SNMPERR_SUCCESS;
    
    DEBUGMSGTL(("internal:pgsqlPgAmTable:_mfd_pgsqlPgAmTable_get_column","called\n"));


    netsnmp_assert(NULL != rowreq_ctx);

    switch(column) {

    /* pgsqlPgAmAmname(2)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */
    case COLUMN_PGSQLPGAMAMNAME:
    var->type = ASN_OCTET_STR;
rc = pgsqlPgAmAmname_get(rowreq_ctx, (char **)&var->val.string, &var->val_len );
        break;

    /* pgsqlPgAmAmstrategies(3)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */
    case COLUMN_PGSQLPGAMAMSTRATEGIES:
    var->val_len = sizeof(long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmstrategies_get(rowreq_ctx, (long *)var->val.string );
        break;

    /* pgsqlPgAmAmsupport(4)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */
    case COLUMN_PGSQLPGAMAMSUPPORT:
    var->val_len = sizeof(long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmsupport_get(rowreq_ctx, (long *)var->val.string );
        break;

    /* pgsqlPgAmAmorderstrategy(5)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */
    case COLUMN_PGSQLPGAMAMORDERSTRATEGY:
    var->val_len = sizeof(long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmorderstrategy_get(rowreq_ctx, (long *)var->val.string );
        break;

    /* pgsqlPgAmAmcanunique(6)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h */
    case COLUMN_PGSQLPGAMAMCANUNIQUE:
    var->val_len = sizeof(u_long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmcanunique_get(rowreq_ctx, (u_long *)var->val.string );
        break;

    /* pgsqlPgAmAmcanmulticol(7)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h */
    case COLUMN_PGSQLPGAMAMCANMULTICOL:
    var->val_len = sizeof(u_long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmcanmulticol_get(rowreq_ctx, (u_long *)var->val.string );
        break;

    /* pgsqlPgAmAmoptionalkey(8)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h */
    case COLUMN_PGSQLPGAMAMOPTIONALKEY:
    var->val_len = sizeof(u_long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmoptionalkey_get(rowreq_ctx, (u_long *)var->val.string );
        break;

    /* pgsqlPgAmAmindexnulls(9)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h */
    case COLUMN_PGSQLPGAMAMINDEXNULLS:
    var->val_len = sizeof(u_long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmindexnulls_get(rowreq_ctx, (u_long *)var->val.string );
        break;

    /* pgsqlPgAmAmstorage(10)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h */
    case COLUMN_PGSQLPGAMAMSTORAGE:
    var->val_len = sizeof(u_long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmstorage_get(rowreq_ctx, (u_long *)var->val.string );
        break;

    /* pgsqlPgAmAmclusterable(11)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h */
    case COLUMN_PGSQLPGAMAMCLUSTERABLE:
    var->val_len = sizeof(u_long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmclusterable_get(rowreq_ctx, (u_long *)var->val.string );
        break;

    /* pgsqlPgAmAminsert(12)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */
    case COLUMN_PGSQLPGAMAMINSERT:
    var->val_len = sizeof(long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAminsert_get(rowreq_ctx, (long *)var->val.string );
        break;

    /* pgsqlPgAmAmbeginscan(13)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */
    case COLUMN_PGSQLPGAMAMBEGINSCAN:
    var->val_len = sizeof(long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmbeginscan_get(rowreq_ctx, (long *)var->val.string );
        break;

    /* pgsqlPgAmAmgettuple(14)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */
    case COLUMN_PGSQLPGAMAMGETTUPLE:
    var->val_len = sizeof(long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmgettuple_get(rowreq_ctx, (long *)var->val.string );
        break;

    /* pgsqlPgAmAmgetmulti(15)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */
    case COLUMN_PGSQLPGAMAMGETMULTI:
    var->val_len = sizeof(long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmgetmulti_get(rowreq_ctx, (long *)var->val.string );
        break;

    /* pgsqlPgAmAmrescan(16)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */
    case COLUMN_PGSQLPGAMAMRESCAN:
    var->val_len = sizeof(long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmrescan_get(rowreq_ctx, (long *)var->val.string );
        break;

    /* pgsqlPgAmAmendscan(17)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */
    case COLUMN_PGSQLPGAMAMENDSCAN:
    var->val_len = sizeof(long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmendscan_get(rowreq_ctx, (long *)var->val.string );
        break;

    /* pgsqlPgAmAmmarkpos(18)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */
    case COLUMN_PGSQLPGAMAMMARKPOS:
    var->val_len = sizeof(long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmmarkpos_get(rowreq_ctx, (long *)var->val.string );
        break;

    /* pgsqlPgAmAmrestrpos(19)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */
    case COLUMN_PGSQLPGAMAMRESTRPOS:
    var->val_len = sizeof(long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmrestrpos_get(rowreq_ctx, (long *)var->val.string );
        break;

    /* pgsqlPgAmAmbuild(20)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */
    case COLUMN_PGSQLPGAMAMBUILD:
    var->val_len = sizeof(long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmbuild_get(rowreq_ctx, (long *)var->val.string );
        break;

    /* pgsqlPgAmAmbulkdelete(21)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */
    case COLUMN_PGSQLPGAMAMBULKDELETE:
    var->val_len = sizeof(long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmbulkdelete_get(rowreq_ctx, (long *)var->val.string );
        break;

    /* pgsqlPgAmAmvacuumcleanup(22)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */
    case COLUMN_PGSQLPGAMAMVACUUMCLEANUP:
    var->val_len = sizeof(long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmvacuumcleanup_get(rowreq_ctx, (long *)var->val.string );
        break;

    /* pgsqlPgAmAmcostestimate(23)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */
    case COLUMN_PGSQLPGAMAMCOSTESTIMATE:
    var->val_len = sizeof(long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmcostestimate_get(rowreq_ctx, (long *)var->val.string );
        break;

    /* pgsqlPgAmAmoptions(24)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */
    case COLUMN_PGSQLPGAMAMOPTIONS:
    var->val_len = sizeof(long);
    var->type = ASN_INTEGER;
rc = pgsqlPgAmAmoptions_get(rowreq_ctx, (long *)var->val.string );
        break;

     default:
         snmp_log(LOG_ERR,"unknown column %d in _pgsqlPgAmTable_get_column\n", column);
         break;
    }

    return rc;
} /* _pgsqlPgAmTable_get_column */
/*
 * @internal
 * Retrieve the value for a particular column
 */
NETSNMP_STATIC_INLINE int
_dmfTable_get_column(dmfTable_rowreq_ctx * rowreq_ctx,
                     netsnmp_variable_list * var, int column)
{
    int             rc = SNMPERR_SUCCESS;

    DEBUGMSGTL(("internal:dmfTable:_mfd_dmfTable_get_column",
                "called for %d\n", column));


    netsnmp_assert(NULL != rowreq_ctx);

    switch (column) {

        /*
         * (INDEX) server(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H 
         */
    case COLUMN_SERVER:
        var->type = ASN_OCTET_STR;
        /*
         * NOTE: val_len is in bytes, server_len might not be (e.g. oids)
         */
        if (var->val_len < (rowreq_ctx->tbl_idx.server_len *
                            sizeof(rowreq_ctx->tbl_idx.server[0]))) {
            var->val.string = malloc(rowreq_ctx->tbl_idx.server_len *
                                     sizeof(rowreq_ctx->tbl_idx.
                                            server[0]));
        }
        var->val_len =
            rowreq_ctx->tbl_idx.server_len *
            sizeof(rowreq_ctx->tbl_idx.server[0]);
        memcpy(var->val.string, rowreq_ctx->tbl_idx.server, var->val_len);
        break;

        /*
         * (INDEX) pagesize(2)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_PAGESIZE:
        var->type = ASN_INTEGER;
        var->val_len = sizeof(long);
        (*var->val.integer) = rowreq_ctx->tbl_idx.pagesize;
        break;

        /*
         * forceCount(3)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_FORCECOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = forceCount_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * ioWaitCount(4)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_IOWAITCOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = ioWaitCount_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * groupBufferReadCount(5)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_GROUPBUFFERREADCOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = groupBufferReadCount_get(rowreq_ctx,
                                      (long *) var->val.string);
        break;

        /*
         * groupBufferWriteCount(6)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_GROUPBUFFERWRITECOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = groupBufferWriteCount_get(rowreq_ctx,
                                       (long *) var->val.string);
        break;

        /*
         * fixCount(7)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_FIXCOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = fixCount_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * unfixCount(8)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_UNFIXCOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = unfixCount_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * readCount(9)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_READCOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = readCount_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * writeCount(10)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_WRITECOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = writeCount_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * hitCount(11)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_HITCOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = hitCount_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * dirtyUnfixCount(12)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_DIRTYUNFIXCOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = dirtyUnfixCount_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * pagesStillValid(13)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_PAGESSTILLVALID:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = pagesStillValid_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * pagesInvalid(14)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_PAGESINVALID:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = pagesInvalid_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * bufferCount(15)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_BUFFERCOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = bufferCount_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * pageBufferCount(16)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_PAGEBUFFERCOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = pageBufferCount_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * fLimit(17)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_FLIMIT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = fLimit_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * mLimit(18)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_MLIMIT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = mLimit_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * wbStart(19)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_WBSTART:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = wbStart_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * wbEnd(20)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_WBEND:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = wbEnd_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * hashBucketCount(21)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_HASHBUCKETCOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = hashBucketCount_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * groupBufferCount(22)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_GROUPBUFFERCOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = groupBufferCount_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * groupBufferSize(23)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_GROUPBUFFERSIZE:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = groupBufferSize_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * cacheStatus(24)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_CACHESTATUS:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = cacheStatus_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * freeBufferCount(25)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_FREEBUFFERCOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = freeBufferCount_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * freeBufferWaiters(26)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_FREEBUFFERWAITERS:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = freeBufferWaiters_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * fixedBufferCount(27)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_FIXEDBUFFERCOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = fixedBufferCount_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * modifiedBufferCount(28)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_MODIFIEDBUFFERCOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = modifiedBufferCount_get(rowreq_ctx, (long *) var->val.string);
        break;

        /*
         * freeGroupBufferCount(29)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_FREEGROUPBUFFERCOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = freeGroupBufferCount_get(rowreq_ctx,
                                      (long *) var->val.string);
        break;

        /*
         * fixedGroupBufferCount(30)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_FIXEDGROUPBUFFERCOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = fixedGroupBufferCount_get(rowreq_ctx,
                                       (long *) var->val.string);
        break;

        /*
         * modifiedGroupBufferCount(31)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h 
         */
    case COLUMN_MODIFIEDGROUPBUFFERCOUNT:
        var->val_len = sizeof(long);
        var->type = ASN_INTEGER;
        rc = modifiedGroupBufferCount_get(rowreq_ctx,
                                          (long *) var->val.string);
        break;

    default:
        if (DMFTABLE_MIN_COL <= column && column <= DMFTABLE_MAX_COL) {
            DEBUGMSGTL(("internal:dmfTable:_mfd_dmfTable_get_column",
                        "assume column %d is reserved\n", column));
            rc = MFD_SKIP;
        } else {
            snmp_log(LOG_ERR,
                     "unknown column %d in _dmfTable_get_column\n",
                     column);
        }
        break;
    }

    return rc;
}                               /* _dmfTable_get_column */
Example #14
0
int
_load_v6(netsnmp_container *container, int idx_offset)
{
    FILE           *in;
    char            line[80], addr[33], if_name[IFNAMSIZ];
    u_char          *buf;
    int             if_index, pfx_len, scope, flags, rc = 0, in_len, out_len;
    netsnmp_ipaddress_entry *entry;
    _ioctl_extras           *extras;
    static int      log_open_err = 1;
    
    netsnmp_assert(NULL != container);

#define PROCFILE "/proc/net/if_inet6"
    if (!(in = fopen(PROCFILE, "r"))) {
        if (1 == log_open_err) {
            snmp_log(LOG_ERR,"could not open " PROCFILE "\n");
            log_open_err = 0;
        }
        return -2;
    }
    /*
     * if we hadn't been able to open file and turned of err logging,
     * turn it back on now that we opened the file.
     */
    if (0 == log_open_err)
        log_open_err = 1;

    /*
     * address index prefix_len scope status if_name
     */
    while (fgets(line, sizeof(line), in)) {
        /*
         * fe800000000000000200e8fffe5b5c93 05 40 20 80 eth0
         *             A                    D  P  S  F  I
         * A: address
         * D: device number
         * P: prefix len
         * S: scope (see include/net/ipv6.h, net/ipv6/addrconf.c)
         * F: flags (see include/linux/rtnetlink.h, net/ipv6/addrconf.c)
         * I: interface
         */
        rc = sscanf(line, "%32s %02x %02x %02x %02x %8s\n",
                    addr, &if_index, &pfx_len, &scope, &flags, if_name);
        if( 6 != rc ) {
            snmp_log(LOG_ERR, PROCFILE " data format error (%d!=6), line ==|%s|\n",
                     rc, line);
            continue;
        }
        DEBUGMSGTL(("access:ipaddress:container",
                    "addr %s, index %d, pfx %d, scope %d, flags 0x%X, name %s\n",
                    addr, if_index, pfx_len, scope, flags, if_name));
        /*
         */
        entry = netsnmp_access_ipaddress_entry_create();
        if(NULL == entry) {
            rc = -3;
            break;
        }

        in_len = entry->ia_address_len = sizeof(entry->ia_address);
        netsnmp_assert(16 == in_len);
        out_len = 0;
        buf = entry->ia_address;
        if(1 != snmp_hex_to_binary(&buf,
                                   &in_len, &out_len, 0, addr)) {
            snmp_log(LOG_ERR,"error parsing '%s', skipping\n",
                     entry->ia_address);
            netsnmp_access_ipaddress_entry_free(entry);
            continue;
        }
        netsnmp_assert(16 == out_len);
        entry->ia_address_len = out_len;

        entry->ns_ia_index = ++idx_offset;

        /*
         * save if name
         */
        extras = netsnmp_ioctl_ipaddress_extras_get(entry);
        memcpy(extras->name, if_name, sizeof(extras->name));
        extras->flags = flags;

        /*
         * yyy-rks: optimization: create a socket outside the loop and use
         * netsnmp_access_interface_ioctl_ifindex_get() here, since
         * netsnmp_access_interface_index_find will open/close a socket
         * every time it is called.
         */
        entry->if_index = netsnmp_access_interface_index_find(if_name);

        /*
          #define IPADDRESSSTATUSTC_PREFERRED  1
          #define IPADDRESSSTATUSTC_DEPRECATED  2
          #define IPADDRESSSTATUSTC_INVALID  3
          #define IPADDRESSSTATUSTC_INACCESSIBLE  4
          #define IPADDRESSSTATUSTC_UNKNOWN  5
          #define IPADDRESSSTATUSTC_TENTATIVE  6
          #define IPADDRESSSTATUSTC_DUPLICATE  7
        */
        if(flags & IFA_F_PERMANENT)
            entry->ia_status = IPADDRESSSTATUSTC_PREFERRED; /* ?? */
        else if(flags & IFA_F_DEPRECATED)
            entry->ia_status = IPADDRESSSTATUSTC_DEPRECATED;
        else if(flags & IFA_F_TENTATIVE)
            entry->ia_status = IPADDRESSSTATUSTC_TENTATIVE;
        else {
            entry->ia_status = IPADDRESSSTATUSTC_UNKNOWN;
            DEBUGMSGTL(("access:ipaddress:ipv6",
                        "unknown flags 0x%x\n", flags));
        }

        /*
         * if it's not multi, it must be uni.
         *  (an ipv6 address is never broadcast)
         */
        if (IN6_IS_ADDR_MULTICAST(entry->ia_address))
            entry->ia_type = IPADDRESSTYPE_ANYCAST;
        else
            entry->ia_type = IPADDRESSTYPE_UNICAST;


        /** entry->ia_prefix_oid ? */

        /*
         * can we figure out if an address is from DHCP?
         * use manual until then...
         *
         *#define IPADDRESSORIGINTC_OTHER  1
         *#define IPADDRESSORIGINTC_MANUAL  2
         *#define IPADDRESSORIGINTC_DHCP  4
         *#define IPADDRESSORIGINTC_LINKLAYER  5
         *#define IPADDRESSORIGINTC_RANDOM  6
         *
         * are 'local' address assigned by link layer??
         */
        if (IN6_IS_ADDR_LINKLOCAL(entry->ia_address) ||
            IN6_IS_ADDR_SITELOCAL(entry->ia_address))
            entry->ia_origin = IPADDRESSORIGINTC_LINKLAYER;
        else
            entry->ia_origin = IPADDRESSORIGINTC_MANUAL;

        /* xxx-rks: what can we do with scope? */

        /*
         * add entry to container
         */
        CONTAINER_INSERT(container, entry);
    }

    fclose(in);

    if(rc<0)
        return rc;

    return idx_offset;
}
static int
_load_v6(netsnmp_container *container, int idx_offset)
{
    char              buffer[16384];
#if defined(HAVE_LINUX_RTNETLINK_H)
    struct nlmsghdr   *nlmp;
#endif
    int               sd = 0;
    int               status = 0;
    int               rc = 0;
    int               len, req_len;
    netsnmp_arp_entry *entry;

    netsnmp_assert(NULL != container);
#if defined(HAVE_LINUX_RTNETLINK_H)
    if((sd = socket (PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE)) < 0) {
        snmp_log(LOG_ERR,"Unable to create netlink socket\n");
        return -2;
    }

    if(get_translation_table_info (sd, &status, buffer, sizeof(buffer)) < 0) {
       snmp_log(LOG_ERR,"Unable to fetch translation table info\n");
       close(sd);
       return -2;
    }

    for (nlmp = (struct nlmsghdr *)buffer; status > sizeof(*nlmp); ) {
         len = nlmp->nlmsg_len;
         req_len = len - sizeof(*nlmp);
         if (req_len < 0 || len > status) {
             snmp_log(LOG_ERR,"invalid length\n");
             return -2;
         }
         if (!NLMSG_OK (nlmp, status)) {
             snmp_log(LOG_ERR,"NLMSG not OK\n");
             return -2;
         }
         entry = netsnmp_access_arp_entry_create();
         if(NULL == entry) {
            rc = -3;
            break;
         }
         entry->ns_arp_index = ++idx_offset;
         if(fillup_entry_info (entry, nlmp) < 0) {
            DEBUGMSGTL(("access:arp:load_v6", "skipping netlink message that"
                        " did not contain valid ARP information\n"));
            netsnmp_access_arp_entry_free(entry);
            status -= NLMSG_ALIGN(len);
            nlmp = (struct nlmsghdr*)((char*)nlmp + NLMSG_ALIGN(len));
            continue;
         }
         CONTAINER_INSERT(container, entry);
         status -= NLMSG_ALIGN(len);
         nlmp = (struct nlmsghdr*)((char*)nlmp + NLMSG_ALIGN(len));
    }

    close(sd);
#endif
    if(rc<0) {
        return rc;
    }

    return idx_offset;
}
/**
 * check dependencies
 *
 * This is useful for for tables which have dependencies between columns
 * (or rows, or tables). For example, two columns allocating a percentage
 * of something add up 100%.
 *
 * Should you need different behavior depending on which columns were
 * set, rowreq_ctx->column_set_flags will indicate which writeable columns were
 * set. The definitions for the COLUMN_*_FLAG bits can be found in
 * dot11ConfigIpGroupTable_oids.h.
 * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags.
 *
 * @retval MFD_SUCCESS all the changes to the row are legal
 * @retval MFD_ERROR   one or more changes are not legal
 *
 * (see README-table-dot11ConfigIpGroupTable if you don't have dependencies)
 */
int
dot11ConfigIpGroupTable_check_dependencies(dot11ConfigIpGroupTable_rowreq_ctx *rowreq_ctx)
{
    int rc = MFD_SUCCESS;
    
    DEBUGMSGTL(("internal:dot11ConfigIpGroupTable:dot11ConfigIpGroupTable_check_dependencies","called\n"));

    netsnmp_assert(NULL != rowreq_ctx);

    /*
     * TODO:470:o: Check dot11ConfigIpGroupTable row dependencies.
     * check that all new value are legal and consistent with each other
     */
    /*
     * check RowStatus dependencies
     */
    if (rowreq_ctx->column_set_flags & COLUMN_CONFIGIPROWSTATUS_FLAG) {
        /*
         * check for valid RowStatus transition (old, new)
         * (Note: move transition check to 
         *  to catch errors earlier)
         */
        rc = check_rowstatus_transition( rowreq_ctx->undo->ConfigIpRowStatus,
                                         rowreq_ctx->data.ConfigIpRowStatus );
        if (MFD_SUCCESS != rc)
            return rc;
        
        /*
         * row creation requirements
         */
        if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) {
            if (ROWSTATUS_DESTROY ==  rowreq_ctx->data.ConfigIpRowStatus) {
                rowreq_ctx->rowreq_flags |= MFD_ROW_DELETED;
            }
            else if (ROWSTATUS_CREATEANDGO ==  rowreq_ctx->data.ConfigIpRowStatus) {
                if ((rowreq_ctx->column_set_flags & DOT11CONFIGIPGROUPTABLE_REQUIRED_COLS)
                    != DOT11CONFIGIPGROUPTABLE_REQUIRED_COLS) {
                    DEBUGMSGTL(("dot11ConfigIpGroupTable",
                                "required columns missing (0x%0x != 0x%0x)\n",
                                rowreq_ctx->column_set_flags, DOT11CONFIGIPGROUPTABLE_REQUIRED_COLS));
                    return MFD_CANNOT_CREATE_NOW;
                }
                rowreq_ctx->data.ConfigIpRowStatus = ROWSTATUS_ACTIVE;
            }
        } /* row creation */
        else {
            /*
             * row change requirements
             */
            /*
             * don't allow a destroy if any other value was changed, since
             * that might call data access routines with bad info.
             *
             * you may or may not require the row be notInService before it
             * can be destroyed.
             */
            if (ROWSTATUS_DESTROY == rowreq_ctx->data.ConfigIpRowStatus) {
                if (rowreq_ctx->column_set_flags & ~COLUMN_CONFIGIPROWSTATUS_FLAG) {
                    DEBUGMSGTL(("dot11ConfigIpGroupTable",
                                "destroy must be only varbind for row\n"));
                    return MFD_NOT_VALID_NOW;
                }
                rowreq_ctx->rowreq_flags |= MFD_ROW_DELETED;

            } /* row destroy */
        } /* row change */
    }
    else {
        /*
         * must have row status to create a row
         */
        if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) {
            DEBUGMSGTL(("dot11ConfigIpGroupTable",
                        "must use RowStatus to create rows\n"));
            return MFD_CANNOT_CREATE_NOW;
        }
    } /* row status not set */

    if ( MFD_SUCCESS != rc )
        return rc;

    return rc;
} /* dot11ConfigIpGroupTable_check_dependencies */
int
fillup_entry_info(netsnmp_arp_entry *entry, struct nlmsghdr *nlmp)
{
    struct ndmsg   *rtmp;
    struct in6_addr *in6p;
    struct rtattr  *tb[NDA_MAX + 1], *rta;
    size_t          in_len, out_len;
    unsigned int    i;
    int             length;
    char            addr[40];
    u_char         *buf;
    u_char         *hwaddr;

    rtmp = (struct ndmsg *) NLMSG_DATA(nlmp);
    if (nlmp->nlmsg_type != RTM_NEWNEIGH) {
        snmp_log(LOG_ERR, "Wrong netlink message type %d\n", nlmp->nlmsg_type);
        return -1;
    }

    if (rtmp->ndm_state != NUD_NOARP) {
        memset(tb, 0, sizeof(struct rtattr *) * (NDA_MAX + 1));
        length = nlmp->nlmsg_len - NLMSG_LENGTH(sizeof(*rtmp));
        if (length < 0) {
            snmp_log(LOG_ERR, "netlink message length %d < %d is invalid\n",
                     nlmp->nlmsg_len, NLMSG_LENGTH(sizeof(*rtmp)));
            return -1;
        }
        /*
         * this is what the kernel-removed NDA_RTA define did 
         */
        rta = ((struct rtattr *) (((char *) (rtmp)) +
                                  NLMSG_ALIGN(sizeof(struct ndmsg))));
        while (RTA_OK(rta, length)) {
            if (rta->rta_type <= NDA_MAX)
                tb[rta->rta_type] = rta;
            rta = RTA_NEXT(rta, length);
        }
        if (length) {
            snmp_log(LOG_ERR, "Received uneven number of netlink"
                        " messages - %d bytes remaining\n", length);
            return -1;
        }
        /*
         * Fill up the index
         */
        entry->if_index = rtmp->ndm_ifindex;
        /*
         * Fill up ip address 
         */
        if (tb[NDA_DST]) {
            memset(&addr, '\0', sizeof(addr));
            in6p = (struct in6_addr *) RTA_DATA(tb[NDA_DST]);
            sprintf(addr, NIP6_FMT, NIP6(*in6p));
            in_len = entry->arp_ipaddress_len =
                sizeof(entry->arp_ipaddress);
            netsnmp_assert(16 == in_len);
            out_len = 0;
            buf = entry->arp_ipaddress;
            if (1 != netsnmp_hex_to_binary(&buf, &in_len,
                                           &out_len, 0, addr, ":")) {
                snmp_log(LOG_ERR, "error parsing '%s', skipping\n",
                         entry->arp_ipaddress);
                return -1;
            }
            netsnmp_assert(16 == out_len);
            entry->arp_ipaddress_len = out_len;
        }
        if (tb[NDA_LLADDR]) {
            memset(&addr, '\0', sizeof(addr));
            hwaddr = RTA_DATA(tb[NDA_LLADDR]);
            entry->arp_physaddress_len = RTA_PAYLOAD(tb[NDA_LLADDR]);
            buf = entry->arp_physaddress;
            for (i = 0; i < entry->arp_physaddress_len; i++)
                entry->arp_physaddress[i] = hwaddr[i];
        }

        switch (rtmp->ndm_state) {
        case NUD_INCOMPLETE:
            entry->arp_state = INETNETTOMEDIASTATE_INCOMPLETE;
            break;
        case NUD_REACHABLE:
        case NUD_PERMANENT:
            entry->arp_state = INETNETTOMEDIASTATE_REACHABLE;
            break;
        case NUD_STALE:
            entry->arp_state = INETNETTOMEDIASTATE_STALE;
            break;
        case NUD_DELAY:
            entry->arp_state = INETNETTOMEDIASTATE_DELAY;
            break;
        case NUD_PROBE:
            entry->arp_state = INETNETTOMEDIASTATE_PROBE;
            break;
        case NUD_FAILED:
            entry->arp_state = INETNETTOMEDIASTATE_INVALID;
            break;
        case NUD_NONE:
            entry->arp_state = INETNETTOMEDIASTATE_UNKNOWN;
            break;
        default:
            snmp_log(LOG_ERR, "Unrecognized ARP entry state %d", rtmp->ndm_state);
            break;
        }

        switch (rtmp->ndm_state) {
        case NUD_INCOMPLETE:
        case NUD_FAILED:
        case NUD_NONE:
            entry->arp_type = INETNETTOMEDIATYPE_INVALID;
            break;
        case NUD_REACHABLE:
        case NUD_STALE:
        case NUD_DELAY:
        case NUD_PROBE:
            entry->arp_type = INETNETTOMEDIATYPE_DYNAMIC;
            break;
        case NUD_PERMANENT:
            entry->arp_type = INETNETTOMEDIATYPE_STATIC;
            break;
        default:
            entry->arp_type = INETNETTOMEDIATYPE_LOCAL;
            break;
        }
    } else {
        return -1;              /* could not create data for this interface */
    }

    return 0;
}
/** @internal Implements the baby_steps handler */
static int
_baby_steps_access_multiplexer(netsnmp_mib_handler *handler,
                               netsnmp_handler_registration *reginfo,
                               netsnmp_agent_request_info *reqinfo,
                               netsnmp_request_info *requests)
{
    void *temp_void;
    Netsnmp_Node_Handler *method = NULL;
    netsnmp_baby_steps_access_methods *access_methods;
    int rc = SNMP_ERR_NOERROR;

    /** call handlers should enforce these */
    netsnmp_assert((handler!=NULL) && (reginfo!=NULL) && (reqinfo!=NULL) &&
                   (requests!=NULL));

    DEBUGMSGT(("baby_steps_mux", "mode %s\n",
               se_find_label_in_slist("babystep_mode",reqinfo->mode)));

    access_methods = (netsnmp_baby_steps_access_methods *)handler->myvoid;
    if(!access_methods) {
        snmp_log(LOG_ERR,"baby_steps_access_multiplexer has no methods\n");
        return SNMPERR_GENERR;
    }

    switch(reqinfo->mode) {
        
    case MODE_BSTEP_PRE_REQUEST:
        if( access_methods->pre_request )
            method = access_methods->pre_request;
        break;
        
    case MODE_BSTEP_OBJECT_LOOKUP:
        if( access_methods->object_lookup )
            method = access_methods->object_lookup;
        break;

    case SNMP_MSG_GET:
    case SNMP_MSG_GETNEXT:
        if( access_methods->get_values )
            method = access_methods->get_values;
        break;
        
    case MODE_BSTEP_CHECK_VALUE:
        if( access_methods->object_syntax_checks )
            method = access_methods->object_syntax_checks;
        break;

    case MODE_BSTEP_ROW_CREATE:
        if( access_methods->row_creation )
            method = access_methods->row_creation;
        break;

    case MODE_BSTEP_UNDO_SETUP:
        if( access_methods->undo_setup )
            method = access_methods->undo_setup;
        break;

    case MODE_BSTEP_SET_VALUE:
        if( access_methods->set_values )
            method = access_methods->set_values;
        break;

    case MODE_BSTEP_CHECK_CONSISTENCY:
        if( access_methods->consistency_checks )
            method = access_methods->consistency_checks;
        break;

    case MODE_BSTEP_UNDO_SET:
        if( access_methods->undo_sets )
            method = access_methods->undo_sets;
        break;

    case MODE_BSTEP_COMMIT:
        if( access_methods->commit )
            method = access_methods->commit;
        break;

    case MODE_BSTEP_UNDO_COMMIT:
        if( access_methods->undo_commit )
            method = access_methods->undo_commit;
        break;

    case MODE_BSTEP_IRREVERSIBLE_COMMIT:
        if( access_methods->irreversible_commit )
            method = access_methods->irreversible_commit;
        break;

    case MODE_BSTEP_UNDO_CLEANUP:
        if( access_methods->undo_cleanup )
            method = access_methods->undo_cleanup;
        break;
        
    case MODE_BSTEP_POST_REQUEST:
        if( access_methods->post_request )
            method = access_methods->post_request;
        break;

    default:
        snmp_log(LOG_ERR,"unknown mode %d\n", reqinfo->mode);
        return SNMP_ERR_GENERR;
    }

    /*
     * if method exists, set up handler void and call method.
     */
    if(NULL != method) {
        temp_void = handler->myvoid;
        handler->myvoid = access_methods->my_access_void;
        rc = (*method)(handler, reginfo, reqinfo, requests);
        handler->myvoid = temp_void;
    }
    else {
        rc = SNMP_ERR_GENERR;
        snmp_log(LOG_ERR,"baby steps multiplexer handler called for a mode "
                 "with no handler\n");
        netsnmp_assert(NULL != method);
    }

    /*
     * don't call any lower handlers, it will be done for us 
     * since we set MIB_HANDLER_AUTO_NEXT
     */

    return rc;
}
static int
_load_ipv6(netsnmp_container* container, u_long *index )
{
    FILE           *in;
    char            line[256];
    netsnmp_route_entry *entry = NULL;
    char            name[16];
    static int      log_open_err = 1;

    DEBUGMSGTL(("access:route:container",
                "route_container_arch_load ipv6\n"));

    netsnmp_assert(NULL != container);

    /*
     * fetch routes from the proc file-system:
     */
    if (!(in = fopen("/proc/net/ipv6_route", "r"))) {
        if (1 == log_open_err) {
            snmp_log(LOG_ERR, "cannot open /proc/net/ipv6_route\n");
            log_open_err = 0;
        }
        return -2;
    }
    /*
     * if we turned off logging of open errors, turn it back on now that
     * we have been able to open the file.
     */
    if (0 == log_open_err)
        log_open_err = 1;
    fgets(line,sizeof(line),in); /* skip header */
    while (fgets(line, sizeof(line), in)) {
        char            c_name[9], c_dest[33], c_src[33], c_next[33];
        int             rc;
        unsigned int    dest_pfx, flags;
        size_t          buf_len, buf_offset;
        u_char          *temp_uchar_ptr;

        entry = netsnmp_access_route_entry_create();

        /*
         * based on /usr/src/linux/net/ipv6/route.c, kernel 2.6.7:
         *
         * [        Dest addr /         plen ]
         * fe80000000000000025056fffec00008 80 \
         *
         * [ (?subtree) : src addr/plen : 0/0]
         * 00000000000000000000000000000000 00 \
         *
         * [        next hop              ][ metric ][ref ctn][ use   ]
         * 00000000000000000000000000000000 00000000 00000000 00000000 \
         *
         * [ flags ][dev name]
         * 80200001       lo
         */
        rc = sscanf(line, "%32s %2x %32s %*x %32s %x %*x %*x %x %8s\n",
                    c_dest, &dest_pfx, c_src, /*src_pfx,*/ c_next,
                    &entry->rt_metric1, /** ref,*/ /* use, */ &flags, c_name);
        DEBUGMSGTL(("9:access:route:container", "line |%s|\n", line));
        if (7 != rc) {
            snmp_log(LOG_ERR,
                     "/proc/net/ipv6_route data format error (%d!=8), "
                     "line ==|%s|", rc, line);
            continue;
        }

        /*
         * temporary null terminated name
         */
        c_name[ sizeof(c_name)-1 ] = 0;
        entry->if_index = se_find_value_in_slist("interfaces", c_name);
        if(SE_DNE == entry->if_index) {
            snmp_log(LOG_ERR,"unknown interface in /proc/net/ipv6_route "
                     "('%s')\n", name);
            netsnmp_access_route_entry_free(entry);
            continue;
        }
        /*
         * arbitrary index
         */
        entry->ns_rt_index = ++(*index);

#ifdef USING_IP_FORWARD_MIB_IPCIDRROUTETABLE_IPCIDRROUTETABLE_MODULE
        /** entry->rt_mask = mask; */ /* IPv4 only */
        /** entry->rt_tos = XXX; */
        /** rt info ?? */
#endif
        /*
         * convert hex addresses to binary
         */
        entry->rt_dest_type = INETADDRESSTYPE_IPV6;
        entry->rt_dest_len = 16;
        buf_len = sizeof(entry->rt_dest);
        buf_offset = 0;
        temp_uchar_ptr = entry->rt_dest;
        netsnmp_hex_to_binary(&temp_uchar_ptr, &buf_len, &buf_offset, 0,
                              c_dest, NULL);

        entry->rt_nexthop_type = INETADDRESSTYPE_IPV6;
        entry->rt_nexthop_len = 16;
        buf_len = sizeof(entry->rt_nexthop);
        buf_offset = 0;
        temp_uchar_ptr = entry->rt_nexthop;
        netsnmp_hex_to_binary(&temp_uchar_ptr, &buf_len, &buf_offset, 0,
                              c_next, NULL);

        entry->rt_pfx_len = dest_pfx;

#ifdef USING_IP_FORWARD_MIB_INETCIDRROUTETABLE_INETCIDRROUTETABLE_MODULE
        /*
    inetCidrRoutePolicy OBJECT-TYPE 
        SYNTAX     OBJECT IDENTIFIER 
        MAX-ACCESS not-accessible 
        STATUS     current 
        DESCRIPTION 
               "This object is an opaque object without any defined 
                semantics.  Its purpose is to serve as an additional 
                index which may delineate between multiple entries to 
                the same destination.  The value { 0 0 } shall be used 
                as the default value for this object."
        */
        /*
         * on linux, default routes all look alike, and would have the same
         * indexed based on dest and next hop. So we use our arbitrary index
         * as the policy, to distinguise between them.
         */
        entry->rt_policy = &entry->ns_rt_index;
        entry->rt_policy_len = 1;
        entry->flags |= NETSNMP_ACCESS_ROUTE_POLICY_STATIC;
#endif

        /*
         * get protocol and type from flags
         */
        entry->rt_type = _type_from_flags(flags);
        
        entry->rt_proto = (flags & RTF_DYNAMIC)
            ? IANAIPROUTEPROTOCOL_ICMP : IANAIPROUTEPROTOCOL_LOCAL;

        /*
         * insert into container
         */
        CONTAINER_INSERT(container, entry);
    }

    fclose(in);
    return 0;
}
/** @internal Implements the baby_steps handler */
static int
_baby_steps_helper(netsnmp_mib_handler *handler,
                         netsnmp_handler_registration *reginfo,
                         netsnmp_agent_request_info *reqinfo,
                         netsnmp_request_info *requests)
{
    netsnmp_baby_steps_modes *bs_modes;
    int save_mode, i, rc = SNMP_ERR_NOERROR;
    u_short *mode_map_ptr;
    
    DEBUGMSGTL(("baby_steps", "Got request, mode %s\n",
                se_find_label_in_slist("agent_mode",reqinfo->mode)));

    bs_modes = (netsnmp_baby_steps_modes*)handler->myvoid;
    netsnmp_assert(NULL != bs_modes);

    switch (reqinfo->mode) {

    case MODE_SET_RESERVE1:
        /*
         * clear completed modes
         * xxx-rks: this will break for pdus with set requests to different
         * rows in the same table when the handler is set up to use the row
         * merge helper as well (or if requests are serialized).
         */
        bs_modes->completed = 0;
        /** fall through */

    case MODE_SET_RESERVE2:
    case MODE_SET_ACTION:
    case MODE_SET_COMMIT:
    case MODE_SET_FREE:
    case MODE_SET_UNDO:
        mode_map_ptr = set_mode_map[reqinfo->mode];
        break;
            
    default:
        /*
         * clear completed modes
         */
        bs_modes->completed = 0;

        mode_map_ptr = get_mode_map;
    }

    /*
     * NOTE: if you update this chart, please update the versions in
     *       local/mib2c-conf.d/parent-set.m2i
     *       agent/mibgroup/helpers/baby_steps.c
     * while you're at it.
     */
    /*
     ***********************************************************************
     * Baby Steps Flow Chart (2004.06.05)                                  *
     *                                                                     *
     * +--------------+    +================+    U = unconditional path    *
     * |optional state|    ||required state||    S = path for success      *
     * +--------------+    +================+    E = path for error        *
     ***********************************************************************
     *
     *                        +--------------+
     *                        |     pre      |
     *                        |   request    |
     *                        +--------------+
     *                               | U
     * +-------------+        +==============+
     * |    row    |f|<-------||  object    ||
     * |  create   |1|      E ||  lookup    ||
     * +-------------+        +==============+
     *     E |   | S                 | S
     *       |   +------------------>|
     *       |                +==============+
     *       |              E ||   check    ||
     *       |<---------------||   values   ||
     *       |                +==============+
     *       |                       | S
     *       |                +==============+
     *       |       +<-------||   undo     ||
     *       |       |      E ||   setup    ||
     *       |       |        +==============+
     *       |       |               | S
     *       |       |        +==============+
     *       |       |        ||    set     ||-------------------------->+
     *       |       |        ||   value    || E                         |
     *       |       |        +==============+                           |
     *       |       |               | S                                 |
     *       |       |        +--------------+                           |
     *       |       |        |    check     |-------------------------->|
     *       |       |        |  consistency | E                         |
     *       |       |        +--------------+                           |
     *       |       |               | S                                 |
     *       |       |        +==============+         +==============+  |
     *       |       |        ||   commit   ||-------->||     undo   ||  |
     *       |       |        ||            || E       ||    commit  ||  |
     *       |       |        +==============+         +==============+  |
     *       |       |               | S                     U |<--------+
     *       |       |        +--------------+         +==============+
     *       |       |        | irreversible |         ||    undo    ||
     *       |       |        |    commit    |         ||     set    ||
     *       |       |        +--------------+         +==============+
     *       |       |               | U                     U |
     *       |       +-------------->|<------------------------+
     *       |                +==============+
     *       |                ||   undo     ||
     *       |                ||  cleanup   ||
     *       |                +==============+
     *       +---------------------->| U
     *                               |
     *                          (err && f1)------------------->+
     *                               |                         |
     *                        +--------------+         +--------------+
     *                        |    post      |<--------|      row     |
     *                        |   request    |       U |    release   |
     *                        +--------------+         +--------------+
     *
     */
    /*
     * save original mode
     */
    save_mode = reqinfo->mode;
    for(i = 0; i < BABY_STEPS_PER_MODE_MAX; ++i ) {
        /*
         * break if we run out of baby steps for this mode
         */
        if(mode_map_ptr[i] == BABY_STEP_NONE)
            break;

        DEBUGMSGTL(("baby_steps", " baby step mode %s\n",
                    se_find_label_in_slist("babystep_mode",mode_map_ptr[i])));

        /*
         * skip modes the handler didn't register for
         */
        if (BSTEP_USE_ORIGINAL != mode_map_ptr[i]) {
            u_int    mode_flag;

            /*
             * skip undo commit if commit wasn't hit, and
             * undo_cleanup if undo_setup wasn't hit.
             */
            if((MODE_SET_UNDO == save_mode) &&
               (MODE_BSTEP_UNDO_COMMIT == mode_map_ptr[i]) &&
               !(BABY_STEP_COMMIT & bs_modes->completed)) {
                DEBUGMSGTL(("baby_steps",
                            "   skipping commit undo (no commit)\n"));
                continue;
            }
            else if((MODE_SET_FREE == save_mode) &&
               (MODE_BSTEP_UNDO_CLEANUP == mode_map_ptr[i]) &&
               !(BABY_STEP_UNDO_SETUP & bs_modes->completed)) {
                DEBUGMSGTL(("baby_steps",
                            "   skipping undo cleanup (no undo setup)\n"));
                continue;
            }

            reqinfo->mode = mode_map_ptr[i];
            mode_flag = netsnmp_baby_step_mode2flag( mode_map_ptr[i] );
            if((mode_flag & bs_modes->registered))
                bs_modes->completed |= mode_flag;
            else {
                DEBUGMSGTL(("baby_steps",
                            "   skipping mode (not registered)\n"));
                continue;
            }

        
        }
        else {
            reqinfo->mode = save_mode;
        }

#ifdef BABY_STEPS_NEXT_MODE
        /*
         * I can't remember why I wanted the next mode in the request,
         * but it's not used anywhere, so don't use this code. saved,
         * in case I remember why I thought needed it. - rstory 040911
         */
        if((BABY_STEPS_PER_MODE_MAX - 1) == i)
            reqinfo->next_mode_ok = BABY_STEP_NONE;
        else {
            if(BSTEP_USE_ORIGINAL == mode_map_ptr[i+1])
                reqinfo->next_mode_ok = save_mode;
            else
                reqinfo->next_mode_ok = mode_map_ptr[i+1];
        }
#endif

        /*
         * call handlers for baby step
         */
        rc = netsnmp_call_next_handler(handler, reginfo, reqinfo,
                                       requests);

        /*
         * check for error calling handler (unlikely, but...)
         */
        if(rc) {
            DEBUGMSGTL(("baby_steps", "   ERROR:handler error\n"));
            break;
        }

        /*
         * check for errors in any of the requests for GET-like, reserve1,
         * reserve2 and action. (there is no recovery from errors
         * in commit, free or undo.)
         */
        if (MODE_IS_GET(save_mode)
            || (save_mode < SNMP_MSG_INTERNAL_SET_COMMIT)) {
            rc = netsnmp_check_requests_error(requests);
            if(rc) {
                DEBUGMSGTL(("baby_steps", "   ERROR:request error\n"));
                break;
            }
        }
    }

    /*
     * restore original mode
     */
    reqinfo->mode = save_mode;

    
    return rc;
}
Example #21
0
/** Implements the cache handler */
int
netsnmp_cache_helper_handler(netsnmp_mib_handler * handler,
                             netsnmp_handler_registration * reginfo,
                             netsnmp_agent_request_info * reqinfo,
                             netsnmp_request_info * requests)
{
    char addrstr[32];

    netsnmp_cache  *cache = NULL;
    netsnmp_handler_args cache_hint;

    DEBUGMSGTL(("helper:cache_handler", "Got request (%d) for %s: ",
                reqinfo->mode, reginfo->handlerName));
    DEBUGMSGOID(("helper:cache_handler", reginfo->rootoid,
                 reginfo->rootoid_len));
    DEBUGMSG(("helper:cache_handler", "\n"));

    netsnmp_assert(handler->flags & MIB_HANDLER_AUTO_NEXT);

    cache = (netsnmp_cache *) handler->myvoid;
    if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
                               NETSNMP_DS_AGENT_NO_CACHING) ||
        !cache || !cache->enabled || !cache->load_cache) {
        DEBUGMSGT(("helper:cache_handler", " caching disabled or "
                   "cache not found, disabled or had no load method\n"));
        return SNMP_ERR_NOERROR;
    }
    snprintf(addrstr,sizeof(addrstr), "%ld", (long int)cache);
    DEBUGMSGTL(("helper:cache_handler", "using cache %s: ", addrstr));
    DEBUGMSGOID(("helper:cache_handler", cache->rootoid, cache->rootoid_len));
    DEBUGMSG(("helper:cache_handler", "\n"));

    /*
     * Make the handler-chain parameters available to
     * the cache_load hook routine.
     */
    cache_hint.handler = handler;
    cache_hint.reginfo = reginfo;
    cache_hint.reqinfo = reqinfo;
    cache_hint.requests = requests;
    cache->cache_hint = &cache_hint;

    switch (reqinfo->mode) {

    case MODE_GET:
    case MODE_GETNEXT:
    case MODE_GETBULK:
#ifndef NETSNMP_NO_WRITE_SUPPORT
    case MODE_SET_RESERVE1:
#endif /* !NETSNMP_NO_WRITE_SUPPORT */

        /*
         * only touch cache once per pdu request, to prevent a cache
         * reload while a module is using cached data.
         *
         * XXX: this won't catch a request reloading the cache while
         * a previous (delegated) request is still using the cache.
         * maybe use a reference counter?
         */
        if (netsnmp_cache_is_valid(reqinfo, addrstr))
            break;

        /*
         * call the load hook, and update the cache timestamp.
         * If it's not already there, add to reqinfo
         */
        netsnmp_cache_check_and_reload(cache);
        netsnmp_cache_reqinfo_insert(cache, reqinfo, addrstr);
        /** next handler called automatically - 'AUTO_NEXT' */
        break;

#ifndef NETSNMP_NO_WRITE_SUPPORT
    case MODE_SET_RESERVE2:
    case MODE_SET_FREE:
    case MODE_SET_ACTION:
    case MODE_SET_UNDO:
        netsnmp_assert(netsnmp_cache_is_valid(reqinfo, addrstr));
        /** next handler called automatically - 'AUTO_NEXT' */
        break;

        /*
         * A (successful) SET request wouldn't typically trigger a reload of
         *  the cache, but might well invalidate the current contents.
         * Only do this on the last pass through.
         */
    case MODE_SET_COMMIT:
        if (cache->valid && 
            ! (cache->flags & NETSNMP_CACHE_DONT_INVALIDATE_ON_SET) ) {
            cache->free_cache(cache, cache->magic);
            cache->valid = 0;
        }
        /** next handler called automatically - 'AUTO_NEXT' */
        break;
#endif /* NETSNMP_NO_WRITE_SUPPORT */

    default:
        snmp_log(LOG_WARNING, "cache_handler: Unrecognised mode (%d)\n",
                 reqinfo->mode);
        netsnmp_request_set_error_all(requests, SNMP_ERR_GENERR);
        return SNMP_ERR_GENERR;
    }
    if (cache->flags & NETSNMP_CACHE_RESET_TIMER_ON_USE)
        netsnmp_set_monotonic_marker(&cache->timestampM);
    return SNMP_ERR_NOERROR;
}
/*
 * @internal
 * Retrieve the value for a particular column
 */
NETSNMP_STATIC_INLINE int
_ipv6ScopeZoneIndexTable_get_column(ipv6ScopeZoneIndexTable_rowreq_ctx *
                                    rowreq_ctx,
                                    netsnmp_variable_list * var,
                                    int column)
{
    int             rc = SNMPERR_SUCCESS;

    DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_mfd_ipv6ScopeZoneIndexTable_get_column", "called for %d\n", column));


    netsnmp_assert(NULL != rowreq_ctx);

    switch (column) {

        /*
         * ipv6ScopeZoneIndexLinkLocal(2)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H 
         */
    case COLUMN_IPV6SCOPEZONEINDEXLINKLOCAL:
        var->val_len = sizeof(u_long);
        var->type = ASN_UNSIGNED;
        rc = ipv6ScopeZoneIndexLinkLocal_get(rowreq_ctx,
                                             (u_long *) var->val.string);
        break;

        /*
         * ipv6ScopeZoneIndex3(3)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H 
         */
    case COLUMN_IPV6SCOPEZONEINDEX3:
        var->val_len = sizeof(u_long);
        var->type = ASN_UNSIGNED;
        rc = ipv6ScopeZoneIndex3_get(rowreq_ctx,
                                     (u_long *) var->val.string);
        break;

        /*
         * ipv6ScopeZoneIndexAdminLocal(4)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H 
         */
    case COLUMN_IPV6SCOPEZONEINDEXADMINLOCAL:
        var->val_len = sizeof(u_long);
        var->type = ASN_UNSIGNED;
        rc = ipv6ScopeZoneIndexAdminLocal_get(rowreq_ctx,
                                              (u_long *) var->val.string);
        break;

        /*
         * ipv6ScopeZoneIndexSiteLocal(5)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H 
         */
    case COLUMN_IPV6SCOPEZONEINDEXSITELOCAL:
        var->val_len = sizeof(u_long);
        var->type = ASN_UNSIGNED;
        rc = ipv6ScopeZoneIndexSiteLocal_get(rowreq_ctx,
                                             (u_long *) var->val.string);
        break;

        /*
         * ipv6ScopeZoneIndex6(6)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H 
         */
    case COLUMN_IPV6SCOPEZONEINDEX6:
        var->val_len = sizeof(u_long);
        var->type = ASN_UNSIGNED;
        rc = ipv6ScopeZoneIndex6_get(rowreq_ctx,
                                     (u_long *) var->val.string);
        break;

        /*
         * ipv6ScopeZoneIndex7(7)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H 
         */
    case COLUMN_IPV6SCOPEZONEINDEX7:
        var->val_len = sizeof(u_long);
        var->type = ASN_UNSIGNED;
        rc = ipv6ScopeZoneIndex7_get(rowreq_ctx,
                                     (u_long *) var->val.string);
        break;

        /*
         * ipv6ScopeZoneIndexOrganizationLocal(8)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H 
         */
    case COLUMN_IPV6SCOPEZONEINDEXORGANIZATIONLOCAL:
        var->val_len = sizeof(u_long);
        var->type = ASN_UNSIGNED;
        rc = ipv6ScopeZoneIndexOrganizationLocal_get(rowreq_ctx,
                                                     (u_long *) var->val.
                                                     string);
        break;

        /*
         * ipv6ScopeZoneIndex9(9)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H 
         */
    case COLUMN_IPV6SCOPEZONEINDEX9:
        var->val_len = sizeof(u_long);
        var->type = ASN_UNSIGNED;
        rc = ipv6ScopeZoneIndex9_get(rowreq_ctx,
                                     (u_long *) var->val.string);
        break;

        /*
         * ipv6ScopeZoneIndexA(10)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H 
         */
    case COLUMN_IPV6SCOPEZONEINDEXA:
        var->val_len = sizeof(u_long);
        var->type = ASN_UNSIGNED;
        rc = ipv6ScopeZoneIndexA_get(rowreq_ctx,
                                     (u_long *) var->val.string);
        break;

        /*
         * ipv6ScopeZoneIndexB(11)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H 
         */
    case COLUMN_IPV6SCOPEZONEINDEXB:
        var->val_len = sizeof(u_long);
        var->type = ASN_UNSIGNED;
        rc = ipv6ScopeZoneIndexB_get(rowreq_ctx,
                                     (u_long *) var->val.string);
        break;

        /*
         * ipv6ScopeZoneIndexC(12)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H 
         */
    case COLUMN_IPV6SCOPEZONEINDEXC:
        var->val_len = sizeof(u_long);
        var->type = ASN_UNSIGNED;
        rc = ipv6ScopeZoneIndexC_get(rowreq_ctx,
                                     (u_long *) var->val.string);
        break;

        /*
         * ipv6ScopeZoneIndexD(13)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H 
         */
    case COLUMN_IPV6SCOPEZONEINDEXD:
        var->val_len = sizeof(u_long);
        var->type = ASN_UNSIGNED;
        rc = ipv6ScopeZoneIndexD_get(rowreq_ctx,
                                     (u_long *) var->val.string);
        break;

    default:
        if (IPV6SCOPEZONEINDEXTABLE_MIN_COL <= column
            && column <= IPV6SCOPEZONEINDEXTABLE_MAX_COL) {
            DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_mfd_ipv6ScopeZoneIndexTable_get_column", "assume column %d is reserved\n", column));
            rc = MFD_SKIP;
        } else {
            snmp_log(LOG_ERR,
                     "unknown column %d in _ipv6ScopeZoneIndexTable_get_column\n",
                     column);
        }
        break;
    }

    return rc;
}                               /* _ipv6ScopeZoneIndexTable_get_column */
Example #23
0
/************************************************************
 * Assuming that the RESERVE phases were successful, the next
 * stage is indicated by the action value ACTION. This is used
 * to actually implement the set operation. However, this must
 * either be done into temporary (persistent) storage, or the
 * previous value stored similarly, in case any of the subsequent
 * ACTION calls fail.
 *
 * In your case, changes should be made to row_ctx. A copy of
 * the original row is in undo_ctx.
 */
void
saHpiWatchdogTable_set_action(netsnmp_request_group * rg)
{
    netsnmp_variable_list *var;
    saHpiWatchdogTable_context *row_ctx =
        (saHpiWatchdogTable_context *) rg->existing_row;
    /*    saHpiWatchdogTable_context *undo_ctx =
	  (saHpiWatchdogTable_context *) rg->undo_info;*/
    netsnmp_request_group_item *current;

    DEBUGMSGTL((AGENT,"saHpiWatchdogTable_set_action. Entry\n"));
    /*
     * TODO: loop through columns, copy varbind values
     * to context structure for the row.
     */
    for (current = rg->list; current; current = current->next) {

        var = current->ri->requestvb;

        switch (current->tri->colnum) {

        case COLUMN_SAHPIWATCHDOGLOG:
            /** TruthValue = ASN_INTEGER */
            row_ctx->saHpiWatchdogLog = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGRUNNING:
            /** TruthValue = ASN_INTEGER */
            row_ctx->saHpiWatchdogRunning = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGTIMERUSE:
            /** INTEGER = ASN_INTEGER */
            row_ctx->saHpiWatchdogTimerUse = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGTIMERACTION:
            /** INTEGER = ASN_INTEGER */
            row_ctx->saHpiWatchdogTimerAction = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGPRETIMERINTERRUPT:
            /** INTEGER = ASN_INTEGER */
            row_ctx->saHpiWatchdogPretimerInterrupt = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGPRETIMEOUTINTERVAL:
            /** UNSIGNED32 = ASN_UNSIGNED */
            row_ctx->saHpiWatchdogPreTimeoutInterval = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGTIMERUSEEXPFLAGS:
            /** UNSIGNED32 = ASN_UNSIGNED */
            row_ctx->saHpiWatchdogTimerUseExpFlags = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGTIMERINITIALCOUNT:
            /** UNSIGNED32 = ASN_UNSIGNED */
            row_ctx->saHpiWatchdogTimerInitialCount = *var->val.integer;
            break;

        case COLUMN_SAHPIWATCHDOGTIMERPRESENTCOUNT:
            /** UNSIGNED32 = ASN_UNSIGNED */
            row_ctx->saHpiWatchdogTimerPresentCount = *var->val.integer;
            break;       

        default:/** We shouldn't get here */
            netsnmp_assert(0); /** why wasn't this caught in reserve1? */
        }

	DEBUGMSGTL((AGENT,"saHpiWatchdogTable_set_action: Calling 'set_watchdog'\n"));
	if (set_watchdog(row_ctx) != AGENT_ERR_NOERROR) {
	  netsnmp_set_mode_request_error(MODE_SET_BEGIN, current->ri,
					 SNMP_ERR_GENERR);
	}
    }

    DEBUGMSGTL((AGENT,"saHpiWatchdogTable_set_action. Exit\n"));   
   
}
int
_mfd_ipv6ScopeZoneIndexTable_get_values(netsnmp_mib_handler *handler,
                                        netsnmp_handler_registration
                                        *reginfo,
                                        netsnmp_agent_request_info
                                        *agtreq_info,
                                        netsnmp_request_info *requests)
{
    ipv6ScopeZoneIndexTable_rowreq_ctx *rowreq_ctx = (ipv6ScopeZoneIndexTable_rowreq_ctx*)
        netsnmp_container_table_row_extract(requests);
    netsnmp_table_request_info *tri;
    u_char         *old_string;
    void            (*dataFreeHook) (void *);
    int             rc;

    DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_mfd_ipv6ScopeZoneIndexTable_get_values", "called\n"));
    netsnmp_assert(NULL != rowreq_ctx);

    for (; requests; requests = requests->next) {
        /*
         * save old pointer, so we can free it if replaced
         */
        old_string = requests->requestvb->val.string;
        dataFreeHook = requests->requestvb->dataFreeHook;
        if (NULL == requests->requestvb->val.string) {
            requests->requestvb->val.string = requests->requestvb->buf;
            requests->requestvb->val_len =
                sizeof(requests->requestvb->buf);
        } else if (requests->requestvb->buf ==
                   requests->requestvb->val.string) {
            if (requests->requestvb->val_len !=
                sizeof(requests->requestvb->buf))
                requests->requestvb->val_len =
                    sizeof(requests->requestvb->buf);
        }

        /*
         * get column data
         */
        tri = netsnmp_extract_table_info(requests);
        if (NULL == tri)
            continue;

        rc = _ipv6ScopeZoneIndexTable_get_column(rowreq_ctx,
                                                 requests->requestvb,
                                                 tri->colnum);
        if (rc) {
            if (MFD_SKIP == rc) {
                requests->requestvb->type = SNMP_NOSUCHINSTANCE;
                rc = SNMP_ERR_NOERROR;
            }
        } else if (NULL == requests->requestvb->val.string) {
            snmp_log(LOG_ERR, "NULL varbind data pointer!\n");
            rc = SNMP_ERR_GENERR;
        }
        if (rc)
            netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));

        /*
         * if the buffer wasn't used previously for the old data (i.e. it
         * was allcoated memory)  and the get routine replaced the pointer,
         * we need to free the previous pointer.
         */
        if (old_string && (old_string != requests->requestvb->buf) &&
            (requests->requestvb->val.string != old_string)) {
            if (dataFreeHook)
                (*dataFreeHook) (old_string);
            else
                free(old_string);
        }
    }                           /* for results */

    return SNMP_ERR_NOERROR;
}                               /* _mfd_ipv6ScopeZoneIndexTable_get_values */
/**
 * the *_extract_index routine
 *
 * This routine is called when a set request is received for an index
 * that was not found in the table container. Here, we parse the oid
 * in the the individual index components and copy those indexes to the
 * context. Then we make sure the indexes for the new row are valid.
 */
int
saHpiSensorReadingNormalMinTable_extract_index( saHpiSensorReadingNormalMinTable_context * ctx, netsnmp_index * hdr )
{
	/*
	 * temporary local storage for extracting oid index
	 *
	 * extract index uses varbinds (netsnmp_variable_list) to parse
	 * the index OID into the individual components for each index part.
	 */
	/** TODO: add storage for external index(s)! */
	netsnmp_variable_list var_saHpiDomainId;
	netsnmp_variable_list var_saHpiResourceId;
	netsnmp_variable_list var_saHpiResourceIsHistorical;
	netsnmp_variable_list var_saHpiSensorNum;
	int err;

	DEBUGMSGTL ((AGENT, "saHpiSensorReadingNormalMinTable_extract_index, called\n"));

        subagent_lock(&hpi_lock_data);
	/*
	 * copy index, if provided
	 */
	if (hdr) {
		netsnmp_assert(ctx->index.oids == NULL);
		if (snmp_clone_mem( (void*)&ctx->index.oids, hdr->oids,
				    hdr->len * sizeof(oid) )) {
			subagent_unlock(&hpi_lock_data);
			return -1;
		}
		ctx->index.len = hdr->len;
	}

	/*
	 * initialize variable that will hold each component of the index.
	 * If there are multiple indexes for the table, the variable_lists
	 * need to be linked together, in order.
	 */
	/** TODO: add code for external index(s)! */
	memset( &var_saHpiDomainId, 0x00, sizeof(var_saHpiDomainId) );
	var_saHpiDomainId.type = ASN_UNSIGNED; /* type hint for parse_oid_indexes */
	/** TODO: link this index to the next, or NULL for the last one */
	var_saHpiDomainId.next_variable = &var_saHpiResourceId;

	memset( &var_saHpiResourceId, 0x00, sizeof(var_saHpiResourceId) );
	var_saHpiResourceId.type = ASN_UNSIGNED; /* type hint for parse_oid_indexes */
	/** TODO: link this index to the next, or NULL for the last one */
	var_saHpiResourceId.next_variable = &var_saHpiResourceIsHistorical;

	memset( &var_saHpiResourceIsHistorical, 0x00, sizeof(var_saHpiResourceIsHistorical) );
	var_saHpiResourceIsHistorical.type = ASN_INTEGER; /* type hint for parse_oid_indexes */
	/** TODO: link this index to the next, or NULL for the last one */
	var_saHpiResourceIsHistorical.next_variable = &var_saHpiSensorNum;

	memset( &var_saHpiSensorNum, 0x00, sizeof(var_saHpiSensorNum) );
	var_saHpiSensorNum.type = ASN_UNSIGNED;	/* type hint for parse_oid_indexes */
	/** TODO: link this index to the next, or NULL for the last one */
	var_saHpiSensorNum.next_variable = NULL;


	/*
	 * parse the oid into the individual index components
	 */
	err = parse_oid_indexes( hdr->oids, hdr->len, &var_saHpiDomainId );
	if (err == SNMP_ERR_NOERROR) {
		/*
		 * copy index components into the context structure
		 */
		/** skipping external index saHpiDomainId */

		/** skipping external index saHpiResourceId */

		/** skipping external index saHpiResourceIsHistorical */

		/** skipping external index saHpiSensorNum */


		err = saHpiDomainId_check_index(
					       *var_saHpiDomainId.val.integer);
		err = saHpiResourceEntryId_check_index(
						      *var_saHpiResourceId.val.integer);  
		err = saHpiResourceIsHistorical_check_index(
							   *var_saHpiResourceIsHistorical.val.integer);
		err = saHpiSensorNum_check_index(
						*var_saHpiSensorNum.val.integer);
	}

	/*
	 * parsing may have allocated memory. free it.
	 */
	snmp_reset_var_buffers( &var_saHpiDomainId );

	subagent_unlock(&hpi_lock_data);
	return err;
}
/*
 * the *_extract_index routine (Mostly auto-generated)
 *
 * This routine is called when a set request is received for an index that 
 * was not found in the table container. Here, we parse the oid in the
 * individual index components and copy those indexes to the context. Then 
 * we make sure the indexes for the new row are valid.
 *
 * It has been modified from its original form in that the indexes aren't
 * returned if they are invalid.  An index is invalid if it is not between 
 * 100 and 699 (Inclusive).
 */
int kamailioSIPStatusCodesTable_extract_index( 
		kamailioSIPStatusCodesTable_context * ctx, netsnmp_index * hdr)
{

	/*
	 * temporary local storage for extracting oid index
	 *
	 * extract index uses varbinds (netsnmp_variable_list) to parse
	 * the index OID into the individual components for each index part.
	 */
	netsnmp_variable_list var_kamailioSIPStatusCodeMethod;
	netsnmp_variable_list var_kamailioSIPStatusCodeValue;
	int err;

	/*
	 * copy index, if provided
	 */
	if(hdr) {
		netsnmp_assert(ctx->index.oids == NULL);
		if((hdr->len > MAX_OID_LEN) || 
				snmp_clone_mem( 
					(void*)&ctx->index.oids,
					hdr->oids,
					hdr->len * sizeof(oid))) 
		{
			return -1;
		}

		ctx->index.len = hdr->len;
	}

 	/* Initialize the two variables responsible for holding our two indices.
	 */
	memset(&var_kamailioSIPStatusCodeMethod, 0x00, 
			 sizeof(var_kamailioSIPStatusCodeMethod));

	memset( &var_kamailioSIPStatusCodeValue, 0x00, 
			sizeof(var_kamailioSIPStatusCodeValue) );

	var_kamailioSIPStatusCodeMethod.type = ASN_UNSIGNED; 
	var_kamailioSIPStatusCodeValue.type  = ASN_UNSIGNED;

	var_kamailioSIPStatusCodeMethod.next_variable = 
		&var_kamailioSIPStatusCodeValue;

	var_kamailioSIPStatusCodeValue.next_variable = NULL;

	/* parse the oid into the individual index components */
	err = parse_oid_indexes( hdr->oids, hdr->len, 
			&var_kamailioSIPStatusCodeMethod );

	if (err == SNMP_ERR_NOERROR) {

		/* copy index components into the context structure */
		ctx->kamailioSIPStatusCodeMethod = 
			*var_kamailioSIPStatusCodeMethod.val.integer;
		ctx->kamailioSIPStatusCodeValue  = 
			*var_kamailioSIPStatusCodeValue.val.integer;
   
   
		if (*var_kamailioSIPStatusCodeMethod.val.integer < 1)
		{
			err = -1;
		}

		if (*var_kamailioSIPStatusCodeValue.val.integer < 100 ||
		    *var_kamailioSIPStatusCodeValue.val.integer > 699) {
			err = -1;
		}

	}

	
	/* parsing may have allocated memory. free it. */
	snmp_reset_var_buffers( &var_kamailioSIPStatusCodeMethod );

	return err;
}
Example #27
0
NETSNMP_INLINE void
group_requests(netsnmp_agent_request_info *agtreq_info,
               netsnmp_request_info *requests,
               netsnmp_container *request_group, table_container_data * tad)
{
    netsnmp_table_request_info *tblreq_info;
    netsnmp_variable_list *var;
    netsnmp_index *row, *tmp, index;
    netsnmp_request_info *current;
    netsnmp_request_group *g;
    netsnmp_request_group_item *i;

    for (current = requests; current; current = current->next) {

        var = current->requestvb;

        /*
         * skip anything that doesn't need processing.
         */
        if (current->processed != 0) {
            DEBUGMSGTL(("table_array:group",
                        "already processed\n"));
            continue;
        }

        /*
         * 3.2.1 Setup and paranoia
         * *
         * * Get pointer to the table information for this request. This
         * * information was saved by table_helper_handler. When
         * * debugging, we double check a few assumptions. For example,
         * * the table_helper_handler should enforce column boundaries.
         */
        row = NULL;
        tblreq_info = netsnmp_extract_table_info(current);
        netsnmp_assert(tblreq_info->colnum <= tad->tblreg_info->max_column);

        /*
         * search for index
         */
        index.oids = tblreq_info->index_oid;
        index.len = tblreq_info->index_oid_len;
        tmp = CONTAINER_FIND(request_group, &index);
        if (tmp) {
            DEBUGMSGTL(("table_array:group",
                        "    existing group:"));
            DEBUGMSGOID(("table_array:group", index.oids,
                         index.len));
            DEBUGMSG(("table_array:group", "\n"));
            g = (netsnmp_request_group *) tmp;
            i = SNMP_MALLOC_TYPEDEF(netsnmp_request_group_item);
            i->ri = current;
            i->tri = tblreq_info;
            i->next = g->list;
            g->list = i;

            /** xxx-rks: store map of colnum to request */
            continue;
        }

        DEBUGMSGTL(("table_array:group", "    new group"));
        DEBUGMSGOID(("table_array:group", index.oids,
                     index.len));
        DEBUGMSG(("table_array:group", "\n"));
        g = SNMP_MALLOC_TYPEDEF(netsnmp_request_group);
        i = SNMP_MALLOC_TYPEDEF(netsnmp_request_group_item);
        g->list = i;
        g->table = tad->table;
        i->ri = current;
        i->tri = tblreq_info;
        /** xxx-rks: store map of colnum to request */

        /*
         * search for row. all changes are made to the original row,
         * later, we'll make a copy in undo_info before we start processing.
         */
        row = g->existing_row = CONTAINER_FIND(tad->table, &index);
        if (!g->existing_row) {
            if (!tad->cb->create_row) {
                if(MODE_IS_SET(agtreq_info->mode))
                    netsnmp_set_request_error(agtreq_info, current,
                                              SNMP_ERR_NOTWRITABLE);
                else
                    netsnmp_set_request_error(agtreq_info, current,
                                              SNMP_NOSUCHINSTANCE);
                free(g);
                free(i);
                continue;
            }
            /** use undo_info temporarily */
            row = g->existing_row = tad->cb->create_row(&index);
            if (!row) {
                /* xxx-rks : parameter to create_row to allow
                 * for better error reporting. */
                netsnmp_set_request_error(agtreq_info, current,
                                          SNMP_ERR_GENERR);
                free(g);
                free(i);
                continue;
            }
            g->row_created = 1;
        }

        g->index.oids = row->oids;
        g->index.len = row->len;

        CONTAINER_INSERT(request_group, g);

    } /** for( current ... ) */
}
/*
 * This function is called only when all the *_reserve[1|2] functions were
 * succeful.  Its purpose is to make any changes to the row before it is
 * inserted into the table.  
 *
 * In our case, we don't require any changes.  So we leave the original
 * auto-generated code as is.   
 */
void kamailioSIPStatusCodesTable_set_action( netsnmp_request_group *rg )
{
	netsnmp_variable_list *var;

	kamailioSIPStatusCodesTable_context *row_ctx = 
		(kamailioSIPStatusCodesTable_context *)rg->existing_row;

	kamailioSIPStatusCodesTable_context *undo_ctx = 
		(kamailioSIPStatusCodesTable_context *)rg->undo_info;

	netsnmp_request_group_item *current;

	int row_err = 0;

	/* Depending on what the snmpset was, set the row to be created or
	 * deleted.   */
	for( current = rg->list; current; current = current->next ) 
	{
		var = current->ri->requestvb;

		switch(current->tri->colnum) 
		{
			case COLUMN_KAMAILIOSIPSTATUSCODEROWSTATUS:
			
				/** RowStatus = ASN_INTEGER */
				row_ctx->kamailioSIPStatusCodeRowStatus = 
					*var->val.integer;

				if (*var->val.integer == TC_ROWSTATUS_CREATEANDGO)
				{
					rg->row_created = 1;
				}
				else if (*var->val.integer == TC_ROWSTATUS_DESTROY)
				{
					rg->row_deleted = 1;
				}
				else {
					/* We should never be here, because the RESERVE
					 * functions should have taken care of all other
					 * values. */
				LM_ERR("Invalid RowStatus in kamailioSIPStatusCodesTable\n");
				}

				break;

			default: /** We shouldn't get here */
				netsnmp_assert(0); /** why wasn't this caught in reserve1? */
		}
	}

	/*
	 * done with all the columns. Could check row related
	 * requirements here.
	 */
#ifndef kamailioSIPStatusCodesTable_CAN_MODIFY_ACTIVE_ROW
	if( undo_ctx && RS_IS_ACTIVE(undo_ctx->kamailioSIPStatusCodeRowStatus) &&
		row_ctx && RS_IS_ACTIVE(row_ctx->kamailioSIPStatusCodeRowStatus)) 
	{
			row_err = 1;
	}
#endif

	/*
	 * check activation/deactivation
	 */
	row_err = netsnmp_table_array_check_row_status(&cb, rg, 
			row_ctx ? 
			&row_ctx->kamailioSIPStatusCodeRowStatus : NULL,
			undo_ctx ? 
			&undo_ctx->kamailioSIPStatusCodeRowStatus : NULL);
	if(row_err) {
		netsnmp_set_mode_request_error(MODE_SET_BEGIN,
				(netsnmp_request_info*)rg->rg_void, row_err);
		return;
	}

}
/**
 * set mib index(es)
 *
 * @param tbl_idx mib index structure
 * @param tcpConnectionLocalAddressType_val
 * @param tcpConnectionLocalAddress_val_ptr
 * @param tcpConnectionLocalAddress_val_ptr_len
 * @param tcpConnectionLocalPort_val
 * @param tcpConnectionRemAddressType_val
 * @param tcpConnectionRemAddress_val_ptr
 * @param tcpConnectionRemAddress_val_ptr_len
 * @param tcpConnectionRemPort_val
 *
 * @retval MFD_SUCCESS     : success.
 * @retval MFD_ERROR       : other error.
 *
 * @remark
 *  This convenience function is useful for setting all the MIB index
 *  components with a single function call. It is assume that the C values
 *  have already been mapped from their native/rawformat to the MIB format.
 */
int
tcpConnectionTable_indexes_set_tbl_idx(tcpConnectionTable_mib_index *
                                       tbl_idx,
                                       u_long
                                       tcpConnectionLocalAddressType_val,
                                       char
                                       *tcpConnectionLocalAddress_val_ptr,
                                       size_t
                                       tcpConnectionLocalAddress_val_ptr_len,
                                       u_long tcpConnectionLocalPort_val,
                                       u_long
                                       tcpConnectionRemAddressType_val,
                                       char
                                       *tcpConnectionRemAddress_val_ptr,
                                       size_t
                                       tcpConnectionRemAddress_val_ptr_len,
                                       u_long tcpConnectionRemPort_val)
{
    DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_indexes_set_tbl_idx", "called\n"));

    /*
     * tcpConnectionLocalAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h 
     */
    /** WARNING: this code might not work for netsnmp_tcpconn_entry */
    /** are cross protocol connections allowed? */
    netsnmp_assert(tbl_idx->tcpConnectionRemAddressType ==
                   tbl_idx->tcpConnectionLocalAddressType);
    if (4 == tcpConnectionLocalAddressType_val)
        tbl_idx->tcpConnectionLocalAddressType = INETADDRESSTYPE_IPV4;
    else if (16 == tcpConnectionLocalAddressType_val)
        tbl_idx->tcpConnectionLocalAddressType = INETADDRESSTYPE_IPV6;
    else
        tbl_idx->tcpConnectionLocalAddressType = INETADDRESSTYPE_UNKNOWN;

    /*
     * tcpConnectionLocalAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h 
     */
    tbl_idx->tcpConnectionLocalAddress_len = sizeof(tbl_idx->tcpConnectionLocalAddress) / sizeof(tbl_idx->tcpConnectionLocalAddress[0]);        /* max length */
    /** WARNING: this code might not work for netsnmp_tcpconn_entry */
    /*
     * make sure there is enough space for tcpConnectionLocalAddress data
     */
    if ((NULL == tbl_idx->tcpConnectionLocalAddress) ||
        (tbl_idx->tcpConnectionLocalAddress_len <
         (tcpConnectionLocalAddress_val_ptr_len))) {
        snmp_log(LOG_ERR, "not enough space for value\n");
        return MFD_ERROR;
    }
    tbl_idx->tcpConnectionLocalAddress_len =
        tcpConnectionLocalAddress_val_ptr_len;
    memcpy(tbl_idx->tcpConnectionLocalAddress,
           tcpConnectionLocalAddress_val_ptr,
           tcpConnectionLocalAddress_val_ptr_len *
           sizeof(tcpConnectionLocalAddress_val_ptr[0]));

    /*
     * tcpConnectionLocalPort(3)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H 
     */
    /** WARNING: this code might not work for netsnmp_tcpconn_entry */
    tbl_idx->tcpConnectionLocalPort = tcpConnectionLocalPort_val;

    /*
     * tcpConnectionRemAddressType(4)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h 
     */
    /** WARNING: this code might not work for netsnmp_tcpconn_entry */
    tbl_idx->tcpConnectionRemAddressType =
        tbl_idx->tcpConnectionLocalAddressType;

    /*
     * tcpConnectionRemAddress(5)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h 
     */
    tbl_idx->tcpConnectionRemAddress_len = sizeof(tbl_idx->tcpConnectionRemAddress) / sizeof(tbl_idx->tcpConnectionRemAddress[0]);      /* max length */
    /** WARNING: this code might not work for netsnmp_tcpconn_entry */
    /*
     * make sure there is enough space for tcpConnectionRemAddress data
     */
    if ((NULL == tbl_idx->tcpConnectionRemAddress) ||
        (tbl_idx->tcpConnectionRemAddress_len <
         (tcpConnectionRemAddress_val_ptr_len))) {
        snmp_log(LOG_ERR, "not enough space for value\n");
        return MFD_ERROR;
    }
    tbl_idx->tcpConnectionRemAddress_len =
        tcpConnectionRemAddress_val_ptr_len;
    memcpy(tbl_idx->tcpConnectionRemAddress,
           tcpConnectionRemAddress_val_ptr,
           tcpConnectionRemAddress_val_ptr_len *
           sizeof(tcpConnectionRemAddress_val_ptr[0]));

    /*
     * tcpConnectionRemPort(6)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H 
     */
    /** WARNING: this code might not work for netsnmp_tcpconn_entry */
    tbl_idx->tcpConnectionRemPort = tcpConnectionRemPort_val;


    return MFD_SUCCESS;
}                               /* tcpConnectionTable_indexes_set_tbl_idx */
/**
 * Set the new value.
 *
 * @param rowreq_ctx
 *        Pointer to the users context. You should know how to
 *        manipulate the value from this object.
 * @param WAPIASIPAddress_val
 *        A u_long containing the new value.
 */
int
WAPIASIPAddress_set( dot11ConfigWapiTable_rowreq_ctx *rowreq_ctx, u_long WAPIASIPAddress_val )
{

    DEBUGMSGTL(("verbose:dot11ConfigWapiTable:WAPIASIPAddress_set","called\n"));

    /** should never get a NULL pointer */
    netsnmp_assert(NULL != rowreq_ctx);

/*
 * TODO:245:o: |-> Implement WAPIASIPAddress reverse mapping.
 * If the values for your data type don't exactly match the
 * possible values defined by the mib, you should map them here.
 */
    /*
     * TODO:461:M: |-> Set WAPIASIPAddress value.
     * set WAPIASIPAddress value in rowreq_ctx->data
     */
	int ret = 2;
	char input[DEFAULT_LEN] = {0};
	memset(input,0,DEFAULT_LEN);
	int ret_one = 2;
	int ret_two = 2;
	int ret_three = 2;	
	int rc = MFD_ERROR;

    void *connection = NULL;
    if(SNMPD_DBUS_ERROR == get_instance_dbus_connection(rowreq_ctx->data.parameter, &connection, SNMPD_INSTANCE_MASTER_V3))
        return MFD_ERROR;
    
	ret = config_wlan_service(rowreq_ctx->data.parameter, connection,rowreq_ctx->data.WapiSSID,"disable");
	if(ret == 1)
	{
		INET_NTOA(WAPIASIPAddress_val,input);
		ret_one = config_wapi_auth(rowreq_ctx->data.parameter, connection,rowreq_ctx->data.SecurityID,input,"X.509");
		if (ret_one == 1)
		{   
			ret_two = apply_wlanID(rowreq_ctx->data.parameter, connection,rowreq_ctx->data.SecurityID,rowreq_ctx->data.WapiSSID); 
			if(ret_two == 1)
			{
				ret_three = config_wlan_service(rowreq_ctx->data.parameter, connection,rowreq_ctx->data.WapiSSID,"enable");
				if (ret_three == 1)
				{
				    rowreq_ctx->data.WAPIASIPAddress = WAPIASIPAddress_val;
					rc = MFD_SUCCESS;
				}
				else
				{
					rc = MFD_ERROR;
				}
			}
			else
			{
				rc = MFD_ERROR;
			}					
		}	
		else
		{
			rc = MFD_ERROR;
		}								 	     

	}
	else 
	{
		rc = MFD_ERROR;
	}

    return rc;
} /* WAPIASIPAddress_set */