📄 snmptalk.c
字号:
} } }#else sty_puts(sty, "\This copy of snmptalk wasn't built as an agent, so it can't find nodes.\n");#endif return (1);}#if INSTALL_ENVOY_SNMP_VERSION_3ALENGTH_T parse_engine_id(struct sty *sty, char form, char *in_string, bits8_t *in_id, char *err_string){ALENGTH_T id_len = 0;int value; switch(form) { case 'x': if (STRLEN(in_string) > 64) sty_printf(sty, "`%s'command requires `engine id' to be <= 64 octets\n", err_string); else for(; (id_len <= 32) && (*in_string != 0) && (*(in_string+1) != 0); id_len++, in_string += 2){ sscanf(in_string, "%02x", &value); in_id[id_len] = value; } break; case 'a': id_len = STRLEN(in_string); if (id_len > 32) sty_printf(sty, "`%s' command requires `engine id' to be <= 32 octets\n", err_string); else MEMCPY(in_id, in_string, id_len); break; default: sty_printf(sty, "`%s' command requires `from' to be `x' or `a'\n", err_string); }return(id_len);}boolean_t do_v3_tos(struct sty *sty, enum help_level help, int argc, char *argv[]){char value; switch (help) { case help_short: sty_puts(sty, "tos <tos> - specify the type of service to use\n"); break; case help_long: sty_puts(sty, "\The 'tos <tos>' command specifies the type of service for use\n\with the version 3 code. No auth: 0, auth: 1, priv: 3\n"); break; case help_none: if (argc < 2) { if (batch_mode) sty_putc(sty, '|'); sty_puts(sty, "`tos' command needs `tos' as argument\n"); } else { value = atoi(argv[1]); switch (value) { case 0: case 1: case 3: v3_tos_flags = value; break; default: if (batch_mode) sty_putc(sty, '|'); sty_puts(sty, "illegal value for `tos' command\n"); break; } } } return (1);}boolean_t do_v3_con_name(struct sty *sty, enum help_level help, int argc, char *argv[]){ switch (help) { case help_short: sty_puts(sty, "con_name <context name> - specify the context name\n"); break; case help_long: sty_puts(sty, "\The 'con_name <context name>' command specifies the name of the context for\n\use with the version 3 code.\n"); break; case help_none: if (argc < 2) { if (batch_mode) sty_putc(sty, '|'); sty_puts(sty, "`con_name' command needs `context name' as argument\n"); } else { v3_con_name = etc_strdup(argv[1]); } } return (1);}boolean_t do_v3_con_id(struct sty *sty, enum help_level help, int argc, char *argv[]){ALENGTH_T id_len; switch (help) { case help_short: sty_puts(sty, "con_id <form> <engine id> - specify the context engine id\n"); break; case help_long: sty_puts(sty, "\The 'con_id <form> <engine id>' command specifies the engine id to use for\n\the context engine id with the version 3 code.\n"); break; case help_none: if (argc < 3) { if (batch_mode) sty_putc(sty, '|'); sty_puts(sty, "`con_id' command needs arguments `form' and `engine id'\n"); } else { id_len = parse_engine_id(sty, *argv[1], argv[2], v3_con_id, "con_id"); if (id_len) v3_con_id_len = id_len; } } return (1);}boolean_t do_v3_sec_name(struct sty *sty, enum help_level help, int argc, char *argv[]){ switch (help) { case help_short: sty_puts(sty, "sec_name <security name> - specify the security name\n"); break; case help_long: sty_puts(sty, "\The 'sec_name <security name>' command specifies the security name for\n\use with the version 3 code.\n"); break; case help_none: if (argc < 2) { if (batch_mode) sty_putc(sty, '|'); sty_puts(sty, "`sec_name' command needs `security name' as argument\n"); } else { v3_sec_name = etc_strdup(argv[1]); } } return (1);}boolean_t do_v3_sec_id(struct sty *sty, enum help_level help, int argc, char *argv[]){ALENGTH_T id_len; switch (help) { case help_short: sty_puts(sty, "sec_id <form> <engine id> - specify the security engine id\n"); break; case help_long: sty_puts(sty, "\The 'sec_id <form> <engine id>' command specifies the engine id to use for\n\the security engine id with the version 3 code.\n"); break; case help_none: if (argc < 3) { if (batch_mode) sty_putc(sty, '|'); sty_puts(sty, "`sec_id' command needs arguments `form' and `engine id'\n"); } else { id_len = parse_engine_id(sty, *argv[1], argv[2], v3_sec_id, "sec_id"); if (id_len) v3_sec_id_len = id_len; } } return (1);}#endif /* #if INSTALL_ENVOY_SNMP_VERSION_3 */ #if INSTALL_ENVOY_SNMP_VERSION_USECboolean_t do_qos(struct sty *sty, enum help_level help, int argc, char *argv[]){ switch (help) { case help_short: sty_puts(sty, "qos <qos> - specify the quality of service to use\n"); break; case help_long: sty_puts(sty, "\The 'qos <qos>' command specifies the quality of service for use\n\with the usec code.\n"); break; case help_none: if (argc < 2) { if (batch_mode) sty_putc(sty, '|'); sty_puts(sty, "`qos' command needs `qos' as argument\n"); } else usec_qos = atoi(argv[1]); } return (1);}boolean_t do_agent(struct sty *sty, enum help_level help, int argc, char *argv[]){ int i; char *cp; switch (help) { case help_short: sty_puts(sty, "agent <form> <agentid> - specify the agent id\n"); break; case help_long: sty_puts(sty, "\The 'agent <form> <agentid>' command specifies the agent id for\n\use with the usec code.\n"); break; case help_none: if (argc < 3) { if (batch_mode) sty_putc(sty, '|'); sty_puts(sty, "`agent' command needs arguments `form' and `agent id'\n"); } else { switch(*argv[1]) { case 'x': if (STRLEN(argv[2]) != 24) sty_puts(sty, "`agent' command requires `agent id' to be 24 octets long\n"); else for(i = 0, cp = argv[2]; i < 12; i++, cp += 2) sscanf(cp, "%02x", &usec_agentid[i]); break; case 'a': if (STRLEN(argv[2]) != 12) sty_puts(sty, "`agent' command requires `agent id' to be 12 octets long\n"); else MEMCPY(usec_agentid, argv[2], 12); break; default: sty_puts(sty, "`agent' command requires `from' to be `x' or `a'\n"); } } } return (1);}boolean_t do_context(struct sty *sty, enum help_level help, int argc, char *argv[]){ switch (help) { case help_short: sty_puts(sty, "context <context> - specify the context string to use\n"); break; case help_long: sty_puts(sty, "\The 'context <context>' command specifies the context string\n\for use with the usec code\n"); break; case help_none: if (argc < 2) { if (batch_mode) sty_putc(sty, '|'); sty_puts(sty, "`usec_context' command needs `context' as argument\n"); } else usec_context = etc_strdup(argv[1]); } return (1);}#endif /* #if INSTALL_ENVOY_SNMP_VERSION_USEC */#if defined(RE_COMP)boolean_t do_vars(struct sty *sty, enum help_level help, int argc, char *argv[]){ char *s; struct nametree *nt; int i; switch (help) { case help_short: sty_puts(sty, "\vars <regular-expression> - list matching MIB variable names\n"); break; case help_long: sty_puts(sty, "\The 'vars <regular-expression>' command compares all known MIB\n\variable names against the regular expression given as an argument,\n\and displays the matches.\n"); break; case help_none: if (argc != 2) { sty_puts(sty, "usage: vars regular-expression\n"); return (1); } s = re_comp(argv[1]); if (s) { sty_printf(sty, "invalid regular expression '%s': %s\n", argv[1], s); return (1); } /* do a very quick scan of the tree */ for (i = 0; i < mibt_entries; i++) if (re_exec(mibt[i].name) == 1) { OIDC_T buffer[40]; int components; char *type; components = string2oid(mibt[i].name, buffer, 40); switch (mibt[i].type) { case 0: type = "node"; break; case VT_NUMBER: type = "NUMBER"; break; case VT_BITSTRING: type = "BITSTRING"; break; case VT_STRING: type = "STRING"; break; case VT_OBJECT: type = "OID"; break; case VT_IPADDRESS: type = "IPADDRESS"; break; case VT_COUNTER: type = "COUNTER"; break; case VT_GAUGE: type = "GAUGE"; break; case VT_TIMETICKS: type = "TIME"; break; case VT_NSAPADDRESS: type = "NSAPADRESS"; break; case VT_COUNTER64: type = "COUNTER64"; break; case VT_UINTEGER32: type = "UINTEGER32"; break; default: type = "UNKNOWN-TYPE"; break; } sty_printf(sty, "%-25s %-10s\n", mibt[i].name, type); } } return (1);}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -