这篇教程C++ snmp_parse_oid函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中snmp_parse_oid函数的典型用法代码示例。如果您正苦于以下问题:C++ snmp_parse_oid函数的具体用法?C++ snmp_parse_oid怎么用?C++ snmp_parse_oid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了snmp_parse_oid函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: view_oidvoid view_oid (oid * it, size_t * len, const char *viewName, char *viewSubtree){ int i; oid c_oid[SPRINT_MAX_LEN]; size_t c_oid_length = SPRINT_MAX_LEN; int itIndex = VIEW_OID_LEN; if (!snmp_parse_oid (viewSubtree, c_oid, &c_oid_length)) { printf ("Error parsing subtree (%s)/n", viewSubtree); exit (1); } *len = itIndex + 2 + strlen (viewName) + c_oid_length; it[itIndex++] = strlen (viewName); for (i = 0; i < (int) strlen (viewName); i++) it[itIndex++] = viewName[i]; it[itIndex++] = c_oid_length; for (i = 0; i < (int) c_oid_length; i++) it[itIndex++] = c_oid[i]; /* * sprint_objid(c_oid, it, *len); */}
开发者ID:274914765,项目名称:C,代码行数:31,
示例2: addintadd(netsnmp_pdu *pdu, const char *mibnodename, oid * index, size_t indexlen){ oid base[MAX_OID_LEN]; size_t base_length = MAX_OID_LEN; memset(base, 0, MAX_OID_LEN * sizeof(oid)); if (!snmp_parse_oid(mibnodename, base, &base_length)) { snmp_perror(mibnodename); fprintf(stderr, "couldn't find mib node %s, giving up/n", mibnodename);#if HAVE_CURSES_H endwin();#endif exit(1); } if (index && indexlen) { memcpy(&(base[base_length]), index, indexlen * sizeof(oid)); base_length += indexlen; } DEBUGMSGTL(("add", "created: ")); DEBUGMSGOID(("add", base, base_length)); DEBUGMSG(("add", "/n")); snmp_add_null_var(pdu, base, base_length); return base_length;}
开发者ID:michalklempa,项目名称:net-snmp,代码行数:30,
示例3: snmp_set/** * The 'raw' SNMP set function. It should not be used directly in external * files. Rather, a non-static wrapper function should be created here that * makes the appropriate call in order to preserve source code readability. * * @return 1 if successful, 0 if not */static int snmp_set(netsnmp_session *s, char *oid_str, char type, const char *val){ netsnmp_pdu *pdu; oid the_oid[MAX_OID_LEN]; size_t oid_len; pdu = snmp_pdu_create(SNMP_MSG_SET); oid_len = MAX_OID_LEN; // Parse the OID if (snmp_parse_oid(oid_str, the_oid, &oid_len) == 0) { snmp_perror(oid_str); return 0; } // Build the packet to be sent if (snmp_add_var(pdu, the_oid, oid_len, type, val) != 0) { printf("type: %c, val: %s, oid_str: %s/n", type, val, oid_str); snmp_perror("SNMP: Could not add var!"); return 0; } // Send the request if (snmp_send(s, pdu) == 0) { snmp_perror("SNMP: Error while sending!"); snmp_free_pdu(pdu); return 0; } return 1;}
开发者ID:limasierra,项目名称:SatelliteConnectionMonitor,代码行数:38,
示例4: simpleSNMPsendvoidsimpleSNMPsend(struct snmp_session *session, oid *name, size_t name_length){ struct snmp_pdu *pdu; oid uptime[MAX_OID_LEN]; size_t uptime_length; /* * Create PDU for GET request and add object names to request. */ pdu = snmp_pdu_create(SNMP_MSG_GET); /* * First insert uptime request into PDU. */ uptime_length = MAX_OID_LEN; if (!snmp_parse_oid("system.sysUpTime.0", uptime, &uptime_length)) { printf("error parsing oid: system.sysUpTime.0/n"); } snmp_add_null_var(pdu, uptime, uptime_length); snmp_add_null_var(pdu, name, name_length); /* * Perform the request. */ snmp_send(session, pdu);}
开发者ID:zuckschwerdt,项目名称:gkrellm-snmp,代码行数:32,
示例5: add_fieldstatic inline void add_field ( netsnmp_pdu *trap_pdu, u_char asn_type, const char *prefix, void *value, size_t value_size){ oid _oid[MAX_OID_LEN]; size_t _oid_len = MAX_OID_LEN; if (snmp_parse_oid(prefix, _oid, &_oid_len)) { snmp_pdu_add_variable (trap_pdu, _oid, _oid_len, asn_type, (u_char *) value, value_size); }}
开发者ID:ClusterLabs,项目名称:corosync,代码行数:13,
示例6: csnmp_config_add_data_valuesstatic int csnmp_config_add_data_values (data_definition_t *dd, oconfig_item_t *ci){ int i; if (ci->values_num < 1) { WARNING ("snmp plugin: `Values' needs at least one argument."); return (-1); } for (i = 0; i < ci->values_num; i++) if (ci->values[i].type != OCONFIG_TYPE_STRING) { WARNING ("snmp plugin: `Values' needs only string argument."); return (-1); } sfree (dd->values); dd->values_len = 0; dd->values = (oid_t *) malloc (sizeof (oid_t) * ci->values_num); if (dd->values == NULL) return (-1); dd->values_len = (size_t) ci->values_num; for (i = 0; i < ci->values_num; i++) { dd->values[i].oid_len = MAX_OID_LEN; if (NULL == snmp_parse_oid (ci->values[i].value.string, dd->values[i].oid, &dd->values[i].oid_len)) { ERROR ("snmp plugin: snmp_parse_oid (%s) failed.", ci->values[i].value.string); free (dd->values); dd->values = NULL; dd->values_len = 0; return (-1); } } return (0);} /* int csnmp_config_add_data_instance */
开发者ID:kmiku7,项目名称:collectd,代码行数:42,
示例7: add_pdu_varstatic void add_pdu_var(netsnmp_pdu *pdu, const char *mib_name, int id, const char *value){ oid oid_name[MAX_OID_LEN]; size_t name_length; char buf[4096]; buf[4095] = '/0'; snprintf(buf, sizeof(buf)-1, "%s.%d", mib_name, id); name_length = MAX_OID_LEN; if (snmp_parse_oid(buf, oid_name, &name_length) == NULL) { snmp_perror(buf); return; } if (snmp_add_var(pdu, oid_name, name_length, '=', value)) { snmp_perror(buf); return; }}
开发者ID:FreeRADIUS,项目名称:freeradius-server,代码行数:20,
示例8: mainint main(int argc, char ** argv){ netsnmp_session session, *ss; netsnmp_pdu *pdu; netsnmp_pdu *response; oid anOID[MAX_OID_LEN]; size_t anOID_len; netsnmp_variable_list *vars; int status; int count=1; /* * Initialize the SNMP library */ init_snmp("snmpdemoapp"); /* * Initialize a "session" that defines who we're going to talk to */ snmp_sess_init( &session ); /* set up defaults */ session.peername = strdup("test.net-snmp.org"); /* set up the authentication parameters for talking to the server */#ifdef DEMO_USE_SNMP_VERSION_3 /* Use SNMPv3 to talk to the experimental server */ /* set the SNMP version number */ session.version=SNMP_VERSION_3; /* set the SNMPv3 user name */ session.securityName = strdup("MD5User"); session.securityNameLen = strlen(session.securityName); /* set the security level to authenticated, but not encrypted */ session.securityLevel = SNMP_SEC_LEVEL_AUTHNOPRIV; /* set the authentication method to MD5 */ session.securityAuthProto = usmHMACMD5AuthProtocol; session.securityAuthProtoLen = sizeof(usmHMACMD5AuthProtocol)/sizeof(oid); session.securityAuthKeyLen = USM_AUTH_KU_LEN; /* set the authentication key to a MD5 hashed version of our passphrase "The Net-SNMP Demo Password" (which must be at least 8 characters long) */ if (generate_Ku(session.securityAuthProto, session.securityAuthProtoLen, (u_char *) our_v3_passphrase, strlen(our_v3_passphrase), session.securityAuthKey, &session.securityAuthKeyLen) != SNMPERR_SUCCESS) { snmp_perror(argv[0]); snmp_log(LOG_ERR, "Error generating Ku from authentication pass phrase. /n"); exit(1); } #else /* we'll use the insecure (but simplier) SNMPv1 */ /* set the SNMP version number */ session.version = SNMP_VERSION_1; /* set the SNMPv1 community name used for authentication */ session.community = "demopublic"; session.community_len = strlen(session.community);#endif /* SNMPv1 */ /* * Open the session */ SOCK_STARTUP; ss = snmp_open(&session); /* establish the session */ if (!ss) { snmp_sess_perror("ack", &session); SOCK_CLEANUP; exit(1); } /* * Create the PDU for the data for our request. * 1) We're going to GET the system.sysDescr.0 node. */ pdu = snmp_pdu_create(SNMP_MSG_GET); anOID_len = MAX_OID_LEN; if (!snmp_parse_oid(".1.3.6.1.2.1.1.1.0", anOID, &anOID_len)) { snmp_perror(".1.3.6.1.2.1.1.1.0"); SOCK_CLEANUP; exit(1); }#if OTHER_METHODS /* * These are alternatives to the 'snmp_parse_oid' call above, * e.g. specifying the OID by name rather than numerically. */ read_objid(".1.3.6.1.2.1.1.1.0", anOID, &anOID_len); get_node("sysDescr.0", anOID, &anOID_len);//.........这里部分代码省略.........
开发者ID:RaonControl,项目名称:siteLibs,代码行数:101,
|