本文整理汇总了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函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle_ipAddressSpinLock
static int
handle_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;
}
示例2: mteEventNotificationTable_handler
/** handles requests for the mteEventNotificationTable table */
int
mteEventNotificationTable_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)
//.........这里部分代码省略.........
示例3: handle_BSSIDFilterSwitch
int
handle_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, ¶Head, 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(¶Head);
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(¶Head, 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);
}
}
//.........这里部分代码省略.........
示例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;
}
示例5: mteTriggerBooleanTable_handler
/** handles requests for the mteTriggerBooleanTable table */
int
mteTriggerBooleanTable_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
//.........这里部分代码省略.........
示例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,
//.........这里部分代码省略.........
示例7: handle_subagent_response
int
handle_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;
}
示例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",
//.........这里部分代码省略.........
示例9: handle_memory
int
handle_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);
//.........这里部分代码省略.........
示例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;
}
示例11: raidSetTable_handler
/** handles requests for the raidSetTable table */
int
raidSetTable_handler(
netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests) {
netsnmp_request_info *request;
netsnmp_table_request_info *table_info;
struct raidSetTable_entry *table_entry;
switch (reqinfo->mode) {
/*
* Read-support (also covers GetNext requests)
*/
case MODE_GET:
update_setlist_if_necessary();
for (request=requests; request; request=request->next) {
table_entry = (struct raidSetTable_entry *)
netsnmp_extract_iterator_context(request);
table_info = netsnmp_extract_table_info( request);
switch (table_info->colnum) {
case COLUMN_RAIDSETNAME:
if ( !table_entry ) {
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
(u_char*)table_entry->raidSetName,
table_entry->raidSetName_len);
break;
case COLUMN_RAIDSETTYPE:
if ( !table_entry ) {
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
(u_char*)table_entry->raidSetType,
table_entry->raidSetType_len);
break;
case COLUMN_RAIDSETSIZE:
if ( !table_entry ) {
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
snmp_set_var_typed_integer( request->requestvb, ASN_GAUGE,
table_entry->raidSetSize);
break;
case COLUMN_RAIDSETUNUSED:
if ( !table_entry ) {
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
snmp_set_var_typed_integer( request->requestvb, ASN_GAUGE,
table_entry->raidSetUnused);
break;
case COLUMN_RAIDSETCOMMENTS:
if ( !table_entry ) {
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHINSTANCE);
continue;
}
snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR,
(u_char*)table_entry->raidSetComments,
table_entry->raidSetComments_len);
break;
default:
netsnmp_set_request_error(reqinfo, request,
SNMP_NOSUCHOBJECT);
break;
}
}
break;
}
return SNMP_ERR_NOERROR;
}
示例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;
}
示例13: handle_ipForwarding
static int
handle_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;
}
示例14: handle_ipv6IpDefaultHopLimit
static int
handle_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
*/
//.........这里部分代码省略.........
示例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:
//.........这里部分代码省略.........