您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ snmp_set_var_typed_value函数代码示例

51自学网 2021-06-03 08:04:21
  C++
这篇教程C++ snmp_set_var_typed_value函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中snmp_set_var_typed_value函数的典型用法代码示例。如果您正苦于以下问题:C++ snmp_set_var_typed_value函数的具体用法?C++ snmp_set_var_typed_value怎么用?C++ snmp_set_var_typed_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了snmp_set_var_typed_value函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: handle_ipAddressSpinLock

static inthandle_ipAddressSpinLock(netsnmp_mib_handler *handler,                          netsnmp_handler_registration *reginfo,                          netsnmp_agent_request_info   *reqinfo,                          netsnmp_request_info         *requests){    long   value;    /* We are never called for a GETNEXT if it's registered as a       "instance", as it's "magically" handled for us.  */    /* a instance handler also only hands us one request at a time, so       we don't need to loop over a list of requests; we'll only get one. */    switch(reqinfo->mode) {        case MODE_GET:            snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,                                     (u_char *)&ipAddressSpinLockValue,                                      sizeof(ipAddressSpinLockValue));            break;#ifndef NETSNMP_NO_WRITE_SUPPORT        /*         * SET REQUEST         *         * multiple states in the transaction.  See:         * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg         */        case MODE_SET_RESERVE1:        case MODE_SET_RESERVE2:            /* just check the value */            value =  *(requests->requestvb->val.integer);            if (value != ipAddressSpinLockValue)                netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_INCONSISTENTVALUE);            break;        case MODE_SET_FREE:            break;        case MODE_SET_ACTION:            /* perform the final spinlock check and increase its value */            value =  *(requests->requestvb->val.integer);            if (value != ipAddressSpinLockValue) {                netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_INCONSISTENTVALUE);            } else {                ipAddressSpinLockValue++;                /* and check it for overflow */                if (ipAddressSpinLockValue > 2147483647 || ipAddressSpinLockValue < 0)                    ipAddressSpinLockValue = 0;            }            break;        case MODE_SET_COMMIT:            break;        case MODE_SET_UNDO:             break;#endif /* !NETSNMP_NO_WRITE_SUPPORT */        default:            /* we should never get here, so this is a really bad error */            snmp_log(LOG_ERR, "unknown mode (%d) in handle_ipAddressSpinLock/n", reqinfo->mode );            return SNMP_ERR_GENERR;    }    return SNMP_ERR_NOERROR;}
开发者ID:WimObiwan,项目名称:net-snmp,代码行数:68,


示例2: mteEventNotificationTable_handler

/** handles requests for the mteEventNotificationTable table */intmteEventNotificationTable_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 *tinfo;    struct mteEvent            *entry;    int ret;    DEBUGMSGTL(("disman:event:mib", "Notification Table handler (%d)/n", reqinfo->mode));    switch (reqinfo->mode) {        /*         * Read-support (also covers GetNext requests)         */    case MODE_GET:        for (request = requests; request; request = request->next) {            entry = (struct mteEvent *) netsnmp_tdata_extract_entry(request);            tinfo = netsnmp_extract_table_info(request);            /*             * The mteEventNotificationTable should only contains entries             *   for rows where the mteEventActions 'notification(0)' bit             *   is set. So skip entries where this isn't the case.             */            if (!entry || !(entry->mteEventActions & MTE_EVENT_NOTIFICATION))                continue;            switch (tinfo->colnum) {            case COLUMN_MTEEVENTNOTIFICATION:                snmp_set_var_typed_value(request->requestvb, ASN_OBJECT_ID,                              (u_char *) entry->mteNotification,                                         entry->mteNotification_len*sizeof(oid));                break;            case COLUMN_MTEEVENTNOTIFICATIONOBJECTSOWNER:                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,                              (u_char *) entry->mteNotifyOwner,                                  strlen(entry->mteNotifyOwner));                break;            case COLUMN_MTEEVENTNOTIFICATIONOBJECTS:                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,                              (u_char *) entry->mteNotifyObjects,                                  strlen(entry->mteNotifyObjects));                break;            }        }        break;        /*         * Write-support         */    case MODE_SET_RESERVE1:        for (request = requests; request; request = request->next) {            tinfo = netsnmp_extract_table_info(request);            /*             * Since the mteEventNotificationTable only contains entries             *   for rows where the mteEventActions 'notification(0)'             *   bit is set, strictly speaking we should reject             *   assignments where this isn't the case.             * But SET requests that include an assignment of the             *   'notification(0)' bit at the same time are valid,             *   so would need to be accepted. Unfortunately, this             *   assignment is only applied in the COMMIT pass, so             *   it's difficult to detect whether this holds or not.             *             * Let's fudge things for now, by processing assignments             *   even if the 'notification(0)' bit isn't set.             */            switch (tinfo->colnum) {            case COLUMN_MTEEVENTNOTIFICATION:                ret = netsnmp_check_vb_oid( request->requestvb );                if (ret != SNMP_ERR_NOERROR) {                    netsnmp_set_request_error(reqinfo, request, ret);                    return SNMP_ERR_NOERROR;                }                break;            case COLUMN_MTEEVENTNOTIFICATIONOBJECTSOWNER:            case COLUMN_MTEEVENTNOTIFICATIONOBJECTS:                ret = netsnmp_check_vb_type_and_max_size(                          request->requestvb, ASN_OCTET_STR, MTE_STR1_LEN);                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;            }            /*             * The Event MIB is somewhat ambiguous as to whether             *  mteEventNotificationTable (and mteEventSetTable)//.........这里部分代码省略.........
开发者ID:KrisChaplin,项目名称:LRT2x4_v1.0.2.06_GPL_source,代码行数:101,


示例3: handle_BSSIDFilterSwitch

inthandle_BSSIDFilterSwitch(netsnmp_mib_handler *handler,                          netsnmp_handler_registration *reginfo,                          netsnmp_agent_request_info   *reqinfo,                          netsnmp_request_info         *requests){    /* We are never called for a GETNEXT if it's registered as a       "instance", as it's "magically" handled for us.  */    /* a instance handler also only hands us one request at a time, so       we don't need to loop over a list of requests; we'll only get one. */	snmp_log(LOG_DEBUG, "enter handle_BSSIDFilterSwitch/n");    switch(reqinfo->mode) {        case MODE_GET:		{			int BSSIDFilterOnOff = 0;            instance_parameter *paraHead = NULL;            if(SNMPD_DBUS_SUCCESS == get_slot_dbus_connection(LOCAL_SLOT_NUM, &paraHead, SNMPD_INSTANCE_MASTER_V2))            {                int ret = 0;    			DCLI_AC_API_GROUP_FIVE *wirelessconfig = NULL;    			wireless_config *head = NULL;    			snmp_log(LOG_DEBUG, "enter show_wc_config/n");    			ret = show_wc_config(paraHead->parameter, paraHead->connection,&wirelessconfig);    			snmp_log(LOG_DEBUG, "exit show_wc_config,ret=%d/n", ret);    			    			if((ret == 1)&&(wirelessconfig->wireless_control != NULL))    			{    				head = wirelessconfig->wireless_control;    				BSSIDFilterOnOff = (head->macfiltrflag==1)?1:0;    			}			    if(ret == 1)    			{    				Free_wc_config(wirelessconfig);    			}			}            free_instance_parameter_list(&paraHead);            snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,                                     (u_char *)&BSSIDFilterOnOff,                                     sizeof(BSSIDFilterOnOff));			        }            break;        /*         * SET REQUEST         *         * multiple states in the transaction.  See:         * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg         */        case MODE_SET_RESERVE1:			#if 0            if (/* XXX: check incoming data in requests->requestvb->val.XXX for failures, like an incorrect type or an illegal value or ... */) {                netsnmp_set_request_error(reqinfo, requests, /* XXX: set error code depending on problem (like SNMP_ERR_WRONGTYPE or SNMP_ERR_WRONGVALUE or ... */);            }			#endif            break;        case MODE_SET_RESERVE2:			#if 0            /* XXX malloc "undo" storage buffer */            if (/* XXX if malloc, or whatever, failed: */) {                netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_RESOURCEUNAVAILABLE);            }			#endif            break;        case MODE_SET_FREE:            /* XXX: free resources allocated in RESERVE1 and/or               RESERVE2.  Something failed somewhere, and the states               below won't be called. */            break;        case MODE_SET_ACTION:		{						int ret = 0;			if(*requests->requestvb->val.integer==0)			{                instance_parameter *paraHead = NULL, *paraNode = NULL;                list_instance_parameter(&paraHead, SNMPD_INSTANCE_MASTER);                for(paraNode = paraHead; NULL != paraNode; paraNode = paraNode->next)                {    				snmp_log(LOG_DEBUG, "enter set_wid_mac_whitelist_cmd/n");    				ret = set_wid_mac_whitelist_cmd(paraNode->parameter, paraNode->connection,"disable");    				snmp_log(LOG_DEBUG, "exit set_wid_mac_whitelist_cmd,ret=%d/n", ret);    				    				if(ret != 1)    				{	    				    if(SNMPD_CONNECTION_ERROR == ret) {                            close_slot_dbus_connection(paraNode->parameter.slot_id);                	    }    					netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_WRONGTYPE);    				}    			}	//.........这里部分代码省略.........
开发者ID:inibir,项目名称:daemongroup,代码行数:101,


示例4: handle_systemStats

int handle_systemStats(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests){	netsnmp_request_info *request = NULL;	oid subid;	switch_time_t uptime;	uint32_t int_val = 0;	switch(reqinfo->mode) {	case MODE_GET:		subid = requests->requestvb->name[reginfo->rootoid_len - 2];		snmp_log(LOG_DEBUG, "systemStats OID-suffix requested (%d)/n", (int) subid);		switch (subid) {		case SS_UPTIME:			uptime = switch_core_uptime() / 10000;			snmp_set_var_typed_value(requests->requestvb, ASN_TIMETICKS, (u_char *) &uptime, sizeof(uptime));			break;		case SS_SESSIONS_SINCE_STARTUP:			int_val = switch_core_session_id() - 1;			snmp_set_var_typed_integer(requests->requestvb, ASN_COUNTER, int_val);			break;		case SS_CURRENT_SESSIONS:			int_val = switch_core_session_count();			snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val);			break;		case SS_MAX_SESSIONS:			switch_core_session_ctl(SCSC_MAX_SESSIONS, &int_val);			snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val);			break;		case SS_CURRENT_CALLS:			{			switch_cache_db_handle_t *dbh;			char sql[1024] = "";			if (switch_core_db_handle(&dbh) != SWITCH_STATUS_SUCCESS) {				return SNMP_ERR_GENERR;			}			sprintf(sql, "SELECT COUNT(*) FROM calls WHERE hostname='%s'", switch_core_get_switchname());			switch_cache_db_execute_sql_callback(dbh, sql, sql_count_callback, &int_val, NULL);			snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val);			switch_cache_db_release_db_handle(&dbh);			}			break;		case SS_SESSIONS_PER_SECOND:			switch_core_session_ctl(SCSC_LAST_SPS, &int_val);			snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val);			break;		case SS_MAX_SESSIONS_PER_SECOND:			switch_core_session_ctl(SCSC_SPS, &int_val);			snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val);			break;		case SS_PEAK_SESSIONS_PER_SECOND:			switch_core_session_ctl(SCSC_SPS_PEAK, &int_val);			snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val);			break;		case SS_PEAK_SESSIONS_PER_FIVEMIN:			switch_core_session_ctl(SCSC_SPS_PEAK_FIVEMIN, &int_val);			snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val);			break;		case SS_PEAK_SESSIONS:			switch_core_session_ctl(SCSC_SESSIONS_PEAK, &int_val);			snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val);			break;		case SS_PEAK_SESSIONS_FIVEMIN:			switch_core_session_ctl(SCSC_SESSIONS_PEAK_FIVEMIN, &int_val);			snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val);			break;		default:			snmp_log(LOG_WARNING, "Unregistered OID-suffix requested (%d)/n", (int) subid);			netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);		}		break;	default:		/* we should never get here, so this is a really bad error */		snmp_log(LOG_ERR, "Unknown mode (%d) in handle_systemStats/n", reqinfo->mode);		return SNMP_ERR_GENERR;	}	return SNMP_ERR_NOERROR;}
开发者ID:PauloFer1,项目名称:FreeSWITCH,代码行数:82,


