这篇教程C++ snmp_set_var_objid函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中snmp_set_var_objid函数的典型用法代码示例。如果您正苦于以下问题:C++ snmp_set_var_objid函数的具体用法?C++ snmp_set_var_objid怎么用?C++ snmp_set_var_objid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了snmp_set_var_objid函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: netsnmp_table_data_build_result/* builds a result given a row, a varbind to set and the data */intnetsnmp_table_data_build_result(netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *request, netsnmp_table_row *row, int column, u_char type, u_char * result_data, size_t result_data_len){ oid build_space[MAX_OID_LEN]; if (!reginfo || !reqinfo || !request) return SNMPERR_GENERR; if (reqinfo->mode == MODE_GETNEXT || reqinfo->mode == MODE_GETBULK) { /* * only need to do this for getnext type cases where oid is changing */ memcpy(build_space, reginfo->rootoid, /* registered oid */ reginfo->rootoid_len * sizeof(oid)); build_space[reginfo->rootoid_len] = 1; /* entry */ build_space[reginfo->rootoid_len + 1] = column; /* column */ memcpy(build_space + reginfo->rootoid_len + 2, /* index data */ row->index_oid, row->index_oid_len * sizeof(oid)); snmp_set_var_objid(request->requestvb, build_space, reginfo->rootoid_len + 2 + row->index_oid_len); } snmp_set_var_typed_value(request->requestvb, type, result_data, result_data_len); return SNMPERR_SUCCESS; /* WWWXXX: check for bounds */}
开发者ID:Undrizzle,项目名称:apps,代码行数:33,
示例2: register_string_indexchar *register_string_index(oid * name, size_t name_len, char *cp){ netsnmp_variable_list varbind, *res; memset(&varbind, 0, sizeof(netsnmp_variable_list)); varbind.type = ASN_OCTET_STR; snmp_set_var_objid(&varbind, name, name_len); if (cp != ANY_STRING_INDEX) { snmp_set_var_value(&varbind, (u_char *) cp, strlen(cp)); res = register_index(&varbind, ALLOCATE_THIS_INDEX, main_session); } else { res = register_index(&varbind, ALLOCATE_ANY_INDEX, main_session); } if (res == NULL) { return NULL; } else { char *rv = (char *)malloc(res->val_len + 1); if (rv) { memcpy(rv, res->val.string, res->val_len); rv[res->val_len] = 0; } free(res); return rv; }}
开发者ID:duniansampa,项目名称:SigLog,代码行数:27,
示例3: register_int_indexintregister_int_index(oid * name, size_t name_len, int val){ netsnmp_variable_list varbind, *res; memset(&varbind, 0, sizeof(netsnmp_variable_list)); varbind.type = ASN_INTEGER; snmp_set_var_objid(&varbind, name, name_len); varbind.val.string = varbind.buf; if (val != ANY_INTEGER_INDEX) { varbind.val_len = sizeof(long); *varbind.val.integer = val; res = register_index(&varbind, ALLOCATE_THIS_INDEX, main_session); } else { res = register_index(&varbind, ALLOCATE_ANY_INDEX, main_session); } if (res == NULL) { return -1; } else { int rv = *(res->val.integer); free(res); return rv; }}
开发者ID:duniansampa,项目名称:SigLog,代码行数:25,
示例4: build_new_oidvoidbuild_new_oid(netsnmp_handler_registration *reginfo, netsnmp_table_request_info *tblreq_info, netsnmp_index *row, netsnmp_request_info *current){ oid coloid[MAX_OID_LEN]; if (!tblreq_info || !reginfo || !row || !current) return; memcpy(coloid, reginfo->rootoid, reginfo->rootoid_len * sizeof(oid)); /** table.entry */ coloid[reginfo->rootoid_len] = 1; /** table.entry.column */ coloid[reginfo->rootoid_len + 1] = tblreq_info->colnum; /** table.entry.column.index */ memcpy(&coloid[reginfo->rootoid_len + 2], row->oids, row->len * sizeof(oid)); snmp_set_var_objid(current->requestvb, coloid, reginfo->rootoid_len + 2 + row->len);}
开发者ID:a5216652166,项目名称:rcp100,代码行数:25,
示例5: _expObject_buildListnetsnmp_variable_list *_expObject_buildList( oid *root, size_t root_len, size_t prefix_len, netsnmp_variable_list *template_list ){ netsnmp_variable_list *query_list = NULL; netsnmp_variable_list *vp1, *vp2 = NULL; oid name[ MAX_OID_LEN ]; int i; if ( prefix_len ) { /* * For wildcarded objects, build a list of all relevant * instances, using the template_list to provide the * necessary instance suffixes. */ memset( name, 0, sizeof(name)); memcpy( name, root, root_len*sizeof(oid)); for ( vp1 = template_list; vp1; vp1=vp1->next_variable ) { /* * Append a new varbind to the list for this object ... */ if ( !query_list ) { query_list = (netsnmp_variable_list*) SNMP_MALLOC_TYPEDEF( netsnmp_variable_list ); vp2 = query_list; } else { vp2->next_variable = (netsnmp_variable_list*) SNMP_MALLOC_TYPEDEF( netsnmp_variable_list ); vp2 = vp2->next_variable; } /* * ... and set the OID using the template suffix */ for ( i=0; i <= vp1->name_length - prefix_len; i++) name[ root_len+i ] = vp1->name[ prefix_len+i ]; snmp_set_var_objid( vp2, name, root_len+i ); } } else { /* * Otherwise, just use the (single) OID provided. */ query_list = (netsnmp_variable_list*) SNMP_MALLOC_TYPEDEF( netsnmp_variable_list ); snmp_set_var_objid( query_list, root, root_len ); } return query_list;}
开发者ID:RasmusKoldsoe,项目名称:performand.k70.2,代码行数:47,
示例6: memsetvoid AlarmTrapSender::send_trap(AlarmTableDef& alarm_table_def){ static const oid snmp_trap_oid[] = {1,3,6,1,6,3,1,1,4,1,0}; static const oid clear_oid[] = {1,3,6,1,2,1,118,0,3}; static const oid active_oid[] = {1,3,6,1,2,1,118,0,2}; static const oid model_ptr_oid[] = {1,3,6,1,2,1,118,1,2,2,1,13,0}; static const oid model_row_oid[] = {1,3,6,1,2,1,118,1,1,2,1,3,0,1,2}; static const oid resource_id_oid[] = {1,3,6,1,2,1,118,1,2,2,1,10,0}; static const oid zero_dot_zero[] = {0,0}; netsnmp_variable_list var_trap; netsnmp_variable_list var_model_row; netsnmp_variable_list var_resource_id; memset(&var_trap, 0x00, sizeof(var_trap)); memset(&var_model_row, 0x00, sizeof(var_model_row)); memset(&var_resource_id, 0x00, sizeof(var_resource_id)); var_trap.next_variable = &var_model_row; var_model_row.next_variable = &var_resource_id; var_resource_id.next_variable = NULL; snmp_set_var_objid(&var_trap, snmp_trap_oid, OID_LENGTH(snmp_trap_oid)); if (alarm_table_def.severity() == AlarmDef::CLEARED) { snmp_set_var_typed_value(&var_trap, ASN_OBJECT_ID, (u_char*) clear_oid, sizeof(clear_oid)); } else { snmp_set_var_typed_value(&var_trap, ASN_OBJECT_ID, (u_char*) active_oid, sizeof(active_oid)); } snmp_set_var_objid(&var_model_row, model_ptr_oid, OID_LENGTH(model_ptr_oid)); snmp_set_var_typed_value(&var_model_row, ASN_OBJECT_ID, (u_char*) model_row_oid, sizeof(model_row_oid)); var_model_row.val.objid[ALARMMODELTABLEROW_INDEX] = alarm_table_def.index(); var_model_row.val.objid[ALARMMODELTABLEROW_STATE] = alarm_table_def.state(); snmp_set_var_objid(&var_resource_id, resource_id_oid, OID_LENGTH(resource_id_oid)); snmp_set_var_typed_value(&var_resource_id, ASN_OBJECT_ID, (u_char*) zero_dot_zero, sizeof(zero_dot_zero)); send_v2trap(&var_trap); snmp_reset_var_buffers(&var_trap);}
开发者ID:AiprNick,项目名称:clearwater-snmp-handlers,代码行数:47,
示例7: unregister_string_indexintunregister_string_index(oid * name, size_t name_len, char *cp){ netsnmp_variable_list varbind; memset(&varbind, 0, sizeof(netsnmp_variable_list)); varbind.type = ASN_OCTET_STR; snmp_set_var_objid(&varbind, name, name_len); snmp_set_var_value(&varbind, (u_char *) cp, strlen(cp)); return (unregister_index(&varbind, FALSE, main_session));}
开发者ID:duniansampa,项目名称:SigLog,代码行数:11,
示例8: my_test_handlerintmy_test_handler(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests){ oid myoid1[] = { 1, 2, 3, 4, 5, 6 }; static u_long accesses = 0; DEBUGMSGTL(("testhandler", "Got request:/n")); /* * loop through requests */ while (requests) { netsnmp_variable_list *var = requests->requestvb; DEBUGMSGTL(("testhandler", " oid:")); DEBUGMSGOID(("testhandler", var->name, var->name_length)); DEBUGMSG(("testhandler", "/n")); switch (reqinfo->mode) { case MODE_GET: if (netsnmp_oid_equals(var->name, var->name_length, myoid1, 6) == 0) { snmp_set_var_typed_value(var, ASN_INTEGER, (u_char *) & accesses, sizeof(accesses)); return SNMP_ERR_NOERROR; } break; case MODE_GETNEXT: if (snmp_oid_compare(var->name, var->name_length, myoid1, 6) < 0) { snmp_set_var_objid(var, myoid1, 6); snmp_set_var_typed_value(var, ASN_INTEGER, (u_char *) & accesses, sizeof(accesses)); return SNMP_ERR_NOERROR; } break; default: netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_GENERR); break; } requests = requests->next; } return SNMP_ERR_NOERROR;}
开发者ID:ClausKlein,项目名称:net-snmp,代码行数:52,
示例9: unregister_int_indexintunregister_int_index(oid * name, size_t name_len, int val){ netsnmp_variable_list varbind; memset(&varbind, 0, sizeof(netsnmp_variable_list)); varbind.type = ASN_INTEGER; snmp_set_var_objid(&varbind, name, name_len); varbind.val.string = varbind.buf; varbind.val_len = sizeof(long); *varbind.val.integer = val; return (unregister_index(&varbind, FALSE, main_session));}
开发者ID:duniansampa,项目名称:SigLog,代码行数:13,
示例10: unregister_oid_indexintunregister_oid_index(oid * name, size_t name_len, oid * value, size_t value_len){ netsnmp_variable_list varbind; memset(&varbind, 0, sizeof(netsnmp_variable_list)); varbind.type = ASN_OBJECT_ID; snmp_set_var_objid(&varbind, name, name_len); snmp_set_var_value(&varbind, (u_char *) value, value_len * sizeof(oid)); return (unregister_index(&varbind, FALSE, main_session));}
开发者ID:duniansampa,项目名称:SigLog,代码行数:13,
示例11: register_oid_indexstruct variable_list *register_oid_index( oid *name, size_t name_len, oid *value, size_t value_len ){ struct variable_list varbind; memset( &varbind, 0, sizeof(struct variable_list)); varbind.type = ASN_OBJECT_ID; snmp_set_var_objid( &varbind, name, name_len ); if ( value != ANY_OID_INDEX ) { snmp_set_var_value( &varbind, (u_char*)value, value_len*sizeof(oid) ); return( register_index( &varbind, ALLOCATE_THIS_INDEX, main_session )); } else return( register_index( &varbind, ALLOCATE_ANY_INDEX, main_session ));}
开发者ID:EPiCS,项目名称:reconos_v2,代码行数:16,
示例12: snmp_clone_var/* * Clone an SNMP variable data structure. * Sets pointers to structure private storage, or * allocates larger object identifiers and values as needed. * * Caller must make list association for cloned variable. * * Returns 0 if successful. */intsnmp_clone_var(netsnmp_variable_list * var, netsnmp_variable_list * newvar){ if (!newvar || !var) return 1; memmove(newvar, var, sizeof(netsnmp_variable_list)); newvar->next_variable = 0; newvar->name = 0; newvar->val.string = 0; newvar->data = 0; newvar->dataFreeHook = 0; newvar->index = 0; /* * Clone the object identifier and the value. * Allocate memory iff original will not fit into local storage. */ if (snmp_set_var_objid(newvar, var->name, var->name_length)) return 1; /* * need a pointer and a length to copy a string value. */ if (var->val.string && var->val_len) { if (var->val.string != &var->buf[0]) { if (var->val_len <= sizeof(var->buf)) newvar->val.string = newvar->buf; else { newvar->val.string = (u_char *) malloc(var->val_len); if (!newvar->val.string) return 1; } memmove(newvar->val.string, var->val.string, var->val_len); } else { /* fix the pointer to new local store */ newvar->val.string = newvar->buf; } } else { newvar->val.string = 0; newvar->val_len = 0; } return 0;}
开发者ID:AllardJ,项目名称:Tomato,代码行数:53,
示例13: _mteEvent_fire_setint _mteEvent_fire_set (struct mteEvent *entry, /* The event to fire */ struct mteTrigger *trigger, /* Trigger that fired */ oid * suffix, size_t sfx_len) /* Matching instance */{ netsnmp_variable_list var; oid set_oid[MAX_OID_LEN]; size_t set_len; /* * Set the basic assignment OID... */ memset (set_oid, 0, sizeof (set_oid)); memcpy (set_oid, entry->mteSetOID, entry->mteSetOID_len * sizeof (oid)); set_len = entry->mteSetOID_len; /* * ... if the trigger value is wildcarded (sfx_len > 0), * *and* the SET event entry is wildcarded, * then add the supplied instance suffix... */ if (sfx_len && entry->flags & MTE_SET_FLAG_OBJWILD) { memcpy (&set_oid[set_len], suffix, sfx_len * sizeof (oid)); set_len += sfx_len; } /* * ... finally build the assignment varbind, * and pass it to be acted on. * * XXX: Need to handle (remote) targets and non-default contexts */ memset (&var, 0, sizeof (var)); snmp_set_var_objid (&var, set_oid, set_len); snmp_set_var_typed_integer (&var, ASN_INTEGER, entry->mteSetValue); if (entry->session) return netsnmp_query_set (&var, entry->session); else return netsnmp_query_set (&var, trigger->session); /* XXX - Need to check result */}
开发者ID:274914765,项目名称:C,代码行数:44,
示例14: oa_bind_varstatic netsnmp_variable_list *oa_bind_var(netsnmp_variable_list * prev, void *value, int type, size_t sz_val, oid * oid, size_t sz_oid){ netsnmp_variable_list *var; var = (netsnmp_variable_list *) malloc(sizeof(netsnmp_variable_list)); if (!var) { ag_trace("FATAL: cannot malloc in oa_bind_var/n"); exit(-1); /* Sorry :( */ } memset(var, 0, sizeof(netsnmp_variable_list)); var->next_variable = prev; snmp_set_var_objid(var, oid, sz_oid); snmp_set_var_value(var, (u_char *) value, sz_val); var->type = type; return var;}
开发者ID:RasmusKoldsoe,项目名称:performand.k70.2,代码行数:19,
示例15: register_string_indexchar *register_string_index( oid *name, size_t name_len, char *cp ){ struct variable_list varbind, *res; memset( &varbind, 0, sizeof(struct variable_list)); varbind.type = ASN_OCTET_STR; snmp_set_var_objid( &varbind, name, name_len ); if ( cp != ANY_STRING_INDEX ) { snmp_set_var_value( &varbind, (u_char *)cp, strlen(cp) ); res = register_index( &varbind, ALLOCATE_THIS_INDEX, main_session ); } else res = register_index( &varbind, ALLOCATE_ANY_INDEX, main_session ); if ( res == NULL ) return NULL; else return (char *)res->val.string;}
开发者ID:EPiCS,项目名称:reconos_v2,代码行数:20,
示例16: send_enterprise_trap_varsvoid send_enterprise_trap_vars (int trap, int specific, oid *enterprise, int enterprise_length, struct variable_list *vars){ struct variable_list uptime_var, snmptrap_var, enterprise_var; struct variable_list *v2_vars, *last_var=NULL; struct snmp_pdu *template_pdu, *pdu; struct timeval now; long uptime; struct sockaddr_in *pduIp; struct trap_sink *sink; oid temp_oid[MAX_OID_LEN]; /* * Initialise SNMPv2 required variables */ gettimeofday(&now, NULL); uptime = calculate_time_diff(&now, &starttime); memset (&uptime_var, 0, sizeof (struct variable_list)); snmp_set_var_objid( &uptime_var, sysuptime_oid, OID_LENGTH(sysuptime_oid)); snmp_set_var_value( &uptime_var, (u_char *)&uptime, sizeof(uptime) ); uptime_var.type = ASN_TIMETICKS; uptime_var.next_variable = &snmptrap_var; memset (&snmptrap_var, 0, sizeof (struct variable_list)); snmp_set_var_objid( &snmptrap_var, snmptrap_oid, OID_LENGTH(snmptrap_oid)); /* value set later .... */ snmptrap_var.type = ASN_OBJECT_ID; if ( vars ) snmptrap_var.next_variable = vars; else snmptrap_var.next_variable = &enterprise_var; /* find end of provided varbind list, ready to append the enterprise info if necessary */ last_var = vars; while ( last_var && last_var->next_variable ) last_var = last_var->next_variable; memset (&enterprise_var, 0, sizeof (struct variable_list)); snmp_set_var_objid( &enterprise_var, snmptrapenterprise_oid, OID_LENGTH(snmptrapenterprise_oid)); snmp_set_var_value( &enterprise_var, (u_char *)enterprise, enterprise_length*sizeof(oid)); enterprise_var.type = ASN_OBJECT_ID; enterprise_var.next_variable = NULL; v2_vars = &uptime_var; /* * Create a template PDU, ready for sending */ template_pdu = snmp_pdu_create( SNMP_MSG_TRAP ); if ( template_pdu == NULL ) { /* Free memory if value stored dynamically */ snmp_set_var_value( &enterprise_var, NULL, 0); return; } template_pdu->trap_type = trap; template_pdu->specific_type = specific; if ( snmp_clone_mem((void **)&template_pdu->enterprise, enterprise, enterprise_length*sizeof(oid))) { snmp_free_pdu( template_pdu ); snmp_set_var_value( &enterprise_var, NULL, 0); return; } template_pdu->enterprise_length = enterprise_length; template_pdu->flags |= UCD_MSG_FLAG_FORCE_PDU_COPY; pduIp = (struct sockaddr_in *)&template_pdu->agent_addr; pduIp->sin_family = AF_INET; pduIp->sin_len = sizeof(*pduIp); pduIp->sin_addr.s_addr = get_myaddr(); template_pdu->time = uptime; /* * Now use the parameters to determine * which v2 variables are needed, * and what values they should take. */ switch ( trap ) { case -1: /* * SNMPv2 only * Check to see whether the variables provided * are sufficient for SNMPv2 notifications */ if (vars && snmp_oid_compare(vars->name, vars->name_length, sysuptime_oid, OID_LENGTH(sysuptime_oid)) == 0 ) v2_vars = vars; else if (vars && snmp_oid_compare(vars->name, vars->name_length, snmptrap_oid, OID_LENGTH(snmptrap_oid)) == 0 ) uptime_var.next_variable = vars; else { /* Hmmm... we don't seem to have a value - oops! */ snmptrap_var.next_variable = vars; } last_var = NULL; /* Don't need enterprise info */ break; /* "Standard" SNMPv1 traps *///.........这里部分代码省略.........
开发者ID:LucidOne,项目名称:Rovio,代码行数:101,
示例17: netsnmp_table_iterator_helper_handler//.........这里部分代码省略......... iinfo); } } break; case MODE_GET_STASH: /* collect data for each column for every row */ build_oid_noalloc(myname, MAX_OID_LEN, &myname_len, coloid, coloid_len, index_search); reqinfo->mode = MODE_GET; if (reqtmp) ldata = netsnmp_get_list_node(reqtmp->parent_data, TABLE_ITERATOR_NAME); if (!ldata) { netsnmp_request_add_list_data(reqtmp, netsnmp_create_data_list (TABLE_ITERATOR_NAME, callback_data_context, NULL)); } else { /* may have changed */ ldata->data = callback_data_context; } table_info->indexes = index_search; for(i = table_reg_info->min_column; i <= (int)table_reg_info->max_column; i++) { myname[reginfo->rootoid_len + 1] = i; table_info->colnum = i; vb = reqtmp->requestvb = SNMP_MALLOC_TYPEDEF(netsnmp_variable_list); vb->type = ASN_NULL; snmp_set_var_objid(vb, myname, myname_len); netsnmp_call_next_handler(handler, reginfo, reqinfo, reqtmp); reqtmp->requestvb = NULL; reqtmp->processed = 0; if (vb->type != ASN_NULL) { /* XXX, not all */ netsnmp_oid_stash_add_data(cinfo, myname, myname_len, vb); } else { snmp_free_var(vb); } } reqinfo->mode = MODE_GET_STASH; break; case MODE_GETNEXT: /* looking for "next" matches */ if (netsnmp_check_getnext_reply (request, coloid, coloid_len, index_search, &ti_info->results)) { netsnmp_iterator_remember(request, ti_info->results->name, ti_info->results->name_length, callback_data_context, callback_loop_context, iinfo); /* * If we've been told that the rows are sorted, * then the first valid one we find * must be the right one. */ if (iinfo->flags & NETSNMP_ITERATOR_FLAG_SORTED) request_count--;
开发者ID:grantc,项目名称:ingres-snmp-agent,代码行数:66,
示例18: 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_variable_list*) 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); } } 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 = (netsnmp_variable_list*)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); } } } break; default: cinfo->cache_valid = 0; return netsnmp_call_next_handler(handler, reginfo, reqinfo, requests); } return SNMP_ERR_NOERROR;}
开发者ID:ClausKlein,项目名称:net-snmp,代码行数:71,
示例19: netsnmp_table_iterator_helper_handler//.........这里部分代码省略......... &callback_data_context, index_search, iinfo); } } break; case MODE_GET: case MODE_SET_RESERVE1: /* * loop through all data till exact results are found */ while (index_search) { build_oid_noalloc(myname, MAX_OID_LEN, &myname_len, coloid, coloid_len, index_search); if (snmp_oid_compare(myname, myname_len, requests->requestvb->name, requests->requestvb->name_length) == 0) { /* * found the exact match, so we're done */ if (iinfo->make_data_context && !callback_data_context) { callback_data_context = (iinfo-> make_data_context) (callback_loop_context, iinfo); } callback_data_keep = callback_data_context; callback_data_context = NULL; results = snmp_clone_varbind(index_search); snmp_set_var_objid(results, myname, myname_len); goto got_results; } else { /* * free not-needed data context */ if (callback_data_context && iinfo->free_data_context) { (iinfo->free_data_context) (callback_data_context, iinfo); callback_data_context = NULL; } } /* * get the next node in the data chain */ index_search = (iinfo->get_next_data_point) (&callback_loop_context, &callback_data_context, index_search, iinfo); } break; default: /* * the rest of the set states have been dealt with already */ goto got_results; } /* * XXX: free index_search?
开发者ID:AllardJ,项目名称:Tomato,代码行数:67,
示例20: netsnmp_old_api_helper/** implements the old_api handler */intnetsnmp_old_api_helper(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests){#if MIB_CLIENTS_ARE_EVIL oid save[MAX_OID_LEN]; size_t savelen = 0;#endif struct variable compat_var, *cvp = &compat_var; int exact = 1; int status; struct variable *vp; netsnmp_old_api_cache *cacheptr; netsnmp_agent_session *oldasp = NULL; u_char *access = NULL; WriteMethod *write_method = NULL; size_t len; size_t tmp_len; oid tmp_name[MAX_OID_LEN]; vp = (struct variable *) handler->myvoid; /* * create old variable structure with right information */ memcpy(cvp->name, reginfo->rootoid, reginfo->rootoid_len * sizeof(oid)); cvp->namelen = reginfo->rootoid_len; cvp->type = vp->type; cvp->magic = vp->magic; cvp->acl = vp->acl; cvp->findVar = vp->findVar; switch (reqinfo->mode) { case MODE_GETNEXT: case MODE_GETBULK: exact = 0; } for (; requests; requests = requests->next) {#if MIB_CLIENTS_ARE_EVIL savelen = requests->requestvb->name_length; memcpy(save, requests->requestvb->name, savelen * sizeof(oid));#endif switch (reqinfo->mode) { case MODE_GET: case MODE_GETNEXT:#ifndef NETSNMP_NO_WRITE_SUPPORT case MODE_SET_RESERVE1:#endif /* !NETSNMP_NO_WRITE_SUPPORT */ /* * Actually call the old mib-module function */ if (vp && vp->findVar) { memcpy(tmp_name, requests->requestvb->name, requests->requestvb->name_length*sizeof(oid)); tmp_len = requests->requestvb->name_length; access = (*(vp->findVar)) (cvp, tmp_name, &tmp_len, exact, &len, &write_method); snmp_set_var_objid( requests->requestvb, tmp_name, tmp_len ); } else access = NULL;#ifdef WWW_FIX if (IS_DELEGATED(cvp->type)) { add_method = (AddVarMethod *) statP; requests->delayed = 1; have_delegated = 1; continue; /* WWW: This may not get to the right place */ }#endif /* * WWW: end range checking */ if (access) { /* * result returned */#ifndef NETSNMP_NO_WRITE_SUPPORT if (reqinfo->mode != MODE_SET_RESERVE1)#endif /* !NETSNMP_NO_WRITE_SUPPORT */ snmp_set_var_typed_value(requests->requestvb, cvp->type, access, len); } else { /* * no result returned */#if MIB_CLIENTS_ARE_EVIL if (access == NULL) { if (netsnmp_oid_equals(requests->requestvb->name, requests->requestvb->name_length,//.........这里部分代码省略.........
开发者ID:ColdStart,项目名称:SNMPD,代码行数:101,
示例21: mainvoidmain(int argc, char argv[]){ oid name[] = { 1, 2, 3, 4, 0 }; int i; memset(&varbind, 0, sizeof(netsnmp_variable_list)); snmp_set_var_objid(&varbind, name, 5); varbind->type = ASN_OCTET_STR; /* * Test index structure linking: * a) sorted by OID */ test_string_register(20, "empty OID"); test_string_register(10, "first OID"); test_string_register(40, "last OID"); test_string_register(30, "middle OID"); /* * b) sorted by index value */ test_string_register(25, "eee: empty IDX"); test_string_register(25, "aaa: first IDX"); test_string_register(25, "zzz: last IDX"); test_string_register(25, "mmm: middle IDX"); printf("This next one should fail..../n"); test_string_register(25, "eee: empty IDX"); /* duplicate */ printf("done/n"); /* * c) test initial index linking */ test_string_register(5, "eee: empty initial IDX"); test_string_register(5, "aaa: replace initial IDX"); /* * Did it all work? */ dump_idx_registry(); unregister_index_by_session(main_session); /* * Now test index allocation * a) integer values */ test_int_register(110, -1); /* empty */ test_int_register(110, -1); /* append */ test_int_register(110, 10); /* append exact */ printf("This next one should fail..../n"); test_int_register(110, 10); /* exact duplicate */ printf("done/n"); test_int_register(110, -1); /* append */ test_int_register(110, 5); /* insert exact */ /* * b) string values */ test_string_register(120, NULL); /* empty */ test_string_register(120, NULL); /* append */ test_string_register(120, "aaaz"); test_string_register(120, NULL); /* minor rollover */ test_string_register(120, "zzzz"); test_string_register(120, NULL); /* major rollover */ /* * c) OID values */ test_oid_register(130, -1); /* empty */ test_oid_register(130, -1); /* append */ varbind->val_len = varbind.name_length * sizeof(oid); memcpy(varbind->buf, varbind.name, varbind.val_len); varbind->val.objid = (oid *) varbind.buf; varbind->val_len += sizeof(oid); test_oid_register(130, 255); /* append exact */ test_oid_register(130, -1); /* minor rollover */ test_oid_register(130, 100); /* insert exact */ printf("This next one should fail..../n"); test_oid_register(130, 100); /* exact duplicate */ printf("done/n"); varbind->val.objid = (oid *) varbind.buf; for (i = 0; i < 6; i++) varbind->val.objid[i] = 255; varbind->val.objid[0] = 1; test_oid_register(130, 255); /* set up rollover */ test_oid_register(130, -1); /* medium rollover */ for (i = 0; i < 6; i++) varbind->val.objid[i] = 255; varbind->val.objid[0] = 2; test_oid_register(130, 255); /* set up rollover */ test_oid_register(130, -1); /* major rollover */ /* * Did it all work? */ dump_idx_registry();//.........这里部分代码省略.........
开发者ID:duniansampa,项目名称:SigLog,代码行数:101,
示例22: netsnmp_stash_to_next_helper/** @internal Implements the stash_to_next handler */intnetsnmp_stash_to_next_helper(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests){ int ret = SNMP_ERR_NOERROR; int namelen; int finished = 0; netsnmp_oid_stash_node **cinfo; netsnmp_variable_list *vb; netsnmp_request_info *reqtmp; /* * this code depends on AUTO_NEXT being set */ netsnmp_assert(handler->flags & MIB_HANDLER_AUTO_NEXT); /* * Don't do anything for any modes except GET_STASH. Just return, * and the agent will call the next handler (AUTO_NEXT). * * If the handler chain already supports GET_STASH, we don't * need to do anything here either. Once again, we just return * and the agent will call the next handler (AUTO_NEXT). * * Otherwise, we munge the mode to GET_NEXT, and call the * next handler ourselves, repeatedly until we've retrieved the * full contents of the table or subtree. * Then restore the mode and return to the calling handler * (setting AUTO_NEXT_OVERRRIDE so the agent knows what we did). */ if (MODE_GET_STASH == reqinfo->mode) { if ( reginfo->modes & HANDLER_CAN_STASH ) { return ret; } cinfo = netsnmp_extract_stash_cache( reqinfo ); reqtmp = SNMP_MALLOC_TYPEDEF(netsnmp_request_info); vb = reqtmp->requestvb = SNMP_MALLOC_TYPEDEF( netsnmp_variable_list ); vb->type = ASN_NULL; snmp_set_var_objid( vb, reginfo->rootoid, reginfo->rootoid_len ); reqinfo->mode = MODE_GETNEXT; while (!finished) { ret = netsnmp_call_next_handler(handler, reginfo, reqinfo, reqtmp); namelen = SNMP_MIN(vb->name_length, reginfo->rootoid_len); if ( !snmp_oid_compare( reginfo->rootoid, reginfo->rootoid_len, vb->name, namelen) && vb->type != ASN_NULL && vb->type != SNMP_ENDOFMIBVIEW ) { /* * This result is relevant so save it, and prepare * the request varbind for the next query. */ netsnmp_oid_stash_add_data( cinfo, vb->name, vb->name_length, snmp_clone_varbind( vb )); /* * Tidy up the response structure, * ready for retrieving the next entry */ netsnmp_free_all_list_data(reqtmp->parent_data); reqtmp->parent_data = NULL; reqtmp->processed = 0; vb->type = ASN_NULL; } else { finished = 1; } } reqinfo->mode = MODE_GET_STASH; /* * let the handler chain processing know that we've already * called the next handler */ handler->flags |= MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE; } return ret;}
开发者ID:ClausKlein,项目名称:net-snmp,代码行数:80,
示例23: netsnmp_scalar_group_helper_handler//.........这里部分代码省略......... */ case MODE_GET: ret = SNMP_NOSUCHOBJECT; /* Fallthrough */#ifndef NETSNMP_NO_WRITE_SUPPORT case MODE_SET_RESERVE1: case MODE_SET_RESERVE2: case MODE_SET_ACTION: case MODE_SET_COMMIT: case MODE_SET_UNDO: case MODE_SET_FREE:#endif /* NETSNMP_NO_WRITE_SUPPORT */ if (cmp != 0 || requests->requestvb->name_length <= reginfo->rootoid_len) { /* * Common prefix doesn't match, or only *just* matches * the registered root (so can't possibly match a scalar) */ netsnmp_set_request_error(reqinfo, requests, ret); return SNMP_ERR_NOERROR; } else { /* * Otherwise, * extract the object subidentifier from the request, * check this is (probably) valid, and then fudge the * registered 'rootoid' to match, before passing the * request off to the next handler ('scalar'). * * Note that we don't bother checking instance subidentifiers * here. That's left to the scalar helper. */ subid = requests->requestvb->name[reginfo->rootoid_len]; if (subid < sgroup->lbound || subid > sgroup->ubound) { netsnmp_set_request_error(reqinfo, requests, ret); return SNMP_ERR_NOERROR; } root_tmp[reginfo->rootoid_len] = subid; reginfo->rootoid_len += 2; reginfo->rootoid = root_tmp; ret = netsnmp_call_next_handler(handler, reginfo, reqinfo, requests); reginfo->rootoid = root_save; reginfo->rootoid_len -= 2; return ret; } break; case MODE_GETNEXT: /* * If we're being asked for something before (or exactly matches) * the registered root OID, then start with the first object. * If we're being asked for something that exactly matches an object * OID, then that's what we pass down. * Otherwise, we pass down the OID of the *next* object.... */ if (cmp < 0 || requests->requestvb->name_length <= reginfo->rootoid_len) { subid = sgroup->lbound; } else if (requests->requestvb->name_length == reginfo->rootoid_len+1) subid = requests->requestvb->name[reginfo->rootoid_len]; else subid = requests->requestvb->name[reginfo->rootoid_len]+1; /* * ... always assuming this is (potentially) valid, of course. */ if (subid < sgroup->lbound) subid = sgroup->lbound; else if (subid > sgroup->ubound) return SNMP_ERR_NOERROR; root_tmp[reginfo->rootoid_len] = subid; reginfo->rootoid_len += 2; reginfo->rootoid = root_tmp; ret = netsnmp_call_next_handler(handler, reginfo, reqinfo, requests); /* * If we didn't get an answer (due to holes in the group) * set things up to retry again. */ if (!requests->delegated && (requests->requestvb->type == ASN_NULL || requests->requestvb->type == SNMP_NOSUCHOBJECT || requests->requestvb->type == SNMP_NOSUCHINSTANCE)) { snmp_set_var_objid(requests->requestvb, reginfo->rootoid, reginfo->rootoid_len - 1); requests->requestvb->name[reginfo->rootoid_len - 2] = ++subid; requests->requestvb->type = ASN_PRIV_RETRY; } reginfo->rootoid = root_save; reginfo->rootoid_len -= 2; return ret; } /* * got here only if illegal mode found */ return SNMP_ERR_GENERR;}
开发者ID:ClausKlein,项目名称:net-snmp,代码行数:101,
示例24: netsnmp_instance_helper_handlerintnetsnmp_instance_helper_handler(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests){ netsnmp_variable_list *var = requests->requestvb; int ret, cmp; DEBUGMSGTL(("helper:instance", "Got request:/n")); cmp = snmp_oid_compare(requests->requestvb->name, requests->requestvb->name_length, reginfo->rootoid, reginfo->rootoid_len); DEBUGMSGTL(("helper:instance", " oid:")); DEBUGMSGOID(("helper:instance", var->name, var->name_length)); DEBUGMSG(("helper:instance", "/n")); switch (reqinfo->mode) { case MODE_GET: if (cmp != 0) { netsnmp_set_request_error(reqinfo, requests, SNMP_NOSUCHINSTANCE); return SNMP_ERR_NOERROR; } else { return netsnmp_call_next_handler(handler, reginfo, reqinfo, requests); } break; case MODE_SET_RESERVE1: case MODE_SET_RESERVE2: case MODE_SET_ACTION: case MODE_SET_COMMIT: case MODE_SET_UNDO: case MODE_SET_FREE: if (cmp != 0) { netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_NOCREATION); return SNMP_ERR_NOERROR; } else { return netsnmp_call_next_handler(handler, reginfo, reqinfo, requests); } break; case MODE_GETNEXT: if (cmp < 0 || (cmp == 0 && requests->inclusive)) { reqinfo->mode = MODE_GET; snmp_set_var_objid(requests->requestvb, reginfo->rootoid, reginfo->rootoid_len); ret = netsnmp_call_next_handler(handler, reginfo, reqinfo, requests); reqinfo->mode = MODE_GETNEXT; /* * if the instance doesn't have data, set type to ASN_NULL * to move to the next sub-tree. Ignore delegated requests; they * might have data later on. */ if (!requests->delegated && (requests->requestvb->type == SNMP_NOSUCHINSTANCE || requests->requestvb->type == SNMP_NOSUCHOBJECT)) { requests->requestvb->type = ASN_NULL; } return ret; } else { return SNMP_ERR_NOERROR; } break; } /* * got here only if illegal mode found */ return SNMP_ERR_GENERR;}
开发者ID:OPSF,项目名称:uClinux,代码行数:78,
示例25: handle_subagent_responseinthandle_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,
示例26: expExpression_getData/* * Gather the data necessary for evaluating an expression. * * This will retrieve *all* the data relevant for all * instances of this expression, rather than just the * just the values needed for expanding a given instance. */voidexpExpression_getData( unsigned int reg, void *clientarg ){ struct expExpression *entry = (struct expExpression *)clientarg; netsnmp_tdata_row *row; netsnmp_variable_list *var; int ret; if ( !entry && reg ) { snmp_alarm_unregister( reg ); return; } if (( entry->expExpression[0] == '/0' ) || !(entry->flags & EXP_FLAG_ACTIVE) || !(entry->flags & EXP_FLAG_VALID)) return; DEBUGMSGTL(("disman:expr:run", "Gathering expression data (%s, %s)/n", entry->expOwner, entry->expName)); /* * This routine can be called in two situations: * - regularly by 'snmp_alarm' (reg != 0) * (as part of ongoing delta-value sampling) * - on-demand (reg == 0) * (for evaluating a particular entry) * * If a regularly sampled expression (entry->alarm != 0) * is invoked on-demand (reg == 0), then use the most * recent sampled values, rather than retrieving them again. */ if ( !reg && entry->alarm ) return; /* * XXX - may want to implement caching for on-demand evaluation * of non-regularly sampled expressions. */ /* * For a wildcarded expression, expExpressionPrefix is used * to determine which object instances to retrieve. * (For a non-wildcarded expression, we already know * explicitly which object instances will be needed). * * If we walk this object here, then the results can be * used to build the necessary GET requests for each * individual parameter object (within expObject_getData) * * This will probably be simpler (and definitely more efficient) * than walking the object instances separately and merging * merging the results). * * NB: Releasing any old results is handled by expObject_getData. * Assigning to 'entry->pvars' without first releasing the * previous contents does *not* introduce a memory leak. */ if ( entry->expPrefix_len ) { var = (netsnmp_variable_list *) SNMP_MALLOC_TYPEDEF( netsnmp_variable_list ); snmp_set_var_objid( var, entry->expPrefix, entry->expPrefix_len); ret = netsnmp_query_walk( var, entry->session ); DEBUGMSGTL(("disman:expr:run", "Walk returned %d/n", ret )); entry->pvars = var; } /* XXX - retrieve sysUpTime.0 value, and check for discontinuity */ /* entry->flags &= ~EXP_FLAG_SYSUT; var = (netsnmp_variable_list *) SNMP_MALLOC_TYPEDEF( netsnmp_variable_list ); snmp_set_var_objid( var, sysUT_oid, sysUT_oid_len ); netsnmp_query_get( var, entry->session ); if ( *var->val.integer != entry->sysUpTime ) { entry->flags |= EXP_FLAG_SYSUT; entry->sysUpTime = *var->val.integer; } snmp_free_varbind(var); */ /* * Loop through the list of relevant objects, * and retrieve the corresponding values. */ for ( row = expObject_getFirst( entry->expOwner, entry->expName ); row; row = expObject_getNext( row )) { /* XXX - may need to check whether owner/name still match */ expObject_getData( entry, (struct expObject *)row->data); }}
开发者ID:KrisChaplin,项目名称:LRT2x4_v1.0.2.06_GPL_source,代码行数:100,
示例27: decode_vbindintdecode_vbind (unsigned char *data, unsigned int vb_len){ unsigned char *var_val; oid var_name[MAX_OID_LEN]; /* To test the objid */ size_t name_len = MAX_OID_LEN; /* To test the objid */ int badtype=0; size_t len; struct variable_list *vp; oid objid[MAX_OID_LEN]; char _docsis_snmp_label[50]; /* To hold the 'name' of the type, i.e. Integer etc */ char *enum_string = NULL; static char outbuf[16384]; struct tree *subtree; struct enum_list *enums; memset (outbuf, 0, 16384); vp = (struct variable_list *) malloc (sizeof (struct variable_list)); if (vp == NULL) { fprintf (stderr, "Out of memory/n"); return 0; } memset (vp, 0, sizeof (struct variable_list)); vp->next_variable = NULL; vp->val.string = NULL; vp->name_length = MAX_OID_LEN; vp->name = 0; data = snmp_parse_var_op (data, objid, &vp->name_length, &vp->type, &vp->val_len, &var_val, (size_t *) & vb_len); if (data == NULL) return -1; if (snmp_set_var_objid (vp, objid, vp->name_length)) return -1; len = PACKET_LENGTH; if (netsnmp_ds_get_boolean (NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_EXTENDED_INDEX)) { netsnmp_ds_toggle_boolean (NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_EXTENDED_INDEX); } /* Disable extended index format ... makes it harder to parse tokens in lex */ if (!netsnmp_ds_get_boolean (NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM)) { netsnmp_ds_toggle_boolean (NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM); } /* Enable printing numeric enums */ if (netsnmp_ds_get_boolean (NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_ESCAPE_QUOTES)) { netsnmp_ds_toggle_boolean (NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_ESCAPE_QUOTES); } /* Disable escape quotes in string index output */ netsnmp_ds_set_int (NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT, NETSNMP_OID_OUTPUT_SUFFIX); if (netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_OID_OUTPUT_NUMERIC)) { netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT, NETSNMP_OID_OUTPUT_NUMERIC); } snprint_objid (outbuf, 1023, vp->name, vp->name_length); if (!get_node (outbuf, var_name, &name_len)) { if (!read_objid (outbuf, var_name, &name_len)) { fprintf (stderr, "/* Hmm ... can't find oid %s at line %d ... perhaps the MIBs are not installed ? *//n", outbuf, line); /* temporarily set full output format */ netsnmp_ds_set_int (NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT, NETSNMP_OID_OUTPUT_FULL); memset (outbuf, 0, 1024); snprint_objid (outbuf, 1023, vp->name, vp->name_length); /* Go back to suffix-mode for better readability */ netsnmp_ds_set_int (NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT, NETSNMP_OID_OUTPUT_SUFFIX); } } printf("%s", outbuf);/* save the subtree - we need it later to show enums */ subtree = get_tree (var_name, name_len, get_tree_head() );/* This first switch is just for saving the type in the format we actually want to print. */ switch ((short) vp->type) {//.........这里部分代码省略.........
开发者ID:tenpin784,项目名称:docsis,代码行数:101,
示例28: mteTrigger_runvoidmteTrigger_run( unsigned int reg, void *clientarg){ struct mteTrigger *entry = (struct mteTrigger *)clientarg; netsnmp_variable_list *var, *vtmp; netsnmp_variable_list *vp1, *vp1_prev; netsnmp_variable_list *vp2, *vp2_prev; netsnmp_variable_list *dvar = NULL; netsnmp_variable_list *dv1 = NULL, *dv2 = NULL; netsnmp_variable_list sysUT_var; int cmp = 0, n, n2; long value; const char *reason; if (!entry) { snmp_alarm_unregister( reg ); return; } if (!(entry->flags & MTE_TRIGGER_FLAG_ENABLED ) || !(entry->flags & MTE_TRIGGER_FLAG_ACTIVE ) || !(entry->flags & MTE_TRIGGER_FLAG_VALID )) { return; } { extern netsnmp_agent_session *netsnmp_processing_set; if (netsnmp_processing_set) { /* * netsnmp_handle_request will not be responsive to our efforts to * Retrieve the requested MIB value(s)... * so we will skip it. * https://sourceforge.net/tracker/ * index.php?func=detail&aid=1557406&group_id=12694&atid=112694 */ DEBUGMSGTL(("disman:event:trigger:monitor", "Skipping trigger (%s) while netsnmp_processing_set/n", entry->mteTName)); return; } } /* * Retrieve the requested MIB value(s)... */ DEBUGMSGTL(( "disman:event:trigger:monitor", "Running trigger (%s)/n", entry->mteTName)); var = (netsnmp_variable_list *)SNMP_MALLOC_TYPEDEF( netsnmp_variable_list ); if (!var) { _mteTrigger_failure("failed to create mteTrigger query varbind"); return; } snmp_set_var_objid( var, entry->mteTriggerValueID, entry->mteTriggerValueID_len ); if ( entry->flags & MTE_TRIGGER_FLAG_VWILD ) { n = netsnmp_query_walk( var, entry->session ); } else { n = netsnmp_query_get( var, entry->session ); } if ( n != SNMP_ERR_NOERROR ) { DEBUGMSGTL(( "disman:event:trigger:monitor", "Trigger query (%s) failed: %d/n", (( entry->flags & MTE_TRIGGER_FLAG_VWILD ) ? "walk" : "get"), n)); _mteTrigger_failure( "failed to run mteTrigger query" ); snmp_free_varbind(var); return; } /* * ... canonicalise the results (to simplify later comparisons)... */ vp1 = var; vp1_prev = NULL; vp2 = entry->old_results; vp2_prev = NULL; entry->count=0; while (vp1) { /* * Flatten various missing values/exceptions into a single form */ switch (vp1->type) { case SNMP_NOSUCHINSTANCE: case SNMP_NOSUCHOBJECT: case ASN_PRIV_RETRY: /* Internal only ? */ vp1->type = ASN_NULL; } /* * Keep track of how many entries have been retrieved. */ entry->count++; /* * Ensure previous and current result match * (with corresponding entries in both lists) * and set the flags indicating which triggers are armed */ if (vp2) { cmp = snmp_oid_compare(vp1->name, vp1->name_length, vp2->name, vp2->name_length); if ( cmp < 0 ) { /* * If a new value has appeared, insert a matching//.........这里部分代码省略.........
开发者ID:liquidradio,项目名称:net-snmp,代码行数:101,
示例29: proxy_got_response//.........这里部分代码省略......... /* * Check the response oid is legitimate, * and discard the value if not. * * XXX - what's the difference between these cases? */ if (sp->base_len && (var->name_length < sp->base_len || snmp_oid_compare(var->name, sp->base_len, sp->base, sp->base_len) != 0)) { DEBUGMSGTL(( "proxy", "out of registered range... ")); DEBUGMSGOID(("proxy", var->name, sp->base_len)); DEBUGMSG(( "proxy", " (%d) != ", sp->base_len)); DEBUGMSGOID(("proxy", sp->base, sp->base_len)); DEBUGMSG(( "proxy", "/n")); snmp_set_var_typed_value(request->requestvb, ASN_NULL, NULL, 0); continue; } else if (!sp->base_len && (var->name_length < sp->name_len || snmp_oid_compare(var->name, sp->name_len, sp->name, sp->name_len) != 0)) { DEBUGMSGTL(( "proxy", "out of registered base range... ")); DEBUGMSGOID(("proxy", var->name, sp->name_len)); DEBUGMSG(( "proxy", " (%d) != ", sp->name_len)); DEBUGMSGOID(("proxy", sp->name, sp->name_len)); DEBUGMSG(( "proxy", "/n")); snmp_set_var_typed_value(request->requestvb, ASN_NULL, NULL, 0); continue; } else { /* * If the returned OID is legitimate, then update * the original request varbind accordingly. */ if (sp->base_len) { /* * XXX: oid size maxed? */ memcpy(myname, sp->name, sizeof(oid) * sp->name_len); myname_len = sp->name_len + var->name_length - sp->base_len; if (myname_len > MAX_OID_LEN) { snmp_log(LOG_WARNING, "proxy OID return length too long./n"); netsnmp_set_request_error(cache->reqinfo, requests, SNMP_ERR_GENERR); if (pdu) snmp_free_pdu(pdu); netsnmp_free_delegated_cache(cache); return 1; } if (var->name_length > sp->base_len) memcpy(&myname[sp->name_len], &var->name[sp->base_len], sizeof(oid) * (var->name_length - sp->base_len)); snmp_set_var_objid(request->requestvb, myname, myname_len); } else { snmp_set_var_objid(request->requestvb, var->name, var->name_length); } } } if (request || var) { /* * ack, this is bad. The # of varbinds don't match and * there is no way to fix the problem */ if (pdu) snmp_free_pdu(pdu); snmp_log(LOG_ERR, "response to proxy request illegal. We're screwed./n"); netsnmp_set_request_error(cache->reqinfo, requests, SNMP_ERR_GENERR); } /* fix bulk_to_next operations */ if (cache->reqinfo->mode == MODE_GETBULK) netsnmp_bulk_to_next_fix_requests(requests); /* * free the response */ if (pdu && 0) snmp_free_pdu(pdu); break; default: DEBUGMSGTL(("proxy", "no response received: op = %d/n", operation)); break; } netsnmp_free_delegated_cache(cache); return 1;}
开发者ID:Nymphetaminer,项目名称:dsl-n55u,代码行数:101,
示例30: agentx_got_response//.........这里部分代码省略......... 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 (i == pdu->errindex) { /* * Mark this varbind as the one generating the error. * Note that the AgentX errindex may not match the * position in the original SNMP PDU (request->index) */ 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. bailing out./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:RasmusKoldsoe,项目名称:performand.k70.2,代码行数:101,
注:本文中的snmp_set_var_objid函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ snmp_set_var_typed_integer函数代码示例 C++ snmp_sess_perror函数代码示例 |