示例#1
0
int
vacm_context_handler(netsnmp_mib_handler *handler,
                     netsnmp_handler_registration *reginfo,
                     netsnmp_agent_request_info *reqinfo,
                     netsnmp_request_info *requests)
{
    subtree_context_cache *context_ptr;

    while (requests) {
        netsnmp_variable_list *var = requests->requestvb;

        if (requests->processed != 0)
            continue;


        context_ptr = (subtree_context_cache *)
            netsnmp_extract_iterator_context(requests);

        if (context_ptr == NULL) {
            snmp_log(LOG_ERR,
                     "vacm_context_handler called without data\n");
            requests = requests->next;
            continue;
        }

        switch (reqinfo->mode) {
        case MODE_GET:
            /*
             * if here we should have a context_ptr passed in already 
             */
            /*
             * only one column should ever reach us, so don't check it 
             */
            snmp_set_var_typed_value(var, ASN_OCTET_STR,
                                     context_ptr->context_name,
                                     strlen(context_ptr->context_name));

            break;

        default:
            /*
             * We should never get here, getnext already have been
             * handled by the table_iterator and we're read_only 
             */
            snmp_log(LOG_ERR,
                     "vacm_context table accessed as mode=%d.  We're improperly registered!",
                     reqinfo->mode);
            break;


        }

        requests = requests->next;
    }

    return SNMP_ERR_NOERROR;
}
示例#2
0
文件: nsCache.c 项目: DYFeng/infinidb
int
handle_nsCacheTable(netsnmp_mib_handler *handler,
                netsnmp_handler_registration *reginfo,
                netsnmp_agent_request_info *reqinfo,
                netsnmp_request_info *requests)
{
    long status;
    netsnmp_request_info       *request     = NULL;
    netsnmp_table_request_info *table_info  = NULL;
    netsnmp_cache              *cache_entry = NULL;

    switch (reqinfo->mode) {

    case MODE_GET:
        for (request=requests; request; request=request->next) {
            if (requests->processed != 0)
                continue;

            cache_entry = (netsnmp_cache*)netsnmp_extract_iterator_context(request);
            table_info  =                 netsnmp_extract_table_info(request);

            switch (table_info->colnum) {
            case NSCACHE_TIMEOUT:
                if (!cache_entry) {
                    netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
                    continue;
		}
		status = cache_entry->timeout;
	        snmp_set_var_typed_value(request->requestvb, ASN_INTEGER,
                                         (u_char*)&status, sizeof(status));
	        break;

            case NSCACHE_STATUS:
                if (!cache_entry) {
                    netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
                    continue;
		}
		status = (cache_entry->enabled ?
	                   (cache_entry->timestamp ?
                             (!atime_ready(cache_entry->timestamp,
                                          1000*cache_entry->timeout) ?
	                        NSCACHE_STATUS_ACTIVE:
	                        NSCACHE_STATUS_EXPIRED) :
	                      NSCACHE_STATUS_EMPTY) :
	                    NSCACHE_STATUS_DISABLED);
	        snmp_set_var_typed_value(request->requestvb, ASN_INTEGER,
                                         (u_char*)&status, sizeof(status));
	        break;

            default:
                netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
                continue;
	    }
	}
	break;


    case MODE_SET_RESERVE1:
        for (request=requests; request; request=request->next) {
            if (requests->processed != 0)
                continue;
            if ( request->status != 0 ) {
                return SNMP_ERR_NOERROR;	/* Already got an error */
            }
            cache_entry = (netsnmp_cache*)netsnmp_extract_iterator_context(request);
            table_info  =                 netsnmp_extract_table_info(request);

            switch (table_info->colnum) {
            case NSCACHE_TIMEOUT:
                if (!cache_entry) {
                    netsnmp_set_request_error(reqinfo, request, SNMP_ERR_NOCREATION);
                    return SNMP_ERR_NOCREATION;
		}
                if ( request->requestvb->type != ASN_INTEGER ) {
                    netsnmp_set_request_error(reqinfo, request, SNMP_ERR_WRONGTYPE);
                    return SNMP_ERR_WRONGTYPE;
                }
                if (*request->requestvb->val.integer < 0 ) {
                    netsnmp_set_request_error(reqinfo, request, SNMP_ERR_WRONGVALUE);
                    return SNMP_ERR_WRONGVALUE;
                }
	        break;

            case NSCACHE_STATUS:
                if (!cache_entry) {
                    netsnmp_set_request_error(reqinfo, request, SNMP_ERR_NOCREATION);
                    return SNMP_ERR_NOCREATION;
		}
                if ( request->requestvb->type != ASN_INTEGER ) {
                    netsnmp_set_request_error(reqinfo, request, SNMP_ERR_WRONGTYPE);
                    return SNMP_ERR_WRONGTYPE;
                }
                status = *request->requestvb->val.integer;
                if (!((status == NSCACHE_STATUS_ENABLED  ) ||
                      (status == NSCACHE_STATUS_DISABLED ) ||
                      (status == NSCACHE_STATUS_EMPTY  ))) {
                    netsnmp_set_request_error(reqinfo, request, SNMP_ERR_WRONGVALUE);
                    return SNMP_ERR_WRONGVALUE;
                }
	        break;

            default:
                netsnmp_set_request_error(reqinfo, request, SNMP_ERR_NOCREATION);
                return SNMP_ERR_NOCREATION;	/* XXX - is this right ? */
                continue;
	    }
	}
	break;


    case MODE_SET_COMMIT:
        for (request=requests; request; request=request->next) {
            if (requests->processed != 0)
                continue;
            if ( request->status != 0 ) {
                return SNMP_ERR_NOERROR;	/* Already got an error */
            }
            cache_entry = (netsnmp_cache*)netsnmp_extract_iterator_context(request);
            if (!cache_entry) {
                netsnmp_set_request_error(reqinfo, request, SNMP_ERR_COMMITFAILED);
                return SNMP_ERR_COMMITFAILED;	/* Shouldn't happen! */
            }
            table_info  =                 netsnmp_extract_table_info(request);

            switch (table_info->colnum) {
            case NSCACHE_TIMEOUT:
                cache_entry->timeout = *request->requestvb->val.integer;
	        break;

            case NSCACHE_STATUS:
                switch (*request->requestvb->val.integer) {
                    case NSCACHE_STATUS_ENABLED:
                        cache_entry->enabled = 1;
                        break;
		    case NSCACHE_STATUS_DISABLED:
                        cache_entry->enabled = 0;
                        break;
		    case NSCACHE_STATUS_EMPTY:
                        cache_entry->free_cache(cache_entry, cache_entry->magic);
                        free(cache_entry->timestamp);
                        cache_entry->timestamp = NULL;
                        break;
		}
	        break;
	    }
	}
	break;
    }

    return SNMP_ERR_NOERROR;
}
示例#3
0
/** handles requests for the nsVacmAccessTable table */
int
nsVacmAccessTable_handler(netsnmp_mib_handler *handler,
                          netsnmp_handler_registration *reginfo,
                          netsnmp_agent_request_info *reqinfo,
                          netsnmp_request_info *requests)
{

    netsnmp_request_info *request;
    netsnmp_table_request_info *table_info;
    netsnmp_variable_list      *idx;
    struct vacm_accessEntry    *entry;
    char atype[20];
    int  viewIdx, ret;
    char *gName, *cPrefix;
    int  model, level;

    switch (reqinfo->mode) {
        /*
         * Read-support (also covers GetNext requests)
         */
    case MODE_GET:
        for (request = requests; request; request = request->next) {
            entry = (struct vacm_accessEntry *)
                netsnmp_extract_iterator_context(request);
            table_info = netsnmp_extract_table_info(request);

            /* Extract the authType token from the list of indexes */
            idx = table_info->indexes->next_variable->next_variable->next_variable->next_variable;
            memset(atype, 0, sizeof(atype));
            memcpy(atype, (char *)idx->val.string, idx->val_len);
            viewIdx = se_find_value_in_slist(VACM_VIEW_ENUM_NAME, atype);
            DEBUGMSGTL(("nsVacm", "GET %s (%d)\n", idx->val.string, viewIdx));

            if (!entry || viewIdx < 0)
                continue;

            switch (table_info->colnum) {
            case COLUMN_NSVACMCONTEXTMATCH:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->contextMatch);
                break;
            case COLUMN_NSVACMVIEWNAME:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                               (u_char *)entry->views[ viewIdx ],
                                  strlen(entry->views[ viewIdx ]));
                break;
            case COLUMN_VACMACCESSSTORAGETYPE:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->storageType);
                break;
            case COLUMN_NSVACMACCESSSTATUS:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->status);
                break;
            }
        }
        break;

#ifndef NETSNMP_NO_WRITE_SUPPORT
        /*
         * Write-support
         */
    case MODE_SET_RESERVE1:
        for (request = requests; request; request = request->next) {
            entry = (struct vacm_accessEntry *)
                netsnmp_extract_iterator_context(request);
            table_info = netsnmp_extract_table_info(request);
            ret = SNMP_ERR_NOERROR;

            switch (table_info->colnum) {
            case COLUMN_NSVACMCONTEXTMATCH:
                ret = netsnmp_check_vb_int_range(request->requestvb, 1, 2);
                break;
            case COLUMN_NSVACMVIEWNAME:
                ret = netsnmp_check_vb_type_and_max_size(request->requestvb,
                                                         ASN_OCTET_STR,
                                                         VACM_MAX_STRING);
                break;
            case COLUMN_VACMACCESSSTORAGETYPE:
                ret = netsnmp_check_vb_storagetype(request->requestvb,
                          (/*entry ? entry->storageType :*/ SNMP_STORAGE_NONE));
                break;
            case COLUMN_NSVACMACCESSSTATUS:
                /*
                 * The usual 'check_vb_rowstatus' call is too simplistic
                 *   to be used here.  Because we're implementing a table
                 *   within an existing table, it's quite possible for a
                 *   the vacmAccessTable entry to exist, even if this is
                 *   a "new" nsVacmAccessEntry.
                 *
                 * We can check that the value being assigned is suitable
                 *   for a RowStatus syntax object, but the transition
                 *   checks need to be done explicitly.
                 */
                ret = netsnmp_check_vb_rowstatus_value(request->requestvb);
                if ( ret != SNMP_ERR_NOERROR )
                    break;

                /*
                 * Extract the authType token from the list of indexes
                 */
                idx = table_info->indexes->next_variable->next_variable->next_variable->next_variable;
                memset(atype, 0, sizeof(atype));
                memcpy(atype, (char *)idx->val.string, idx->val_len);
                viewIdx = se_find_value_in_slist(VACM_VIEW_ENUM_NAME, atype);
                if ( viewIdx < 0 ) {
                    ret = SNMP_ERR_NOCREATION;
                    break;
                }
                switch ( *request->requestvb->val.integer ) {
                case RS_ACTIVE:
                case RS_NOTINSERVICE:
                    /* Check that this particular view is already set */
                    if ( !entry || !entry->views[viewIdx][0] )
                        ret = SNMP_ERR_INCONSISTENTVALUE;
                    break;
                case RS_CREATEANDWAIT:
                case RS_CREATEANDGO:
                    /* Check that this particular view is not yet set */
                    if ( entry && entry->views[viewIdx][0] )
                        ret = SNMP_ERR_INCONSISTENTVALUE;
                    break;
                }
                break;
            } /* switch(colnum) */
            if ( ret != SNMP_ERR_NOERROR ) {
                netsnmp_set_request_error(reqinfo, request, ret);
                return SNMP_ERR_NOERROR;
            }
        }
        break;

    case MODE_SET_RESERVE2:
        for (request = requests; request; request = request->next) {
            entry = (struct vacm_accessEntry *)
                netsnmp_extract_iterator_context(request);
            table_info = netsnmp_extract_table_info(request);

            switch (table_info->colnum) {
            case COLUMN_NSVACMACCESSSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_CREATEANDGO:
                case RS_CREATEANDWAIT:
                    if (!entry) {
                         idx = table_info->indexes; gName = (char*)idx->val.string;
                         idx = idx->next_variable;  cPrefix = (char*)idx->val.string;
                         idx = idx->next_variable;  model = *idx->val.integer;
                         idx = idx->next_variable;  level = *idx->val.integer;
                         entry = vacm_createAccessEntry( gName, cPrefix, model, level );
                         entry->storageType = ST_NONVOLATILE;
                         netsnmp_insert_iterator_context(request, (void*)entry);
                    }
                }
            }
        }
        break;

    case MODE_SET_FREE:
    case MODE_SET_UNDO:
        /* XXX - TODO */
        break;

    case MODE_SET_ACTION:
        /* ??? Empty ??? */
        break;

    case MODE_SET_COMMIT:
        for (request = requests; request; request = request->next) {
            entry = (struct vacm_accessEntry *)
                netsnmp_extract_iterator_context(request);
            table_info = netsnmp_extract_table_info(request);
            if ( !entry )
                continue;  /* Shouldn't happen */

            /* Extract the authType token from the list of indexes */
            idx = table_info->indexes->next_variable->next_variable->next_variable->next_variable;
            memset(atype, 0, sizeof(atype));
            memcpy(atype, (char *)idx->val.string, idx->val_len);
            viewIdx = se_find_value_in_slist(VACM_VIEW_ENUM_NAME, atype);
            if (viewIdx < 0)
                    continue;

            switch (table_info->colnum) {
            case COLUMN_NSVACMCONTEXTMATCH:
                entry->contextMatch = *request->requestvb->val.integer;
                break;
            case COLUMN_NSVACMVIEWNAME:
                memset( entry->views[viewIdx], 0, VACMSTRINGLEN );
                memcpy( entry->views[viewIdx], request->requestvb->val.string,
                                               request->requestvb->val_len);
                break;
            case COLUMN_VACMACCESSSTORAGETYPE:
                entry->storageType = *request->requestvb->val.integer;
                break;
            case COLUMN_NSVACMACCESSSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_DESTROY:
                    memset( entry->views[viewIdx], 0, VACMSTRINGLEN );
                    break;
                }
                break;
            }
        }
        break;
#endif /* !NETSNMP_NO_WRITE_SUPPORT */
    }
    return SNMP_ERR_NOERROR;
}
示例#4
0
/** handles requests for the nsModuleTable table, if anything else needs to be done */
int
nsModuleTable_handler(netsnmp_mib_handler *handler,
                      netsnmp_handler_registration *reginfo,
                      netsnmp_agent_request_info *reqinfo,
                      netsnmp_request_info *requests)
{

    netsnmp_table_request_info *table_info;
    netsnmp_request_info *request;
    netsnmp_variable_list *var;
    netsnmp_subtree *tree;
    u_long          ultmp;
    u_char          modes[1];

    for (request = requests; request; request = request->next) {
        var = request->requestvb;
        if (request->processed != 0)
            continue;

        /*
         * perform anything here that you need to do.  The request have
         * already been processed by the master table_dataset handler, but
         * this gives you chance to act on the request in some other way if
         * need be.
         */

        /*
         * the following extracts the my_data_context pointer set in the
         * loop functions above.  You can then use the results to help
         * return data for the columns of the nsModuleTable table in
         * question
         */
        tree = (netsnmp_subtree *)netsnmp_extract_iterator_context(request);
        if (tree == NULL) {
            if (reqinfo->mode == MODE_GET) {
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_NOSUCHINSTANCE);
                continue;
            }
            /*
             * XXX: no row existed, if you support creation and this is a
             * set, start dealing with it here, else continue
             */
        }

        /*
         * extracts the information about the table from the request
         */
        table_info = netsnmp_extract_table_info(request);

        /*
         * table_info->colnum contains the column number requested
         */
        /*
         * table_info->indexes contains a linked list of snmp variable
         * bindings for the indexes of the table.  Values in the list have
         * been set corresponding to the indexes of the request
         */
        if (table_info == NULL) {
            continue;
        }

        switch (reqinfo->mode) {
        /*
         * the table_iterator helper should change all GETNEXTs into
         * GETs for you automatically, so you don't have to worry
         * about the GETNEXT case.  Only GETs and SETs need to be
         * dealt with here
         */
        case MODE_GET:
            switch (table_info->colnum) {
            case COLUMN_NSMODULENAME:
                if (tree->reginfo->handlerName) {
                    snmp_set_var_typed_value(var, ASN_OCTET_STR,
                                             tree->reginfo->handlerName,
                                             strlen(tree->reginfo->handlerName));
                } else {
                    snmp_set_var_typed_value(var, ASN_OCTET_STR, "", 0);
                }
                break;

            case COLUMN_NSMODULEMODES:
                /*
                 * basically, these BITS needs to be inverted in order
                 */
                modes[0] =
                    ((HANDLER_CAN_GETANDGETNEXT & tree->reginfo->
                      modes) << 7) | ((HANDLER_CAN_SET & tree->reginfo->
                                       modes) << 5) | ((HANDLER_CAN_GETBULK
                                                        & tree->reginfo->
                                                        modes) << 3);
                /*  yuck  */
                snmp_set_var_typed_value(var, ASN_OCTET_STR, modes, 1);
                break;

            case COLUMN_NSMODULETIMEOUT:
                ultmp = tree->timeout;
                snmp_set_var_typed_value(var, ASN_INTEGER,
                                         (u_char *) & ultmp,
                                         sizeof(u_long));
                break;

            default:
                /*
                 * We shouldn't get here
                 */
                snmp_log(LOG_ERR,
                         "problem encountered in nsModuleTable_handler: unknown column\n");
            }
            break;

        default:
            snmp_log(LOG_ERR,
                     "problem encountered in nsModuleTable_handler: unsupported mode\n");
        }
    }
    return SNMP_ERR_NOERROR;
}
/** handles requests for the nsTransactionTable table, if anything
   else needs to be done */