示例5: mteTriggerBooleanTable_handler

/** handles requests for the mteTriggerBooleanTable table */intmteTriggerBooleanTable_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 *tinfo;    struct mteTrigger          *entry;    int ret;    DEBUGMSGTL(("disman:event:mib", "Boolean Table handler (%d)/n",                                     reqinfo->mode));    switch (reqinfo->mode) {        /*         * Read-support (also covers GetNext requests)         */    case MODE_GET:        for (request = requests; request; request = request->next) {            if (request->processed)                continue;            entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);            tinfo = netsnmp_extract_table_info(request);            /*             * The mteTriggerBooleanTable should only contains entries for             *   rows where the mteTriggerTest 'boolean(1)' bit is set.             * So skip entries where this isn't the case.             */            if (!entry || !(entry->mteTriggerTest & MTE_TRIGGER_BOOLEAN )) {                netsnmp_request_set_error(request, SNMP_NOSUCHINSTANCE);                continue;            }            switch (tinfo->colnum) {            case COLUMN_MTETRIGGERBOOLEANCOMPARISON:                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,                                           entry->mteTBoolComparison);                break;            case COLUMN_MTETRIGGERBOOLEANVALUE:                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,                                           entry->mteTBoolValue);                break;            case COLUMN_MTETRIGGERBOOLEANSTARTUP:                ret = (entry->flags & MTE_TRIGGER_FLAG_BSTART ) ?                           TV_TRUE : TV_FALSE;                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, ret);                break;            case COLUMN_MTETRIGGERBOOLEANOBJECTSOWNER:                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,                              (u_char *) entry->mteTBoolObjOwner,                                  strlen(entry->mteTBoolObjOwner));                break;            case COLUMN_MTETRIGGERBOOLEANOBJECTS:                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,                              (u_char *) entry->mteTBoolObjects,                                  strlen(entry->mteTBoolObjects));                break;            case COLUMN_MTETRIGGERBOOLEANEVENTOWNER:                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,                              (u_char *) entry->mteTBoolEvOwner,                                  strlen(entry->mteTBoolEvOwner));                break;            case COLUMN_MTETRIGGERBOOLEANEVENT:                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,                              (u_char *) entry->mteTBoolEvent,                                  strlen(entry->mteTBoolEvent));                break;            }        }        break;#ifndef NETSNMP_NO_WRITE_SUPPORT        /*         * Write-support         */    case MODE_SET_RESERVE1:        for (request = requests; request; request = request->next) {            if (request->processed)                continue;            entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);            tinfo = netsnmp_extract_table_info(request);            /*             * Since the mteTriggerBooleanTable only contains entries for             *   rows where the mteTriggerTest 'boolean(1)' bit is set,             *   strictly speaking we should reject assignments where             *   this isn't the case.             * But SET requests that include an assignment of the             *   'boolean(1)' bit at the same time are valid, so would             *    need to be accepted. Unfortunately, this assignment             *   is only applied in the COMMIT pass, so it's difficult             *   to detect whether this holds or not.             *             * Let's fudge things for now, by processing assignments//.........这里部分代码省略.........
开发者ID:ClausKlein,项目名称:net-snmp,代码行数:101,


示例6: saHpiSensorTable_get_value

/************************************************************ * saHpiSensorTable_get_value * * This routine is called for get requests to copy the data * from the context to the varbind for the request. If the * context has been properly maintained, you don't need to * change in code in this fuction. */int saHpiSensorTable_get_value(            netsnmp_request_info *request,            netsnmp_index *item,            netsnmp_table_request_info *table_info ){    netsnmp_variable_list *var = request->requestvb;    saHpiSensorTable_context *context = (saHpiSensorTable_context *)item;    DEBUGMSGTL ((AGENT, "saHpiSensorTable_get_value, called/n"));    switch(table_info->colnum) {        case COLUMN_SAHPISENSORNUM:            /** SaHpiInstrumentId = ASN_UNSIGNED */            snmp_set_var_typed_value(var, ASN_UNSIGNED,                         (char*)&context->saHpiSensorNum,                         sizeof(context->saHpiSensorNum) );        break;            case COLUMN_SAHPISENSORTYPE:            /** SaHpiSensorType = ASN_INTEGER */            snmp_set_var_typed_value(var, ASN_INTEGER,                         (char*)&context->saHpiSensorType,                         sizeof(context->saHpiSensorType) );        break;            case COLUMN_SAHPISENSORCATEGORY:            /** SaHpiEventCategory = ASN_INTEGER */            snmp_set_var_typed_value(var, ASN_INTEGER,                         (char*)&context->saHpiSensorCategory,                         sizeof(context->saHpiSensorCategory) );        break;            case COLUMN_SAHPISENSORENABLECTRL:            /** TruthValue = ASN_INTEGER */            snmp_set_var_typed_value(var, ASN_INTEGER,                         (char*)&context->saHpiSensorEnableCtrl,                         sizeof(context->saHpiSensorEnableCtrl) );        break;            case COLUMN_SAHPISENSOREVENTCTRL:            /** INTEGER = ASN_INTEGER */            snmp_set_var_typed_value(var, ASN_INTEGER,                         (char*)&context->saHpiSensorEventCtrl,                         sizeof(context->saHpiSensorEventCtrl) );        break;            case COLUMN_SAHPISENSORSUPPORTEDEVENTSTATES:            /** SaHpiEventState = ASN_OCTET_STR */            snmp_set_var_typed_value(var, ASN_OCTET_STR,                         (char*)&context->saHpiSensorSupportedEventStates,                         context->saHpiSensorSupportedEventStates_len );        break;            case COLUMN_SAHPISENSORISSUPPORTED:            /** TruthValue = ASN_INTEGER */            snmp_set_var_typed_value(var, ASN_INTEGER,                         (char*)&context->saHpiSensorIsSupported,                         sizeof(context->saHpiSensorIsSupported) );        break;            case COLUMN_SAHPISENSORREADINGTYPE:            /** SaHpiSensorReadingType = ASN_INTEGER */            snmp_set_var_typed_value(var, ASN_INTEGER,                         (char*)&context->saHpiSensorReadingType,                         sizeof(context->saHpiSensorReadingType) );        break;            case COLUMN_SAHPISENSORBASEUNITS:            /** SaHpiSensorUnits = ASN_INTEGER */            snmp_set_var_typed_value(var, ASN_INTEGER,                         (char*)&context->saHpiSensorBaseUnits,                         sizeof(context->saHpiSensorBaseUnits) );        break;            case COLUMN_SAHPISENSORMODIFIERUNITS:            /** SaHpiSensorUnits = ASN_INTEGER */            snmp_set_var_typed_value(var, ASN_INTEGER,                         (char*)&context->saHpiSensorModifierUnits,                         sizeof(context->saHpiSensorModifierUnits) );        break;            case COLUMN_SAHPISENSORMODIFIERUSE:            /** INTEGER = ASN_INTEGER */            snmp_set_var_typed_value(var, ASN_INTEGER,                         (char*)&context->saHpiSensorModifierUse,                         sizeof(context->saHpiSensorModifierUse) );        break;            case COLUMN_SAHPISENSORPERCENTAGE:            /** TruthValue = ASN_INTEGER */            snmp_set_var_typed_value(var, ASN_INTEGER,//.........这里部分代码省略.........
开发者ID:openhpi1,项目名称:testrepo,代码行数:101,


示例7: handle_subagent_response

inthandle_subagent_response(int op, netsnmp_session * session, int reqid,                         netsnmp_pdu *pdu, void *magic){    ns_subagent_magic *smagic = (ns_subagent_magic *) magic;    netsnmp_variable_list *u = NULL, *v = NULL;    int             rc = 0;    if (op != NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE || magic == NULL) {        return 1;    }    pdu = snmp_clone_pdu(pdu);    DEBUGMSGTL(("agentx/subagent",                "handling AgentX response (cmd 0x%02x orig_cmd 0x%02x)/n",                pdu->command, smagic->original_command));    if (pdu->command == SNMP_MSG_INTERNAL_SET_FREE ||        pdu->command == SNMP_MSG_INTERNAL_SET_UNDO ||        pdu->command == SNMP_MSG_INTERNAL_SET_COMMIT) {        free_set_vars(smagic->session, pdu);    }    if (smagic->original_command == AGENTX_MSG_GETNEXT) {        DEBUGMSGTL(("agentx/subagent",                    "do getNext scope processing %p %p/n", smagic->ovars,                    pdu->variables));        for (u = smagic->ovars, v = pdu->variables; u != NULL && v != NULL;             u = u->next_variable, v = v->next_variable) {            if (snmp_oid_compare                (u->val.objid, u->val_len / sizeof(oid), nullOid,                 nullOidLen) != 0) {                /*                 * The master agent requested scoping for this variable.                   */                rc = snmp_oid_compare(v->name, v->name_length,                                      u->val.objid,                                      u->val_len / sizeof(oid));                DEBUGMSGTL(("agentx/subagent", "result "));                DEBUGMSGOID(("agentx/subagent", v->name, v->name_length));                DEBUGMSG(("agentx/subagent", " scope to "));                DEBUGMSGOID(("agentx/subagent",                             u->val.objid, u->val_len / sizeof(oid)));                DEBUGMSG(("agentx/subagent", " result %d/n", rc));                if (rc >= 0) {                    /*                     * The varbind is out of scope.  From RFC2741, p. 66: "If                     * the subagent cannot locate an appropriate variable,                     * v.name is set to the starting OID, and the VarBind is                     * set to `endOfMibView'".                       */                    snmp_set_var_objid(v, u->name, u->name_length);                    snmp_set_var_typed_value(v, SNMP_ENDOFMIBVIEW, 0, 0);                    DEBUGMSGTL(("agentx/subagent",                                "scope violation -- return endOfMibView/n"));                }            } else {                DEBUGMSGTL(("agentx/subagent", "unscoped var/n"));            }        }    }    /*     * XXXJBPN: similar for GETBULK but the varbinds can get re-ordered I     * think which makes it er more difficult.       */    if (smagic->ovars != NULL) {        snmp_free_varbind(smagic->ovars);    }    pdu->command = AGENTX_MSG_RESPONSE;    pdu->version = smagic->session->version;    if (!snmp_send(smagic->session, pdu)) {        snmp_free_pdu(pdu);    }    DEBUGMSGTL(("agentx/subagent", "  FINISHED/n"));    free(smagic);    return 1;}
开发者ID:KrisChaplin,项目名称:LRT2x4_v1.0.2.06_GPL_source,代码行数:82,


示例8: sipProxyCfgTable_handler

/** handles requests for the sipProxyCfgTable table. * For every request it checks the specified object to see if it has a * handler, and calls it */static int sipProxyCfgTable_handler(		netsnmp_mib_handler               *handler,		netsnmp_handler_registration      *reginfo,		netsnmp_agent_request_info        *reqinfo,		netsnmp_request_info              *requests) {	netsnmp_variable_list *var;	netsnmp_table_request_info *table_info;	struct sip_snmp_handler *h;	struct sip_snmp_obj *o;	const char *func = "snmp_mod";	int res;	void *tmp_val;	size_t tmp_len;	while(requests) {		var = requests->requestvb;		if(requests->processed != 0)			goto next;		table_info = netsnmp_extract_table_info(requests);		if(!table_info)			goto next;		/* this is not an error, since table-walks work by trying to get		 * things until we run off of it */		if(table_info->colnum > SIPPROXYCFGTABLE_COLUMNS)			goto next;		/* Get the handler and its object */		if(sipProxyCfgTable_gh) {			h = sipProxyCfgTable_gh;			/* sip_obj is valid since we create upon registration */			h->sip_obj->opaque = (void*)sipProxyCfgTable_replaceRow;		} else {			h = sipProxyCfgTable_h[table_info->colnum];			if(!h) 				goto next;		}		o = h->sip_obj;		if(!o) {	/* bad bad boy... */			LOG(L_ERR, "%s: Found handler without an object!!!/n", func);			goto next;		}		o->col = table_info->colnum;		o->row = var->name[var->name_length-1];		switch(reqinfo->mode) {			case MODE_GET:			case MODE_GETNEXT:				if(!h->on_get) break;				res = h->on_get(o, SER_GET);				if(res == -1) {					/* since we don't have a way of knowing what went wrong,					 * just use a generic error code */					netsnmp_set_request_error(reqinfo, requests,							SNMP_ERR_RESOURCEUNAVAILABLE);					break;				} else if(res == 0)					/* the handler has new value to pass back up */					snmp_set_var_typed_value(var, ser_types[o->type],							(u_char*)o->value.voidp, o->val_len);				break;			case MODE_SET_RESERVE1:				/* NOTE: We don't require the handler for a on_reserve				 * function since for our cases it seems that just				 * checking the type is enough */				/* First make sure handler wants SETs */				if(!h->on_set) break;				/* Check the type */				if(requests->requestvb->type != ser_types[o->type]) {					LOG(L_ERR, "%s: Wrong type on SET processing/n", func);					netsnmp_set_request_error(reqinfo, requests,							SNMP_ERR_WRONGTYPE);					break;				}				break;			case MODE_SET_ACTION: /* the real deal */				if(!h->on_set) break;				/* copy in the new value for the handler */				tmp_val = o->value.voidp;				tmp_len = o->val_len;				o->value.voidp = requests->requestvb->val.string;				o->val_len = requests->requestvb->val_len;				if(h->on_set(o, SER_SET) == -1) {					LOG(L_ERR, "%s: SET Handler for object failed/n", func);					netsnmp_set_request_error(reqinfo, requests,						SNMP_ERR_RESOURCEUNAVAILABLE);					o->value.voidp = tmp_val;					o->val_len = tmp_len;					break;				}				o->value.voidp = tmp_val;				o->val_len = tmp_len;				break;			case MODE_SET_UNDO:				if(!h->on_end) {					if(h->on_set) /*tsk, tsk, bad boy, gonna tell your mamma..*/						LOG(L_ERR, "%s: Found object without UNDO handler/n",//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:ser,代码行数:101,


示例9: handle_memory

inthandle_memory(netsnmp_mib_handler *handler,                netsnmp_handler_registration *reginfo,                netsnmp_agent_request_info *reqinfo,                netsnmp_request_info *requests){    netsnmp_memory_info *mem_info;    int val;    char buf[1024];    /*     * We just need to handle valid GET requests, as invalid instances     *   are rejected automatically, and (valid) GETNEXT requests are     *   converted into the appropriate GET request.     *     * We also only ever receive one request at a time.     */    switch (reqinfo->mode) {    case MODE_GET:        netsnmp_memory_load();        switch (requests->requestvb->name[ reginfo->rootoid_len - 2 ]) {        case MEMORY_INDEX:            val = 0;            break;        case MEMORY_ERRNAME:            sprintf(buf, "swap");            snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,                                     (u_char *)buf, strlen(buf));            return SNMP_ERR_NOERROR;        case MEMORY_SWAP_TOTAL:            mem_info = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_SWAP, 0 );            if (!mem_info)               goto NOSUCH;            val  =  mem_info->size;     /* swaptotal */            val *= (mem_info->units/1024);            break;        case MEMORY_SWAP_AVAIL:            mem_info = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_SWAP, 0 );            if (!mem_info)               goto NOSUCH;            val  =  mem_info->free;     /* swapfree */            val *= (mem_info->units/1024);            break;        case MEMORY_REAL_TOTAL:            mem_info = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_PHYSMEM, 0 );            if (!mem_info)               goto NOSUCH;            val  =  mem_info->size;     /* memtotal */            val *= (mem_info->units/1024);            break;        case MEMORY_REAL_AVAIL:            mem_info = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_PHYSMEM, 0 );            if (!mem_info)               goto NOSUCH;            val  =  mem_info->free;     /* memfree */            val *= (mem_info->units/1024);            break;        case MEMORY_STXT_TOTAL:            mem_info = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_STEXT, 0 );            if (!mem_info)               goto NOSUCH;            val  =  mem_info->size;            val *= (mem_info->units/1024);            break;        case MEMORY_STXT_AVAIL:    /* Deprecated */        case MEMORY_STXT_USED:            /*             *   The original MIB description of memAvailSwapTXT             * was inconsistent with that implied by the name.             *   Retain the actual behaviour for the (sole)             * implementation of this object, but deprecate it in             * favour of a more consistently named replacement object.             */            mem_info = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_STEXT, 0 );            if (!mem_info)               goto NOSUCH;            val  = (mem_info->size - mem_info->free);            val *= (mem_info->units/1024);            break;        case MEMORY_RTXT_TOTAL:            mem_info = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_RTEXT, 0 );            if (!mem_info)               goto NOSUCH;            val  =  mem_info->size;            val *= (mem_info->units/1024);            break;        case MEMORY_RTXT_AVAIL:    /* Deprecated */        case MEMORY_RTXT_USED:            /*             *   The original MIB description of memAvailRealTXT             * was inconsistent with that implied by the name.             *   Retain the actual behaviour for the (sole)             * implementation of this object, but deprecate it in             * favour of a more consistently named replacement object.             */            mem_info = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_RTEXT, 0 );            if (!mem_info)               goto NOSUCH;            val  = (mem_info->size - mem_info->free);            val *= (mem_info->units/1024);//.........这里部分代码省略.........
开发者ID:duniansampa,项目名称:SigLog,代码行数:101,


示例10: saHpiSoftwareEventTable_get_value

/************************************************************ * saHpiSoftwareEventTable_get_value * * This routine is called for get requests to copy the data * from the context to the varbind for the request. If the * context has been properly maintained, you don't need to * change in code in this fuction. */int saHpiSoftwareEventTable_get_value(            netsnmp_request_info *request,            netsnmp_index *item,            netsnmp_table_request_info *table_info ){    netsnmp_variable_list *var = request->requestvb;    saHpiSoftwareEventTable_context *context = (saHpiSoftwareEventTable_context *)item;    switch(table_info->colnum) {        case COLUMN_SAHPISOFTWAREEVENTENTRYID:            /** SaHpiEntryId = ASN_UNSIGNED */            snmp_set_var_typed_value(var, ASN_UNSIGNED,                         (char*)&context->saHpiSoftwareEventEntryId,                         sizeof(context->saHpiSoftwareEventEntryId) );        break;            case COLUMN_SAHPISOFTWAREEVENTTIMESTAMP:            /** SaHpiTime = ASN_COUNTER64 */            snmp_set_var_typed_value(var, ASN_COUNTER64,                         (char*)&context->saHpiSoftwareEventTimestamp,                         sizeof(context->saHpiSoftwareEventTimestamp) );        break;            case COLUMN_SAHPISOFTWAREEVENTMANUFACTURERIDT:            /** SaHpiManufacturerId = ASN_UNSIGNED */            snmp_set_var_typed_value(var, ASN_UNSIGNED,                         (char*)&context->saHpiSoftwareEventManufacturerIdT,                         sizeof(context->saHpiSoftwareEventManufacturerIdT) );        break;            case COLUMN_SAHPISOFTWAREEVENTTYPE:            /** INTEGER = ASN_INTEGER */            snmp_set_var_typed_value(var, ASN_INTEGER,                         (char*)&context->saHpiSoftwareEventType,                         sizeof(context->saHpiSoftwareEventType) );        break;            case COLUMN_SAHPISOFTWAREEVENTTEXTTYPE:            /** SaHpiTextType = ASN_INTEGER */            snmp_set_var_typed_value(var, ASN_INTEGER,                         (char*)&context->saHpiSoftwareEventTextType,                         sizeof(context->saHpiSoftwareEventTextType) );        break;            case COLUMN_SAHPISOFTWAREEVENTTEXTLANGUAGE:            /** SaHpiTextLanguage = ASN_INTEGER */            snmp_set_var_typed_value(var, ASN_INTEGER,                         (char*)&context->saHpiSoftwareEventTextLanguage,                         sizeof(context->saHpiSoftwareEventTextLanguage) );        break;            case COLUMN_SAHPISOFTWAREEVENTTEXT:            /** SaHpiText = ASN_OCTET_STR */            snmp_set_var_typed_value(var, ASN_OCTET_STR,                         (char*)&context->saHpiSoftwareEventText,                         context->saHpiSoftwareEventText_len );        break;        default: /** We shouldn't get here */        snmp_log(LOG_ERR, "unknown column in "                 "saHpiSoftwareEventTable_get_value/n");        return SNMP_ERR_GENERR;    }    return SNMP_ERR_NOERROR;}
开发者ID:openhpi1,项目名称:testrepo,代码行数:74,


示例11: raidSetTable_handler

/** handles requests for the raidSetTable table */intraidSetTable_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;}
开发者ID:Jaharmi,项目名称:Xsnmp,代码行数:83,


示例12: agentx_got_response

//.........这里部分代码省略.........         */        int err;        DEBUGMSGTL(("agentx/master",                    "agentx_got_response() error branch/n"));        switch (pdu->errstat) {        case AGENTX_ERR_PARSE_FAILED:        case AGENTX_ERR_REQUEST_DENIED:        case AGENTX_ERR_PROCESSING_ERROR:            err = SNMP_ERR_GENERR;            break;        default:            err = pdu->errstat;        }        ret = 0;        for (request = requests, i = 1; request;             request = request->next, i++) {            if (request->index == pdu->errindex) {                /*                 * mark this one as the one generating the error                 */                netsnmp_set_request_error(cache->reqinfo, request,                                          err);                ret = 1;            }            request->delegated = REQUEST_IS_NOT_DELEGATED;        }        if (!ret) {            /*             * ack, unknown, mark the first one             */            netsnmp_set_request_error(cache->reqinfo, requests,                                      SNMP_ERR_GENERR);        }        netsnmp_free_delegated_cache(cache);        DEBUGMSGTL(("agentx/master", "end error branch/n"));        return 1;    } else if (cache->reqinfo->mode == MODE_GET ||               cache->reqinfo->mode == MODE_GETNEXT ||               cache->reqinfo->mode == MODE_GETBULK) {        /*         * Replace varbinds for data request types, but not SETs.           */        DEBUGMSGTL(("agentx/master",                    "agentx_got_response() beginning.../n"));        for (var = pdu->variables, request = requests; request && var;             request = request->next, var = var->next_variable) {            /*             * Otherwise, process successful requests             */            DEBUGMSGTL(("agentx/master",                        "  handle_agentx_response: processing: "));            DEBUGMSGOID(("agentx/master", var->name, var->name_length));            DEBUGMSG(("agentx/master", "/n"));            if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_VERBOSE)) {                DEBUGMSGTL(("snmp_agent", "    >> "));                DEBUGMSGVAR(("snmp_agent", var));                DEBUGMSG(("snmp_agent", "/n"));            }            /*             * update the oid in the original request              */            if (var->type != SNMP_ENDOFMIBVIEW) {                snmp_set_var_typed_value(request->requestvb, var->type,                                         var->val.string, var->val_len);                snmp_set_var_objid(request->requestvb, var->name,                                   var->name_length);            }            request->delegated = REQUEST_IS_NOT_DELEGATED;        }        if (request || var) {            /*             * ack, this is bad.  The # of varbinds don't match and             * there is no way to fix the problem              */            snmp_log(LOG_ERR,                     "response to agentx request illegal.  We're screwed./n");            netsnmp_set_request_error(cache->reqinfo, requests,                                      SNMP_ERR_GENERR);        }        if (cache->reqinfo->mode == MODE_GETBULK)            netsnmp_bulk_to_next_fix_requests(requests);    } else {        /*         * mark set requests as handled          */        for (request = requests; request; request = request->next) {            request->delegated = REQUEST_IS_NOT_DELEGATED;        }    }    DEBUGMSGTL(("agentx/master",                "handle_agentx_response() finishing.../n"));    netsnmp_free_delegated_cache(cache);    return 1;}
开发者ID:sjz6578,项目名称:net-snmp-5.1.4.2,代码行数:101,


示例13: handle_ipForwarding

static inthandle_ipForwarding(netsnmp_mib_handler *handler,                          netsnmp_handler_registration *reginfo,                          netsnmp_agent_request_info   *reqinfo,                          netsnmp_request_info         *requests){    int      rc;    u_long   value;    /* We are never called for a GETNEXT if it's registered as a       "instance", as it's "magically" handled for us.  */    /* a instance handler also only hands us one request at a time, so       we don't need to loop over a list of requests; we'll only get one. */    switch(reqinfo->mode) {        case MODE_GET:            rc = netsnmp_arch_ip_scalars_ipForwarding_get(&value);            if (rc != 0) {                netsnmp_set_request_error(reqinfo, requests,                                      SNMP_NOSUCHINSTANCE);            }            else {                value = value ? 1 : 2;                snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,                                     (u_char *)&value, sizeof(value));            }            break;#ifndef NETSNMP_NO_WRITE_SUPPORT        /*         * SET REQUEST         *         * multiple states in the transaction.  See:         * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg         */        case MODE_SET_RESERVE1:            break;        case MODE_SET_RESERVE2:            /*             * store old info for undo later             */            rc = netsnmp_arch_ip_scalars_ipForwarding_get(&value);            if (rc < 0) {                netsnmp_set_request_error(reqinfo, requests,                                          SNMP_ERR_NOCREATION);            } else {                u_long *value_save;                memdup((u_char **) & value_save, (u_char *) &value,                       sizeof(value));                if ( NULL == value_save )                    netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_RESOURCEUNAVAILABLE);                else                    netsnmp_request_add_list_data(requests,                                                  netsnmp_create_data_list                                                  ("ipfw", value_save,                                                  free));	    }            break;        case MODE_SET_FREE:            /* XXX: free resources allocated in RESERVE1 and/or               RESERVE2.  Something failed somewhere, and the states               below won't be called. */            break;        case MODE_SET_ACTION:            /* XXX: perform the value change here */            value =  *(requests->requestvb->val.integer);            rc = netsnmp_arch_ip_scalars_ipForwarding_set(value);            if ( 0 != rc ) {                netsnmp_set_request_error(reqinfo, requests, rc);            }            break;        case MODE_SET_COMMIT:            break;        case MODE_SET_UNDO:             value =                 *((u_long *) netsnmp_request_get_list_data(requests,                                                            "ipfw"));             rc = netsnmp_arch_ip_scalars_ipForwarding_set(value);             if ( 0 != rc ) {                 netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_UNDOFAILED);             }             break;#endif /* !NETSNMP_NO_WRITE_SUPPORT */        default:            /* we should never get here, so this is a really bad error */            snmp_log(LOG_ERR, "unknown mode (%d) in handle_ipForwarding/n", reqinfo->mode );            return SNMP_ERR_GENERR;    }    return SNMP_ERR_NOERROR;}
开发者ID:WimObiwan,项目名称:net-snmp,代码行数:99,


示例14: handle_ipv6IpDefaultHopLimit

static inthandle_ipv6IpDefaultHopLimit(netsnmp_mib_handler *handler,                             netsnmp_handler_registration *reginfo,                             netsnmp_agent_request_info *reqinfo,                             netsnmp_request_info *requests){    u_long          value;    int             rc;    /*     * We are never called for a GETNEXT if it's registered as a     * "instance", as it's "magically" handled for us.       */    /*     * a instance handler also only hands us one request at a time, so     * we don't need to loop over a list of requests; we'll only get one.      */    switch (reqinfo->mode) {    case MODE_GET:        rc = netsnmp_arch_ip_scalars_ipv6IpDefaultHopLimit_get(&value);        if (rc != 0) {            netsnmp_set_request_error(reqinfo, requests,                                  SNMP_NOSUCHINSTANCE);        }        else {            snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,                                 (u_char *)&value, sizeof(value));        }        break;#ifdef NOTYET        /*         * SET REQUEST         *         * multiple states in the transaction.  See:         * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg         */    case MODE_SET_RESERVE1:        /*         * or you could use netsnmp_check_vb_type_and_size instead          */        rc = netsnmp_check_vb_type(requests->requestvb, ASN_INTEGER);        if (rc != SNMP_ERR_NOERROR) {            netsnmp_set_request_error(reqinfo, requests, rc);        }        break;    case MODE_SET_RESERVE2:        /*         * XXX malloc "undo" storage buffer          */        if ( /* XXX if malloc, or whatever, failed: */ ) {            netsnmp_set_request_error(reqinfo, requests,                                      SNMP_ERR_RESOURCEUNAVAILABLE);        }        break;    case MODE_SET_FREE:        /*         * XXX: free resources allocated in RESERVE1 and/or         * RESERVE2.  Something failed somewhere, and the states         * below won't be called.          */        break;    case MODE_SET_ACTION:        /*         * XXX: perform the value change here          */        if ( /* XXX: error? */ ) {            netsnmp_set_request_error(reqinfo, requests, /* some error */                                      );        }        break;    case MODE_SET_COMMIT:        /*         * XXX: delete temporary storage          */        if ( /* XXX: error? */ ) {            /*             * try _really_really_ hard to never get to this point              */            netsnmp_set_request_error(reqinfo, requests,                                      SNMP_ERR_COMMITFAILED);        }        break;    case MODE_SET_UNDO:        /*         * XXX: UNDO and return to previous value for the object          */        if ( /* XXX: error? */ ) {            /*             * try _really_really_ hard to never get to this point              *///.........这里部分代码省略.........
开发者ID:WimObiwan,项目名称:net-snmp,代码行数:101,


示例15: instance_get_set_handler

int instance_get_set_handler(netsnmp_mib_handler * handler,                             netsnmp_handler_registration * reginfo,                             netsnmp_agent_request_info * reqinfo,                             netsnmp_request_info * requests){  snmp_adm_type_union var;  unsigned char type;  register_info *info = NULL;  int branch, num_stat_conf, err = 0, err_fct;  char str[256];  unsigned int tmp_it;        /** XXX	 *  Yet another tree structure specific computation	 */  /* what node do you want? */  num_stat_conf = reginfo->rootoid[reginfo->rootoid_len - 3];  branch = reginfo->rootoid[reginfo->rootoid_len - 4];  /* look for our get_set */  for(info = register_info_list; info; info = info->next)    if(info->type == GET_SET &&       info->function_info.get_set->num == num_stat_conf &&       info->function_info.get_set->branch == branch)      break;  if(!info)    {                           /* not found */      netsnmp_request_set_error(requests, SNMP_ERR_GENERR);      return SNMP_ERR_GENERR;    }  type = info->function_info.get_set->type;  switch (reqinfo->mode)    {    case MODE_GET:      /*       * data requests       */      /* call the function */      err =          info->function_info.get_set->getter(&var, info->function_info.get_set->opt_arg);      if(err)        {          snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,                                   (u_char *) "SNMP_ADM_ERROR", strlen("SNMP_ADM_ERROR"));          return SNMP_ERR_NOERROR;        }      switch (type)        {        case SNMP_ADM_INTEGER:          snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,                                   (u_char *) & (var.integer), sizeof(var.integer));          break;        case SNMP_ADM_STRING:          snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,                                   (u_char *) var.string, strlen((char *)var.string));          break;        case SNMP_ADM_REAL:          err = real2str(str, var.real);          if(!err)            snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,                                     (u_char *) str, strlen(str));          else            netsnmp_request_set_error(requests, SNMP_ERR_BADVALUE);          break;        case SNMP_ADM_BIGINT:          err = big2str(str, var.bigint);          if(!err)            snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,                                     (u_char *) str, strlen(str));          else            netsnmp_request_set_error(requests, SNMP_ERR_BADVALUE);          break;        case SNMP_ADM_TIMETICKS:          tmp_it = (var.time) * 100;          snmp_set_var_typed_value(requests->requestvb, ASN_TIMETICKS,                                   (u_char *) & (tmp_it), sizeof(tmp_it));          break;        default:          netsnmp_request_set_error(requests, SNMP_ERR_BADVALUE);        }      break;    case MODE_SET_ACTION:      switch (type)        {        case SNMP_ADM_INTEGER:          var.integer = *(int *)requests->requestvb->val.integer;          break;        case SNMP_ADM_STRING:          strncpy(var.string, (char *)(requests->requestvb->val.string),                  sizeof(var.string));          break;        case SNMP_ADM_REAL://.........这里部分代码省略.........
开发者ID:fmarsch,项目名称:nfs-ganesha-1,代码行数:101,


示例16: netsnmp_stash_cache_helper

/** @internal Implements the stash_cache handler */intnetsnmp_stash_cache_helper(netsnmp_mib_handler *handler,                           netsnmp_handler_registration *reginfo,                           netsnmp_agent_request_info *reqinfo,                           netsnmp_request_info *requests){    netsnmp_cache            *cache;    netsnmp_stash_cache_info *cinfo;    netsnmp_oid_stash_node   *cnode;    netsnmp_variable_list    *cdata;    netsnmp_request_info     *request;    DEBUGMSGTL(("helper:stash_cache", "Got request/n"));    cache = netsnmp_cache_reqinfo_extract( reqinfo, reginfo->handlerName );    if (!cache) {        DEBUGMSGTL(("helper:stash_cache", "No cache structure/n"));        return SNMP_ERR_GENERR;    }    cinfo = (netsnmp_stash_cache_info *) cache->magic;    switch (reqinfo->mode) {    case MODE_GET:        DEBUGMSGTL(("helper:stash_cache", "Processing GET request/n"));        for(request = requests; request; request = request->next) {            cdata =                netsnmp_oid_stash_get_data(cinfo->cache,                                           requests->requestvb->name,                                           requests->requestvb->name_length);            if (cdata && cdata->val.string && cdata->val_len) {                DEBUGMSGTL(("helper:stash_cache", "Found cached GET varbind/n"));                DEBUGMSGOID(("helper:stash_cache", cdata->name, cdata->name_length));                DEBUGMSG(("helper:stash_cache", "/n"));                snmp_set_var_typed_value(request->requestvb, cdata->type,                                         cdata->val.string, cdata->val_len);            }        }        return SNMP_ERR_NOERROR;        break;    case MODE_GETNEXT:        DEBUGMSGTL(("helper:stash_cache", "Processing GETNEXT request/n"));        for(request = requests; request; request = request->next) {            cnode =                netsnmp_oid_stash_getnext_node(cinfo->cache,                                               requests->requestvb->name,                                               requests->requestvb->name_length);            if (cnode && cnode->thedata) {                cdata = cnode->thedata;                if (cdata->val.string && cdata->name && cdata->name_length) {                    DEBUGMSGTL(("helper:stash_cache", "Found cached GETNEXT varbind/n"));                    DEBUGMSGOID(("helper:stash_cache", cdata->name, cdata->name_length));                    DEBUGMSG(("helper:stash_cache", "/n"));                    snmp_set_var_typed_value(request->requestvb, cdata->type,                                             cdata->val.string, cdata->val_len);                    snmp_set_var_objid(request->requestvb, cdata->name,                                       cdata->name_length);                }            }        }        return SNMP_ERR_NOERROR;        break;    default:        cinfo->cache_valid = 0;        return netsnmp_call_next_handler(handler, reginfo, reqinfo,                                         requests);    }    return SNMP_ERR_GENERR;     /* should never get here */}
开发者ID:Undrizzle,项目名称:apps,代码行数:72,


示例17: mib_ipRouteTable_handler

//.........这里部分代码省略.........                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 )                {
开发者ID:millken,项目名称:zhuxianB30,代码行数:67,


示例18: handle_usmDHParameters

inthandle_usmDHParameters (netsnmp_mib_handler * handler,                        netsnmp_handler_registration * reginfo,                        netsnmp_agent_request_info * reqinfo, netsnmp_request_info * requests){    /*     * We are never called for a GETNEXT if it's registered as a     * "instance", as it's "magically" handled for us.       */    static unsigned char *cp = NULL;    static DH *dh_tmpp = NULL;    int cp_len;    /*     * a instance handler also only hands us one request at a time, so     * we don't need to loop over a list of requests; we'll only get one.      */    switch (reqinfo->mode)    {        case MODE_GET:            if (cp)            {                free (cp);                cp = NULL;            }            cp_len = i2d_DHparams (dh_params, &cp);            if (cp_len > 0)                snmp_set_var_typed_value (requests->requestvb, ASN_OCTET_STR, (u_char *) cp, cp_len);            break;            /*             * SET REQUEST             *             * multiple states in the transaction.  See:             * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg             */        case MODE_SET_RESERVE1:            break;        case MODE_SET_RESERVE2:            cp = requests->requestvb->val.string;            dh_tmpp = d2i_DHparams (NULL, (const unsigned char **) (void *) &cp, requests->requestvb->val_len);            if (!dh_tmpp)            {                netsnmp_set_request_error (reqinfo, requests, SNMP_ERR_WRONGVALUE);            }            if (cp - requests->requestvb->val.string != requests->requestvb->val_len)            {                /* value too long; we didn't parse the whole thing */                netsnmp_set_request_error (reqinfo, requests, SNMP_ERR_WRONGVALUE);                DH_free (dh_tmpp);                dh_tmpp = NULL;            }            break;        case MODE_SET_FREE:        case MODE_SET_COMMIT:            DH_free (dh_tmpp);            dh_tmpp = NULL;            break;        case MODE_SET_ACTION:            {                DH *tmpp;                tmpp = dh_params;                dh_params = dh_tmpp;                dh_tmpp = tmpp;                break;            }        case MODE_SET_UNDO:            {                DH_free (dh_params);    /* free new value */                dh_params = dh_tmpp;    /* restore old value */                dh_tmpp = NULL;                break;            }        default:            /*             * we should never get here, so this is a really bad error              */            return SNMP_ERR_GENERR;    }    return SNMP_ERR_NOERROR;}
开发者ID:274914765,项目名称:C,代码行数:93,


示例19: saHpiWatchdogTable_get_value

/************************************************************ * saHpiWatchdogTable_get_value */intsaHpiWatchdogTable_get_value(netsnmp_request_info *request,                             netsnmp_index * item,                             netsnmp_table_request_info *table_info){    netsnmp_variable_list *var = request->requestvb;    saHpiWatchdogTable_context *context =        (saHpiWatchdogTable_context *) item;    switch (table_info->colnum) {    case COLUMN_SAHPIWATCHDOGNUM:            /** UNSIGNED32 = ASN_UNSIGNED */        snmp_set_var_typed_value(var, ASN_UNSIGNED,                                 (char *) &context->saHpiWatchdogNum,                                 sizeof(context->saHpiWatchdogNum));        break;    case COLUMN_SAHPIWATCHDOGLOG:            /** TruthValue = ASN_INTEGER */        snmp_set_var_typed_value(var, ASN_INTEGER,                                 (char *) &context->saHpiWatchdogLog,                                 sizeof(context->saHpiWatchdogLog));        break;    case COLUMN_SAHPIWATCHDOGRUNNING:            /** TruthValue = ASN_INTEGER */        snmp_set_var_typed_value(var, ASN_INTEGER,                                 (char *) &context->saHpiWatchdogRunning,                                 sizeof(context->saHpiWatchdogRunning));        break;    case COLUMN_SAHPIWATCHDOGTIMERUSE:            /** INTEGER = ASN_INTEGER */        snmp_set_var_typed_value(var, ASN_INTEGER,                                 (char *) &context->saHpiWatchdogTimerUse,                                 sizeof(context->saHpiWatchdogTimerUse));        break;    case COLUMN_SAHPIWATCHDOGTIMERACTION:            /** INTEGER = ASN_INTEGER */        snmp_set_var_typed_value(var, ASN_INTEGER,                                 (char *) &context->                                 saHpiWatchdogTimerAction,                                 sizeof(context->                                        saHpiWatchdogTimerAction));        break;    case COLUMN_SAHPIWATCHDOGPRETIMERINTERRUPT:            /** INTEGER = ASN_INTEGER */        snmp_set_var_typed_value(var, ASN_INTEGER,                                 (char *) &context->                                 saHpiWatchdogPretimerInterrupt,                                 sizeof(context->                                        saHpiWatchdogPretimerInterrupt));        break;    case COLUMN_SAHPIWATCHDOGPRETIMEOUTINTERVAL:            /** UNSIGNED32 = ASN_UNSIGNED */        snmp_set_var_typed_value(var, ASN_UNSIGNED,                                 (char *) &context->                                 saHpiWatchdogPreTimeoutInterval,                                 sizeof(context->                                        saHpiWatchdogPreTimeoutInterval));        break;    case COLUMN_SAHPIWATCHDOGTIMERUSEEXPFLAGS:            /** UNSIGNED32 = ASN_UNSIGNED */        snmp_set_var_typed_value(var, ASN_UNSIGNED,                                 (char *) &context->                                 saHpiWatchdogTimerUseExpFlags,                                 sizeof(context->                                        saHpiWatchdogTimerUseExpFlags));        break;    case COLUMN_SAHPIWATCHDOGTIMERINITIALCOUNT:            /** UNSIGNED32 = ASN_UNSIGNED */        snmp_set_var_typed_value(var, ASN_UNSIGNED,                                 (char *) &context->                                 saHpiWatchdogTimerInitialCount,                                 sizeof(context->                                        saHpiWatchdogTimerInitialCount));        break;    case COLUMN_SAHPIWATCHDOGTIMERPRESENTCOUNT:            /** UNSIGNED32 = ASN_UNSIGNED */        snmp_set_var_typed_value(var, ASN_UNSIGNED,                                 (char *) &context->                                 saHpiWatchdogTimerPresentCount,                                 sizeof(context->                                        saHpiWatchdogTimerPresentCount));        break;    case COLUMN_SAHPIWATCHDOGOEM:            /** UNSIGNED32 = ASN_UNSIGNED */        snmp_set_var_typed_value(var, ASN_UNSIGNED,                                 (char *) &context->saHpiWatchdogOem,//.........这里部分代码省略.........
开发者ID:openhpi1,项目名称:testrepo,代码行数:101,


示例20: handle_nsLoggingTable

inthandle_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);//.........这里部分代码省略.........
开发者ID:duniansampa,项目名称:SigLog,代码行数:101,


示例21: netsnmp_extract_table_info

/**********************************************************************    prototype:		int		CcspTableHelperGetMibValues			(				ANSC_HANDLE                 hThisObject,				netsnmp_agent_request_info  *reqinfo,				netsnmp_request_info		*requests			);    description:        This function is called to retrieve MIB values.    argument:   ANSC_HANDLE				hThisObject	            The handle of the object;				netsnmp_agent_request_info  *reqinfo,				The request info				netsnmp_request_info		*requests				The requests;	return:     The error code**********************************************************************/intCcspTableHelperGetMibValues	(        ANSC_HANDLE                 hThisObject,        netsnmp_agent_request_info  *reqinfo,        netsnmp_request_info		*requests	){	PCCSP_TABLE_HELPER_OBJECT       pThisObject     = (PCCSP_TABLE_HELPER_OBJECT)hThisObject;	PCCSP_MIB_VALUE                 pMibValueObj    = (PCCSP_MIB_VALUE)NULL;    netsnmp_request_info            *request		= NULL;    netsnmp_variable_list           *requestvb		= NULL;    oid                             subid			= 0;    netsnmp_table_request_info*		table_info      = NULL;    netsnmp_tdata*					table_data      = NULL;    netsnmp_tdata_row*				table_row       = NULL;    PCCSP_TABLE_ENTRY				table_entry     = NULL;    for (request = requests; request != NULL; request = request->next) 	{		if( request->processed != 0) { continue;}            table_entry = (PCCSP_TABLE_ENTRY)netsnmp_tdata_extract_entry(request);            table_info = netsnmp_extract_table_info(request);			subid = table_info->colnum;			if(!table_entry)			{				netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);				continue;			}			requestvb = request->requestvb;			pMibValueObj = CcspUtilLookforMibValueObjWithOid(&table_entry->MibValueQueue, subid);			if( pMibValueObj != NULL)			{				if( pMibValueObj->uType == ASN_INTEGER || pMibValueObj->uType == ASN_BOOLEAN ||					(pMibValueObj->uType >= ASN_IPADDRESS && pMibValueObj->uType <= ASN_OPAQUE))				{					pMibValueObj->uSize = 4;					snmp_set_var_typed_value(request->requestvb, (u_char)pMibValueObj->uType,						(u_char *)&pMibValueObj->Value.uValue, pMibValueObj->uSize);				}				else if( pMibValueObj->uType == ASN_BIT_STR || pMibValueObj->uType == ASN_OCTET_STR)				{					snmp_set_var_typed_value(request->requestvb, (u_char)pMibValueObj->uType,						(u_char *)pMibValueObj->Value.pBuffer, pMibValueObj->uSize);				}				else if( pMibValueObj->uType == ASN_COUNTER64)				{					snmp_set_var_typed_value(request->requestvb, (u_char)pMibValueObj->uType,						(u_char *)&pMibValueObj->Value.u64Value, pMibValueObj->uSize);				}				else				{					AnscTraceWarning(("Unknown MIB type '%lu'/n", pMibValueObj->uType));				}			}				else			{				netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);			} 	}    return SNMP_ERR_NOERROR;}
开发者ID:rdkcmf,项目名称:rdkb-CcspSnmpPa,代码行数:97,


示例22: mteEventTable_handler

/** handles requests for the mteEventTable table */intmteEventTable_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 *tinfo;    netsnmp_tdata_row          *row;    struct mteEvent            *entry;    char mteOwner[MTE_STR1_LEN+1];    char mteEName[MTE_STR1_LEN+1];    long ret;    DEBUGMSGTL(("disman:event:mib", "Event Table handler (%d)/n",                                     reqinfo->mode));    switch (reqinfo->mode) {        /*         * Read-support (also covers GetNext requests)         */    case MODE_GET:        for (request = requests; request; request = request->next) {            if (request->processed)                continue;            entry = (struct mteEvent *) netsnmp_tdata_extract_entry(request);            tinfo = netsnmp_extract_table_info(request);            if (!entry || !(entry->flags & MTE_EVENT_FLAG_VALID))                continue;            switch (tinfo->colnum) {            case COLUMN_MTEEVENTCOMMENT:                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,                                         entry->mteEventComment,                                  strlen(entry->mteEventComment));                break;            case COLUMN_MTEEVENTACTIONS:                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,                                        &entry->mteEventActions, 1);                break;            case COLUMN_MTEEVENTENABLED:                ret = (entry->flags & MTE_EVENT_FLAG_ENABLED ) ?                           TV_TRUE : TV_FALSE;                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, ret);                break;            case COLUMN_MTEEVENTENTRYSTATUS:                ret = (entry->flags & MTE_EVENT_FLAG_ACTIVE ) ?                           RS_ACTIVE : RS_NOTINSERVICE;                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, ret);                break;            }        }        break;#ifndef NETSNMP_NO_WRITE_SUPPORT        /*         * Write-support         */    case MODE_SET_RESERVE1:        for (request = requests; request; request = request->next) {            if (request->processed)                continue;            entry = (struct mteEvent *) netsnmp_tdata_extract_entry(request);            tinfo = netsnmp_extract_table_info(request);            switch (tinfo->colnum) {            case COLUMN_MTEEVENTCOMMENT:                ret = netsnmp_check_vb_type_and_max_size(                          request->requestvb, ASN_OCTET_STR, MTE_STR1_LEN);                if (ret != SNMP_ERR_NOERROR) {                    netsnmp_set_request_error(reqinfo, request, ret);                    return SNMP_ERR_NOERROR;                }                /*                 * Can't modify the comment of an active row                 *   (No good reason for this, but that's what the MIB says!)                 */                if (entry &&                    entry->flags & MTE_EVENT_FLAG_ACTIVE ) {                    netsnmp_set_request_error(reqinfo, request,                                              SNMP_ERR_INCONSISTENTVALUE);                    return SNMP_ERR_NOERROR;                }                break;            case COLUMN_MTEEVENTACTIONS:                ret = netsnmp_check_vb_type_and_size(                          request->requestvb, ASN_OCTET_STR, 1);                if (ret != SNMP_ERR_NOERROR) {                    netsnmp_set_request_error(reqinfo, request, ret);                    return SNMP_ERR_NOERROR;                }                /*                 * Can't modify the event types of an active row                 *   (A little more understandable perhaps,                 *    but still an unnecessary restriction IMO)//.........这里部分代码省略.........
开发者ID:duniansampa,项目名称:SigLog,代码行数:101,