int
nsTransactionTable_handler(netsnmp_mib_handler *handler,
                           netsnmp_handler_registration *reginfo,
                           netsnmp_agent_request_info *reqinfo,
                           netsnmp_request_info *requests)
{

    netsnmp_table_request_info *table_info;
    netsnmp_variable_list *var;
    netsnmp_agent_session *asp;

    for (; requests; requests = requests->next) {
        var = requests->requestvb;
        if (requests->processed != 0)
            continue;

        /*
         * perform anything here that you need to do.  The requests have
         * already been processed by the master table_dataset handler, but
         * this gives you chance to act on the request in some other way if 
         * need be. 
         */

        /*
         * the following extracts the my_data_context pointer set in the
         * loop functions above.  You can then use the results to help
         * return data for the columns of the nsTransactionTable table in
         * question 
         */
        asp =
            (netsnmp_agent_session *)
            netsnmp_extract_iterator_context(requests);
        if (asp == NULL) {
            netsnmp_set_request_error(reqinfo, requests,
                                      SNMP_NOSUCHINSTANCE);
        }

        /*
         * extracts the information about the table from the request 
         */
        table_info = netsnmp_extract_table_info(requests);

        /*
         * table_info->colnum contains the column number requested 
         */
        /*
         * table_info->indexes contains a linked list of snmp variable
         * bindings for the indexes of the table.  Values in the list have 
         * been set corresponding to the indexes of the request 
         */
        if (table_info == NULL) {
            continue;
        }

        switch (reqinfo->mode) {
            /*
             * the table_iterator helper should change all GETNEXTs into
             * GETs for you automatically, so you don't have to worry
             * about the GETNEXT case.  Only GETs and SETs need to be
             * dealt with here 
             */
        case MODE_GET:
            switch (table_info->colnum) {

            case COLUMN_NSTRANSACTIONMODE:
                snmp_set_var_typed_value(var, ASN_INTEGER,
                                         (u_char *) & asp->mode,
                                         sizeof(asp->mode));
                break;

            default:
                /*
                 * We shouldn't get here 
                 */
                snmp_log(LOG_ERR,
                         "problem encountered in nsTransactionTable_handler: unknown column\n");
            }
            break;

        default:
            snmp_log(LOG_ERR,
                     "problem encountered in nsTransactionTable_handler: unsupported mode\n");
        }
    }
    return SNMP_ERR_NOERROR;
}
/** handles requests for the dot11QosWirelessTable table */
int
dot11QosWirelessTable_handler(
    netsnmp_mib_handler               *handler,
    netsnmp_handler_registration      *reginfo,
    netsnmp_agent_request_info        *reqinfo,
    netsnmp_request_info              *requests) {

    netsnmp_request_info       *request;
    netsnmp_table_request_info *table_info;
    struct dot11QosWirelessTable_entry          *table_entry;

    switch (reqinfo->mode) {
        /*
         * Read-support (also covers GetNext requests)
         */
    case MODE_GET:
        for (request=requests; request; request=request->next) {
            table_entry = (struct dot11QosWirelessTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);			
			if( !table_entry )
			{
					netsnmp_set_request_error(reqinfo,request,SNMP_NOSUCHINSTANCE);
					continue;
				}	
				
            void *connection = NULL;
            if(SNMPD_DBUS_ERROR == get_slot_dbus_connection(table_entry->parameter.slot_id, &connection, SNMPD_INSTANCE_MASTER_V3))
                break;
    
            switch (table_info->colnum) {
            case COLUMN_WTPID:
                snmp_set_var_typed_value( request->requestvb, ASN_INTEGER,
                                          (u_char*)&table_entry->globalWtpID,
                                          sizeof(long));
                break;
            case COLUMN_RADIOLOCALID:
                snmp_set_var_typed_value( request->requestvb, ASN_INTEGER,
                                          (u_char*)&table_entry->RadioLocalID,
                                          sizeof(long));
                break;
            case COLUMN_QOSTYPE:
                snmp_set_var_typed_value( request->requestvb, ASN_INTEGER,
                                          (u_char*)&table_entry->QosType,
                                          sizeof(long));
                break;
            case COLUMN_QOSWIRELESSAIFS:
            {   
			    char wtpID[10] = { 0 };
				memset(wtpID,0,10);
				char type[20] = { 0 };
				memset(type,0,20);
				char radioID[10] = { 0 };
                memset(radioID,0,10);
				int ret = 0;
				DCLI_WQOS *WQOS = NULL;
				snprintf(wtpID,sizeof(wtpID)-1,"%d",table_entry->WtpID);
                snprintf(radioID,sizeof(radioID)-1,"%d",table_entry->RadioLocalID);

				if(table_entry->QosType == 1)
				{
					memset(type,0,20);
					strncpy(type,"BESTEFFORT",sizeof(type)-1);
				}
				else if(table_entry->QosType == 2)
				{
					memset(type,0,20);
	                strncpy(type,"BACKGROUND",sizeof(type)-1);
				}
				else if(table_entry->QosType == 3)
				{
					memset(type,0,20);
	                strncpy(type,"VIDEO",sizeof(type)-1);
				}
				else if(table_entry->QosType == 4)
				{
					memset(type,0,20);
	                strncpy(type,"VOICE",sizeof(type)-1);
				}				

				ret = wid_show_qos_radio_cmd(table_entry->parameter, connection,wtpID,radioID,type,&WQOS);
				if((ret == 1)&&(WQOS->qos[0])&&(WQOS->qos[0]->radio_qos[table_entry->QosType-1]))
				{
					table_entry->QosWirelessAIFS = WQOS->qos[0]->radio_qos[table_entry->QosType-1]->AIFS;
				}
				
                snmp_set_var_typed_value( request->requestvb, ASN_INTEGER,
                                          (u_char*)&table_entry->QosWirelessAIFS,
                                          sizeof(long));

				if(ret == 1)
				{
					Free_qos_one(WQOS);
				}
            }
                break;
            case COLUMN_QOSWIRELESSCWMIN:
			 {   
			    char wtpID[10] = { 0 };
				memset(wtpID,0,10);
				char type[20] = { 0 };
				memset(type,0,20);
				char radioID[10] = { 0 };
                memset(radioID,0,10);
				int ret = 0;
				DCLI_WQOS *WQOS = NULL;
				snprintf(wtpID,sizeof(wtpID)-1,"%d",table_entry->WtpID);
                snprintf(radioID,sizeof(radioID)-1,"%d",table_entry->RadioLocalID);

				if(table_entry->QosType == 1)
				{
					memset(type,0,20);
					strncpy(type,"BESTEFFORT",sizeof(type)-1);
				}
				else if(table_entry->QosType == 2)
				{
					memset(type,0,20);
	                strncpy(type,"BACKGROUND",sizeof(type)-1);
				}
				else if(table_entry->QosType == 3)
				{
					memset(type,0,20);
	                strncpy(type,"VIDEO",sizeof(type)-1);
				}
				else if(table_entry->QosType == 4)
				{
					memset(type,0,20);
	                strncpy(type,"VOICE",sizeof(type)-1);
				}
				
				ret = wid_show_qos_radio_cmd(table_entry->parameter, connection,wtpID,radioID,type,&WQOS);
				if((ret == 1)&&(WQOS->qos[0])&&(WQOS->qos[0]->radio_qos[table_entry->QosType-1]))
				{
					table_entry->QosWirelessCWmin = WQOS->qos[0]->radio_qos[table_entry->QosType-1]->CWMin;
				}
				
                snmp_set_var_typed_value( request->requestvb, ASN_INTEGER,
                                          (u_char*)&table_entry->QosWirelessCWmin,
                                          sizeof(long));

				if(ret == 1)
				{
					Free_qos_one(WQOS);
				}
            }
                break;
            case COLUMN_QOSWIRELESSCWMAX:
			{   
			    char wtpID[10] = { 0 };
				memset(wtpID,0,10);
				char type[20] = { 0 };
				memset(type,0,20);
				char radioID[10] = { 0 };
                memset(radioID,0,10);
				int ret = 0;
				DCLI_WQOS *WQOS = NULL;
				snprintf(wtpID,sizeof(wtpID)-1,"%d",table_entry->WtpID);
                snprintf(radioID,sizeof(radioID)-1,"%d",table_entry->RadioLocalID);

				if(table_entry->QosType == 1)
				{
					memset(type,0,20);
					strncpy(type,"BESTEFFORT",sizeof(type)-1);
				}
				else if(table_entry->QosType == 2)
				{
					memset(type,0,20);
	                strncpy(type,"BACKGROUND",sizeof(type)-1);
				}
				else if(table_entry->QosType == 3)
				{
					memset(type,0,20);
	                strncpy(type,"VIDEO",sizeof(type)-1);
				}
				else if(table_entry->QosType == 4)
				{
					memset(type,0,20);
	                strncpy(type,"VOICE",sizeof(type)-1);
				}
				
				ret = wid_show_qos_radio_cmd(table_entry->parameter, connection,wtpID,radioID,type,&WQOS);
				if((ret == 1)&&(WQOS->qos[0])&&(WQOS->qos[0]->radio_qos[table_entry->QosType-1]))
				{
					table_entry->QoSWirelessCWmax = WQOS->qos[0]->radio_qos[table_entry->QosType-1]->CWMax;
				}
				
                snmp_set_var_typed_value( request->requestvb, ASN_INTEGER,
                                          (u_char*)&table_entry->QoSWirelessCWmax,
                                          sizeof(long));

				if(ret == 1)
				{
					Free_qos_one(WQOS);
				}
            }
                break;
            case COLUMN_QOSWIRELESSTXOPLIM:
			{   
			    char wtpID[10] = { 0 };
				memset(wtpID,0,10);
				char type[20] = { 0 };
				memset(type,0,20);
				char radioID[10] = { 0 };
                memset(radioID,0,10);
				int ret = 0;
				DCLI_WQOS *WQOS = NULL;
				snprintf(wtpID,sizeof(wtpID)-1,"%d",table_entry->WtpID);
                snprintf(radioID,sizeof(radioID)-1,"%d",table_entry->RadioLocalID);

				if(table_entry->QosType == 1)
				{
					memset(type,0,20);
					strncpy(type,"BESTEFFORT",sizeof(type)-1);
				}
				else if(table_entry->QosType == 2)
				{
					memset(type,0,20);
	                strncpy(type,"BACKGROUND",sizeof(type)-1);
				}
				else if(table_entry->QosType == 3)
				{
					memset(type,0,20);
	                strncpy(type,"VIDEO",sizeof(type)-1);
				}
				else if(table_entry->QosType == 4)
				{
					memset(type,0,20);
	                strncpy(type,"VOICE",sizeof(type)-1);
				}
				
				ret = wid_show_qos_radio_cmd(table_entry->parameter, connection,wtpID,radioID,type,&WQOS);
				if((ret == 1)&&(WQOS->qos[0])&&(WQOS->qos[0]->radio_qos[table_entry->QosType-1]))
				{
					table_entry->QoSWirelessTXOPLim = WQOS->qos[0]->radio_qos[table_entry->QosType-1]->TXOPlimit;
				}
				
                snmp_set_var_typed_value( request->requestvb, ASN_INTEGER,
                                          (u_char*)&table_entry->QoSWirelessTXOPLim,                                          
                                          sizeof(long));

				if(ret == 1)
				{
					Free_qos_one(WQOS);
				}
            }
                break;
            }
        }
        break;

        /*
         * Write-support
         */
    case MODE_SET_RESERVE1:
        for (request=requests; request; request=request->next) {
            table_entry = (struct dot11QosWirelessTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);
    
            switch (table_info->colnum) {
            case COLUMN_QOSWIRELESSAIFS:
                if ( request->requestvb->type != ASN_INTEGER ) {
                    netsnmp_set_request_error( reqinfo, request,
                                               SNMP_ERR_WRONGTYPE );
                    return SNMP_ERR_NOERROR;
                }
                /* Also may need to check size/value */
                break;
            case COLUMN_QOSWIRELESSCWMIN:
                if ( request->requestvb->type != ASN_INTEGER ) {
                    netsnmp_set_request_error( reqinfo, request,
                                               SNMP_ERR_WRONGTYPE );
                    return SNMP_ERR_NOERROR;
                }
                /* Also may need to check size/value */
                break;
            case COLUMN_QOSWIRELESSCWMAX:
                if ( request->requestvb->type != ASN_INTEGER ) {
                    netsnmp_set_request_error( reqinfo, request,
                                               SNMP_ERR_WRONGTYPE );
                    return SNMP_ERR_NOERROR;
                }
                /* Also may need to check size/value */
                break;
            case COLUMN_QOSWIRELESSTXOPLIM:
                if ( request->requestvb->type != ASN_INTEGER ) {
                    netsnmp_set_request_error( reqinfo, request,
                                               SNMP_ERR_WRONGTYPE );
                    return SNMP_ERR_NOERROR;
                }
                /* Also may need to check size/value */
                break;
            default:
                netsnmp_set_request_error( reqinfo, request,
                                           SNMP_ERR_NOTWRITABLE );
                return SNMP_ERR_NOERROR;
            }
        }
        break;

    case MODE_SET_RESERVE2:
        break;

    case MODE_SET_FREE:
        break;

   case MODE_SET_ACTION:
        for (request=requests; request; request=request->next) {
            table_entry = (struct dot11QosWirelessTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info( request);

			if( !table_entry ){
		       	netsnmp_set_request_error(reqinfo,request,SNMP_NOSUCHINSTANCE);
				continue;
		    }   

			void *connection = NULL;
            if(SNMPD_DBUS_ERROR == get_instance_dbus_connection(table_entry->parameter, &connection, SNMPD_INSTANCE_MASTER_V3))
                break;
            
            switch (table_info->colnum) {

			 case COLUMN_QOSWIRELESSAIFS:
			{	
				int result1 = 0,result2 = 0;
				char wtpID[10] = { 0 };
				memset(wtpID,0,10);
				char type[20] = { 0 };
				memset(type,0,20);
				char radioID[10] = { 0 };
				memset(radioID,0,10);
				char cwMin[20] = { 0 };
				char cwMax[20] = { 0 };
				char aifs[20] = { 0 };
				char txopLimit[20] = { 0 };
				char ack[20] = { 0 };
				int radioGId;
				char radio_g_id[10] = { 0 };
				memset(radio_g_id,0,10);
				char qos_name[10] = { 0 };
				memset(qos_name,0,10);
				int ret = 0;
				DCLI_WQOS *WQOS1 = NULL,*WQOS2 = NULL;
				snprintf(wtpID,sizeof(wtpID)-1,"%d",table_entry->WtpID);
				snprintf(radioID,sizeof(radioID)-1,"%d",table_entry->RadioLocalID);

				if(table_entry->QosType == 1)
				{
					memset(type,0,20);
					strncpy(type,"besteffort",sizeof(type)-1);//"BESTEFFORT");
				}
				else if(table_entry->QosType == 2)
				{
					memset(type,0,20);
					strncpy(type,"background",sizeof(type)-1);//BACKGROUND");
				}
				else if(table_entry->QosType == 3)
				{
					memset(type,0,20);
					strncpy(type,"video",sizeof(type)-1);//VIDEO");
				}
				else if(table_entry->QosType == 4)
				{
					memset(type,0,20);
					strncpy(type,"voice",sizeof(type)-1);//VOICE");
				}
				
				result1 = wid_show_qos_radio_cmd(table_entry->parameter, connection,wtpID,radioID,type,&WQOS1);
				if(( 1 == result1 )&&(WQOS1->qos[0])&&(WQOS1->qos[0]->radio_qos[0]))
				{
					memset(cwMin,0,20);
					memset(cwMax,0,20);
					memset(aifs,0,20);
					memset(txopLimit,0,20);
					memset(ack,0,20);
					
					snprintf( cwMin, sizeof(cwMin)-1, "%u", WQOS1->qos[0]->radio_qos[0]->CWMin);
					snprintf( cwMax, sizeof(cwMax)-1, "%u", WQOS1->qos[0]->radio_qos[0]->CWMax);
					snprintf( aifs, sizeof(aifs)-1, "%u", *request->requestvb->val.integer );
					snprintf( txopLimit, sizeof(txopLimit)-1, "%u",WQOS1->qos[0]->radio_qos[0]->TXOPlimit);
					if( 1 == WQOS1->qos[0]->radio_qos[0]->ACK)
					{
						snprintf( ack, sizeof(ack)-1, "ack");
					}
					else
					{
						snprintf( ack, sizeof(ack)-1, "noack");
					}
				
					ret = 0;
					ret = config_radio_qos_service(table_entry->parameter, connection,WQOS1->qos[0]->QosID, type,
										cwMin, cwMax, aifs, txopLimit, ack );	/*返回0表示失败,返回1表示成功,返回-1表示unknown qos type,返回-2表示unknown id format*/
				}
				else
				{
					radioGId = table_entry->WtpID * 4 + table_entry->RadioLocalID;
					snprintf(radio_g_id,sizeof(radio_g_id)-1,"%d",radioGId);
					snprintf(qos_name,sizeof(qos_name)-1,"wqos%d",radioGId);

					create_qos(table_entry->parameter, connection,radio_g_id,qos_name);
					
					ret = 0;
					ret = radio_apply_qos(table_entry->parameter, connection,radioGId,radio_g_id);
					if(ret == 1)
					{
						result2=wid_show_qos_radio_cmd(table_entry->parameter, connection,wtpID,radioID,type,&WQOS2);
						if(( 1 == result2 )&&(WQOS2->qos[0])&&(WQOS2->qos[0]->radio_qos[0]))
						{
							memset(cwMin,0,20);
							memset(cwMax,0,20);
							memset(aifs,0,20);
							memset(txopLimit,0,20);
							memset(ack,0,20);
							
							snprintf( cwMin, sizeof(cwMin)-1, "%u", WQOS2->qos[0]->radio_qos[0]->CWMin);
							snprintf( cwMax, sizeof(cwMax)-1, "%u", WQOS2->qos[0]->radio_qos[0]->CWMax);
							snprintf( aifs, sizeof(aifs)-1, "%u", *request->requestvb->val.integer );
							snprintf( txopLimit, sizeof(txopLimit)-1, "%u",WQOS2->qos[0]->radio_qos[0]->TXOPlimit);
							if( 1 == WQOS2->qos[0]->radio_qos[0]->ACK)
							{
								snprintf( ack, sizeof(ack)-1, "ack");
							}
							else
							{
								snprintf( ack, sizeof(ack)-1, "noack");
							}
						
							ret = 0;
							ret = config_radio_qos_service(table_entry->parameter, connection,WQOS2->qos[0]->QosID, type,
												cwMin, cwMax, aifs, txopLimit, ack );	/*返回0表示失败,返回1表示成功,返回-1表示unknown qos type,返回-2表示unknown id format*/
						}

						if( result2 == 1 )
						{
							Free_qos_one(WQOS2);
						}
					}
				}

				if( 1 != ret )
				{
					netsnmp_set_request_error(reqinfo, requests,SNMP_ERR_WRONGTYPE);
				}

				if( result1 == 1 )
				{
					Free_qos_one(WQOS1);
				}
			}
			 	break;
		    case COLUMN_QOSWIRELESSCWMIN:
			{	
				int result1 = 0,result2 = 0;
				char wtpID[10] = { 0 };
				memset(wtpID,0,10);
				char type[20] = { 0 };
				memset(type,0,20);
				char radioID[10] = { 0 };
				memset(radioID,0,10);
				char cwMin[20] = { 0 };
				char cwMax[20] = { 0 };
				char aifs[20] = { 0 };
				char txopLimit[20] = { 0 };
				char ack[20] = { 0 };
				int radioGId;
				char radio_g_id[10] = { 0 };
				memset(radio_g_id,0,10);
				char qos_name[10] = { 0 };
				memset(qos_name,0,10);
				int ret = 0;
				DCLI_WQOS *WQOS1 = NULL,*WQOS2 = NULL;
				snprintf(wtpID,sizeof(wtpID)-1,"%d",table_entry->WtpID);
				snprintf(radioID,sizeof(radioID)-1,"%d",table_entry->RadioLocalID);

				if(table_entry->QosType == 1)
				{
					memset(type,0,20);
					strncpy(type,"besteffort",sizeof(type)-1);//"BESTEFFORT");
				}
				else if(table_entry->QosType == 2)
				{
					memset(type,0,20);
					strncpy(type,"background",sizeof(type)-1);//BACKGROUND");
				}
				else if(table_entry->QosType == 3)
				{
					memset(type,0,20);
					strncpy(type,"video",sizeof(type)-1);//VIDEO");
				}
				else if(table_entry->QosType == 4)
				{
					memset(type,0,20);
					strncpy(type,"voice",sizeof(type)-1);//VOICE");
				}
				
				result1= wid_show_qos_radio_cmd(table_entry->parameter, connection,wtpID,radioID,type,&WQOS1);				
				if(( 1 == result1 )&&(WQOS1->qos[0])&&(WQOS1->qos[0]->radio_qos[0]))
				{
					memset(cwMin,0,20);
					memset(cwMax,0,20);
					memset(aifs,0,20);
					memset(txopLimit,0,20);
					memset(ack,0,20);
					
					snprintf( cwMin, sizeof(cwMin)-1, "%u", *request->requestvb->val.integer );
					snprintf( cwMax, sizeof(cwMax)-1, "%u", WQOS1->qos[0]->radio_qos[0]->CWMax);
					snprintf( aifs, sizeof(aifs)-1, "%u", WQOS1->qos[0]->radio_qos[0]->AIFS);
					snprintf( txopLimit, sizeof(txopLimit)-1, "%u", WQOS1->qos[0]->radio_qos[0]->TXOPlimit);
					if( 1 == WQOS1->qos[0]->radio_qos[0]->ACK )
					{
						snprintf( ack, sizeof(ack)-1, "ack");
					}
					else
					{
						snprintf( ack, sizeof(ack)-1, "noack");
					}
				
					ret = 0;
					ret = config_radio_qos_service(table_entry->parameter, connection, WQOS1->qos[0]->QosID, type,
										cwMin, cwMax, aifs, txopLimit, ack );	/*返回0表示失败,返回1表示成功,返回-1表示unknown qos type,返回-2表示unknown id format*/
				}
				else
				{
					radioGId = table_entry->WtpID * 4 + table_entry->RadioLocalID;
					snprintf(radio_g_id,sizeof(radio_g_id)-1,"%d",radioGId);
					snprintf(qos_name,sizeof(qos_name)-1,"wqos%d",radioGId);
					create_qos(table_entry->parameter, connection,radio_g_id,qos_name);
					ret = 0;
					ret = radio_apply_qos(table_entry->parameter, connection,radioGId,radio_g_id);
					if(ret == 1)
					{
						result2=wid_show_qos_radio_cmd(table_entry->parameter, connection,wtpID,radioID,type,&WQOS2);
						if(( 1 == result2 )&&(WQOS2->qos[0])&&(WQOS2->qos[0]->radio_qos[0]))
						{
							memset(cwMin,0,20);
							memset(cwMax,0,20);
							memset(aifs,0,20);
							memset(txopLimit,0,20);
							memset(ack,0,20);
							
							snprintf( cwMin, sizeof(cwMin)-1, "%u", *request->requestvb->val.integer );
							snprintf( cwMax, sizeof(cwMax)-1, "%u", WQOS2->qos[0]->radio_qos[0]->CWMax );
							snprintf( aifs, sizeof(aifs)-1, "%u", WQOS2->qos[0]->radio_qos[0]->AIFS );
							snprintf( txopLimit, sizeof(txopLimit)-1, "%u", WQOS2->qos[0]->radio_qos[0]->TXOPlimit);
							if( 1 == WQOS2->qos[0]->radio_qos[0]->ACK )
							{
								snprintf( ack, sizeof(ack)-1, "ack");
							}
							else
							{
								snprintf( ack, sizeof(ack)-1, "noack");
							}
						
							ret = 0;
							ret = config_radio_qos_service(table_entry->parameter, connection, WQOS2->qos[0]->QosID, type,
												cwMin, cwMax, aifs, txopLimit, ack );	/*返回0表示失败,返回1表示成功,返回-1表示unknown qos type,返回-2表示unknown id format*/
						}

						if( result2 == 1 )
						{
							Free_qos_one(WQOS2);
						}
					}
				}

				if( 1 != ret )
				{
					netsnmp_set_request_error(reqinfo, requests,SNMP_ERR_WRONGTYPE);
				}

				if( result1 == 1 )
				{
					Free_qos_one(WQOS1);
				}
			}
				break;
			case COLUMN_QOSWIRELESSCWMAX:
			{	
				int result1=0,result2=0;
				char wtpID[10] = { 0 };
				memset(wtpID,0,10);
				char type[20] = { 0 };
				memset(type,0,20);
				char radioID[10] = { 0 };
				memset(radioID,0,10);
				char cwMin[20] = { 0 };
				char cwMax[20] = { 0 };
				char aifs[20] = { 0 };
				char txopLimit[20] = { 0 };
				char ack[20] = { 0 };
				int radioGId;
				char radio_g_id[10] = { 0 };
				memset(radio_g_id,0,10);
				char qos_name[10] = { 0 };
				memset(qos_name,0,10);
				int ret = 0;
				DCLI_WQOS *WQOS1 = NULL,*WQOS2 = NULL;
				snprintf(wtpID,sizeof(wtpID)-1,"%d",table_entry->WtpID);
				snprintf(radioID,sizeof(radioID)-1,"%d",table_entry->RadioLocalID);
				if(table_entry->QosType == 1)
				{
					memset(type,0,20);
					strncpy(type,"besteffort",sizeof(type)-1);//"BESTEFFORT");
				}
				else if(table_entry->QosType == 2)
				{
					memset(type,0,20);
					strncpy(type,"background",sizeof(type)-1);//BACKGROUND");
				}
				else if(table_entry->QosType == 3)
				{
					memset(type,0,20);
					strncpy(type,"video",sizeof(type)-1);//VIDEO");
				}
				else if(table_entry->QosType == 4)
				{
					memset(type,0,20);
					strncpy(type,"voice",sizeof(type)-1);//VOICE");
				}
				result1 = wid_show_qos_radio_cmd(table_entry->parameter, connection,wtpID,radioID,type,&WQOS1);
				
				if(( 1 == result1 )&&(WQOS1->qos[0])&&(WQOS1->qos[0]->radio_qos[0]))
				{
					memset(cwMin,0,20);
					memset(cwMax,0,20);
					memset(aifs,0,20);
					memset(txopLimit,0,20);
					memset(ack,0,20);
					
					snprintf( cwMin, sizeof(cwMin)-1, "%u", WQOS1->qos[0]->radio_qos[0]->CWMin );
					snprintf( cwMax, sizeof(cwMax)-1, "%u", *request->requestvb->val.integer);
					snprintf( aifs, sizeof(aifs)-1, "%u", WQOS1->qos[0]->radio_qos[0]->AIFS );
					snprintf( txopLimit, sizeof(txopLimit)-1, "%u",WQOS1->qos[0]->radio_qos[0]->TXOPlimit);
					if( 1 == WQOS1->qos[0]->radio_qos[0]->ACK )
					{
						snprintf( ack, sizeof(ack)-1, "ack");
					}
					else
					{
						snprintf( ack, sizeof(ack)-1, "noack");
					}
				
					ret = 0;
					ret = config_radio_qos_service(table_entry->parameter, connection,WQOS1->qos[0]->QosID, type,
										cwMin, cwMax, aifs, txopLimit, ack );	/*返回0表示失败,返回1表示成功,返回-1表示unknown qos type,返回-2表示unknown id format*/
				}
				else
				{
					radioGId = table_entry->WtpID * 4 + table_entry->RadioLocalID;
					snprintf(radio_g_id,sizeof(radio_g_id)-1,"%d",radioGId);
					snprintf(qos_name,sizeof(qos_name)-1,"wqos%d",radioGId);

					create_qos(table_entry->parameter, connection,radio_g_id,qos_name);
					
					ret = 0;
					ret = radio_apply_qos(table_entry->parameter, connection,radioGId,radio_g_id);
					if(ret == 1)
					{
						result2=wid_show_qos_radio_cmd(table_entry->parameter, connection,wtpID,radioID,type,&WQOS2);
						if(( 1 == result2 )&&(WQOS2->qos[0])&&(WQOS2->qos[0]->radio_qos[0]))
						{
							memset(cwMin,0,20);
							memset(cwMax,0,20);
							memset(aifs,0,20);
							memset(txopLimit,0,20);
							memset(ack,0,20);
							
							snprintf( cwMin, sizeof(cwMin)-1, "%u", WQOS2->qos[0]->radio_qos[0]->CWMin );
							snprintf( cwMax, sizeof(cwMax)-1, "%u", *request->requestvb->val.integer);
							snprintf( aifs, sizeof(aifs)-1, "%u", WQOS2->qos[0]->radio_qos[0]->AIFS );
							snprintf( txopLimit, sizeof(txopLimit)-1, "%u",WQOS2->qos[0]->radio_qos[0]->TXOPlimit);
							if( 1 == WQOS2->qos[0]->radio_qos[0]->ACK )
							{
								snprintf( ack, sizeof(ack)-1, "ack");
							}
							else
							{
								snprintf( ack, sizeof(ack)-1, "noack");
							}
						
							ret = 0;
							ret = config_radio_qos_service(table_entry->parameter, connection,WQOS2->qos[0]->QosID, type,
												cwMin, cwMax, aifs, txopLimit, ack );	/*返回0表示失败,返回1表示成功,返回-1表示unknown qos type,返回-2表示unknown id format*/
						}

						if( result2 == 1 )
						{
							Free_qos_one(WQOS2);
						}
					}
				}

				if( 1 != ret )
				{
					netsnmp_set_request_error(reqinfo, requests,SNMP_ERR_WRONGTYPE);
				}


				if( result1 == 1 )
				{
					Free_qos_one(WQOS1);
				}
			}
				break;
			case COLUMN_QOSWIRELESSTXOPLIM:
			{	
				int result1 = 0,result2 = 0;
				char wtpID[10] = { 0 };
				memset(wtpID,0,10);
				char type[20] = { 0 };
				memset(type,0,20);
				char radioID[10] = { 0 };
				memset(radioID,0,10);
				char cwMin[20] = { 0 };
				char cwMax[20] = { 0 };
				char aifs[20] = { 0 };
				char txopLimit[20] = { 0 };
				char ack[20] = { 0 };
				int radioGId;
				char radio_g_id[10] = { 0 };
				memset(radio_g_id,0,10);
				char qos_name[10] = { 0 };
				memset(qos_name,0,10);
				int ret = 0;
				DCLI_WQOS *WQOS1 = NULL,*WQOS2 = NULL;
				snprintf(wtpID,sizeof(wtpID)-1,"%d",table_entry->WtpID);
				snprintf(radioID,sizeof(radioID)-1,"%d",table_entry->RadioLocalID);

				if(table_entry->QosType == 1)
				{
					memset(type,0,20);
					strncpy(type,"besteffort",sizeof(type)-1);//"BESTEFFORT");
				}
				else if(table_entry->QosType == 2)
				{
					memset(type,0,20);
					strncpy(type,"background",sizeof(type)-1);//BACKGROUND");
				}
				else if(table_entry->QosType == 3)
				{
					memset(type,0,20);
					strncpy(type,"video",sizeof(type)-1);//VIDEO");
				}
				else if(table_entry->QosType == 4)
				{
					memset(type,0,20);
					strncpy(type,"voice",sizeof(type)-1);//VOICE");
				}
				
				result1= wid_show_qos_radio_cmd(table_entry->parameter, connection,wtpID,radioID,type,&WQOS1);				
				if(( 1 == result1 )&&(WQOS1->qos[0])&&(WQOS1->qos[0]->radio_qos[0]))
				{
					memset(cwMin,0,20);
					memset(cwMax,0,20);
					memset(aifs,0,20);
					memset(txopLimit,0,20);
					memset(ack,0,20);
					
					snprintf( cwMin, sizeof(cwMin)-1, "%u", WQOS1->qos[0]->radio_qos[0]->CWMin );
					snprintf( cwMax, sizeof(cwMax)-1, "%u", WQOS1->qos[0]->radio_qos[0]->CWMax );
					snprintf( aifs, sizeof(aifs)-1, "%u", WQOS1->qos[0]->radio_qos[0]->AIFS );
					snprintf( txopLimit, sizeof(txopLimit)-1, "%u", *request->requestvb->val.integer);
					if( 1 == WQOS1->qos[0]->radio_qos[0]->ACK )
					{
						snprintf( ack, sizeof(ack)-1, "ack");
					}
					else
					{
						snprintf( ack, sizeof(ack)-1, "noack");
					}

					ret = 0;				
					ret = config_radio_qos_service(table_entry->parameter, connection, WQOS1->qos[0]->QosID, type,
										cwMin, cwMax, aifs, txopLimit, ack );	/*返回0表示失败,返回1表示成功,返回-1表示unknown qos type,返回-2表示unknown id format*/

				}
				else
				{
					radioGId = table_entry->WtpID * 4 + table_entry->RadioLocalID;
					snprintf(radio_g_id,sizeof(radio_g_id)-1,"%d",radioGId);
					snprintf(qos_name,sizeof(qos_name)-1,"wqos%d",radioGId);

					create_qos(table_entry->parameter, connection,radio_g_id,qos_name);
					
					ret = 0;
					ret = radio_apply_qos(table_entry->parameter, connection,radioGId,radio_g_id);
					if(ret == 1)
					{
						result2=wid_show_qos_radio_cmd(table_entry->parameter, connection,wtpID,radioID,type,&WQOS2);
						if(( 1 == result2 )&&(WQOS2->qos[0])&&(WQOS2->qos[0]->radio_qos[0]))
						{
							memset(cwMin,0,20);
							memset(cwMax,0,20);
							memset(aifs,0,20);
							memset(txopLimit,0,20);
							memset(ack,0,20);
							
							snprintf( cwMin, sizeof(cwMin)-1, "%u", WQOS2->qos[0]->radio_qos[0]->CWMin );
							snprintf( cwMax, sizeof(cwMax)-1, "%u", WQOS2->qos[0]->radio_qos[0]->CWMax );
							snprintf( aifs, sizeof(aifs)-1, "%u", WQOS2->qos[0]->radio_qos[0]->AIFS );
							snprintf( txopLimit, sizeof(txopLimit)-1, "%u", *request->requestvb->val.integer);
							if( 1 == WQOS2->qos[0]->radio_qos[0]->ACK )
							{
								snprintf( ack, sizeof(ack)-1, "ack");
							}
							else
							{
								snprintf( ack, sizeof(ack)-1, "noack");
							}
						
							ret = 0;
							ret = config_radio_qos_service(table_entry->parameter, connection, WQOS2->qos[0]->QosID, type,
												cwMin, cwMax, aifs, txopLimit, ack );	/*返回0表示失败,返回1表示成功,返回-1表示unknown qos type,返回-2表示unknown id format*/
						
						}

						if( result2 == 1 )
						{
							Free_qos_one(WQOS2);
						}
					}
				}

				if( 1 != ret )
				{
					netsnmp_set_request_error(reqinfo, requests,SNMP_ERR_WRONGTYPE);
				}

				if( result1 == 1 )
				{
					Free_qos_one(WQOS1);
				}
			}
			break;
            }
        }
        break;

    case MODE_SET_UNDO:
        for (request=requests; request; request=request->next) {
            table_entry = (struct dot11QosWirelessTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);
    
            switch (table_info->colnum) {
            case COLUMN_QOSWIRELESSAIFS:
                /* Need to restore old 'table_entry->QosWirelessAIFS' value.
                   May need to use 'memcpy' */
                break;
            case COLUMN_QOSWIRELESSCWMIN:
                /* Need to restore old 'table_entry->QosWirelessCWmin' value.
                   May need to use 'memcpy' */
                break;
            case COLUMN_QOSWIRELESSCWMAX:
                /* Need to restore old 'table_entry->QoSWirelessCWmax' value.
                   May need to use 'memcpy' */
                break;
            case COLUMN_QOSWIRELESSTXOPLIM:
                /* Need to restore old 'table_entry->QoSWirelessTXOPLim' value.
                   May need to use 'memcpy' */
                break;
            }
        }
        break;

    case MODE_SET_COMMIT:
        break;
    }
    return SNMP_ERR_NOERROR;
}
/** handles requests for the dot11VlanAbilityTable table */
int
dot11VlanAbilityTable_handler(
    netsnmp_mib_handler               *handler,
    netsnmp_handler_registration      *reginfo,
    netsnmp_agent_request_info        *reqinfo,
    netsnmp_request_info              *requests) 
{

	netsnmp_request_info       *request;
	netsnmp_table_request_info *table_info;
	struct dot11VlanAbilityTable_entry          *table_entry;

	switch (reqinfo->mode) 
	{
		/*
		* Read-support (also covers GetNext requests)
		*/
		case MODE_GET:
		{
			for (request=requests; request; request=request->next) 
			{
				table_entry = (struct dot11VlanAbilityTable_entry *)
				netsnmp_extract_iterator_context(request);
				table_info  =     netsnmp_extract_table_info(request);


				if( !table_entry )
				{
					netsnmp_set_request_error(reqinfo,request,SNMP_NOSUCHINSTANCE);
					continue;
				}     

				switch (table_info->colnum) 
				{
					case COLUMN_VLANID:
					{
						snmp_set_var_typed_value( request->requestvb, ASN_INTEGER,
						(u_char*)&table_entry->vlanID,
						sizeof(long));
					
						break;
					}
					case COLUMN_PRIORITY:
					{
						snmp_set_var_typed_value( request->requestvb, ASN_INTEGER,
						(u_char*)&table_entry->Priority,
						sizeof(long));
					
						break;
					}
				default:
				                netsnmp_set_request_error( reqinfo, request,
				                                           SNMP_ERR_NOTWRITABLE );
				                return SNMP_ERR_NOERROR;	
				}
			}
		}
		break;

		/*
		* Write-support
		*/
		case MODE_SET_RESERVE1:
		{
			for (request=requests; request; request=request->next) 
			{
				table_entry = (struct dot11VlanAbilityTable_entry *)
				netsnmp_extract_iterator_context(request);
				table_info  =     netsnmp_extract_table_info(request);

				switch (table_info->colnum) 
				{
					case COLUMN_VLANID:
					{
						if ( request->requestvb->type != ASN_INTEGER ) 
						{
							netsnmp_set_request_error( reqinfo, request,SNMP_ERR_WRONGTYPE );
							return SNMP_ERR_NOERROR;
						}
					}
					/* Also may need to check size/value */
					break;

					case COLUMN_PRIORITY:
					{
						if ( request->requestvb->type != ASN_INTEGER ) 
						{
							netsnmp_set_request_error( reqinfo, request,SNMP_ERR_WRONGTYPE );
							return SNMP_ERR_NOERROR;
						}
					}
					/* Also may need to check size/value */
					break;

					
					default:
					netsnmp_set_request_error( reqinfo, request,SNMP_ERR_NOTWRITABLE );
					return SNMP_ERR_NOERROR;
				}
			}
		}
		break;

		case MODE_SET_RESERVE2:
		break;

		case MODE_SET_FREE:
		break;

		case MODE_SET_ACTION:
		{
			for (request=requests; request; request=request->next) 
			{
				table_entry = (struct dot11VlanAbilityTable_entry *)
				netsnmp_extract_iterator_context(request);
				table_info  =     netsnmp_extract_table_info(      request);

				if( !table_entry )
				{
					netsnmp_set_request_error(reqinfo,request,SNMP_NOSUCHINSTANCE);
					continue;
				}  
				switch (table_info->colnum) 
				{
					case COLUMN_VLANID:
					{
                        void *connection = NULL;
                        if(SNMPD_DBUS_ERROR == get_instance_dbus_connection(table_entry->parameter, &connection, SNMPD_INSTANCE_MASTER_V3))
                            return MFD_ERROR;
        
						int ret1=0,ret2=0;
						char vlanid[10] = { 0 };
						memset(vlanid,0,10);
						/* Need to save old 'table_entry->vlanID' value.
						May need to use 'memcpy' */
						//table_entry->old_vlanID = table_entry->vlanID;
						table_entry->vlanID     = *request->requestvb->val.integer;
						ret1=config_wlan_service(table_entry->parameter, connection,table_entry->local_wlanCurrID,"disable");
						if(ret1!=1)
						{	
						    if(SNMPD_CONNECTION_ERROR == ret1) {
                                close_slot_dbus_connection(table_entry->parameter.slot_id);
                    	    }
							netsnmp_set_request_error(reqinfo,request,SNMP_ERR_WRONGTYPE);
							break;
						}
						
						snprintf(vlanid,sizeof(vlanid)-1,"%d",table_entry->vlanID);
						ret2=set_wlan_vlan_id(table_entry->parameter, connection,table_entry->local_wlanCurrID,vlanid);
						if(ret2!=1)
						{	
						    if(SNMPD_CONNECTION_ERROR == ret2) {
                                close_slot_dbus_connection(table_entry->parameter.slot_id);
                    	    }
							netsnmp_set_request_error(reqinfo,request,SNMP_ERR_WRONGTYPE);
						}						
					}
					break;

					case COLUMN_PRIORITY:
					{
                        void *connection = NULL;
                        if(SNMPD_DBUS_ERROR == get_instance_dbus_connection(table_entry->parameter, &connection, SNMPD_INSTANCE_MASTER_V3))
                            return MFD_ERROR;
                            
						int ret1=0,ret2=0;
						char pro[10] = { 0 };
						memset(pro,0,10);
						/* Need to save old 'table_entry->Priority' value.
						May need to use 'memcpy' */
						//table_entry->old_Priority = table_entry->Priority;
						table_entry->Priority = *request->requestvb->val.integer;
						ret1=config_wlan_service(table_entry->parameter, connection,table_entry->local_wlanCurrID,"disable");
						if(ret1!=1)
						{	
						    if(SNMPD_CONNECTION_ERROR == ret1) {
                                close_slot_dbus_connection(table_entry->parameter.slot_id);
                    	    }
							netsnmp_set_request_error(reqinfo,request,SNMP_ERR_WRONGTYPE);
							break;
						}
						
						snprintf(pro,sizeof(pro)-1,"%d",table_entry->Priority);
						ret2=set_wlan_vlan_priority(table_entry->parameter, connection,table_entry->local_wlanCurrID,pro);
						if(ret2!=1)
						{	
						    if(SNMPD_CONNECTION_ERROR == ret2) {
                                close_slot_dbus_connection(table_entry->parameter.slot_id);
                    	    }
							netsnmp_set_request_error(reqinfo,request,SNMP_ERR_WRONGTYPE);
						}
					}
					break;

				}
			}
		}
		break;

		case MODE_SET_UNDO:
		{
			for (request=requests; request; request=request->next) 
			{
				table_entry = (struct dot11VlanAbilityTable_entry *)
				netsnmp_extract_iterator_context(request);
				table_info  =     netsnmp_extract_table_info(request);

				switch (table_info->colnum) 
				{
					case COLUMN_VLANID:
					{
						/* Need to restore old 'table_entry->vlanID' value.
						May need to use 'memcpy' */
						//  table_entry->vlanID = table_entry->old_vlanID;
					}
					break;

					case COLUMN_PRIORITY:
					{
						/* Need to restore old 'table_entry->Priority' value.
						May need to use 'memcpy' */
						//  table_entry->Priority = table_entry->old_Priority;
					}
					break;
				}
			}
		}
		break;

		case MODE_SET_COMMIT:
		break;
	}
return SNMP_ERR_NOERROR;
}
示例#8
0
/** handles requests for the LHANodeTable table, if anything else needs to be done */
int
LHANodeTable_handler(
    netsnmp_mib_handler               *handler,
    netsnmp_handler_registration      *reginfo,
    netsnmp_agent_request_info        *reqinfo,
    netsnmp_request_info              *requests) 
{

    netsnmp_request_info *request;
    netsnmp_table_request_info *table_info;
    netsnmp_variable_list *var;

    struct hb_nodeinfo * entry;

    for (request = requests; request; request = request->next) {
        var = request->requestvb;
        if (request->processed != 0)
            continue;

        /** perform anything here that you need to do before each
           request is processed. */
	entry = (struct hb_nodeinfo *) 
	    netsnmp_extract_iterator_context(request);

        if (entry == NULL) {
            if (reqinfo->mode == MODE_GET) {
                netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
                continue;
            }
            /** XXX: no row existed, if you support creation and this is a
               set, start dealing with it here, else continue */
        }

        /** extracts the information about the table from the request */
        table_info = netsnmp_extract_table_info(request);
        /** table_info->colnum contains the column number requested */
        /** table_info->indexes contains a linked list of snmp variable
           bindings for the indexes of the table.  Values in the list
           have been set corresponding to the indexes of the
           request */
        if (table_info==NULL) {
            continue;
        }

        switch(reqinfo->mode) {
            /** the table_iterator helper should change all GETNEXTs
               into GETs for you automatically, so you don't have to
               worry about the GETNEXT case.  Only GETs and SETs need
               to be dealt with here */
            case MODE_GET:
                switch(table_info->colnum) {
		    case COLUMN_LHANODEINDEX:
			snmp_set_var_typed_value(var,
				ASN_INTEGER,
				(u_char*)&entry->id,
				sizeof(entry->id));
			break;

                    case COLUMN_LHANODENAME:
                        snmp_set_var_typed_value(var, 
				ASN_OCTET_STR, 
				(u_char *) (entry->name), 
				strlen(entry->name) + 1);
                        break;

                    case COLUMN_LHANODETYPE:
                        snmp_set_var_typed_value(var, 
				ASN_INTEGER, 
				(u_char *) & entry->type, 
				sizeof(entry->type));
                        break;

                    case COLUMN_LHANODESTATUS:
                        snmp_set_var_typed_value(var, 
				ASN_INTEGER, 
				(u_char *) & entry->status, 
				sizeof(entry->status));
                        break;

#ifdef HAVE_NEW_HB_API
                    case COLUMN_LHANODEUUID:
                        snmp_set_var_typed_value(var, 
				ASN_OCTET_STR, 
				(u_char *) &entry->uuid, 
				sizeof(entry->uuid));
                        break;
#endif /* HAVE_NEW_HB_API */

                    case COLUMN_LHANODEIFCOUNT:
                        snmp_set_var_typed_value(var, 
				ASN_COUNTER, 
				(u_char *) & entry->ifcount, 
				sizeof(entry->ifcount));
                        break;


                    default:
                        /** We shouldn't get here */
                        snmp_log(LOG_ERR, "problem encountered in LHANodeTable_handler: unknown column\n");
                }
                break;

            case MODE_SET_RESERVE1:
                /** set handling... */

            default:
                snmp_log(LOG_ERR, "problem encountered in LHANodeTable_handler: unsupported mode\n");
        }
    }
    return SNMP_ERR_NOERROR;
}
示例#9
0
/*
 * Handles requests for the swRaidTable table, if anything else needs to be done
 */
int swRaidTable_handler(netsnmp_mib_handler *handler,
                        netsnmp_handler_registration *reginfo,
                        netsnmp_agent_request_info *reqinfo,
                        netsnmp_request_info *requests)
{
  netsnmp_request_info *request;
  netsnmp_table_request_info *table_info;
  netsnmp_variable_list *var;
  void *data_context = NULL;

  /*
   * column and row index encoded portion
   */
  for (request = requests; request; request = request->next) {
	var = request->requestvb;
	if (request->processed != 0)
		continue;
	if (reqinfo->mode != MODE_GET) {
		snmp_log(LOG_ERR, "problem encountered in swRaidTable_handler: unsupported mode\n");
		continue;
	}

	/*
	 * get next data context
	 */
	data_context = netsnmp_extract_iterator_context(request);
	if (data_context == NULL) {
		netsnmp_set_request_error(reqinfo, request,
					SNMP_NOSUCHINSTANCE);
		continue;
	}

	/*
	 * extracts the information about the table from the request
	 *   table_info->colnum contains the column number requested
	 *   table_info->indexes contains a linked list of snmp variable
	 *   bindings for the indexes of the table.  Values in the list
	 *   have been set corresponding to the indexes of the
	 *   request
	 */
	table_info = netsnmp_extract_table_info(request);
	if (table_info == NULL)
		continue;
	switch (table_info->colnum) {
		case COLUMN_SWRAIDINDEX:
			{
				long   *retval;
				size_t  retval_len = 0;
				retval = get_swRaidIndex(data_context, &retval_len);
				if (retval != NULL)
					snmp_set_var_typed_value(var, ASN_INTEGER,
					                         (const u_char *) retval,
					                         retval_len);
			}
			break;

		case COLUMN_SWRAIDDEVICE:
			{
				char   *retval;
				size_t  retval_len = 0;
				retval = get_swRaidDevice(data_context, &retval_len);
				if (retval != NULL)
					snmp_set_var_typed_value(var, ASN_OCTET_STR,
					                         (const u_char *) retval,
					                         retval_len);
			}
			break;

		case COLUMN_SWRAIDPERSONALITY:
			{
				char   *retval;
				size_t  retval_len = 0;
				retval = get_swRaidPersonality(data_context, &retval_len);
				if (retval != NULL)
					snmp_set_var_typed_value(var, ASN_OCTET_STR,
					                         (const u_char *) retval,
					                         retval_len);
			}
			break;

		case COLUMN_SWRAIDUNITS:
			{
				char   *retval;
				size_t  retval_len = 0;
				retval = get_swRaidUnits(data_context, &retval_len);
				if (retval != NULL)
					snmp_set_var_typed_value(var, ASN_OCTET_STR,
					                         (const u_char *) retval,
					                         retval_len);
			}
			break;

		case COLUMN_SWRAIDUNITCOUNT:
			{
				long   *retval;
				size_t  retval_len = 0;
				retval = get_swRaidUnitCount(data_context, &retval_len);
				if (retval != NULL)
					snmp_set_var_typed_value(var, ASN_INTEGER,
					                         (const u_char *) retval,
					                         retval_len);
			}
			break;

		case COLUMN_SWRAIDSTATUS:
			{
				long   *retval;
				size_t  retval_len = 0;
				retval = get_swRaidStatus(data_context, &retval_len);
				if (retval != NULL)
					snmp_set_var_typed_value(var, ASN_INTEGER,
					                         (const u_char *) retval,
					                         retval_len);
			}
			break;

		default:
			/* We shouldn't get here */
			snmp_log(LOG_ERR, "problem encountered in swRaidTable_handler: unknown column\n");
	}
  }
  return SNMP_ERR_NOERROR;
}
示例#10
0
/*******************************************************************************
 函数名称  : mib_dot1qPortVlanTable_handler
 功能描述  : handles requests for the dot1qPortVlanTable table
 输入参数  :
 输出参数  :
 返 回 值  :
 --------------------------------------------------------------------------------
 最近一次修改记录 :
 修改作者   :
 修改目的   :
 修改日期   :
*******************************************************************************/
static int mib_dot1qPortVlanTable_handler(netsnmp_mib_handler *handler,
                    netsnmp_handler_registration *reginfo,
                    netsnmp_agent_request_info *reqinfo,
                    netsnmp_request_info *requests)
{
    netsnmp_request_info       *request;
    netsnmp_table_request_info *table_req_info;
    struct dot1qPortVlanTable_entry *table_entry;
    int                         ret;

    switch (reqinfo->mode)
    {
    /*
     * 这里的GET操作已经覆盖了GET_NEXT操作
     */
    case MODE_GET:
        for (request=requests; request; request=request->next)
        {
            table_entry = (struct dot1qPortVlanTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_req_info  = netsnmp_extract_table_info(request);
            if(NULL == table_req_info)
            {
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOACCESS);
                continue;
            }

            switch (table_req_info->colnum)
            {
            case COLUMN_DOT1QPVID:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_UNSIGNED,
                                            htonl(table_entry->dot1qPvid));
                break;

            case COLUMN_DOT1QPORTACCEPTABLEFRAMETYPES:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            htonl(table_entry->dot1qPortAcceptableFrameTypes));
                break;

            case COLUMN_DOT1QPORTINGRESSFILTERING:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            htonl(table_entry->dot1qPortIngressFiltering));
                break;

            case COLUMN_DOT1QPORTGVRPSTATUS:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            htonl(table_entry->dot1qPortGvrpStatus));
                break;

            case COLUMN_DOT1QPORTGVRPFAILEDREGISTRATIONS:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_COUNTER,
                                            htonl(table_entry->dot1qPortGvrpFailedRegistrations));
                break;

            case COLUMN_DOT1QPORTGVRPLASTPDUORIGIN:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
                                 (u_char*)table_entry->dot1qPortGvrpLastPduOrigin,
                                          table_entry->dot1qPortGvrpLastPduOrigin_len);
                break;

            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_NOSUCHOBJECT);
                break;

            }
        }
        break;

    /*
     * SET 操作
     */
    case MODE_SET_RESERVE1:
        /* SET第一阶段,检查参数类型 */
        for (request=requests; request; request=request->next)
        {
            table_entry = (struct dot1qPortVlanTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_req_info  = netsnmp_extract_table_info(request);
            if(NULL == table_req_info)
            {
                netsnmp_set_request_error( reqinfo, request,
                                           SNMP_ERR_NOACCESS );
                return SNMP_ERR_NOERROR;
            }

            switch (table_req_info->colnum)
            {
            case COLUMN_DOT1QPVID:
                /* or possibly 'netsnmp_check_vb_int_range' */
                ret = netsnmp_check_vb_int( request->requestvb );
                if ( ret != SNMP_ERR_NOERROR )
                {
                    netsnmp_set_request_error( reqinfo, request, ret );
                    return SNMP_ERR_NOERROR;
                }
                break;

            case COLUMN_DOT1QPORTGVRPSTATUS:
                /* or possibly 'netsnmp_check_vb_int_range' */
                ret = netsnmp_check_vb_int( request->requestvb );
                if ( ret != SNMP_ERR_NOERROR )
                {
                    netsnmp_set_request_error( reqinfo, request, ret );
                    return SNMP_ERR_NOERROR;
                }
                break;

            default:
                netsnmp_set_request_error( reqinfo, request,
                                           SNMP_ERR_NOTWRITABLE );
                return SNMP_ERR_NOERROR;
            }
        }
        break;

    case MODE_SET_RESERVE2:
        /* SET第二阶段,检查参数值是否正常并分配内存 */
        break;

    case MODE_SET_FREE:
        /* 出错处理,MODE_SET_RESERVE1或MODE_SET_RESERVE2出错时调用。
                  需要释放第一阶段和第二阶段分配的内存 */
        break;

    case MODE_SET_ACTION:
        /* SET第三阶段,执行设置值的具体动作 */
        for (request=requests; request; request=request->next)
        {
            table_entry = (struct dot1qPortVlanTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_req_info  = netsnmp_extract_table_info(request);

            switch (table_req_info->colnum)
            {
            case COLUMN_DOT1QPVID:
                table_entry->old_dot1qPvid = table_entry->dot1qPvid;
                table_entry->dot1qPvid     = *request->requestvb->val.integer;
                break;

            case COLUMN_DOT1QPORTGVRPSTATUS:
                table_entry->old_dot1qPortGvrpStatus = table_entry->dot1qPortGvrpStatus;
                table_entry->dot1qPortGvrpStatus     = *request->requestvb->val.integer;
                break;

            }
        }
        break;

    case MODE_SET_COMMIT:
        /* SET第四阶段,提交设置的值,并释放第三阶段的内存 */
        break;

    case MODE_SET_UNDO:
        /* 出错处理,MODE_SET_ACTION出错时调用
                  需要释放第三阶段分配的内存 */
        for (request=requests; request; request=request->next)
        {
            table_entry = (struct dot1qPortVlanTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_req_info  = netsnmp_extract_table_info( request);

            switch (table_req_info->colnum)
            {
            case COLUMN_DOT1QPVID:
                table_entry->dot1qPvid     = table_entry->old_dot1qPvid;
                table_entry->old_dot1qPvid = 0;
                break;

            case COLUMN_DOT1QPORTGVRPSTATUS:
                table_entry->dot1qPortGvrpStatus     = table_entry->old_dot1qPortGvrpStatus;
                table_entry->old_dot1qPortGvrpStatus = 0;
                break;

            }
        }
        break;

    }
    return SNMP_ERR_NOERROR;
}
示例#11
0
文件: qos.c 项目: AllardJ/Tomato
/** handles requests for the qosObjectTable table, if anything else needs to be done */
int
qosObjectTable_handler(netsnmp_mib_handler *handler,
                       netsnmp_handler_registration *reginfo,
                       netsnmp_agent_request_info *reqinfo,
                       netsnmp_request_info *requests)
{

    netsnmp_request_info *request;
    netsnmp_table_request_info *table_info;
    netsnmp_variable_list *var;
    struct commitInfo *ci = NULL;

    void           *data_context = NULL;

    oid            *suffix;
    size_t          suffix_len;

    /** column and row index encoded portion */
    suffix = requests->requestvb->name + reginfo->rootoid_len + 1;
    suffix_len = requests->requestvb->name_length -
        (reginfo->rootoid_len + 1);

    for (request = requests; request; request = request->next) {
        var = request->requestvb;
        if (request->processed != 0)
            continue;

        switch (reqinfo->mode) {
        case MODE_GET:
        case MODE_SET_RESERVE1:
            data_context = netsnmp_extract_iterator_context(request);
            if (data_context == NULL) {
                if (reqinfo->mode == MODE_GET) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
            }
            break;

        default:               /* == the other SET modes */
            ci = netsnmp_oid_stash_get_data(commitStorage,
                                            suffix + 1, suffix_len - 1);
            break;

        }

        /** extracts the information about the table from the request */
        table_info = netsnmp_extract_table_info(request);
        /** table_info->colnum contains the column number requested */
        /** table_info->indexes contains a linked list of snmp variable
           bindings for the indexes of the table.  Values in the list
           have been set corresponding to the indexes of the
           request */
        if (table_info == NULL) {
            continue;
        }

        switch (reqinfo->mode) {
        case MODE_GET:
            switch (table_info->colnum) {

            case COLUMN_QOSDEVICETYPE:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval = get_qosDeviceIndex(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSDEVICEINDEX:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval = get_qosDeviceIndex(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSMAJORHANDLE:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval = get_qosMajorHandle(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_UNSIGNED,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSMINORHANDLE:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval = get_qosMinorHandle(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_UNSIGNED,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSTEXTHANDLE:
                {
                    char *retval;
                    size_t          retval_len = 0;
                    retval = get_qosTextHandle(data_context, &retval_len);
                    snmp_set_var_typed_value(var,ASN_OCTET_STR,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSTEXTLEAF:
                {
                    char *retval;
                    size_t          retval_len = 0;
                    retval = get_qosTextLeaf(data_context, &retval_len);
                    snmp_set_var_typed_value(var,ASN_OCTET_STR,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSPARENT:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval = get_qosParent(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_UNSIGNED,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSTEXTPARENT:
                {
                    char *retval;
                    size_t          retval_len = 0;
                    retval = get_qosTextParent(data_context, &retval_len);
                    snmp_set_var_typed_value(var,ASN_OCTET_STR,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSDEVICENAME:
                {
                    char *retval;
                    size_t          retval_len = 0;
                    retval = get_qosDeviceName(data_context, &retval_len);
                    snmp_set_var_typed_value(var,ASN_OCTET_STR,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;


            case COLUMN_QOSTYPE:
                {
                    char *retval;
                    size_t          retval_len = 0;
                    retval = get_qosType(data_context, &retval_len);
                    snmp_set_var_typed_value(var,ASN_OCTET_STR,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSBYTES:
                {
                    unsigned long long     *retval;
//		    u_long		*retval;
                    size_t          retval_len = 0;
                    retval = get_qosBytes(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_COUNTER64,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSPACKETS:
                {
                    u_long         *retval;
                    size_t          retval_len = 0;
                    retval = get_qosPackets(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_COUNTER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSDROPPED:
                {
                    u_long         *retval;
                    size_t          retval_len = 0;
                    retval = get_qosDropped(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_COUNTER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSOVERLIMIT:
                {
                    u_long         *retval;
                    size_t          retval_len = 0;
                    retval = get_qosOverlimit(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_COUNTER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSBPS:
                {
                    u_long           *retval;
                    size_t          retval_len = 0;
                    retval = get_qosBps(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_UNSIGNED,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSPPS:
                {
                    u_long           *retval;
                    size_t          retval_len = 0;
                    retval = get_qosPps(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_UNSIGNED,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSQLEN:
                {
                    u_long           *retval;
                    size_t          retval_len = 0;
                    retval = get_qosQlen(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_UNSIGNED,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSBACKLOG:
                {
                    u_long           *retval;
                    size_t          retval_len = 0;
                    retval = get_qosBacklog(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_UNSIGNED,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSREDEARLY:
                {
                    u_long           *retval;
                    size_t          retval_len = 0;
                    retval = get_redEarly(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_COUNTER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSREDPDROP:
                {
                    u_long           *retval;
                    size_t          retval_len = 0;
                    retval = get_redPdrop(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_COUNTER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSREDOTHER:
                {
                    u_long           *retval;
                    size_t          retval_len = 0;
                    retval = get_redOther(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_COUNTER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSREDMARKED:
                {
                    u_long           *retval;
                    size_t          retval_len = 0;
                    retval = get_redMarked(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_COUNTER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSHTBLENDS:
                {
                    u_long           *retval;
                    size_t          retval_len = 0;
                    retval = get_htbLends(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_COUNTER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSHTBBORROWS:
                {
                    u_long           *retval;
                    size_t          retval_len = 0;
                    retval = get_htbBorrows(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_COUNTER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSHTBGIANTS:
                {
                    u_long           *retval;
                    size_t          retval_len = 0;
                    retval = get_htbGiants(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_COUNTER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSHTBTOKENS:
                {
                    u_long           *retval;
                    size_t          retval_len = 0;
                    retval = get_htbTokens(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSHTBCTOKENS:
                {
                    u_long           *retval;
                    size_t          retval_len = 0;
                    retval = get_htbCTokens(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSHTBRATE:
                {
                    u_long           *retval;
                    size_t          retval_len = 0;
                    retval = get_htbRate(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_UNSIGNED,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSHTBCEIL:
                {
                    u_long           *retval;
                    size_t          retval_len = 0;
                    retval = get_htbCeil(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_UNSIGNED,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSHTBPRIO:
                {
                    u_long           *retval;
                    size_t          retval_len = 0;
                    retval = get_htbPrio(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_UNSIGNED,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;
		
            case COLUMN_QOSCBQBORROWS:
                {
                    u_long           *retval;
                    size_t          retval_len = 0;
                    retval = get_cbqBorrows(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_COUNTER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;
		
            case COLUMN_QOSCBQOVERACTIONS:
                {
                    u_long           *retval;
                    size_t          retval_len = 0;
                    retval = get_cbqOveractions(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_COUNTER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSCBQAVGIDLE:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval = get_cbqUndertime(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_QOSCBQUNDERTIME:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval = get_cbqUndertime(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;
            case COLUMN_QOSINFO:
                {
                    char *retval;
                    size_t          retval_len = 0;
                    retval = get_qosInfo(data_context, &retval_len);
                    snmp_set_var_typed_value(var,ASN_OCTET_STR,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;
		
            default:
                /** We shouldn't get here */
                snmp_log(LOG_ERR,
                         "problem encountered in qosObjectTable_handler: unknown column\n");
            }
            break;

        case MODE_SET_RESERVE1:
            ci = netsnmp_oid_stash_get_data(commitStorage,
                                            suffix + 1, suffix_len - 1);

            if (!ci) {
                    /** create the commit storage info */
                ci = SNMP_MALLOC_STRUCT(commitInfo);
                if (!data_context) {
                    ci->data_context =
                        qosObjectTable_create_data_context(table_info->
                                                           indexes);
                    ci->new_row = 1;
                } else {
                    ci->data_context = data_context;
                }
                netsnmp_oid_stash_add_data(&commitStorage,
                                           suffix + 1, suffix_len - 1, ci);
            }
            break;

        case MODE_SET_RESERVE2:
            switch (table_info->colnum) {
            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOTWRITABLE);
                break;
            }
            break;

        case MODE_SET_ACTION:
            /** save a variable copy */
            switch (table_info->colnum) {
            }
            break;

        case MODE_SET_COMMIT:
            if (!ci->have_committed) {
                    /** do this once per row only */
                qosObjectTable_commit_row(&ci->data_context, ci->new_row);
                ci->have_committed = 1;
            }
            break;

        case MODE_SET_UNDO:
             /** save a variable copy */
            switch (table_info->colnum) {
            }
            break;

        case MODE_SET_FREE:
            break;

        default:
            snmp_log(LOG_ERR,
                     "problem encountered in qosObjectTable_handler: unsupported mode\n");
        }
    }

    /** clean up after all requset processing has ended */
    switch (reqinfo->mode) {
    case MODE_SET_UNDO:
    case MODE_SET_FREE:
    case MODE_SET_COMMIT:
        /** clear out the undo cache */
        netsnmp_oid_stash_free(&undoStorage, qos_free_undoInfo);
        netsnmp_oid_stash_free(&commitStorage, netsnmp_oid_stash_no_free);
    }


    return SNMP_ERR_NOERROR;
}
示例#12
0
static int
table_handler(netsnmp_mib_handler * handler,
			  netsnmp_handler_registration * reginfo,
			  netsnmp_agent_request_info * reqinfo, 
			  netsnmp_request_info * requests)
{
	netsnmp_request_info *request;

	DEBUG("Calling table handler\n");

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

		char *generic_stat_name;
		netsnmp_table_request_info *table_info;
		row_entry_t *entry;
		snmp_table_t *table_data;
		char *specific_stat_name;
		char index_str[3];
		int result;
		double stat_val;

		if (request->processed != 0) {
			continue;
		}

		table_info = netsnmp_extract_table_info(request);

		entry = (row_entry_t *) netsnmp_extract_iterator_context(request);

		if (entry == NULL) {
			continue;  
		}

		table_data = entry->table_data;

		if (table_info == NULL) {
			INFO("Couldn't get table info\n");
			continue; 
		}

		if (reqinfo->mode != MODE_GET) {
			continue;
		}

		DEBUG_OID(request->requestvb->name, request->requestvb->name_length);

		generic_stat_name = table_data->columns[table_info->colnum - 1].name;

		snprintf(index_str, sizeof(index_str), "%d", entry->index);
		specific_stat_name = replace_wildcard(generic_stat_name, index_str);

		if (specific_stat_name == NULL)
			return SNMP_ERR_GENERR;

		result = get_single_value_from_collectd(specific_stat_name, &stat_val);

		free(specific_stat_name);

		if (result != 0)
			return SNMP_ERR_GENERR;

		set_snmp_value(ASN_INTEGER, stat_val, request->requestvb);

	}

	return SNMP_ERR_NOERROR;
}
/** handles requests for the pcapFilterTable table */
int pcapFilterTable_handler (
	netsnmp_mib_handler		*handler,
	netsnmp_handler_registration	*reginfo,
	netsnmp_agent_request_info	*reqinfo,
	netsnmp_request_info		*requests
)
{
	netsnmp_request_info		*request;
	netsnmp_table_request_info	*table_info;
	netsnmp_variable_list		*var = NULL;
	struct filter			*filter = NULL;

	for (request = requests; request; request = request->next)
	{
		if (request->processed) continue;

		if (NULL == (filter = (struct filter*) netsnmp_extract_iterator_context (request)))
		{
			netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
			continue;
		}

		if (NULL == (table_info = netsnmp_extract_table_info (request)))
		{
			continue;
		}

/*		// Sanity checking.
		if (*table_info->indexes->val.integer != *index)
		{
			snmp_log (LOG_ERR, "pcapFilterTable_handler(): very odd mismatch of indicies (%ld, %ld).\n",
				*table_info->indexes->val.integer, *index);
			continue;
		}
*/
		var = request->requestvb;		// caching for brevity.

		if (MODE_GET != reqinfo->mode)
		{
			snmp_log (LOG_ERR, "pcapFilterTable_handler(), unsupported mode '%d'\n", reqinfo->mode);
			continue;
		}

//		fprintf (stderr, "snmp GET for %s, %d\n", filter->name, table_info->colnum);

		struct device *device = filter->parent_device;	// For brevity.

		switch (table_info->colnum)
		{
			case COLUMN_IFDESCR:
				netsnmp_set_var_string (var, device->dev_name);
				break;

			case COLUMN_FLTDESCR:
				netsnmp_set_var_string (var, filter->name);
				break;

			case COLUMN_FLTBPF:
				netsnmp_set_var_string (var, filter->bpf_text);
				break;

			case COLUMN_FLTPACKETS:
				netsnmp_set_var_counter64 (var, &(filter->packets));
				break;

			case COLUMN_FLTBYTES:
				netsnmp_set_var_counter64 (var, &(filter->bytes));
				break;

			case COLUMN_FLTTERMINAL:
				netsnmp_set_var_gauge (var, filter->terminal);
				break;

			default:
				netsnmp_set_request_error (reqinfo, request, SNMP_NOSUCHOBJECT);
				break;
		}
	}

	return SNMP_ERR_NOERROR;
}
示例#14
0
static int mib_dot1dBasePortTable_handler(netsnmp_mib_handler *handler,
                    netsnmp_handler_registration *reginfo,
                    netsnmp_agent_request_info *reqinfo,
                    netsnmp_request_info *requests)
{
    netsnmp_request_info       *request;
    netsnmp_table_request_info *table_req_info;
    struct dot1dBasePortTable_entry *table_entry;

    switch (reqinfo->mode)
    {
    case MODE_GET:
        for (request=requests; request; request=request->next)
        {
            table_entry = (struct dot1dBasePortTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_req_info  = netsnmp_extract_table_info(request);
            if(NULL == table_req_info)
            {
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOACCESS);
                continue;
            }

            switch (table_req_info->colnum)
            {
            case COLUMN_DOT1DBASEPORT:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            htonl(table_entry->dot1dBasePort));
                break;

            case COLUMN_DOT1DBASEPORTIFINDEX:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            htonl(table_entry->dot1dBasePortIfIndex));
                break;

            case COLUMN_DOT1DBASEPORTCIRCUIT:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_value( request->requestvb, ASN_OBJECT_ID,
                                 (u_char*)table_entry->dot1dBasePortCircuit,
                                          table_entry->dot1dBasePortCircuit_len);
                break;

            case COLUMN_DOT1DBASEPORTDELAYEXCEEDEDDISCARDS:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_COUNTER,
                                            htonl(table_entry->dot1dBasePortDelayExceededDiscards));
                break;

            case COLUMN_DOT1DBASEPORTMTUEXCEEDEDDISCARDS:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_COUNTER,
                                            htonl(table_entry->dot1dBasePortMtuExceededDiscards));
                break;

            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_NOSUCHOBJECT);
                break;

            }
        }
        break;

    }
    return SNMP_ERR_NOERROR;
}
示例#15
0
/** handles requests for the dot1dBasePortTable table, if anything else needs to be done */
int
dot1dBasePortTable_handler(
  netsnmp_mib_handler               *handler,
  netsnmp_handler_registration      *reginfo,
  netsnmp_agent_request_info        *reqinfo,
  netsnmp_request_info              *requests) {

  netsnmp_request_info *request;
  netsnmp_table_request_info *table_info;
  netsnmp_variable_list *var;

  void *data_context = NULL;

  (void) reginfo;
  (void) handler;

  for (request = requests; request; request = request->next) {
    var = request->requestvb;
    if (request->processed != 0) {
      continue;
    }

    switch (reqinfo->mode) {
      case MODE_GET:
        data_context =  netsnmp_extract_iterator_context(request);
        if (data_context == NULL) {
          netsnmp_set_request_error(reqinfo, request,
                                    SNMP_NOSUCHINSTANCE);
          continue;
        }
        break;

    }

    /** extracts the information about the table from the request */
    table_info = netsnmp_extract_table_info(request);
    /** table_info->colnum contains the column number requested */
    /** table_info->indexes contains a linked list of snmp variable
        bindings for the indexes of the table.  Values in the list
        have been set corresponding to the indexes of the
        request */
    if (table_info == NULL) {
      continue;
    }

    switch (reqinfo->mode) {
      case MODE_GET:
        switch (table_info->colnum) {
          case COLUMN_DOT1DBASEPORT: {
            int32_t *retval;
            size_t retval_len = 0;
            retval = get_dot1dBasePort(data_context, &retval_len);
            if (retval)
              snmp_set_var_typed_value(var, ASN_INTEGER,
                                       (const u_char *) retval,
                                       retval_len);
          }
          break;

          case COLUMN_DOT1DBASEPORTIFINDEX: {
            int32_t *retval;
            size_t retval_len = 0;
            retval = get_dot1dBasePortIfIndex(data_context, &retval_len);
            if (retval)
              snmp_set_var_typed_value(var, ASN_INTEGER,
                                       (const u_char *) retval,
                                       retval_len);
          }
          break;

          case COLUMN_DOT1DBASEPORTCIRCUIT: {
            oid *retval;
            size_t retval_len = 0;
            retval = get_dot1dBasePortCircuit(data_context, &retval_len);
            if (retval)
              snmp_set_var_typed_value(var, ASN_OBJECT_ID,
                                       (const u_char *) retval,
                                       retval_len);
          }
          break;

          case COLUMN_DOT1DBASEPORTDELAYEXCEEDEDDISCARDS: {
            uint32_t *retval;
            size_t retval_len = 0;
            retval = get_dot1dBasePortDelayExceededDiscards(data_context, &retval_len);
            if (retval)
              snmp_set_var_typed_value(var, ASN_COUNTER,
                                       (const u_char *) retval,
                                       retval_len);
          }
          break;

          case COLUMN_DOT1DBASEPORTMTUEXCEEDEDDISCARDS: {
            uint32_t *retval;
            size_t retval_len = 0;
            retval = get_dot1dBasePortMtuExceededDiscards(data_context, &retval_len);
            if (retval)
              snmp_set_var_typed_value(var, ASN_COUNTER,
                                       (const u_char *) retval,
                                       retval_len);
          }
          break;

          default:
            /** We shouldn't get here */
            snmp_log(LOG_ERR,
                     "problem encountered in dot1dBasePortTable_handler: unknown column\n");
        }
        break;


      default:
        snmp_log(LOG_ERR,
                 "problem encountered in dot1dBasePortTable_handler: unsupported mode\n");
    }
  }


  return SNMP_ERR_NOERROR;
}
示例#16
0
/** handles requests for the pgsqlPgAmopTable table */
int
pgsqlPgAmopTable_handler(
    netsnmp_mib_handler               *handler,
    netsnmp_handler_registration      *reginfo,
    netsnmp_agent_request_info        *reqinfo,
    netsnmp_request_info              *requests) {

    netsnmp_request_info       *request;
    netsnmp_table_request_info *table_info;
    struct pgsqlPgAmopTable_entry          *table_entry;

    snmp_log(LOG_INFO, "Handler called\n");
    switch (reqinfo->mode) {
        /*
         * Read-support (also covers GetNext requests)
         */
    case MODE_GET:
        for (request=requests; request; request=request->next) {
            table_entry = (struct pgsqlPgAmopTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);
    
            switch (table_info->colnum) {
            case COLUMN_PGSQLPGAMOPENTRYOID:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->pgsqlPgAmopEntryOID);
                break;
            case COLUMN_PGSQLPGAMOPAMOPFAMILY:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->pgsqlPgAmopAmopfamily);
                break;
            case COLUMN_PGSQLPGAMOPAMOPLEFTTYPE:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->pgsqlPgAmopAmoplefttype);
                break;
            case COLUMN_PGSQLPGAMOPAMOPRIGHTTYPE:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->pgsqlPgAmopAmoprighttype);
                break;
            case COLUMN_PGSQLPGAMOPAMOPSTRATEGY:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->pgsqlPgAmopAmopstrategy);
                break;
            case COLUMN_PGSQLPGAMOPAMOPREQCHECK:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->pgsqlPgAmopAmopreqcheck);
                break;
            case COLUMN_PGSQLPGAMOPAMOPOPR:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->pgsqlPgAmopAmopopr);
                break;
            case COLUMN_PGSQLPGAMOPAMOPMETHOD:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->pgsqlPgAmopAmopmethod);
                break;
            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_NOSUCHOBJECT);
                break;
            }
        }
        break;

    }
    return SNMP_ERR_NOERROR;
}
示例#17
0
/** handles requests for the dot11WtpKeyConfigTable table */
int
dot11WtpKeyConfigTable_handler(
    netsnmp_mib_handler               *handler,
    netsnmp_handler_registration      *reginfo,
    netsnmp_agent_request_info        *reqinfo,
    netsnmp_request_info              *requests) {

    netsnmp_request_info       *request;
    netsnmp_table_request_info *table_info;
    struct dot11WtpKeyConfigTable_entry          *table_entry;

    switch (reqinfo->mode) {
        /*
         * Read-support (also covers GetNext requests)
         */
    case MODE_GET:
        for (request=requests; request; request=request->next) {
            table_entry = (struct dot11WtpKeyConfigTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);


			if( !table_entry ){
								netsnmp_set_request_error(reqinfo,request,SNMP_NOSUCHINSTANCE);
								continue;
							}  

	
            switch (table_info->colnum) {
            case COLUMN_CIPHERKEYINDEX:
                snmp_set_var_typed_value( request->requestvb, ASN_INTEGER,
                                          (u_char*)&table_entry->CipherKeyIndex,
                                          sizeof(long));
                break;
            case COLUMN_CIPHERKEYVALUE:
                snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
                                          (u_char*)table_entry->CipherKeyValue,
                                          strlen(table_entry->CipherKeyValue));
                break;
            case COLUMN_CIPHERKEYCHARTYPE:
                snmp_set_var_typed_value( request->requestvb, ASN_INTEGER,
                                          (u_char*)&table_entry->CipherKeyCharType,
                                          sizeof(long));
                break;
            }
        }
        break;

        /*
         * Write-support
         */
    case MODE_SET_RESERVE1:
        for (request=requests; request; request=request->next) {
            table_entry = (struct dot11WtpKeyConfigTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);
    
            switch (table_info->colnum) {
            case COLUMN_CIPHERKEYVALUE:
                if ( request->requestvb->type != ASN_OCTET_STR ) {
                    netsnmp_set_request_error( reqinfo, request,
                                               SNMP_ERR_WRONGTYPE );
                    return SNMP_ERR_NOERROR;
                }
                /* Also may need to check size/value */
                break;
            case COLUMN_CIPHERKEYCHARTYPE:
                if ( request->requestvb->type != ASN_INTEGER ) {
                    netsnmp_set_request_error( reqinfo, request,
                                               SNMP_ERR_WRONGTYPE );
                    return SNMP_ERR_NOERROR;
                }
                /* Also may need to check size/value */
                break;
            default:
                netsnmp_set_request_error( reqinfo, request,
                                           SNMP_ERR_NOTWRITABLE );
                return SNMP_ERR_NOERROR;
            }
        }
        break;

    case MODE_SET_RESERVE2:
        break;

    case MODE_SET_FREE:
        break;

    case MODE_SET_ACTION:
        for (request=requests; request; request=request->next) {
            table_entry = (struct dot11WtpKeyConfigTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);
    
            switch (table_info->colnum) {
            case COLUMN_CIPHERKEYVALUE:
                /* Need to save old 'table_entry->CipherKeyValue' value.
                   May need to use 'memcpy' */
                table_entry->old_CipherKeyValue = table_entry->CipherKeyValue;
             //   table_entry->CipherKeyValue     = request->requestvb->val.YYY;
                break;
            case COLUMN_CIPHERKEYCHARTYPE:
                /* Need to save old 'table_entry->CipherKeyCharType' value.
                   May need to use 'memcpy' */
                table_entry->old_CipherKeyCharType = table_entry->CipherKeyCharType;
             //   table_entry->CipherKeyCharType     = request->requestvb->val.YYY;
                break;
            }
        }
        break;

    case MODE_SET_UNDO:
        for (request=requests; request; request=request->next) {
            table_entry = (struct dot11WtpKeyConfigTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);
    
            switch (table_info->colnum) {
            case COLUMN_CIPHERKEYVALUE:
                /* Need to restore old 'table_entry->CipherKeyValue' value.
                   May need to use 'memcpy' */
                table_entry->CipherKeyValue = table_entry->old_CipherKeyValue;
                break;
            case COLUMN_CIPHERKEYCHARTYPE:
                /* Need to restore old 'table_entry->CipherKeyCharType' value.
                   May need to use 'memcpy' */
                table_entry->CipherKeyCharType = table_entry->old_CipherKeyCharType;
                break;
            }
        }
        break;

    case MODE_SET_COMMIT:
        break;
    }
    return SNMP_ERR_NOERROR;
}
/** handles requests for the dot11WidDetectHistoryTable table */
int
dot11WidDetectHistoryTable_handler(
    netsnmp_mib_handler               *handler,
    netsnmp_handler_registration      *reginfo,
    netsnmp_agent_request_info        *reqinfo,
    netsnmp_request_info              *requests) {

    netsnmp_request_info       *request;
    netsnmp_table_request_info *table_info;
    struct dot11WidDetectHistoryTable_entry          *table_entry;

    switch (reqinfo->mode) {
        /*
         * Read-support (also covers GetNext requests)
         */
    case MODE_GET:
        for (request=requests; request; request=request->next) {
            table_entry = (struct dot11WidDetectHistoryTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);
    if( !table_entry ){
        		netsnmp_set_request_error(reqinfo,request,SNMP_NOSUCHINSTANCE);
				continue;
	    	}     
            switch (table_info->colnum) {
            case COLUMN_DEVICEID:
                snmp_set_var_typed_value( request->requestvb, ASN_INTEGER,
                                          (u_char *)&table_entry->deviceID,
                                          sizeof(long));
                break;
            case COLUMN_DEVICEMAC:
                snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
                                          (u_char *)table_entry->deviceMac,
                                          strlen(table_entry->deviceMac));
                break;
            case COLUMN_ATTACKTYPE:
                snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
                                          (u_char *)table_entry->attackType,
                                          strlen(table_entry->attackType));
                break;
            case COLUMN_FRAMETYPE:
                snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
                                          (u_char *)table_entry->frameType,
                                          strlen(table_entry->frameType));
                break;
            case COLUMN_ATTACKCOUNT:
                snmp_set_var_typed_value( request->requestvb, ASN_COUNTER,
                                          (u_char *)&table_entry->attackCount,
                                          sizeof(u_long));
                break;
            case COLUMN_FIRSTATTACK:
                snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
                                          (u_char *)table_entry->firstAttack,
                                          strlen(table_entry->firstAttack));
                break;
            case COLUMN_LASTATTACK:
                snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
                                          (u_char *)table_entry->lastAttack,
                                          strlen(table_entry->lastAttack));
                break;
			case COLUMN_ROGSTAMONAPNUM:
                snmp_set_var_typed_value( request->requestvb, ASN_INTEGER,
                                          (u_char *)&table_entry->RogStaMonApNum,
                                          sizeof(long));
                break;
			case COLUMN_ROGSTAACCBSSID:
                snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
                                          (u_char *)table_entry->RogStaAccBSSID,
                                          strlen(table_entry->RogStaAccBSSID));
                break;
			case COLUMN_ROGSTAMAXSIGSTRENGTH:
                snmp_set_var_typed_value( request->requestvb, ASN_INTEGER,
                                          (u_char *)&table_entry->RogStaMaxSigStrength,
                                          sizeof(long));
                break;
			case COLUMN_ROGSTACHANNEL:
                snmp_set_var_typed_value( request->requestvb, ASN_INTEGER,
                                          (u_char *)&table_entry->RogStaChannel,
                                          sizeof(long));
                break;
			case COLUMN_ROGSTAADHOCSTATUS:
                snmp_set_var_typed_value( request->requestvb, ASN_INTEGER,
                                          (u_char *)&table_entry->RogStaAdHocStatus,
                                          sizeof(long));
                break;
			case COLUMN_ROGSTAATTACKSTATUS:
			{
			    void *connection = NULL;
                if(SNMPD_DBUS_ERROR == get_slot_dbus_connection(table_entry->parameter.slot_id, &connection, SNMPD_INSTANCE_MASTER_V3))
                    break;
                    
				int RogStaAttackStatus = 2;
				int ret = 0;
				DCLI_WTP_API_GROUP_THREE *WTPINFO = NULL;   

				ret = show_ap_wids_set_cmd_func(table_entry->parameter, connection, &WTPINFO);
				if(ret==1)
				{
					if(WTPINFO->wids.weakiv==1)
						RogStaAttackStatus = 1; 
					else
						RogStaAttackStatus = 2;
				}
				else if(SNMPD_CONNECTION_ERROR == ret) {
                    close_slot_dbus_connection(table_entry->parameter.slot_id);
        	    }
				
                snmp_set_var_typed_value( request->requestvb, ASN_INTEGER,
                                          (u_char *)&RogStaAttackStatus,
                                          sizeof(RogStaAttackStatus));
				if(ret==1)
				{
					free_show_ap_wids_set_cmd(WTPINFO);
				}
			}
                break;
			case COLUMN_ROGSTATOIGNORE:
                snmp_set_var_typed_value( request->requestvb, ASN_INTEGER,
                                          (u_char *)&table_entry->RogStaToIgnore,
                                          sizeof(long));
                break;
            }
        }
        break;
	        /*
         * Write-support
         */
    case MODE_SET_RESERVE1:
        for (request=requests; request; request=request->next) {
            table_entry = (struct dot11WidDetectHistoryTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);
    
            switch (table_info->colnum) {
            case COLUMN_ROGSTAATTACKSTATUS:
                if ( request->requestvb->type != ASN_INTEGER ) {
                    netsnmp_set_request_error( reqinfo, request,
                                               SNMP_ERR_WRONGTYPE );
                    return SNMP_ERR_NOERROR;
                }
                /* Also may need to check size/value */
                break;
			case COLUMN_ROGSTATOIGNORE:
                if ( request->requestvb->type != ASN_INTEGER ) {
                    netsnmp_set_request_error( reqinfo, request,
                                               SNMP_ERR_WRONGTYPE );
                    return SNMP_ERR_NOERROR;
                }
                /* Also may need to check size/value */
                break;
            default:
                netsnmp_set_request_error( reqinfo, request,
                                           SNMP_ERR_NOTWRITABLE );
                return SNMP_ERR_NOERROR;
            }
        }
        break;

    case MODE_SET_RESERVE2:
        break;

    case MODE_SET_FREE:
        break;

    case MODE_SET_ACTION:
        for (request=requests; request; request=request->next) {
            table_entry = (struct dot11WidDetectHistoryTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);
    
            switch (table_info->colnum) {
            case COLUMN_ROGSTAATTACKSTATUS:
			{
                void *connection = NULL;
                if(SNMPD_DBUS_ERROR == get_instance_dbus_connection(table_entry->parameter, &connection, SNMPD_INSTANCE_MASTER_V3))
                    return MFD_ERROR;
                    
				int ret = 0;

				if(*request->requestvb->val.integer==1)
				{
					ret = set_wtp_wids_policy_cmd(table_entry->parameter, connection,"forbid");
					if(ret != 1)
					{
					    if(SNMPD_CONNECTION_ERROR == ret) {
                            close_slot_dbus_connection(table_entry->parameter.slot_id);
                	    }
						netsnmp_set_request_error(reqinfo,request,SNMP_ERR_WRONGTYPE);
					}
				}
				else if(*request->requestvb->val.integer==2)
				{
					ret = set_wtp_wids_policy_cmd(table_entry->parameter, connection,"no");
					if(ret != 1)
					{
					    if(SNMPD_CONNECTION_ERROR == ret) {
                            close_slot_dbus_connection(table_entry->parameter.slot_id);
                	    }
						netsnmp_set_request_error(reqinfo,request,SNMP_ERR_WRONGTYPE);
					}
				}
				else
				{
					netsnmp_set_request_error(reqinfo,request,SNMP_ERR_WRONGTYPE);
				}

        	}
                break;
			case COLUMN_ROGSTATOIGNORE:
			{
                void *connection = NULL;
                if(SNMPD_DBUS_ERROR == get_instance_dbus_connection(table_entry->parameter, &connection, SNMPD_INSTANCE_MASTER_V3))
                    return MFD_ERROR;
                    
				int ret = 0;

				if(*request->requestvb->val.integer==1)
				{
					ret = add_wids_mac_cmd(table_entry->parameter, connection,table_entry->deviceMac);	
					if(ret != 1)
					{
					    if(SNMPD_CONNECTION_ERROR == ret) {
                            close_slot_dbus_connection(table_entry->parameter.slot_id);
                	    }
						netsnmp_set_request_error(reqinfo,request,SNMP_ERR_WRONGTYPE);
					}
				}
				else if(*request->requestvb->val.integer!=2)
				{
					netsnmp_set_request_error(reqinfo,request,SNMP_ERR_WRONGTYPE);
				}
        	}
                break;
            }
        }
        break;

    case MODE_SET_UNDO:
        for (request=requests; request; request=request->next) {
            table_entry = (struct dot11WidDetectHistoryTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);
    
            switch (table_info->colnum) {
            case COLUMN_ROGSTAATTACKSTATUS:
                /* Need to restore old 'table_entry->RogStaAttackStatus' value.
                   May need to use 'memcpy' */
                table_entry->RogStaAttackStatus= table_entry->old_RogStaAttackStatus;
                break;
			case COLUMN_ROGSTATOIGNORE:
                /* Need to restore old 'table_entry->RogStaToIgnore' value.
                   May need to use 'memcpy' */
                table_entry->RogStaToIgnore= table_entry->old_RogStaToIgnore;
                break;
            }
        }
        break;

    case MODE_SET_COMMIT:
        break;

    }
    return SNMP_ERR_NOERROR;
}
示例#19
0
int
handle_nsDebugTable(netsnmp_mib_handler *handler,
                netsnmp_handler_registration *reginfo,
                netsnmp_agent_request_info *reqinfo,
                netsnmp_request_info *requests)
{
    long status;
    netsnmp_request_info       *request    =NULL;
    netsnmp_table_request_info *table_info    =NULL;
    netsnmp_token_descr        *debug_entry=NULL;

    switch (reqinfo->mode) {

    case MODE_GET:
        for (request=requests; request; request=request->next) {
            if (request->processed != 0)
                continue;
            debug_entry = (netsnmp_token_descr*)
                           netsnmp_extract_iterator_context(request);
            if (!debug_entry)
                continue;
	    status = (debug_entry->enabled ? RS_ACTIVE : RS_NOTINSERVICE);
	    snmp_set_var_typed_value(request->requestvb, ASN_INTEGER,
                                     (u_char*)&status, sizeof(status));
	}
	break;


#ifndef NETSNMP_NO_WRITE_SUPPORT
    case MODE_SET_RESERVE1:
	for (request = requests; request; request=request->next) {
            if (request->processed != 0)
                continue;
            if ( request->status != 0 ) {
                return SNMP_ERR_NOERROR;	/* Already got an error */
            }
            if ( request->requestvb->type != ASN_INTEGER ) {
                netsnmp_set_request_error(reqinfo, request, SNMP_ERR_WRONGTYPE);
                return SNMP_ERR_WRONGTYPE;
            }

            debug_entry = (netsnmp_token_descr*)
                           netsnmp_extract_iterator_context(request);
            switch (*request->requestvb->val.integer) {
            case RS_ACTIVE:
            case RS_NOTINSERVICE:
                /*
		 * These operations require an existing row
		 */
                if (!debug_entry) {
		    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_ERR_INCONSISTENTVALUE);
                    return SNMP_ERR_INCONSISTENTVALUE;
		}
		break;

            case RS_CREATEANDWAIT:
            case RS_CREATEANDGO:
                /*
		 * These operations assume the row doesn't already exist
		 */
                if (debug_entry) {
		    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_ERR_INCONSISTENTVALUE);
                    return SNMP_ERR_INCONSISTENTVALUE;
		}
		break;

            case RS_DESTROY:
                /*
		 * This operation can work regardless
		 */
		break;

            case RS_NOTREADY:
            default:
		netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_WRONGVALUE);
                return SNMP_ERR_WRONGVALUE;
	    }
        }
        break;


    case MODE_SET_COMMIT:
	for (request = requests; request; request=request->next) {
            if (request->processed != 0)
                continue;
            if ( request->status != 0 ) {
                return SNMP_ERR_NOERROR;	/* Already got an error */
            }

            switch (*request->requestvb->val.integer) {
            case RS_ACTIVE:
            case RS_NOTINSERVICE:
                /*
		 * Update the enabled field appropriately
		 */
                debug_entry = (netsnmp_token_descr*)
                               netsnmp_extract_iterator_context(request);
                if (debug_entry)
                    debug_entry->enabled =
                        (*request->requestvb->val.integer == RS_ACTIVE);
		break;

            case RS_CREATEANDWAIT:
            case RS_CREATEANDGO:
                /*
		 * Create the entry, and set the enabled field appropriately
		 */
                table_info = netsnmp_extract_table_info(request);
                debug_register_tokens((char *) table_info->indexes->val.string);
#ifdef UMMMMM
                if (*request->requestvb->val.integer == RS_CREATEANDWAIT) {
		    /* XXX - how to locate the entry ??  */
		    debug_entry->enabled = 0;
		}
#endif
		break;

            case RS_DESTROY:
                /*
		 * XXX - there's no "remove" API  :-(
		 */
                debug_entry = (netsnmp_token_descr*)
                               netsnmp_extract_iterator_context(request);
                if (debug_entry) {
		    debug_entry->enabled = 0;
		    free(debug_entry->token_name);
		    debug_entry->token_name = NULL;
		}
		break;
	    }
        }
        break;
#endif /* !NETSNMP_NO_WRITE_SUPPORT */
    }

    return SNMP_ERR_NOERROR;
}
示例#20
0
/** handles requests for the raidSetTable table */
int
raidSetTable_handler(
    netsnmp_mib_handler               *handler,
    netsnmp_handler_registration      *reginfo,
    netsnmp_agent_request_info        *reqinfo,
    netsnmp_request_info              *requests) {

    netsnmp_request_info       *request;
    netsnmp_table_request_info *table_info;
    struct raidSetTable_entry          *table_entry;

    switch (reqinfo->mode) {
        /*
         * Read-support (also covers GetNext requests)
         */
    case MODE_GET:
        update_setlist_if_necessary();
        for (request=requests; request; request=request->next) {
            table_entry = (struct raidSetTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);
    
            switch (table_info->colnum) {
            case COLUMN_RAIDSETNAME:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
                                 (u_char*)table_entry->raidSetName,
                                          table_entry->raidSetName_len);
                break;
            case COLUMN_RAIDSETTYPE:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
                                 (u_char*)table_entry->raidSetType,
                                          table_entry->raidSetType_len);
                break;
            case COLUMN_RAIDSETSIZE:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_GAUGE,
                                            table_entry->raidSetSize);
                break;
            case COLUMN_RAIDSETUNUSED:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_GAUGE,
                                            table_entry->raidSetUnused);
                break;
            case COLUMN_RAIDSETCOMMENTS:
                if ( !table_entry ) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
                                 (u_char*)table_entry->raidSetComments,
                                          table_entry->raidSetComments_len);
                break;
            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_NOSUCHOBJECT);
                break;
            }
        }
        break;

    }
    return SNMP_ERR_NOERROR;
}
/* neIeee8021QBridgeVlanCurrentTable table mapper */
int
neIeee8021QBridgeVlanCurrentTable_mapper (
	netsnmp_mib_handler *handler,
	netsnmp_handler_registration *reginfo,
	netsnmp_agent_request_info *reqinfo,
	netsnmp_request_info *requests)
{
	netsnmp_request_info *request;
	netsnmp_table_request_info *table_info;
	neIeee8021QBridgeVlanCurrentEntry_t *table_entry;
	register ieee8021QBridgeVlanCurrentEntry_t *poEntry = NULL;
	void *pvOldDdata = NULL;
	int ret;
	
	switch (reqinfo->mode)
	{
	/*
	 * Read-support (also covers GetNext requests)
	 */
	case MODE_GET:
		for (request = requests; request != NULL; request = request->next)
		{
			poEntry = (ieee8021QBridgeVlanCurrentEntry_t*) netsnmp_extract_iterator_context (request);
			table_info = netsnmp_extract_table_info (request);
			if (poEntry == NULL)
			{
				netsnmp_set_request_error (reqinfo, request, SNMP_NOSUCHINSTANCE);
				continue;
			}
			table_entry = &poEntry->oNe;
			
			switch (table_info->colnum)
			{
			case NEIEEE8021QBRIDGEVLANCURRENTADMINFLAGS:
				snmp_set_var_typed_value (request->requestvb, ASN_OCTET_STR, (u_char*) table_entry->au8AdminFlags, table_entry->u16AdminFlags_len);
				break;
			case NEIEEE8021QBRIDGEVLANCURRENTOPERSTATE:
				snmp_set_var_typed_integer (request->requestvb, ASN_INTEGER, table_entry->i32OperState);
				break;
			case NEIEEE8021QBRIDGEVLANCURRENTLEARNT:
				snmp_set_var_typed_value (request->requestvb, ASN_OCTET_STR, (u_char*) table_entry->pu8Learnt, table_entry->u16Learnt_len);
				break;
			case NEIEEE8021QBRIDGEVLANCURRENTIFINDEX:
				snmp_set_var_typed_integer (request->requestvb, ASN_INTEGER, table_entry->u32IfIndex);
				break;
				
			default:
				netsnmp_set_request_error (reqinfo, request, SNMP_NOSUCHOBJECT);
				break;
			}
		}
		break;
		
	/*
	 * Write-support
	 */
	case MODE_SET_RESERVE1:
		for (request = requests; request != NULL; request = request->next)
		{
			poEntry = (ieee8021QBridgeVlanCurrentEntry_t*) netsnmp_extract_iterator_context (request);
			table_info = netsnmp_extract_table_info (request);
			table_entry = &poEntry->oNe;
			
			switch (table_info->colnum)
			{
			case NEIEEE8021QBRIDGEVLANCURRENTADMINFLAGS:
				ret = netsnmp_check_vb_type_and_max_size (request->requestvb, ASN_OCTET_STR, sizeof (table_entry->au8AdminFlags));
				if (ret != SNMP_ERR_NOERROR)
				{
					netsnmp_set_request_error (reqinfo, request, ret);
					return SNMP_ERR_NOERROR;
				}
				break;
				
			default:
				netsnmp_set_request_error (reqinfo, request, SNMP_ERR_NOTWRITABLE);
				return SNMP_ERR_NOERROR;
			}
		}
		break;
		
	case MODE_SET_RESERVE2:
		for (request = requests; request != NULL; request = request->next)
		{
			poEntry = (ieee8021QBridgeVlanCurrentEntry_t*) netsnmp_extract_iterator_context (request);
			table_info = netsnmp_extract_table_info (request);
			if (poEntry == NULL)
			{
				netsnmp_set_request_error (reqinfo, request, SNMP_NOSUCHINSTANCE);
				continue;
			}
			table_entry = &poEntry->oNe;
			
			switch (table_info->colnum)
			{
			case NEIEEE8021QBRIDGEVLANCURRENTADMINFLAGS:
				if (poEntry->u8RowStatus == xRowStatus_active_c || poEntry->u8RowStatus == xRowStatus_notReady_c)
				{
					netsnmp_set_request_error (reqinfo, request, SNMP_ERR_RESOURCEUNAVAILABLE);
					return SNMP_ERR_NOERROR;
				}
				break;
			}
		}
		break;
		
	case MODE_SET_FREE:
		break;
		
	case MODE_SET_ACTION:
		for (request = requests; request != NULL; request = request->next)
		{
			pvOldDdata = netsnmp_request_get_list_data (request, ROLLBACK_BUFFER);
			poEntry = (ieee8021QBridgeVlanCurrentEntry_t*) netsnmp_extract_iterator_context (request);
			table_info = netsnmp_extract_table_info (request);
			table_entry = &poEntry->oNe;
			
			switch (table_info->colnum)
			{
			case NEIEEE8021QBRIDGEVLANCURRENTADMINFLAGS:
				if (pvOldDdata == NULL && (pvOldDdata = xBuffer_cAlloc (sizeof (xOctetString_t) + sizeof (table_entry->au8AdminFlags))) == NULL)
				{
					netsnmp_set_request_error (reqinfo, request, SNMP_ERR_RESOURCEUNAVAILABLE);
					return SNMP_ERR_NOERROR;
				}
				else if (pvOldDdata != table_entry)
				{
					((xOctetString_t*) pvOldDdata)->pData = pvOldDdata + sizeof (xOctetString_t);
					((xOctetString_t*) pvOldDdata)->u16Len = table_entry->u16AdminFlags_len;
					memcpy (((xOctetString_t*) pvOldDdata)->pData, table_entry->au8AdminFlags, sizeof (table_entry->au8AdminFlags));
					netsnmp_request_add_list_data (request, netsnmp_create_data_list (ROLLBACK_BUFFER, pvOldDdata, &xBuffer_free));
				}
				
				memset (table_entry->au8AdminFlags, 0, sizeof (table_entry->au8AdminFlags));
				memcpy (table_entry->au8AdminFlags, request->requestvb->val.string, request->requestvb->val_len);
				table_entry->u16AdminFlags_len = request->requestvb->val_len;
				break;
			}
		}
		break;
		
	case MODE_SET_UNDO:
		for (request = requests; request != NULL; request = request->next)
		{
			pvOldDdata = netsnmp_request_get_list_data (request, ROLLBACK_BUFFER);
			poEntry = (ieee8021QBridgeVlanCurrentEntry_t*) netsnmp_extract_iterator_context (request);
			table_info = netsnmp_extract_table_info (request);
			if (poEntry == NULL || pvOldDdata == NULL)
			{
				continue;
			}
			table_entry = &poEntry->oNe;
			
			switch (table_info->colnum)
			{
			case NEIEEE8021QBRIDGEVLANCURRENTADMINFLAGS:
				memcpy (table_entry->au8AdminFlags, ((xOctetString_t*) pvOldDdata)->pData, ((xOctetString_t*) pvOldDdata)->u16Len);
				table_entry->u16AdminFlags_len = ((xOctetString_t*) pvOldDdata)->u16Len;
				break;
			}
		}
		break;
		
	case MODE_SET_COMMIT:
		break;
	}
	
	return SNMP_ERR_NOERROR;
}
示例#22
0
int
handle_nsLoggingTable(netsnmp_mib_handler *handler,
                netsnmp_handler_registration *reginfo,
                netsnmp_agent_request_info *reqinfo,
                netsnmp_request_info *requests)
{
    long temp;
    netsnmp_request_info       *request     = NULL;
    netsnmp_table_request_info *table_info  = NULL;
    netsnmp_log_handler        *logh        = NULL;
    netsnmp_variable_list      *idx         = NULL;

    switch (reqinfo->mode) {

    case MODE_GET:
        for (request=requests; request; request=request->next) {
            if (request->processed != 0)
                continue;
            logh = (netsnmp_log_handler*)netsnmp_extract_iterator_context(request);
            table_info  =                netsnmp_extract_table_info(request);

            switch (table_info->colnum) {
            case NSLOGGING_TYPE:
                if (!logh) {
                    netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
                    continue;
		}
		temp = logh->type;
	        snmp_set_var_typed_value(request->requestvb, ASN_INTEGER,
                                         (u_char*)&temp,
                                            sizeof(temp));
	        break;

            case NSLOGGING_MAXLEVEL:
                if (!logh) {
                    netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
                    continue;
		}
		temp = logh->pri_max;
	        snmp_set_var_typed_value(request->requestvb, ASN_INTEGER,
                                         (u_char*)&temp,
                                            sizeof(temp));
	        break;

            case NSLOGGING_STATUS:
                if (!logh) {
                    netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
                    continue;
		}
		temp = (logh->type ?
	                   (logh->enabled ?
	                      RS_ACTIVE:
	                      RS_NOTINSERVICE) :
	                    RS_NOTREADY);
	        snmp_set_var_typed_value(request->requestvb, ASN_INTEGER,
                                         (u_char*)&temp, sizeof(temp));
	        break;

            default:
                netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
                continue;
	    }
	}
	break;


#ifndef NETSNMP_NO_WRITE_SUPPORT
    case MODE_SET_RESERVE1:
        for (request=requests; request; request=request->next) {
            if ( request->status != 0 ) {
                return SNMP_ERR_NOERROR;	/* Already got an error */
            }
            logh = (netsnmp_log_handler*)netsnmp_extract_iterator_context(request);
            table_info  =                 netsnmp_extract_table_info(request);

            switch (table_info->colnum) {
            case NSLOGGING_TYPE:
                if ( request->requestvb->type != ASN_INTEGER ) {
                    netsnmp_set_request_error(reqinfo, request, SNMP_ERR_WRONGTYPE);
                    return SNMP_ERR_WRONGTYPE;
                }
                if (*request->requestvb->val.integer < 0 ) {
                    netsnmp_set_request_error(reqinfo, request, SNMP_ERR_WRONGVALUE);
                    return SNMP_ERR_WRONGVALUE;
                }
		/*
		 * It's OK to create a new logging entry
		 *  (either in one go, or built up using createAndWait)
		 *  but it's not possible to change the type of an entry
		 *  once it's been created.
		 */
                if (logh && logh->type) {
                    netsnmp_set_request_error(reqinfo, request, SNMP_ERR_NOTWRITABLE);
                    return SNMP_ERR_NOTWRITABLE;
		}
	        break;

            case NSLOGGING_MAXLEVEL:
                if ( request->requestvb->type != ASN_INTEGER ) {
                    netsnmp_set_request_error(reqinfo, request, SNMP_ERR_WRONGTYPE);
                    return SNMP_ERR_WRONGTYPE;
                }
                if (*request->requestvb->val.integer < 0 ||
                    *request->requestvb->val.integer > 7 ) {
                    netsnmp_set_request_error(reqinfo, request, SNMP_ERR_WRONGVALUE);
                    return SNMP_ERR_WRONGVALUE;
                }
	        break;

            case NSLOGGING_STATUS:
                if ( request->requestvb->type != ASN_INTEGER ) {
                    netsnmp_set_request_error(reqinfo, request, SNMP_ERR_WRONGTYPE);
                    return SNMP_ERR_WRONGTYPE;
                }
		switch ( *request->requestvb->val.integer ) {
                case RS_ACTIVE:
                case RS_NOTINSERVICE:
                    /*
		     * Can only work on existing rows
		     */
                    if (!logh) {
                        netsnmp_set_request_error(reqinfo, request,
                                                  SNMP_ERR_INCONSISTENTVALUE);
                        return SNMP_ERR_INCONSISTENTVALUE;
                    }
	            break;

                case RS_CREATEANDWAIT:
                case RS_CREATEANDGO:
                    /*
		     * Can only work with new rows
		     */
                    if (logh) {
                        netsnmp_set_request_error(reqinfo, request,
                                                  SNMP_ERR_INCONSISTENTVALUE);
                        return SNMP_ERR_INCONSISTENTVALUE;
                    }

                    /*
                     *  Normally, we'd create the row at a later stage
                     *   (probably during the RESERVE2 or ACTION passes)
                     *
                     *  But we need to check that the values are
                     *   consistent during the ACTION pass (which is the
                     *   latest that an error can be safely handled),
                     *   so the values all need to be set up before this
                     *      (i.e. during the RESERVE2 pass)
                     *  So the new row needs to be created before that
                     *   in order to have somewhere to put them.
                     *
                     *  That's why we're doing this here.
                     */
                    idx = table_info->indexes;
	            logh = netsnmp_register_loghandler(
				    /* not really, but we need a valid type */
				    NETSNMP_LOGHANDLER_STDOUT,
				    *idx->val.integer);
                    if (!logh) {
                        netsnmp_set_request_error(reqinfo, request,
                                                  SNMP_ERR_GENERR); /* ??? */
                        return SNMP_ERR_GENERR;
                    }
                    idx = idx->next_variable;
	            logh->type  = 0;
	            logh->token = strdup((char *) idx->val.string);
                    netsnmp_insert_iterator_context(request, (void*)logh);
	            break;

                case RS_DESTROY:
                    /*
		     * Can work with new or existing rows
		     */
                    break;

                case RS_NOTREADY:
		default:
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_ERR_WRONGVALUE);
                    return SNMP_ERR_WRONGVALUE;
                }
                break;

            default:
                netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
                return SNMP_NOSUCHOBJECT;
	    }
	}
	break;


    case MODE_SET_RESERVE2:
        for (request=requests; request; request=request->next) {
            if ( request->status != 0 ) {
                return SNMP_ERR_NOERROR;	/* Already got an error */
            }
            logh = (netsnmp_log_handler*)netsnmp_extract_iterator_context(request);
            table_info  =                 netsnmp_extract_table_info(request);

            switch (table_info->colnum) {
            case NSLOGGING_TYPE:
                /*
		 * If we're creating a row using createAndGo,
		 * we need to set the type early, so that we
		 * can validate it in the ACTION pass.
		 *
		 * Remember that we need to be able to reverse this
		 */
                if ( logh )
                    logh->type = *request->requestvb->val.integer;
	        break;
            /*
	     * Don't need to handle nsLogToken or nsLogStatus in this pass
	     */
	    }
	}
	break;

    case MODE_SET_ACTION:
        for (request=requests; request; request=request->next) {
            if (request->processed != 0)
                continue;
            if ( request->status != 0 ) {
                return SNMP_ERR_NOERROR;	/* Already got an error */
            }
            logh = (netsnmp_log_handler*)netsnmp_extract_iterator_context(request);
            table_info  =                 netsnmp_extract_table_info(request);

            switch (table_info->colnum) {
            case NSLOGGING_STATUS:
                /*
		 * This is where we can check the internal consistency
		 * of the request.  Basically, for a row to be marked
		 * 'active', then there needs to be a valid type value.
		 */
		switch ( *request->requestvb->val.integer ) {
                case RS_ACTIVE:
                case RS_CREATEANDGO:
                    if ( !logh || !logh->type ) {
                        netsnmp_set_request_error(reqinfo, request,
                                                  SNMP_ERR_INCONSISTENTVALUE);
                        return SNMP_ERR_INCONSISTENTVALUE;
		    }
	            break;
		}
	        break;
            /*
	     * Don't need to handle nsLogToken or nsLogType in this pass
	     */
	    }
	}
	break;

    case MODE_SET_FREE:
    case MODE_SET_UNDO:
        /*
         * If any resources were allocated in either of the
         *  two RESERVE passes, they need to be released here,
         *  and any assignments (in RESERVE2) reversed.
         *
         * Nothing additional will have been done during ACTION
         *  so this same code can do for UNDO as well.
         */
        for (request=requests; request; request=request->next) {
            if (request->processed != 0)
                continue;
            logh = (netsnmp_log_handler*)netsnmp_extract_iterator_context(request);
            table_info  =                 netsnmp_extract_table_info(request);

            switch (table_info->colnum) {
            case NSLOGGING_TYPE:
                /*
		 * If we've been setting the type, and the request
		 * has failed, then revert to an unset type.
		 *
		 * We need to be careful here - if the reason it failed is
		 *  that the type was already set, then we shouldn't "undo"
		 *  the assignment (since it won't actually have been made).
		 *
		 * Check the current value against the 'new' one.  If they're
		 * the same, then this is probably a successful assignment,
		 * and the failure was elsewhere, so we need to undo it.
		 *  (Or else there was an attempt to write the same value!)
		 */
                if ( logh && logh->type == *request->requestvb->val.integer )
                    logh->type = 0;
	        break;

            case NSLOGGING_STATUS:
                temp = *request->requestvb->val.integer;
                if ( logh && ( temp == RS_CREATEANDGO ||
                               temp == RS_CREATEANDWAIT)) {
		    netsnmp_remove_loghandler( logh );
		}
	        break;
            /*
	     * Don't need to handle nsLogToken in this pass
	     */
	    }
	}
	break;


    case MODE_SET_COMMIT:
        for (request=requests; request; request=request->next) {
            if (request->processed != 0)
                continue;
            if ( request->status != 0 ) {
                return SNMP_ERR_NOERROR;	/* Already got an error */
            }
            logh = (netsnmp_log_handler*)netsnmp_extract_iterator_context(request);
            if (!logh) {
                netsnmp_set_request_error(reqinfo, request, SNMP_ERR_COMMITFAILED);
                return SNMP_ERR_COMMITFAILED;	/* Shouldn't happen! */
            }
            table_info  =                 netsnmp_extract_table_info(request);

            switch (table_info->colnum) {
            case NSLOGGING_MAXLEVEL:
                logh->pri_max = *request->requestvb->val.integer;
	        break;

            case NSLOGGING_STATUS:
                switch (*request->requestvb->val.integer) {
                    case RS_ACTIVE:
                    case RS_CREATEANDGO:
                        netsnmp_enable_this_loghandler(logh);
                        break;
                    case RS_NOTINSERVICE:
                    case RS_CREATEANDWAIT:
                        netsnmp_disable_this_loghandler(logh);
                        break;
		    case RS_DESTROY:
		        netsnmp_remove_loghandler( logh );
                        break;
		}
	        break;
	    }
	}
	break;
#endif /* !NETSNMP_NO_WRITE_SUPPORT */
    }

    return SNMP_ERR_NOERROR;
}
示例#23
0
int
udpTable_handler(netsnmp_mib_handler          *handler,
                 netsnmp_handler_registration *reginfo,
                 netsnmp_agent_request_info   *reqinfo,
                 netsnmp_request_info         *requests)
{
    netsnmp_request_info  *request;
    netsnmp_variable_list *requestvb;
    netsnmp_table_request_info *table_info;
    UDPTABLE_ENTRY_TYPE	  *entry;
    oid      subid;
    long     port,addr;

    DEBUGMSGTL(("mibII/udpTable", "Handler - mode %s\n",
                se_find_label_in_slist("agent_mode", reqinfo->mode)));
    switch (reqinfo->mode) {
    case MODE_GET:
        for (request=requests; request; request=request->next) {
            requestvb = request->requestvb;
            DEBUGMSGTL(( "mibII/udpTable", "oid: "));
            DEBUGMSGOID(("mibII/udpTable", requestvb->name,
                         requestvb->name_length));
            DEBUGMSG((   "mibII/udpTable", "\n"));

            entry = (UDPTABLE_ENTRY_TYPE *)netsnmp_extract_iterator_context(request);
            if (!entry)
                continue;
            table_info = netsnmp_extract_table_info(request);
            subid      = table_info->colnum;

            switch (subid) {
            case UDPLOCALADDRESS:
#if defined(osf5) && defined(IN6_EXTRACT_V4ADDR)
                addr = ntohl(IN6_EXTRACT_V4ADDR(&entry->pcb.inp_laddr));
                snmp_set_var_typed_value(requestvb, ASN_IPADDRESS,
                                         (u_char*)&addr,
                                         sizeof(addr));
#else
                addr = UDP_ADDRESS_TO_HOST_ORDER(entry->UDPTABLE_LOCALADDRESS);
                snmp_set_var_typed_value(requestvb, ASN_IPADDRESS,
                                         (u_char *)&addr,
                                         sizeof(addr));
#endif
                break;
            case UDPLOCALPORT:
                port = UDP_PORT_TO_HOST_ORDER((u_short)entry->UDPTABLE_LOCALPORT);
                snmp_set_var_typed_value(requestvb, ASN_INTEGER,
                                         (u_char *)&port, sizeof(port));
                break;
            }
        }
        break;

    case MODE_GETNEXT:
    case MODE_GETBULK:
    case MODE_SET_RESERVE1:
    case MODE_SET_RESERVE2:
    case MODE_SET_ACTION:
    case MODE_SET_COMMIT:
    case MODE_SET_FREE:
    case MODE_SET_UNDO:
        snmp_log(LOG_WARNING, "mibII/udpTable: Unsupported mode (%d)\n",
                 reqinfo->mode);
        break;
    default:
        snmp_log(LOG_WARNING, "mibII/udpTable: Unrecognised mode (%d)\n",
                 reqinfo->mode);
        break;
    }

    return SNMP_ERR_NOERROR;
}
示例#24
0
static int mib_ipAddrTable_handler(netsnmp_mib_handler *handler,
                    netsnmp_handler_registration *reginfo,
                    netsnmp_agent_request_info *reqinfo,
                    netsnmp_request_info *requests)
{
    netsnmp_request_info       *request;
    netsnmp_table_request_info *table_req_info;
    struct ipAddrTable_entry *table_entry;

    switch (reqinfo->mode)
    {
    case MODE_GET:
        for (request=requests; request; request=request->next)
        {
            table_entry = (struct ipAddrTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_req_info  = netsnmp_extract_table_info(request);
            if(NULL == table_req_info)
            {
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOACCESS);
                continue;
            }

            switch (table_req_info->colnum)
            {
            case COLUMN_IPADENTADDR:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_IPADDRESS,
                                            htonl(table_entry->ipAdEntAddr));
                break;

            case COLUMN_IPADENTIFINDEX:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->ipAdEntIfIndex);
                break;

            case COLUMN_IPADENTNETMASK:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_IPADDRESS,
                                            htonl(table_entry->ipAdEntNetMask));
                break;

            case COLUMN_IPADENTBCASTADDR:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->ipAdEntBcastAddr);
                break;

            case COLUMN_IPADENTREASMMAXSIZE:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->ipAdEntReasmMaxSize);
                break;

            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_NOSUCHOBJECT);
                break;

            }
        }
        break;

    }
    return SNMP_ERR_NOERROR;
}
示例#25
0
/** handles requests for the ipCidrRouteTable table, if anything else
   needs to be done */
int
ipCidrRouteTable_handler(netsnmp_mib_handler *handler,
                         netsnmp_handler_registration *reginfo,
                         netsnmp_agent_request_info *reqinfo,
                         netsnmp_request_info *requests)
{

    netsnmp_request_info *request;
    netsnmp_table_request_info *table_info;
    netsnmp_variable_list *var;

    void           *data_context;

    oid            *suffix;
    size_t          suffix_len;

    /** column and row index encoded portion */
    suffix = requests->requestvb->name + reginfo->rootoid_len + 1;
    suffix_len = requests->requestvb->name_length -
        (reginfo->rootoid_len + 1);

    for (request = requests; request; request = request->next) {
        var = request->requestvb;
        if (request->processed != 0)
            continue;

        data_context = netsnmp_extract_iterator_context(request);
        if (data_context == NULL) {
            if (reqinfo->mode == MODE_GET) {
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_NOSUCHINSTANCE);
                continue;
            }
            /** XXX: no row existed, if you support creation and this is a
               set, start dealing with it here, else continue */
        }

        /** extracts the information about the table from the request */
        table_info = netsnmp_extract_table_info(request);
        /** table_info->colnum contains the column number requested */
        /** table_info->indexes contains a linked list of snmp variable
           bindings for the indexes of the table.  Values in the list
           have been set corresponding to the indexes of the
           request */
        if (table_info == NULL) {
            continue;
        }

        switch (reqinfo->mode) {
        case MODE_GET:
            switch (table_info->colnum) {
            case COLUMN_IPCIDRROUTEDEST:
                {
                    u_long         *retval;
                    size_t          retval_len = 0;
                    retval =
                        get_ipCidrRouteDest(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_IPADDRESS,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_IPCIDRROUTEMASK:
                {
                    u_long         *retval;
                    size_t          retval_len = 0;
                    retval =
                        get_ipCidrRouteMask(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_IPADDRESS,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_IPCIDRROUTETOS:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval = get_ipCidrRouteTos(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_IPCIDRROUTENEXTHOP:
                {
                    u_long         *retval;
                    size_t          retval_len = 0;
                    retval =
                        get_ipCidrRouteNextHop(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_IPADDRESS,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_IPCIDRROUTEIFINDEX:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval =
                        get_ipCidrRouteIfIndex(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_IPCIDRROUTETYPE:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval =
                        get_ipCidrRouteType(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_IPCIDRROUTEPROTO:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval =
                        get_ipCidrRouteProto(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_IPCIDRROUTEAGE:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval = get_ipCidrRouteAge(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_IPCIDRROUTEINFO:
                {
                    oid            *retval;
                    size_t          retval_len = 0;
                    retval =
                        get_ipCidrRouteInfo(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_OBJECT_ID,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_IPCIDRROUTENEXTHOPAS:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval =
                        get_ipCidrRouteNextHopAS(data_context,
                                                 &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_IPCIDRROUTEMETRIC1:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval =
                        get_ipCidrRouteMetric1(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_IPCIDRROUTEMETRIC2:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval =
                        get_ipCidrRouteMetric2(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_IPCIDRROUTEMETRIC3:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval =
                        get_ipCidrRouteMetric3(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_IPCIDRROUTEMETRIC4:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval =
                        get_ipCidrRouteMetric4(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_IPCIDRROUTEMETRIC5:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval =
                        get_ipCidrRouteMetric5(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_IPCIDRROUTESTATUS:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval =
                        get_ipCidrRouteStatus(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            default:
                        /** We shouldn't get here */
                snmp_log(LOG_ERR,
                         "problem encountered in ipCidrRouteTable_handler: unknown column\n");
            }
            break;

        case MODE_SET_RESERVE1:
                /** mib2cXXX: clear out old undo info if we have any.  Remove if
                   table_iterator becomes un-serialized */
            netsnmp_oid_stash_free(&undoStorage, free_undoInfo);

            switch (table_info->colnum) {
            case COLUMN_IPCIDRROUTEIFINDEX:
                {
                    int             ret =
                        check_ipCidrRouteIfIndex(request->requestvb->type,
                                                 (long *) request->
                                                 requestvb->val.string,
                                                 request->requestvb->
                                                 val_len);
                    if (ret != 0) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTETYPE:
                {
                    int             ret =
                        check_ipCidrRouteType(request->requestvb->type,
                                              (long *) request->requestvb->
                                              val.string,
                                              request->requestvb->val_len);
                    if (ret != 0) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEINFO:
                {
                    int             ret =
                        check_ipCidrRouteInfo(request->requestvb->type,
                                              (oid *) request->requestvb->
                                              val.string,
                                              request->requestvb->val_len);
                    if (ret != 0) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTENEXTHOPAS:
                {
                    int             ret =
                        check_ipCidrRouteNextHopAS(request->requestvb->
                                                   type,
                                                   (long *) request->
                                                   requestvb->val.string,
                                                   request->requestvb->
                                                   val_len);
                    if (ret != 0) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC1:
                {
                    int             ret =
                        check_ipCidrRouteMetric1(request->requestvb->type,
                                                 (long *) request->
                                                 requestvb->val.string,
                                                 request->requestvb->
                                                 val_len);
                    if (ret != 0) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC2:
                {
                    int             ret =
                        check_ipCidrRouteMetric2(request->requestvb->type,
                                                 (long *) request->
                                                 requestvb->val.string,
                                                 request->requestvb->
                                                 val_len);
                    if (ret != 0) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC3:
                {
                    int             ret =
                        check_ipCidrRouteMetric3(request->requestvb->type,
                                                 (long *) request->
                                                 requestvb->val.string,
                                                 request->requestvb->
                                                 val_len);
                    if (ret != 0) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC4:
                {
                    int             ret =
                        check_ipCidrRouteMetric4(request->requestvb->type,
                                                 (long *) request->
                                                 requestvb->val.string,
                                                 request->requestvb->
                                                 val_len);
                    if (ret != 0) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC5:
                {
                    int             ret =
                        check_ipCidrRouteMetric5(request->requestvb->type,
                                                 (long *) request->
                                                 requestvb->val.string,
                                                 request->requestvb->
                                                 val_len);
                    if (ret != 0) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTESTATUS:
                {
                    int             ret =
                        check_ipCidrRouteStatus(request->requestvb->type,
                                                (long *) request->
                                                requestvb->val.string,
                                                request->requestvb->
                                                val_len);
                    if (ret != 0) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            default:
                netsnmp_set_request_error(reqinfo, requests,
                                          SNMP_ERR_NOTWRITABLE);
                break;
            }
            break;

        case MODE_SET_RESERVE2:
                /** save a variable copy */
            switch (table_info->colnum) {
            case COLUMN_IPCIDRROUTEIFINDEX:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    struct undoInfo *ui;
                    retval =
                        get_ipCidrRouteIfIndex(data_context, &retval_len);
                    if (retval) {
                        ui = SNMP_MALLOC_STRUCT(undoInfo);
                        ui->len = retval_len;
                        memdup((u_char **) & ui->ptr,
                               (u_char *) retval, ui->len);
                        netsnmp_oid_stash_add_data(&undoStorage,
                                                   suffix, suffix_len, ui);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTETYPE:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    struct undoInfo *ui;
                    retval =
                        get_ipCidrRouteType(data_context, &retval_len);
                    if (retval) {
                        ui = SNMP_MALLOC_STRUCT(undoInfo);
                        ui->len = retval_len;
                        memdup((u_char **) & ui->ptr,
                               (u_char *) retval, ui->len);
                        netsnmp_oid_stash_add_data(&undoStorage,
                                                   suffix, suffix_len, ui);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEINFO:
                {
                    oid            *retval;
                    size_t          retval_len = 0;
                    struct undoInfo *ui;
                    retval =
                        get_ipCidrRouteInfo(data_context, &retval_len);
                    if (retval) {
                        ui = SNMP_MALLOC_STRUCT(undoInfo);
                        ui->len = retval_len;
                        memdup((u_char **) & ui->ptr,
                               (u_char *) retval, ui->len);
                        netsnmp_oid_stash_add_data(&undoStorage,
                                                   suffix, suffix_len, ui);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTENEXTHOPAS:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    struct undoInfo *ui;
                    retval =
                        get_ipCidrRouteNextHopAS(data_context,
                                                 &retval_len);
                    if (retval) {
                        ui = SNMP_MALLOC_STRUCT(undoInfo);
                        ui->len = retval_len;
                        memdup((u_char **) & ui->ptr,
                               (u_char *) retval, ui->len);
                        netsnmp_oid_stash_add_data(&undoStorage,
                                                   suffix, suffix_len, ui);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC1:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    struct undoInfo *ui;
                    retval =
                        get_ipCidrRouteMetric1(data_context, &retval_len);
                    if (retval) {
                        ui = SNMP_MALLOC_STRUCT(undoInfo);
                        ui->len = retval_len;
                        memdup((u_char **) & ui->ptr,
                               (u_char *) retval, ui->len);
                        netsnmp_oid_stash_add_data(&undoStorage,
                                                   suffix, suffix_len, ui);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC2:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    struct undoInfo *ui;
                    retval =
                        get_ipCidrRouteMetric2(data_context, &retval_len);
                    if (retval) {
                        ui = SNMP_MALLOC_STRUCT(undoInfo);
                        ui->len = retval_len;
                        memdup((u_char **) & ui->ptr,
                               (u_char *) retval, ui->len);
                        netsnmp_oid_stash_add_data(&undoStorage,
                                                   suffix, suffix_len, ui);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC3:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    struct undoInfo *ui;
                    retval =
                        get_ipCidrRouteMetric3(data_context, &retval_len);
                    if (retval) {
                        ui = SNMP_MALLOC_STRUCT(undoInfo);
                        ui->len = retval_len;
                        memdup((u_char **) & ui->ptr,
                               (u_char *) retval, ui->len);
                        netsnmp_oid_stash_add_data(&undoStorage,
                                                   suffix, suffix_len, ui);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC4:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    struct undoInfo *ui;
                    retval =
                        get_ipCidrRouteMetric4(data_context, &retval_len);
                    if (retval) {
                        ui = SNMP_MALLOC_STRUCT(undoInfo);
                        ui->len = retval_len;
                        memdup((u_char **) & ui->ptr,
                               (u_char *) retval, ui->len);
                        netsnmp_oid_stash_add_data(&undoStorage,
                                                   suffix, suffix_len, ui);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC5:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    struct undoInfo *ui;
                    retval =
                        get_ipCidrRouteMetric5(data_context, &retval_len);
                    if (retval) {
                        ui = SNMP_MALLOC_STRUCT(undoInfo);
                        ui->len = retval_len;
                        memdup((u_char **) & ui->ptr,
                               (u_char *) retval, ui->len);
                        netsnmp_oid_stash_add_data(&undoStorage,
                                                   suffix, suffix_len, ui);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTESTATUS:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    struct undoInfo *ui;
                    retval =
                        get_ipCidrRouteStatus(data_context, &retval_len);
                    if (retval) {
                        ui = SNMP_MALLOC_STRUCT(undoInfo);
                        ui->len = retval_len;
                        memdup((u_char **) & ui->ptr,
                               (u_char *) retval, ui->len);
                        netsnmp_oid_stash_add_data(&undoStorage,
                                                   suffix, suffix_len, ui);
                    }
                }
                break;
            }
            break;

        case MODE_SET_FREE:
                /** Forget undo data, if exists */
            netsnmp_oid_stash_free(&undoStorage, free_undoInfo);
            break;

        case MODE_SET_ACTION:
                /** save a variable copy */
            switch (table_info->colnum) {
            case COLUMN_IPCIDRROUTEIFINDEX:
                {
                    int             ret =
                        set_ipCidrRouteIfIndex(data_context,
                                               (long *) request->
                                               requestvb->val.string,
                                               request->requestvb->
                                               val_len);
                    if (ret) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTETYPE:
                {
                    int             ret = set_ipCidrRouteType(data_context,
                                                              (long *)
                                                              request->
                                                              requestvb->
                                                              val.string,
                                                              request->
                                                              requestvb->
                                                              val_len);
                    if (ret) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEINFO:
                {
                    int             ret = set_ipCidrRouteInfo(data_context,
                                                              (oid *)
                                                              request->
                                                              requestvb->
                                                              val.string,
                                                              request->
                                                              requestvb->
                                                              val_len);
                    if (ret) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTENEXTHOPAS:
                {
                    int             ret =
                        set_ipCidrRouteNextHopAS(data_context,
                                                 (long *) request->
                                                 requestvb->val.string,
                                                 request->requestvb->
                                                 val_len);
                    if (ret) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC1:
                {
                    int             ret =
                        set_ipCidrRouteMetric1(data_context,
                                               (long *) request->
                                               requestvb->val.string,
                                               request->requestvb->
                                               val_len);
                    if (ret) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC2:
                {
                    int             ret =
                        set_ipCidrRouteMetric2(data_context,
                                               (long *) request->
                                               requestvb->val.string,
                                               request->requestvb->
                                               val_len);
                    if (ret) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC3:
                {
                    int             ret =
                        set_ipCidrRouteMetric3(data_context,
                                               (long *) request->
                                               requestvb->val.string,
                                               request->requestvb->
                                               val_len);
                    if (ret) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC4:
                {
                    int             ret =
                        set_ipCidrRouteMetric4(data_context,
                                               (long *) request->
                                               requestvb->val.string,
                                               request->requestvb->
                                               val_len);
                    if (ret) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC5:
                {
                    int             ret =
                        set_ipCidrRouteMetric5(data_context,
                                               (long *) request->
                                               requestvb->val.string,
                                               request->requestvb->
                                               val_len);
                    if (ret) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTESTATUS:
                {
                    int             ret =
                        set_ipCidrRouteStatus(data_context,
                                              (long *) request->requestvb->
                                              val.string,
                                              request->requestvb->val_len);
                    if (ret) {
                        netsnmp_set_request_error(reqinfo, requests, ret);
                    }
                }
                break;
            }
            break;

        case MODE_SET_COMMIT:
                /** answers were all good.  Forget undo data */
            netsnmp_oid_stash_free(&undoStorage, free_undoInfo);
                /** mib2cXXX: call commit hook */
            break;

        case MODE_SET_UNDO:
                /** save a variable copy */
            switch (table_info->colnum) {
            case COLUMN_IPCIDRROUTEIFINDEX:
                {
                    int             retval;
                    struct undoInfo *ui;
                    ui = netsnmp_oid_stash_get_data(undoStorage,
                                                    suffix, suffix_len);
                    retval =
                        set_ipCidrRouteIfIndex(data_context, ui->ptr,
                                               ui->len);
                    if (retval) {
                        netsnmp_set_request_error(reqinfo, requests,
                                                  SNMP_ERR_UNDOFAILED);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTETYPE:
                {
                    int             retval;
                    struct undoInfo *ui;
                    ui = netsnmp_oid_stash_get_data(undoStorage,
                                                    suffix, suffix_len);
                    retval =
                        set_ipCidrRouteType(data_context, ui->ptr,
                                            ui->len);
                    if (retval) {
                        netsnmp_set_request_error(reqinfo, requests,
                                                  SNMP_ERR_UNDOFAILED);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEINFO:
                {
                    int             retval;
                    struct undoInfo *ui;
                    ui = netsnmp_oid_stash_get_data(undoStorage,
                                                    suffix, suffix_len);
                    retval =
                        set_ipCidrRouteInfo(data_context, ui->ptr,
                                            ui->len);
                    if (retval) {
                        netsnmp_set_request_error(reqinfo, requests,
                                                  SNMP_ERR_UNDOFAILED);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTENEXTHOPAS:
                {
                    int             retval;
                    struct undoInfo *ui;
                    ui = netsnmp_oid_stash_get_data(undoStorage,
                                                    suffix, suffix_len);
                    retval =
                        set_ipCidrRouteNextHopAS(data_context, ui->ptr,
                                                 ui->len);
                    if (retval) {
                        netsnmp_set_request_error(reqinfo, requests,
                                                  SNMP_ERR_UNDOFAILED);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC1:
                {
                    int             retval;
                    struct undoInfo *ui;
                    ui = netsnmp_oid_stash_get_data(undoStorage,
                                                    suffix, suffix_len);
                    retval =
                        set_ipCidrRouteMetric1(data_context, ui->ptr,
                                               ui->len);
                    if (retval) {
                        netsnmp_set_request_error(reqinfo, requests,
                                                  SNMP_ERR_UNDOFAILED);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC2:
                {
                    int             retval;
                    struct undoInfo *ui;
                    ui = netsnmp_oid_stash_get_data(undoStorage,
                                                    suffix, suffix_len);
                    retval =
                        set_ipCidrRouteMetric2(data_context, ui->ptr,
                                               ui->len);
                    if (retval) {
                        netsnmp_set_request_error(reqinfo, requests,
                                                  SNMP_ERR_UNDOFAILED);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC3:
                {
                    int             retval;
                    struct undoInfo *ui;
                    ui = netsnmp_oid_stash_get_data(undoStorage,
                                                    suffix, suffix_len);
                    retval =
                        set_ipCidrRouteMetric3(data_context, ui->ptr,
                                               ui->len);
                    if (retval) {
                        netsnmp_set_request_error(reqinfo, requests,
                                                  SNMP_ERR_UNDOFAILED);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC4:
                {
                    int             retval;
                    struct undoInfo *ui;
                    ui = netsnmp_oid_stash_get_data(undoStorage,
                                                    suffix, suffix_len);
                    retval =
                        set_ipCidrRouteMetric4(data_context, ui->ptr,
                                               ui->len);
                    if (retval) {
                        netsnmp_set_request_error(reqinfo, requests,
                                                  SNMP_ERR_UNDOFAILED);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTEMETRIC5:
                {
                    int             retval;
                    struct undoInfo *ui;
                    ui = netsnmp_oid_stash_get_data(undoStorage,
                                                    suffix, suffix_len);
                    retval =
                        set_ipCidrRouteMetric5(data_context, ui->ptr,
                                               ui->len);
                    if (retval) {
                        netsnmp_set_request_error(reqinfo, requests,
                                                  SNMP_ERR_UNDOFAILED);
                    }
                }
                break;
            case COLUMN_IPCIDRROUTESTATUS:
                {
                    int             retval;
                    struct undoInfo *ui;
                    ui = netsnmp_oid_stash_get_data(undoStorage,
                                                    suffix, suffix_len);
                    retval =
                        set_ipCidrRouteStatus(data_context, ui->ptr,
                                              ui->len);
                    if (retval) {
                        netsnmp_set_request_error(reqinfo, requests,
                                                  SNMP_ERR_UNDOFAILED);
                    }
                }
                break;
            }
                /** mib2cXXX: remove cache!  hard to do when serialized, however */
            break;

        default:
            snmp_log(LOG_ERR,
                     "problem encountered in ipCidrRouteTable_handler: unsupported mode\n");
        }
    }
    return SNMP_ERR_NOERROR;
}
示例#26
0
static int mib_ipRouteTable_handler(netsnmp_mib_handler *handler,
                    netsnmp_handler_registration *reginfo,
                    netsnmp_agent_request_info *reqinfo,
                    netsnmp_request_info *requests)
{
    netsnmp_request_info       *request;
    netsnmp_table_request_info *table_req_info;
    struct ipRouteTable_entry *table_entry;
    int                         ret;
    switch (reqinfo->mode)
    {
    case MODE_GET:
        for (request=requests; request; request=request->next)
        {
            table_entry = (struct ipRouteTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_req_info  = netsnmp_extract_table_info(request);
            if(NULL == table_req_info)
            {
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOACCESS);
                continue;
            }

            switch (table_req_info->colnum)
            {
            case COLUMN_IPROUTEDEST:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_IPADDRESS,
                                            htonl(table_entry->ipRouteDest));
                break;

            case COLUMN_IPROUTEIFINDEX:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->ipRouteIfIndex);
                break;

            case COLUMN_IPROUTEMETRIC1:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->ipRouteMetric1);
                break;

            case COLUMN_IPROUTEMETRIC2:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->ipRouteMetric2);
                break;

            case COLUMN_IPROUTEMETRIC3:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->ipRouteMetric3);
                break;

            case COLUMN_IPROUTEMETRIC4:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->ipRouteMetric4);
                break;

            case COLUMN_IPROUTENEXTHOP:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_IPADDRESS,
                                            htonl(table_entry->ipRouteNextHop));
                break;

            case COLUMN_IPROUTETYPE:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->ipRouteType);
                break;

            case COLUMN_IPROUTEPROTO:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->ipRouteProto);
                break;

            case COLUMN_IPROUTEAGE:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->ipRouteAge);
                break;

            case COLUMN_IPROUTEMASK:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_IPADDRESS,
                                            htonl(table_entry->ipRouteMask));
                break;

            case COLUMN_IPROUTEMETRIC5:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER,
                                            table_entry->ipRouteMetric5);
                break;

            case COLUMN_IPROUTEINFO:
                if ( !table_entry )
                {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_value( request->requestvb, ASN_OBJECT_ID,
                                 (u_char*)table_entry->ipRouteInfo,
                                          table_entry->ipRouteInfo_len);
                break;

            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_NOSUCHOBJECT);
                break;

            }
        }
        break;
    case MODE_SET_RESERVE1:
        for (request=requests; request; request=request->next)
        {
            table_entry = (struct ipRouteTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_req_info  = netsnmp_extract_table_info(request);
            if(NULL == table_req_info)
            {
                netsnmp_set_request_error( reqinfo, request,
                                           SNMP_ERR_NOACCESS );
                return SNMP_ERR_NOERROR;
            }

            switch (table_req_info->colnum)
            {
            case COLUMN_IPROUTEDEST:
                ret = netsnmp_check_vb_type_and_size(
                          request->requestvb, ASN_IPADDRESS, sizeof(table_entry->ipRouteDest));
                if ( ret != SNMP_ERR_NOERROR )
                {
                    netsnmp_set_request_error( reqinfo, request, ret );
                    return SNMP_ERR_NOERROR;
                }
                break;

            case COLUMN_IPROUTEIFINDEX:
                ret = netsnmp_check_vb_int( request->requestvb );
                if ( ret != SNMP_ERR_NOERROR )
                {
                    netsnmp_set_request_error( reqinfo, request, ret );
                    return SNMP_ERR_NOERROR;
                }
                break;

            case COLUMN_IPROUTEMETRIC1:
                ret = netsnmp_check_vb_int( request->requestvb );
                if ( ret != SNMP_ERR_NOERROR )
                {
                    netsnmp_set_request_error( reqinfo, request, ret );
                    return SNMP_ERR_NOERROR;
                }
                break;

            case COLUMN_IPROUTEMETRIC2:
                ret = netsnmp_check_vb_int( request->requestvb );
                if ( ret != SNMP_ERR_NOERROR )
                {
                    netsnmp_set_request_error( reqinfo, request, ret );
                    return SNMP_ERR_NOERROR;
                }
                break;

            case COLUMN_IPROUTEMETRIC3:
                ret = netsnmp_check_vb_int( request->requestvb );
                if ( ret != SNMP_ERR_NOERROR )
                {
                    netsnmp_set_request_error( reqinfo, request, ret );
                    return SNMP_ERR_NOERROR;
                }
                break;

            case COLUMN_IPROUTEMETRIC4:
                ret = netsnmp_check_vb_int( request->requestvb );
                if ( ret != SNMP_ERR_NOERROR )
                {
                    netsnmp_set_request_error( reqinfo, request, ret );
                    return SNMP_ERR_NOERROR;
                }
                break;

            case COLUMN_IPROUTENEXTHOP:
                ret = netsnmp_check_vb_type_and_size(
                          request->requestvb, ASN_IPADDRESS, sizeof(table_entry->ipRouteNextHop));
                if ( ret != SNMP_ERR_NOERROR )
                {
                    netsnmp_set_request_error( reqinfo, request, ret );
                    return SNMP_ERR_NOERROR;
                }
                break;

            case COLUMN_IPROUTETYPE:
                ret = netsnmp_check_vb_int( request->requestvb );
                if ( ret != SNMP_ERR_NOERROR )
                {
                    netsnmp_set_request_error( reqinfo, request, ret );
                    return SNMP_ERR_NOERROR;
                }
                break;

            case COLUMN_IPROUTEAGE:
                ret = netsnmp_check_vb_int( request->requestvb );
                if ( ret != SNMP_ERR_NOERROR )
                {
                    netsnmp_set_request_error( reqinfo, request, ret );
                    return SNMP_ERR_NOERROR;
                }
                break;

            case COLUMN_IPROUTEMASK:
                ret = netsnmp_check_vb_type_and_size(
                          request->requestvb, ASN_IPADDRESS, sizeof(table_entry->ipRouteMask));
                if ( ret != SNMP_ERR_NOERROR )
                {
                    netsnmp_set_request_error( reqinfo, request, ret );
                    return SNMP_ERR_NOERROR;
                }
                break;

            case COLUMN_IPROUTEMETRIC5:
                ret = netsnmp_check_vb_int( request->requestvb );
                if ( ret != SNMP_ERR_NOERROR )
                {
                    netsnmp_set_request_error( reqinfo, request, ret );
                    return SNMP_ERR_NOERROR;
                }
                break;

            default:
                netsnmp_set_request_error( reqinfo, request,
                                           SNMP_ERR_NOTWRITABLE );
                return SNMP_ERR_NOERROR;
            }
        }
        break;

    case MODE_SET_RESERVE2:
        break;

    case MODE_SET_FREE:
        break;

    case MODE_SET_ACTION:
        for (request=requests; request; request=request->next)
        {
            table_entry = (struct ipRouteTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_req_info  = netsnmp_extract_table_info(request);

            switch (table_req_info->colnum)
            {
            case COLUMN_IPROUTEDEST:
                table_entry->old_ipRouteDest = table_entry->ipRouteDest;
                table_entry->ipRouteDest     = *request->requestvb->val.integer;
                break;

            case COLUMN_IPROUTEIFINDEX:
                table_entry->old_ipRouteIfIndex = table_entry->ipRouteIfIndex;
                table_entry->ipRouteIfIndex     = *request->requestvb->val.integer;
                break;

            case COLUMN_IPROUTEMETRIC1:
                table_entry->old_ipRouteMetric1 = table_entry->ipRouteMetric1;
                table_entry->ipRouteMetric1     = *request->requestvb->val.integer;
                break;

            case COLUMN_IPROUTEMETRIC2:
                table_entry->old_ipRouteMetric2 = table_entry->ipRouteMetric2;
                table_entry->ipRouteMetric2     = *request->requestvb->val.integer;
                break;

            case COLUMN_IPROUTEMETRIC3:
                table_entry->old_ipRouteMetric3 = table_entry->ipRouteMetric3;
                table_entry->ipRouteMetric3     = *request->requestvb->val.integer;
                break;

            case COLUMN_IPROUTEMETRIC4:
                table_entry->old_ipRouteMetric4 = table_entry->ipRouteMetric4;
                table_entry->ipRouteMetric4     = *request->requestvb->val.integer;
                break;

            case COLUMN_IPROUTENEXTHOP:
                table_entry->old_ipRouteNextHop = table_entry->ipRouteNextHop;
                table_entry->ipRouteNextHop     = *request->requestvb->val.integer;
                break;

            case COLUMN_IPROUTETYPE:
                table_entry->old_ipRouteType = table_entry->ipRouteType;
                table_entry->ipRouteType     = *request->requestvb->val.integer;
                break;

            case COLUMN_IPROUTEAGE:
                table_entry->old_ipRouteAge = table_entry->ipRouteAge;
                table_entry->ipRouteAge     = *request->requestvb->val.integer;
                break;

            case COLUMN_IPROUTEMASK:
                table_entry->old_ipRouteMask = table_entry->ipRouteMask;
                table_entry->ipRouteMask     = *request->requestvb->val.integer;
                break;

            case COLUMN_IPROUTEMETRIC5:
                table_entry->old_ipRouteMetric5 = table_entry->ipRouteMetric5;
                table_entry->ipRouteMetric5     = *request->requestvb->val.integer;
                break;

            }
        }
        break;

    case MODE_SET_COMMIT:
        break;

    case MODE_SET_UNDO:
        for (request=requests; request; request=request->next)
        {
            table_entry = (struct ipRouteTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_req_info  = netsnmp_extract_table_info( request);

            switch (table_req_info->colnum)
            {
            case COLUMN_IPROUTEDEST:
                table_entry->ipRouteDest     = table_entry->old_ipRouteDest;
                table_entry->old_ipRouteDest = 0;
                break;

            case COLUMN_IPROUTEIFINDEX:
                table_entry->ipRouteIfIndex     = table_entry->old_ipRouteIfIndex;
                table_entry->old_ipRouteIfIndex = 0;
                break;

            case COLUMN_IPROUTEMETRIC1:
                table_entry->ipRouteMetric1     = table_entry->old_ipRouteMetric1;
                table_entry->old_ipRouteMetric1 = 0;
                break;

            case COLUMN_IPROUTEMETRIC2:
                table_entry->ipRouteMetric2     = table_entry->old_ipRouteMetric2;
                table_entry->old_ipRouteMetric2 = 0;
                break;

            case COLUMN_IPROUTEMETRIC3:
                table_entry->ipRouteMetric3     = table_entry->old_ipRouteMetric3;
                table_entry->old_ipRouteMetric3 = 0;
                break;

            case COLUMN_IPROUTEMETRIC4:
                table_entry->ipRouteMetric4     = table_entry->old_ipRouteMetric4;
                table_entry->old_ipRouteMetric4 = 0;
                break;

            case COLUMN_IPROUTENEXTHOP:
                table_entry->ipRouteNextHop     = table_entry->old_ipRouteNextHop;
                table_entry->old_ipRouteNextHop = 0;
                break;

            case COLUMN_IPROUTETYPE:
                table_entry->ipRouteType     = table_entry->old_ipRouteType;
                table_entry->old_ipRouteType = 0;
                break;

            case COLUMN_IPROUTEAGE:
                table_entry->ipRouteAge     = table_entry->old_ipRouteAge;
                table_entry->old_ipRouteAge = 0;
                break;

            case COLUMN_IPROUTEMASK:
                table_entry->ipRouteMask     = table_entry->old_ipRouteMask;
                table_entry->old_ipRouteMask = 0;
                break;

            case COLUMN_IPROUTEMETRIC5:
                table_entry->ipRouteMetric5     = table_entry->old_ipRouteMetric5;
                table_entry->old_ipRouteMetric5 = 0;
                break;

            }
        }
        break;

    }
    return SNMP_ERR_NOERROR;
}
/** handles requests for the dot11WtpWirelessCapStatTable table */
int
dot11WtpWirelessCapStatTable_handler(
    netsnmp_mib_handler               *handler,
    netsnmp_handler_registration      *reginfo,
    netsnmp_agent_request_info        *reqinfo,
    netsnmp_request_info              *requests) {


    netsnmp_request_info       *request;
    netsnmp_table_request_info *table_info;
    struct dot11WtpWirelessCapStatTable_entry          *table_entry;

    switch (reqinfo->mode) {
        /*
         * Read-support (also covers GetNext requests)
         */
    case MODE_GET:
        for (request=requests; request; request=request->next) {
			
            table_entry = (struct dot11WtpWirelessCapStatTable_entry *)
                              netsnmp_extract_iterator_context(request);
            table_info  =     netsnmp_extract_table_info(      request);
           
			if( !table_entry )
			{
					netsnmp_set_request_error(reqinfo,request,SNMP_NOSUCHINSTANCE);
					continue;
				}	  
            switch (table_info->colnum) {
            case COLUMN_AVGRXSIGNALSTRENGTH:
			{   
                void *connection = NULL;
                if(SNMPD_DBUS_ERROR == get_instance_dbus_connection(table_entry->parameter, &connection, SNMPD_INSTANCE_MASTER_V3))
                    break;
                    
				int ret = 0;
				int AvgRxSignalStrength = 0;
				DCLI_WTP_API_GROUP_TWO *WTPINFO;
				char value[256] = { 0 };
				memset(value,0,256);
				char snr_avg[256] = { 0 };
				memset(snr_avg,0,256);
				strncpy(value,"-",sizeof(value)-1);	
				ret=show_wtp_wifi_snr_func(table_entry->parameter, connection,table_entry->wtpCurrID,&WTPINFO);
				if(ret==1)
				{
					if((WTPINFO)&&(WTPINFO->WTP[0]))
					{
						AvgRxSignalStrength = WTPINFO->WTP[0]->wtp_wifi_snr_stats.snr_average;
					}
					snprintf(snr_avg,sizeof(snr_avg)-1,"%d",AvgRxSignalStrength);
					strncat(value,snr_avg,sizeof(value)-strlen(value)-1);
					strncat(value,"dB",sizeof(value)-strlen(value)-1);
				}
				else if(SNMPD_CONNECTION_ERROR == ret) {
                    close_slot_dbus_connection(table_entry->parameter.slot_id);
    	        }
    	        
                snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
                                          (u_char*)value,
                                          strlen(value));
				if(ret==1)
				{
					free_show_wtp_wifi_snr(WTPINFO);
				}
            }
                break;
            case COLUMN_HIGHESTRXSIGNALSTRENGTH:
			{
                void *connection = NULL;
                if(SNMPD_DBUS_ERROR == get_instance_dbus_connection(table_entry->parameter, &connection, SNMPD_INSTANCE_MASTER_V3))
                    break;
                    
				int ret = 0;
				int HighestRxSignalStrength = 0;
				DCLI_WTP_API_GROUP_TWO *WTPINFO;
				char value[256] = { 0 };
				memset(value,0,256);
				char snr_max[256] = { 0 };
				memset(snr_max,0,256);
				strncpy(value,"-",sizeof(value)-1);				
				ret=show_wtp_wifi_snr_func(table_entry->parameter, connection,table_entry->wtpCurrID,&WTPINFO);
				if(ret==1)
				{
					if((WTPINFO)&&(WTPINFO->WTP[0]))
					{
						HighestRxSignalStrength = WTPINFO->WTP[0]->wtp_wifi_snr_stats.snr_max;
					}
					snprintf(snr_max,sizeof(snr_max)-1,"%d",HighestRxSignalStrength);
					strncat(value,snr_max,sizeof(value)-strlen(value)-1);
					strncat(value,"dB",sizeof(value)-strlen(value)-1);
				}
				else if(SNMPD_CONNECTION_ERROR == ret) {
                    close_slot_dbus_connection(table_entry->parameter.slot_id);
    	        }
    	        
                snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
                                          (u_char*)value,
                                          strlen(value));
				if(ret==1)
				{
					free_show_wtp_wifi_snr(WTPINFO);
				}
            }
                break;
            case COLUMN_LOWESTRXSIGNALSTRENGTH:
			{
                void *connection = NULL;
                if(SNMPD_DBUS_ERROR == get_instance_dbus_connection(table_entry->parameter, &connection, SNMPD_INSTANCE_MASTER_V3))
                    break;
                    
				int ret = 0;
				int LowestRxSignalStrength=0;
				DCLI_WTP_API_GROUP_TWO *WTPINFO;
                char value[256] = { 0 };
				memset(value,0,256);
				char snr_min[256] = { 0 };
				memset(snr_min,0,256);
				strncpy(value,"-",sizeof(value)-1);		
				ret=show_wtp_wifi_snr_func(table_entry->parameter, connection,table_entry->wtpCurrID,&WTPINFO);
				if(ret==1)
				{
					if((WTPINFO)&&(WTPINFO->WTP[0]))
					{
						if((WTPINFO->WTP[0]->wtp_wifi_snr_stats.snr_min) == 100)
						{
							LowestRxSignalStrength=0;
						}
						else
						{
							LowestRxSignalStrength	=WTPINFO->WTP[0]->wtp_wifi_snr_stats.snr_min;
						}					
					}
				
					snprintf(snr_min,sizeof(snr_min)-1,"%d",LowestRxSignalStrength);
					strncat(value,snr_min,sizeof(value)-strlen(value)-1);
					strncat(value,"dB",sizeof(value)-strlen(value)-1);
				}
				else if(SNMPD_CONNECTION_ERROR == ret) {
                    close_slot_dbus_connection(table_entry->parameter.slot_id);
    	        }
    	        
                snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
                                          (u_char*)value,
                                          strlen(value));
				if(ret==1)
				{
					free_show_wtp_wifi_snr(WTPINFO);
				}
            }
                break;
            case COLUMN_CHSTATSPHYERRPKTS:
			{
                void *connection = NULL;
                if(SNMPD_DBUS_ERROR == get_instance_dbus_connection(table_entry->parameter, &connection, SNMPD_INSTANCE_MASTER_V3))
                    break;
                    
			    int ret = 0;
				unsigned int PhyErrors = 0; 
				DCLI_AC_API_GROUP_THREE *statics = NULL;
				wlan_stats_info *head = NULL;

				ret=show_ap_statistics_list_bywtp(table_entry->parameter, connection,table_entry->wtpCurrID,&statics);
				if(ret==1)
				{
					if((statics)&&(statics->ap_statics_list)&&(statics->ap_statics_list->ap_statics_ele))
					{						
						head = statics->ap_statics_list->ap_statics_ele;
						while(head)
						{	
							if((head->type == 2)&&(head->wlanId == (table_entry->wtpWirelessIfIndex-1)))
							{
								PhyErrors = head->ast_rx_phyerr; 
								break;
							}
							head = head->next;
						}
					}
				}
				else if(SNMPD_CONNECTION_ERROR == ret) {
                    close_slot_dbus_connection(table_entry->parameter.slot_id);
    	        }
    	        
				table_entry->ChstatsPhyerrPkts = PhyErrors;
                snmp_set_var_typed_value( request->requestvb, ASN_COUNTER,
                                          (u_char*)&table_entry->ChstatsPhyerrPkts,
                                          sizeof(long));
				     if(ret==1)
					{
						Free_ap_statistics_head(statics);
					}
			}
                break;
            case COLUMN_CHSTATSFRAMERETRYCNT:
			{
                void *connection = NULL;
                if(SNMPD_DBUS_ERROR == get_instance_dbus_connection(table_entry->parameter, &connection, SNMPD_INSTANCE_MASTER_V3))
                    break;
                    
				int ret =  0;
				DCLI_WTP_API_GROUP_TWO *WTPINFO = NULL;
				ret  = show_wtp_extension_information_v4_func(table_entry->parameter, connection,table_entry->wtpCurrID,&WTPINFO);
				if((ret == 1)&&(WTPINFO)&&(WTPINFO->WTP[0]))
				{ 
				  table_entry->ChstatsFrameRetryCnt = WTPINFO->WTP[0]->wifi_extension_info.tx_retry;
				}
				else if(SNMPD_CONNECTION_ERROR == ret) {
                    close_slot_dbus_connection(table_entry->parameter.slot_id);
    	        }
    	        
                snmp_set_var_typed_value( request->requestvb, ASN_COUNTER,
                                      (u_char*)&table_entry->ChstatsFrameRetryCnt,
                                      sizeof(long));
				if(ret == 1)
				{ 
				  free_show_wtp_extension_information_v4(WTPINFO);
				}
            }
                break;
            case COLUMN_CHSTATSFRAMEERRORCNT:
			{
                void *connection = NULL;
                if(SNMPD_DBUS_ERROR == get_instance_dbus_connection(table_entry->parameter, &connection, SNMPD_INSTANCE_MASTER_V3))
                    break;
                    
			    int ret = 0;
				unsigned int RxErrors = 0; 
				DCLI_AC_API_GROUP_THREE *statics = NULL;
				wlan_stats_info *head = NULL;
				
				ret=show_ap_statistics_list_bywtp(table_entry->parameter, connection,table_entry->wtpCurrID,&statics);
				if(ret==1)
				{
					if((statics)&&(statics->ap_statics_list)&&(statics->ap_statics_list->ap_statics_ele))
					{						
						head = statics->ap_statics_list->ap_statics_ele;
						while(head)
						{	
							if((head->type == 2)&&(head->wlanId == (table_entry->wtpWirelessIfIndex-1)))
							{
								RxErrors = head->rx_errors; 
								break;
							}
							head = head->next;
						}
					}
				}
				else if(SNMPD_CONNECTION_ERROR == ret) {
                    close_slot_dbus_connection(table_entry->parameter.slot_id);
    	        }
    	        
					
                snmp_set_var_typed_value( request->requestvb, ASN_COUNTER,
                                          (u_char*)&table_entry->ChstatsFrameErrorCnt,
                                          sizeof(long));
			    if(ret==1)
				{
					Free_ap_statistics_head(statics);
				}
			}
                break;
            }
        }
        break;

    }
    return SNMP_ERR_NOERROR;
}
示例#28
0
/*******************************************************************************
 函数名称  : mib_etherHistoryTable_handler
 功能描述  : handles requests for the etherHistoryTable table
 输入参数  :
 输出参数  :
 返 回 值  :
 --------------------------------------------------------------------------------
 最近一次修改记录 :
 修改作者   :
 修改目的   :
 修改日期   :
*******************************************************************************/
static int
mib_etherHistoryTable_handler(netsnmp_mib_handler *handler,
                              netsnmp_handler_registration *reginfo,
                              netsnmp_agent_request_info *reqinfo,
                              netsnmp_request_info *requests)
{
    netsnmp_request_info *request;
    netsnmp_table_request_info *table_req_info;
    struct etherHistoryTable_entry *table_entry;

    switch (reqinfo->mode) {
        /*
         * 这里的GET操作已经覆盖了GET_NEXT操作
         */
    case MODE_GET:
        for (request = requests; request; request = request->next) {
            table_entry = (struct etherHistoryTable_entry *)
                netsnmp_extract_iterator_context(request);
            table_req_info = netsnmp_extract_table_info(request);
            if (NULL == table_req_info) {
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOACCESS);
                continue;
            }

            switch (table_req_info->colnum) {
            case COLUMN_ETHERHISTORYINDEX:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           htonl(table_entry->
                                                 etherHistoryIndex));
                break;
            case COLUMN_ETHERHISTORYSAMPLEINDEX:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           htonl(table_entry->
                                                 etherHistorySampleIndex));
                break;
            case COLUMN_ETHERHISTORYINTERVALSTART:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb,
                                           ASN_TIMETICKS,
                                           htonl(table_entry->
                                                 etherHistoryIntervalStart));
                break;
            case COLUMN_ETHERHISTORYDROPEVENTS:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER,
                                           htonl(table_entry->
                                                 etherHistoryDropEvents));
                break;
            case COLUMN_ETHERHISTORYOCTETS:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER,
                                           htonl(table_entry->
                                                 etherHistoryOctets));
                break;
            case COLUMN_ETHERHISTORYPKTS:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER,
                                           htonl(table_entry->
                                                 etherHistoryPkts));
                break;
            case COLUMN_ETHERHISTORYBROADCASTPKTS:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER,
                                           htonl(table_entry->
                                                 etherHistoryBroadcastPkts));
                break;
            case COLUMN_ETHERHISTORYMULTICASTPKTS:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER,
                                           htonl(table_entry->
                                                 etherHistoryMulticastPkts));
                break;
            case COLUMN_ETHERHISTORYCRCALIGNERRORS:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER,
                                           htonl(table_entry->
                                                 etherHistoryCRCAlignErrors));
                break;
            case COLUMN_ETHERHISTORYUNDERSIZEPKTS:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER,
                                           htonl(table_entry->
                                                 etherHistoryUndersizePkts));
                break;
            case COLUMN_ETHERHISTORYOVERSIZEPKTS:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER,
                                           htonl(table_entry->
                                                 etherHistoryOversizePkts));
                break;
            case COLUMN_ETHERHISTORYFRAGMENTS:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER,
                                           htonl(table_entry->
                                                 etherHistoryFragments));
                break;
            case COLUMN_ETHERHISTORYJABBERS:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER,
                                           htonl(table_entry->
                                                 etherHistoryJabbers));
                break;
            case COLUMN_ETHERHISTORYCOLLISIONS:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER,
                                           htonl(table_entry->
                                                 etherHistoryCollisions));
                break;
            case COLUMN_ETHERHISTORYUTILIZATION:
                if (!table_entry) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           htonl(table_entry->
                                                 etherHistoryUtilization));
                break;
            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_NOSUCHOBJECT);
                break;
            }
        }
        break;

    }
    return SNMP_ERR_NOERROR;
}
示例#29
0
/** handles requests for the netSnmpHostsTable table, if anything else needs to be done */
int
netSnmpHostsTable_handler(netsnmp_mib_handler *handler,
                          netsnmp_handler_registration *reginfo,
                          netsnmp_agent_request_info *reqinfo,
                          netsnmp_request_info *requests)
{

    netsnmp_request_info *request;
    netsnmp_table_request_info *table_info;
    struct commitInfo *ci = NULL;

    void           *data_context = NULL;

    for (request = requests; request; request = request->next) {
        /* column and row index encoded portion */
        netsnmp_variable_list *var = request->requestvb;
        const oid * const suffix = var->name + reginfo->rootoid_len + 1;
        const size_t suffix_len = var->name_length - (reginfo->rootoid_len + 1);

        if (request->processed != 0)
            continue;

        switch (reqinfo->mode) {
        case MODE_GET:
        case MODE_SET_RESERVE1:
            data_context = netsnmp_extract_iterator_context(request);
            if (data_context == NULL) {
                if (reqinfo->mode == MODE_GET) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_NOSUCHINSTANCE);
                    continue;
                }
            }
            break;

        default:               /* == the other SET modes */
            ci = netsnmp_oid_stash_get_data(commitStorage,
                                            suffix + 1, suffix_len - 1);
            break;

        }

        /** extracts the information about the table from the request */
        table_info = netsnmp_extract_table_info(request);
        /** table_info->colnum contains the column number requested */
        /** table_info->indexes contains a linked list of snmp variable
           bindings for the indexes of the table.  Values in the list
           have been set corresponding to the indexes of the
           request */
        if (table_info == NULL) {
            continue;
        }

        switch (reqinfo->mode) {
        case MODE_GET:
            switch (table_info->colnum) {
            case COLUMN_NETSNMPHOSTADDRESSTYPE:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval =
                        get_netSnmpHostAddressType(data_context,
                                                   &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_NETSNMPHOSTADDRESS:
                {
                    char           *retval;
                    size_t          retval_len = 0;
                    retval =
                        get_netSnmpHostAddress(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_OCTET_STR,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_NETSNMPHOSTSTORAGE:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval =
                        get_netSnmpHostStorage(data_context, &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            case COLUMN_NETSNMPHOSTROWSTATUS:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    retval =
                        get_netSnmpHostRowStatus(data_context,
                                                 &retval_len);
                    snmp_set_var_typed_value(var, ASN_INTEGER,
                                             (const u_char *) retval,
                                             retval_len);
                }
                break;

            default:
                /** We shouldn't get here */
                snmp_log(LOG_ERR,
                         "problem encountered in netSnmpHostsTable_handler: unknown column\n");
            }
            break;

        case MODE_SET_RESERVE1:
            ci = netsnmp_oid_stash_get_data(commitStorage,
                                            suffix + 1, suffix_len - 1);

            if (!ci) {
                    /** create the commit storage info */
                ci = SNMP_MALLOC_STRUCT(commitInfo);
                if (!data_context) {
                    ci->data_context =
                        netSnmpHostsTable_create_data_context(table_info->
                                                              indexes);
                    ci->new_row = 1;
                } else {
                    ci->data_context = data_context;
                }
                netsnmp_oid_stash_add_data(&commitStorage,
                                           suffix + 1, suffix_len - 1, ci);
            }
            break;

        case MODE_SET_RESERVE2:
            switch (table_info->colnum) {
            case COLUMN_NETSNMPHOSTADDRESSTYPE:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    struct undoInfo *ui = NULL;
                    int             ret;

                    /** first, get the old value */
                    retval =
                        get_netSnmpHostAddressType(ci->data_context,
                                                   &retval_len);
                    if (retval) {
                        ui = SNMP_MALLOC_STRUCT(undoInfo);
                        ui->len = retval_len;
                        memdup((u_char **) & ui->ptr,
                               (u_char *) retval, ui->len);
                    }

                    /** check the new value, possibly against the
                        older value for a valid state transition */
                    ret =
                        check_netSnmpHostAddressType(request->requestvb->
                                                     type,
                                                     (long *) request->
                                                     requestvb->val.string,
                                                     request->requestvb->
                                                     val_len, retval,
                                                     retval_len);
                    if (ret != 0) {
                        netsnmp_set_request_error(reqinfo, request, ret);
                        netSnmpHostsTable_free_undoInfo(ui);
                    } else if (ui) {
                        /** remember information for undo purposes later */
                        netsnmp_oid_stash_add_data(&undoStorage,
                                                   suffix, suffix_len, ui);
                    }

                }
                break;
            case COLUMN_NETSNMPHOSTADDRESS:
                {
                    char           *retval;
                    size_t          retval_len = 0;
                    struct undoInfo *ui = NULL;
                    int             ret;

                    /** first, get the old value */
                    retval =
                        get_netSnmpHostAddress(ci->data_context,
                                               &retval_len);
                    if (retval) {
                        ui = SNMP_MALLOC_STRUCT(undoInfo);
                        ui->len = retval_len;
                        memdup((u_char **) & ui->ptr,
                               (u_char *) retval, ui->len);
                    }

                    /** check the new value, possibly against the
                        older value for a valid state transition */
                    ret =
                        check_netSnmpHostAddress(request->requestvb->type,
                                                 (char *) request->
                                                 requestvb->val.string,
                                                 request->requestvb->
                                                 val_len, retval,
                                                 retval_len);
                    if (ret != 0) {
                        netsnmp_set_request_error(reqinfo, request, ret);
                        netSnmpHostsTable_free_undoInfo(ui);
                    } else if (ui) {
                        /** remember information for undo purposes later */
                        netsnmp_oid_stash_add_data(&undoStorage,
                                                   suffix, suffix_len, ui);
                    }

                }
                break;
            case COLUMN_NETSNMPHOSTSTORAGE:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    struct undoInfo *ui = NULL;
                    int             ret;

                    /** first, get the old value */
                    retval =
                        get_netSnmpHostStorage(ci->data_context,
                                               &retval_len);
                    if (retval) {
                        ui = SNMP_MALLOC_STRUCT(undoInfo);
                        ui->len = retval_len;
                        memdup((u_char **) & ui->ptr,
                               (u_char *) retval, ui->len);
                    }

                    /** check the new value, possibly against the
                        older value for a valid state transition */
                    ret =
                        check_netSnmpHostStorage(request->requestvb->type,
                                                 (long *) request->
                                                 requestvb->val.string,
                                                 request->requestvb->
                                                 val_len, retval,
                                                 retval_len);
                    if (ret != 0) {
                        netsnmp_set_request_error(reqinfo, request, ret);
                        netSnmpHostsTable_free_undoInfo(ui);
                    } else if (ui) {
                        /** remember information for undo purposes later */
                        netsnmp_oid_stash_add_data(&undoStorage,
                                                   suffix, suffix_len, ui);
                    }

                }
                break;
            case COLUMN_NETSNMPHOSTROWSTATUS:
                {
                    long           *retval;
                    size_t          retval_len = 0;
                    struct undoInfo *ui = NULL;
                    int             ret;

                    /** first, get the old value */
                    retval =
                        get_netSnmpHostRowStatus(ci->data_context,
                                                 &retval_len);
                    if (retval) {
                        ui = SNMP_MALLOC_STRUCT(undoInfo);
                        ui->len = retval_len;
                        memdup((u_char **) & ui->ptr,
                               (u_char *) retval, ui->len);
                    }

                    /** check the new value, possibly against the
                        older value for a valid state transition */
                    ret =
                        check_netSnmpHostRowStatus(request->requestvb->
                                                   type,
                                                   (long *) request->
                                                   requestvb->val.string,
                                                   request->requestvb->
                                                   val_len, retval,
                                                   retval_len);
                    if (ret != 0) {
                        netsnmp_set_request_error(reqinfo, request, ret);
                        netSnmpHostsTable_free_undoInfo(ui);
                    } else if (ui) {
                        /** remember information for undo purposes later */
                        netsnmp_oid_stash_add_data(&undoStorage,
                                                   suffix, suffix_len, ui);
                    }

                }
                break;
            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOTWRITABLE);
                break;
            }
            break;

        case MODE_SET_ACTION:
            /** save a variable copy */
            switch (table_info->colnum) {
            case COLUMN_NETSNMPHOSTADDRESSTYPE:
                {
                    int             ret;
                    ret = set_netSnmpHostAddressType(ci->data_context,
                                                     (long *) request->
                                                     requestvb->val.string,
                                                     request->requestvb->
                                                     val_len);
                    if (ret) {
                        netsnmp_set_request_error(reqinfo, request, ret);
                    }
                }
                break;
            case COLUMN_NETSNMPHOSTADDRESS:
                {
                    int             ret;
                    ret = set_netSnmpHostAddress(ci->data_context,
                                                 (char *) request->
                                                 requestvb->val.string,
                                                 request->requestvb->
                                                 val_len);
                    if (ret) {
                        netsnmp_set_request_error(reqinfo, request, ret);
                    }
                }
                break;
            case COLUMN_NETSNMPHOSTSTORAGE:
                {
                    int             ret;
                    ret = set_netSnmpHostStorage(ci->data_context,
                                                 (long *) request->
                                                 requestvb->val.string,
                                                 request->requestvb->
                                                 val_len);
                    if (ret) {
                        netsnmp_set_request_error(reqinfo, request, ret);
                    }
                }
                break;
            case COLUMN_NETSNMPHOSTROWSTATUS:
                {
                    int             ret;
                    ret = set_netSnmpHostRowStatus(ci->data_context,
                                                   (long *) request->
                                                   requestvb->val.string,
                                                   request->requestvb->
                                                   val_len);
                    if (ret) {
                        netsnmp_set_request_error(reqinfo, request, ret);
                    }
                    if (*request->requestvb->val.integer == RS_DESTROY) {
                        ci->new_row = -1;
                    }
                }
                break;
            }
            break;

        case MODE_SET_COMMIT:
            if (!ci->have_committed) {
                    /** do this once per row only */
                netSnmpHostsTable_commit_row(&ci->data_context,
                                             ci->new_row);
                ci->have_committed = 1;
            }
            break;

        case MODE_SET_UNDO:
             /** save a variable copy */
            switch (table_info->colnum) {
            case COLUMN_NETSNMPHOSTADDRESSTYPE:
                {
                    int             retval;
                    struct undoInfo *ui;
                    ui = netsnmp_oid_stash_get_data(undoStorage,
                                                    suffix, suffix_len);
                    retval =
                        set_netSnmpHostAddressType(ci->data_context,
                                                   ui->ptr, ui->len);
                    if (retval) {
                        netsnmp_set_request_error(reqinfo, request,
                                                  SNMP_ERR_UNDOFAILED);
                    }
                }
                break;
            case COLUMN_NETSNMPHOSTADDRESS:
                {
                    int             retval;
                    struct undoInfo *ui;
                    ui = netsnmp_oid_stash_get_data(undoStorage,
                                                    suffix, suffix_len);
                    retval =
                        set_netSnmpHostAddress(ci->data_context, ui->ptr,
                                               ui->len);
                    if (retval) {
                        netsnmp_set_request_error(reqinfo, request,
                                                  SNMP_ERR_UNDOFAILED);
                    }
                }
                break;
            case COLUMN_NETSNMPHOSTSTORAGE:
                {
                    int             retval;
                    struct undoInfo *ui;
                    ui = netsnmp_oid_stash_get_data(undoStorage,
                                                    suffix, suffix_len);
                    retval =
                        set_netSnmpHostStorage(ci->data_context, ui->ptr,
                                               ui->len);
                    if (retval) {
                        netsnmp_set_request_error(reqinfo, request,
                                                  SNMP_ERR_UNDOFAILED);
                    }
                }
                break;
            case COLUMN_NETSNMPHOSTROWSTATUS:
                {
                    int             retval;
                    struct undoInfo *ui;
                    ui = netsnmp_oid_stash_get_data(undoStorage,
                                                    suffix, suffix_len);
                    retval =
                        set_netSnmpHostRowStatus(ci->data_context, ui->ptr,
                                                 ui->len);
                    if (retval) {
                        netsnmp_set_request_error(reqinfo, request,
                                                  SNMP_ERR_UNDOFAILED);
                    }
                }
                break;
            }
            break;

        case MODE_SET_FREE:
            break;

        default:
            snmp_log(LOG_ERR,
                     "problem encountered in netSnmpHostsTable_handler: unsupported mode\n");
        }
    }

    /** clean up after all requset processing has ended */
    switch (reqinfo->mode) {
    case MODE_SET_UNDO:
    case MODE_SET_FREE:
    case MODE_SET_COMMIT:
        /** clear out the undo cache */
        netsnmp_oid_stash_free(&undoStorage,
                               netSnmpHostsTable_free_undoInfo);
        netsnmp_oid_stash_free(&commitStorage, netsnmp_oid_stash_no_free);
    }


    return SNMP_ERR_NOERROR;
}
示例#30
0
/** handles requests for the LHAMembershipTable table, if anything else needs to be done */
int
LHAMembershipTable_handler(
    netsnmp_mib_handler               *handler,
    netsnmp_handler_registration      *reginfo,
    netsnmp_agent_request_info        *reqinfo,
    netsnmp_request_info              *requests) {

    netsnmp_request_info *request;
    netsnmp_table_request_info *table_info;
    netsnmp_variable_list *var;

    SaClmClusterNotificationT * entry;
    int member;
    
    for(request = requests; request; request = request->next) {
        var = request->requestvb;
        if (request->processed != 0)
            continue;

        /** perform anything here that you need to do before each
           request is processed. */

        /** the following extracts the my_data_context pointer set in
           the loop functions above.  You can then use the results to
           help return data for the columns of the LHAMembershipTable table in question */
        entry = (SaClmClusterNotificationT *) 
	    netsnmp_extract_iterator_context(request);

        if (entry == NULL) {
            if (reqinfo->mode == MODE_GET) {
                netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
                continue;
            }
            /** XXX: no row existed, if you support creation and this is a
               set, start dealing with it here, else continue */
        }

        /** extracts the information about the table from the request */
        table_info = netsnmp_extract_table_info(request);
        /** table_info->colnum contains the column number requested */
        /** table_info->indexes contains a linked list of snmp variable
           bindings for the indexes of the table.  Values in the list
           have been set corresponding to the indexes of the
           request */
        if (table_info==NULL) {
            continue;
        }

        switch(reqinfo->mode) {
            /** the table_iterator helper should change all GETNEXTs
               into GETs for you automatically, so you don't have to
               worry about the GETNEXT case.  Only GETs and SETs need
               to be dealt with here */
            case MODE_GET:
                switch(table_info->colnum) {
                    case COLUMN_LHAMEMBERNAME:
                        snmp_set_var_typed_value(var, 
				ASN_OCTET_STR, 
				(u_char *) entry->clusterNode.nodeName.value, 
				strlen((char *)entry->clusterNode.nodeName.value) + 1);
                        break;

                    case COLUMN_LHAMEMBERADDRESS:
                        snmp_set_var_typed_value(var, 
				ASN_OCTET_STR, 
				(u_char *) entry->clusterNode.nodeAddress.value, 
				SA_CLM_MAX_ADDRESS_LENGTH);
                        break;

                    case COLUMN_LHAMEMBERCLUSTERNAME:
                        snmp_set_var_typed_value(var, 
				ASN_OCTET_STR, 
				(u_char *) entry->clusterNode.clusterName.value, 
				strlen((char *)entry->clusterNode.clusterName.value) + 1);
                        break;

                    case COLUMN_LHAMEMBERISMEMBER:
			if (entry->clusterNode.member)
			    member = 1;
			else 
			    member = 2;

                        snmp_set_var_typed_value(var, 
				ASN_INTEGER, 
				(u_char *) &member, 
				sizeof(member));
                        break;

                    case COLUMN_LHAMEMBERLASTCHANGE:
                        snmp_set_var_typed_value(var, 
				ASN_INTEGER, 
				(u_char *) & entry->clusterChanges, 
				sizeof(entry->clusterChanges));
                        break;

                    case COLUMN_LHAMEMBERBOOTTIME:
                        snmp_set_var_typed_value(var, 
				ASN_TIMETICKS, 
				(u_char *) & entry->clusterNode.bootTimestamp, 
				sizeof(entry->clusterNode.bootTimestamp));
                        break;

                    default:
                        /** We shouldn't get here */
                        snmp_log(LOG_ERR, "problem encountered in LHAMembershipTable_handler: unknown column\n");
                }
                break;

            case MODE_SET_RESERVE1:
                /** set handling... */

            default:
                snmp_log(LOG_ERR, "problem encountered in LHAMembershipTable_handler: unsupported mode\n");
        }
    }
    return SNMP_ERR_NOERROR;
}