示例23: handle_channelList

int handle_channelList(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;	chan_entry_t *entry;	char dt_str[12];	switch (reqinfo->mode) {	case MODE_GET:		for (request = requests; request; request = request->next) {			if (request->processed)				continue;			table_info = netsnmp_extract_table_info(request);			entry = (chan_entry_t *) netsnmp_tdata_extract_entry(request);			switch (table_info->colnum) {			case CH_INDEX:				snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, entry->idx);				break;			case CH_UUID:				snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, (u_char *) entry->uuid, strlen(entry->uuid));				break;			case CH_DIRECTION:				snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, (u_char *) entry->direction, strlen(entry->direction));				break;			case CH_CREATED:				time_t_to_datetime(entry->created_epoch, (char *) &dt_str, sizeof(dt_str));				snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, (u_char *) &dt_str, sizeof(dt_str));				break;			case CH_NAME:				snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, (u_char *) entry->name, strlen(entry->name));				break;			case CH_STATE:				snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, (u_char *) entry->state, strlen(entry->state));				break;			case CH_CID_NAME:				snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, (u_char *) entry->cid_name, strlen(entry->cid_name));				break;			case CH_CID_NUM:				snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, (u_char *) entry->cid_num, strlen(entry->cid_num));				break;			case CH_IP_ADDR_TYPE:				if (entry->addr_family == AF_INET6) {					snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, INETADDRESSTYPE_IPV6);				} else {					snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, INETADDRESSTYPE_IPV4);				}				break;			case CH_IP_ADDR:				if (entry->addr_family == AF_INET6) {					snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, (u_char *) &entry->ip_addr.v6, sizeof(entry->ip_addr.v6));				} else {					snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, (u_char *) &entry->ip_addr.v4, sizeof(entry->ip_addr.v4));				}				break;			case CH_DEST:				snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, (u_char *) entry->dest, strlen(entry->dest));				break;			case CH_APPLICATION:				snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, (u_char *) entry->application, strlen(entry->application));				break;			case CH_APPLICATION_DATA:				snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, (u_char *) entry->application_data, strlen(entry->application_data));				break;			case CH_DIALPLAN:				snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, (u_char *) entry->dialplan, strlen(entry->dialplan));				break;			case CH_CONTEXT:				snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, (u_char *) entry->context, strlen(entry->context));				break;			case CH_READ_CODEC:				snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, (u_char *) entry->read_codec, strlen(entry->read_codec));				break;			case CH_READ_RATE:				snmp_set_var_typed_value(request->requestvb, ASN_GAUGE, (u_char *) &entry->read_rate, sizeof(entry->read_rate));				break;			case CH_READ_BITRATE:				snmp_set_var_typed_value(request->requestvb, ASN_GAUGE, (u_char *) &entry->read_bitrate, sizeof(entry->read_bitrate));				break;			case CH_WRITE_CODEC:				snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR, (u_char *) entry->write_codec, strlen(entry->write_codec));				break;			case CH_WRITE_RATE:				snmp_set_var_typed_value(request->requestvb, ASN_GAUGE, (u_char *) &entry->write_rate, sizeof(entry->write_rate));				break;			case CH_WRITE_BITRATE:				snmp_set_var_typed_value(request->requestvb, ASN_GAUGE, (u_char *) &entry->write_bitrate, sizeof(entry->write_bitrate));				break;			default:				snmp_log(LOG_WARNING, "Unregistered OID-suffix requested (%d)/n", table_info->colnum);				netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);			}		}		break;	default:		/* we should never get here, so this is a really bad error */		snmp_log(LOG_ERR, "Unknown mode (%d) in handle_channelList/n", reqinfo->mode );		return SNMP_ERR_GENERR;	}//.........这里部分代码省略.........
开发者ID:PauloFer1,项目名称:FreeSWITCH,代码行数:101,


示例24: tcpTable_handler

inttcpTable_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;    TCPTABLE_ENTRY_TYPE	  *entry;    oid      subid;    long     port;    long     state;    DEBUGMSGTL(("mibII/tcpTable", "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/tcpTable", "oid: "));            DEBUGMSGOID(("mibII/tcpTable", requestvb->name,                         requestvb->name_length));            DEBUGMSG((   "mibII/tcpTable", "/n"));            entry = (TCPTABLE_ENTRY_TYPE *)netsnmp_extract_iterator_context(request);            if (!entry)                continue;            table_info = netsnmp_extract_table_info(request);            subid      = table_info->colnum;            switch (subid) {            case TCPCONNSTATE:                state = entry->TCPTABLE_STATE;                snmp_set_var_typed_value(requestvb, ASN_INTEGER,                                         (u_char *)&state, sizeof(state));                break;            case TCPCONNLOCALADDRESS:#if defined(osf5) && defined(IN6_EXTRACT_V4ADDR)                snmp_set_var_typed_value(requestvb, ASN_IPADDRESS,                                         (u_char*)IN6_EXTRACT_V4ADDR(&entry->pcb.inp_laddr),                                         sizeof(IN6_EXTRACT_V4ADDR(&entry->pcb.inp_laddr)));#else                snmp_set_var_typed_value(requestvb, ASN_IPADDRESS,                                         (u_char *)&entry->TCPTABLE_LOCALADDRESS,                                         sizeof(entry->TCPTABLE_LOCALADDRESS));#endif                break;            case TCPCONNLOCALPORT:                port = TCP_PORT_TO_HOST_ORDER((u_short)entry->TCPTABLE_LOCALPORT);                snmp_set_var_typed_value(requestvb, ASN_INTEGER,                                         (u_char *)&port, sizeof(port));                break;            case TCPCONNREMOTEADDRESS:#if defined(osf5) && defined(IN6_EXTRACT_V4ADDR)                snmp_set_var_typed_value(requestvb, ASN_IPADDRESS,                                         (u_char*)IN6_EXTRACT_V4ADDR(&entry->pcb.inp_laddr),                                         sizeof(IN6_EXTRACT_V4ADDR(&entry->pcb.inp_laddr)));#else                snmp_set_var_typed_value(requestvb, ASN_IPADDRESS,                                         (u_char *)&entry->TCPTABLE_REMOTEADDRESS,                                         sizeof(entry->TCPTABLE_REMOTEADDRESS));#endif                break;            case TCPCONNREMOTEPORT:                port = TCP_PORT_TO_HOST_ORDER((u_short)entry->TCPTABLE_REMOTEPORT);                snmp_set_var_typed_value(requestvb, ASN_INTEGER,                                         (u_char *)&port, sizeof(port));                break;            }        }        break;    case MODE_GETNEXT:    case MODE_GETBULK:#ifndef NETSNMP_NO_WRITE_SUPPORT    case MODE_SET_RESERVE1:    case MODE_SET_RESERVE2:    case MODE_SET_ACTION:    case MODE_SET_COMMIT:    case MODE_SET_FREE:    case MODE_SET_UNDO:#endif /* !NETSNMP_NO_WRITE_SUPPORT */        snmp_log(LOG_WARNING, "mibII/tcpTable: Unsupported mode (%d)/n",                 reqinfo->mode);        break;    default:        snmp_log(LOG_WARNING, "mibII/tcpTable: Unrecognised mode (%d)/n",                 reqinfo->mode);        break;    }    return SNMP_ERR_NOERROR;}
开发者ID:vincentbernat,项目名称:net-snmp,代码行数:94,


示例25: handle_acIfPortNum

inthandle_acIfPortNum(netsnmp_mib_handler *handler,                          netsnmp_handler_registration *reginfo,                          netsnmp_agent_request_info   *reqinfo,                          netsnmp_request_info         *requests){	snmp_log(LOG_DEBUG, "enter handle_acIfPortNum/n");	switch(reqinfo->mode) {	case MODE_GET:	{		#if 0		int number = 0,ret1=0,port_count = 0;		ETH_SLOT_LIST  head,*p;		memset(&head,0,sizeof(ETH_SLOT_LIST));		ETH_PORT_LIST *pp;		ret1=show_ethport_list(&head,&number);		p=head.next;		if(p!=NULL)		{			while(p!=NULL)			{				port_count +=p->port_num;				pp=p->port.next;				p=p->next;			}		#endif		unsigned int ret = 0, num = 0;		struct flow_data_list *alldata = NULL;		struct flow_data_list *temp = NULL;				snmp_log(LOG_DEBUG, "enter intflib_getdata/n");		ret = intflib_getdata(&alldata);		snmp_log(LOG_DEBUG, "exit intflib_getdata,ret=%d/n", ret);				if(ret < 0)		{			printf("intflib get data error! ret %d.<br>",ret);		}		temp = alldata;		for(temp; NULL != temp; temp = temp->next)		{						if(strncmp(temp->ltdata.ifname,"r",1)==0 			|| strncmp(temp->ltdata.ifname,"pimreg",6)==0 			|| strncmp(temp->ltdata.ifname,"sit0",4)==0)			{				continue;			}				num++;		}		snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,								(u_char *)&num,								sizeof(num));		intflib_memfree(&alldata);		#if 0		if((ret1==0)&&(number>0))		{			Free_ethslot_head(&head);		}		#endif	}	break;	default:	/* we should never get here, so this is a really bad error */	snmp_log(LOG_ERR, "unknown mode (%d) in handle_acIfPortNum/n", reqinfo->mode );	return SNMP_ERR_GENERR;	}	snmp_log(LOG_DEBUG, "exit handle_acIfPortNum/n");	return SNMP_ERR_NOERROR;}inthandle_acPhyPortNum(netsnmp_mib_handler *handler,                          netsnmp_handler_registration *reginfo,                          netsnmp_agent_request_info   *reqinfo,                          netsnmp_request_info         *requests){	snmp_log(LOG_DEBUG, "enter handle_acPhyPortNum/n");	switch(reqinfo->mode) {	case MODE_GET:	{		int acPhyPortNum = 0;		snmp_log(LOG_DEBUG, "enter count_eth_port_num/n");		acPhyPortNum=count_eth_port_num();		snmp_log(LOG_DEBUG, "exit count_eth_port_num,acPhyPortNum=%d/n", acPhyPortNum);				snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,								(u_char *)&acPhyPortNum,								sizeof(acPhyPortNum));//.........这里部分代码省略.........
开发者ID:inibir,项目名称:daemongroup,代码行数:101,


示例26: kamailioSIPStatusCodesTable_get_value

/* * This function is called to handle SNMP GET requests.   * * The row which this function is called with, will store a message code.  The * function will retrieve the 'number of messages in' and 'number of messages * out' statistic for this particular message code from the statistics * framework.   * * The function will then subtract from this value the value it was initialized * with when the row was first created.  In this sense, the row shows how many * ins and how many outs have been received (With respect to the message code) * since this row was created.  */int kamailioSIPStatusCodesTable_get_value(			netsnmp_request_info *request,			netsnmp_index *item,			netsnmp_table_request_info *table_info ){	stat_var *the_stat;	netsnmp_variable_list *var = request->requestvb;	kamailioSIPStatusCodesTable_context *context = 		(kamailioSIPStatusCodesTable_context *)item;	/* Retrieve the statusCodeIdx so we can calculate deltas between current	 * values and previous values. */	int statusCodeIdx = context->kamailioSIPStatusCodeValue;	switch(table_info->colnum) 	{		case COLUMN_KAMAILIOSIPSTATUSCODEINS:			context->kamailioSIPStatusCodeIns = 0;			the_stat = get_stat_var_from_num_code(statusCodeIdx, 0);			if (the_stat != NULL)  			{				/* Calculate the Delta */				context->kamailioSIPStatusCodeIns = get_stat_val(the_stat) -					context->startingInStatusCodeValue;			}			snmp_set_var_typed_value(var, ASN_COUNTER,					(unsigned char*)					&context->kamailioSIPStatusCodeIns,					sizeof(context->kamailioSIPStatusCodeIns));			break;			case COLUMN_KAMAILIOSIPSTATUSCODEOUTS:						context->kamailioSIPStatusCodeOuts = 0;			the_stat = get_stat_var_from_num_code(statusCodeIdx, 1);			if (the_stat != NULL)			{				/* Calculate the Delta */				context->kamailioSIPStatusCodeOuts =					get_stat_val(the_stat) -					context->startingOutStatusCodeValue;			}			snmp_set_var_typed_value(var, ASN_COUNTER,					 (unsigned char*)					 &context->kamailioSIPStatusCodeOuts,					 sizeof(context->kamailioSIPStatusCodeOuts) );		break;			case COLUMN_KAMAILIOSIPSTATUSCODEROWSTATUS:			/** RowStatus = ASN_INTEGER */			snmp_set_var_typed_value(var, ASN_INTEGER,					 (unsigned char*)					 &context->kamailioSIPStatusCodeRowStatus,					 sizeof(context->kamailioSIPStatusCodeRowStatus) );		break;		default: /** We shouldn't get here */		snmp_log(LOG_ERR, "unknown column in "				 "kamailioSIPStatusCodesTable_get_value/n");		return SNMP_ERR_GENERR;	}	return SNMP_ERR_NOERROR;}
开发者ID:GreenfieldTech,项目名称:kamailio,代码行数:84,


示例27: handle_widsFloodDetectOnOff

inthandle_widsFloodDetectOnOff(netsnmp_mib_handler *handler,                          netsnmp_handler_registration *reginfo,                          netsnmp_agent_request_info   *reqinfo,                          netsnmp_request_info         *requests){    /* We are never called for a GETNEXT if it's registered as a       "instance", as it's "magically" handled for us.  */    /* a instance handler also only hands us one request at a time, so       we don't need to loop over a list of requests; we'll only get one. */	snmp_log(LOG_DEBUG, "enter handle_widsFloodDetectOnOff/n");    switch(reqinfo->mode) {        case MODE_GET:		{			#if 0			int widsFloodDetectOnOff = 0;            instance_parameter *paraHead = NULL;            if(SNMPD_DBUS_SUCCESS == get_slot_dbus_connection(LOCAL_SLOT_NUM, &paraHead, SNMPD_INSTANCE_MASTER_V2))            {			    int ret = 0;    			DCLI_WTP_API_GROUP_THREE *WTPINFO = NULL;       			    			snmp_log(LOG_DEBUG, "enter show_ap_wids_set_cmd_func/n");    			ret=show_ap_wids_set_cmd_func(paraHead->parameter, paraHead->connection,&WTPINFO);    			snmp_log(LOG_DEBUG, "exit show_ap_wids_set_cmd_func,ret=%d/n", ret);    			    			if(ret==1)    			{    				if(WTPINFO->wids.flooding==1)    					widsFloodDetectOnOff = 1;    				else    					widsFloodDetectOnOff = 0;    				free_show_ap_wids_set_cmd(WTPINFO);	    			}    		}							free_instance_parameter_list(&paraHead);			#endif			update_data_for_show_ap_wids_set_cmd_func();            snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,                                     (u_char *)&widsFloodDetectOnOff,                                     sizeof(widsFloodDetectOnOff));        }            break;        /*         * SET REQUEST         *         * multiple states in the transaction.  See:         * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg         */        case MODE_SET_RESERVE1:			#if 0            if (/* XXX: check incoming data in requests->requestvb->val.XXX for failures, like an incorrect type or an illegal value or ... */) {                netsnmp_set_request_error(reqinfo, requests, /* XXX: set error code depending on problem (like SNMP_ERR_WRONGTYPE or SNMP_ERR_WRONGVALUE or ... */);            }			#endif            break;        case MODE_SET_RESERVE2:			#if 0            /* XXX malloc "undo" storage buffer */            if (/* XXX if malloc, or whatever, failed: */) {                netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_RESOURCEUNAVAILABLE);            }			#endif            break;        case MODE_SET_FREE:            /* XXX: free resources allocated in RESERVE1 and/or               RESERVE2.  Something failed somewhere, and the states               below won't be called. */            break;        case MODE_SET_ACTION:		{			                instance_parameter *paraHead = NULL, *paraNode = NULL;            list_instance_parameter(&paraHead, SNMPD_INSTANCE_MASTER);            for(paraNode = paraHead; NULL != paraNode; paraNode = paraNode->next)            {    			int ret = 0,flag = 1;				char state[10] = { 0 };    			memset(state,0,10);    			if(*requests->requestvb->val.integer==0)					strncpy(state,"disable",sizeof(state)-1);    			else if(*requests->requestvb->val.integer==1)					strncpy(state,"enable",sizeof(state)-1);    			else    			{    				flag = 0;    				netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_WRONGTYPE);    			}    			    			if(flag==1)//.........这里部分代码省略.........
开发者ID:inibir,项目名称:daemongroup,代码行数:101,


示例28: vmstat_handler

intvmstat_handler (netsnmp_mib_handler * handler,                netsnmp_handler_registration * reginfo,                netsnmp_agent_request_info * reqinfo, netsnmp_request_info * requests){    oid obj;    unsigned long long value = 0;    char cp[300];    netsnmp_cpu_info *info = netsnmp_cpu_get_byIdx (-1, 0);    switch (reqinfo->mode)    {        case MODE_GET:            obj = requests->requestvb->name[requests->requestvb->name_length - 2];            switch (obj)            {                case MIBINDEX:    /* dummy value */                    snmp_set_var_typed_integer (requests->requestvb, ASN_INTEGER, 1);                    break;                case ERRORNAME:    /* dummy name */                    sprintf (cp, "systemStats");                    snmp_set_var_typed_value (requests->requestvb, ASN_OCTET_STR, cp, strlen (cp));                    break;/*        case IOSENT:            long_ret = vmstat(iosent);            return ((u_char *) (&long_ret));        case IORECEIVE:            long_ret = vmstat(ioreceive);            return ((u_char *) (&long_ret));        case IORAWSENT:            long_ret = vmstat(rawiosent);            return ((u_char *) (&long_ret));        case IORAWRECEIVE:            long_ret = vmstat(rawioreceive);            return ((u_char *) (&long_ret));*/                    /*                     *  Raw CPU statistics                     *  Taken directly from the (overall) cpu_info structure.                     *                     *  XXX - Need some form of flag to skip objects that                     *        aren't supported on a given architecture.                     */                case CPURAWUSER:                    snmp_set_var_typed_integer (requests->requestvb, ASN_COUNTER, info->user_ticks & 0xffffffff);                    break;                case CPURAWNICE:                    snmp_set_var_typed_integer (requests->requestvb, ASN_COUNTER, info->nice_ticks & 0xffffffff);                    break;                case CPURAWSYSTEM:                    /*                     * Some architecture have traditionally reported a                     *   combination of CPU statistics for this object.                     * The CPU HAL module uses 'sys2_ticks' for this,                     *   so use this value in preference to 'sys_ticks'                     *   if it has a non-zero value.                     */                    snmp_set_var_typed_integer (requests->requestvb, ASN_COUNTER,                                                (info->sys2_ticks ? info->sys2_ticks : info->sys_ticks) & 0xffffffff);                    break;                case CPURAWIDLE:                    snmp_set_var_typed_integer (requests->requestvb, ASN_COUNTER, info->idle_ticks & 0xffffffff);                    break;                case CPURAWWAIT:                    snmp_set_var_typed_integer (requests->requestvb, ASN_COUNTER, info->wait_ticks & 0xffffffff);                    break;                case CPURAWKERNEL:                    snmp_set_var_typed_integer (requests->requestvb, ASN_COUNTER, info->kern_ticks & 0xffffffff);                    break;                case CPURAWINTR:                    snmp_set_var_typed_integer (requests->requestvb, ASN_COUNTER, info->intrpt_ticks & 0xffffffff);                    break;                case CPURAWSOFTIRQ:                    snmp_set_var_typed_integer (requests->requestvb, ASN_COUNTER, info->sirq_ticks & 0xffffffff);                    break;                case CPURAWSTEAL:                    snmp_set_var_typed_integer (requests->requestvb, ASN_COUNTER, info->steal_ticks & 0xffffffff);                    break;                case CPURAWGUEST:                    snmp_set_var_typed_integer (requests->requestvb, ASN_COUNTER, info->guest_ticks & 0xffffffff);                    break;                case CPURAWGUESTNICE:                    snmp_set_var_typed_integer (requests->requestvb, ASN_COUNTER, info->guestnice_ticks & 0xffffffff);                    break;                    /*                     *  'Cooked' CPU statistics                     *     Percentage usage of the specified statistic calculated                     *     over the period (1 min) that history is being kept for.                     *                     *   This is actually a change of behaviour for some architectures,                     *     but://.........这里部分代码省略.........
开发者ID:274914765,项目名称:C,代码行数:101,


示例29: saHpiRdrTable_get_value

/************************************************************ * saHpiRdrTable_get_value * * This routine is called for get requests to copy the data * from the context to the varbind for the request. If the * context has been properly maintained, you don't need to * change in code in this fuction. */int saHpiRdrTable_get_value(            netsnmp_request_info *request,            netsnmp_index *item,            netsnmp_table_request_info *table_info ){	netsnmp_variable_list *var = request->requestvb;	saHpiRdrTable_context *context = (saHpiRdrTable_context *)item;	DEBUGMSGTL ((AGENT, "saHpiRdrTable_get_value, called/n"));	switch(table_info->colnum) {		    case COLUMN_SAHPIRDRENTRYID:		/** COUNTER = ASN_COUNTER */		snmp_set_var_typed_value(var, ASN_COUNTER,			 (char*)&context->saHpiRdrEntryId,			 sizeof(context->saHpiRdrEntryId) );	    break;		    case COLUMN_SAHPIRDRNEXTENTRYID:		/** COUNTER = ASN_COUNTER */		snmp_set_var_typed_value(var, ASN_COUNTER,			 (char*)&context->saHpiRdrNextEntryId,			 sizeof(context->saHpiRdrNextEntryId) );	    break;		    case COLUMN_SAHPIRDRTYPE:		/** INTEGER = ASN_INTEGER */		snmp_set_var_typed_value(var, ASN_INTEGER,			 (char*)&context->saHpiRdrType,			 sizeof(context->saHpiRdrType) );	    break;		    case COLUMN_SAHPIRDRENTITYPATH:		/** SaHpiEntityPath = ASN_OCTET_STR */		snmp_set_var_typed_value(var, ASN_OCTET_STR,			 (char*)&context->saHpiRdrEntityPath,			 context->saHpiRdrEntityPath_len );	    break;		    case COLUMN_SAHPIRDRISFRU:		/** TruthValue = ASN_INTEGER */		snmp_set_var_typed_value(var, ASN_INTEGER,			 (char*)&context->saHpiRdrIsFru,			 sizeof(context->saHpiRdrIsFru) );	    break;		    case COLUMN_SAHPIRDRROWPOINTER:		/** RowPointer = ASN_OBJECT_ID */		snmp_set_var_typed_value(var, ASN_OBJECT_ID,			 (char*)&context->saHpiRdrRowPointer,			 context->saHpiRdrRowPointer_len );	    break;		    case COLUMN_SAHPIRDRRPT:		/** RowPointer = ASN_OBJECT_ID */		snmp_set_var_typed_value(var, ASN_OBJECT_ID,			 (char*)&context->saHpiRdrRPT,			 context->saHpiRdrRPT_len );	    break;		    case COLUMN_SAHPIRDRTEXTTYPE:		/** SaHpiTextType = ASN_INTEGER */		snmp_set_var_typed_value(var, ASN_INTEGER,			 (char*)&context->saHpiRdrTextType,			 sizeof(context->saHpiRdrTextType) );	    break;		    case COLUMN_SAHPIRDRTEXTLANGUAGE:		/** SaHpiTextLanguage = ASN_INTEGER */		snmp_set_var_typed_value(var, ASN_INTEGER,			 (char*)&context->saHpiRdrTextLanguage,			 sizeof(context->saHpiRdrTextLanguage) );	    break;		    case COLUMN_SAHPIRDRIDSTRING:		/** OCTETSTR = ASN_OCTET_STR */		snmp_set_var_typed_value(var, ASN_OCTET_STR,			 (char*)&context->saHpiRdrIdString,			 context->saHpiRdrIdString_len );	    break;		default: /** We shouldn't get here */	    snmp_log(LOG_ERR, "unknown column in "		 "saHpiRdrTable_get_value/n");	    return SNMP_ERR_GENERR;	}	return SNMP_ERR_NOERROR;}
开发者ID:openhpi1,项目名称:testrepo,代码行数:97,


示例30: handle_nsDebugTable

inthandle_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;    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);                debug_entry->enabled =//.........这里部分代码省略.........
开发者ID:Undrizzle,项目名称:apps,代码行数:101,



注:本文中的snmp_set_var_typed_value函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ snmp_set_var_value函数代码示例
C++ snmp_set_var_typed_integer函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。