version 1.1, 2019/08/09 06:17:59 |
version 1.2, 2019/08/11 14:41:20 |
|
|
const int usecommonopt; |
const int usecommonopt; |
const char *optstring; |
const char *optstring; |
const char *usage; |
const char *usage; |
int (*exec)(int, char *[]); |
int (*exec)(int, char *[]); |
}; |
}; |
|
|
struct snmp_app snmp_apps[] = { |
struct snmp_app snmp_apps[] = { |
{"get", 1, NULL, "agent oid ...", snmpc_get}, |
{ "get", 1, NULL, "agent oid ...", snmpc_get }, |
{"getnext", 1, NULL, "agent oid ...", snmpc_get}, |
{ "getnext", 1, NULL, "agent oid ...", snmpc_get }, |
{"walk", 1, "C:", "[-C cIipt] [-C E OID] agent [oid]", snmpc_walk}, |
{ "walk", 1, "C:", "[-C cIipt] [-C E OID] agent [oid]", snmpc_walk }, |
{"bulkget", 1, "C:", "[-C n<nonrep>r<maxrep>] agent oid ...", snmpc_get}, |
{ "bulkget", 1, "C:", "[-C n<nonrep>r<maxrep>] agent oid ...", snmpc_get }, |
{"bulkwalk", 1, "C:", "[-C cipn<nonrep>r<maxrep>] agent [oid]", snmpc_walk}, |
{ "bulkwalk", 1, "C:", "[-C cipn<nonrep>r<maxrep>] agent [oid]", snmpc_walk }, |
{ "trap", 1, NULL, "agent uptime oid [oid type value] ...", snmpc_trap}, |
{ "trap", 1, NULL, "agent uptime oid [oid type value] ...", snmpc_trap }, |
{"mibtree", 0, "O:", "[-O fnS]", snmpc_mibtree} |
{ "mibtree", 0, "O:", "[-O fnS]", snmpc_mibtree } |
}; |
}; |
struct snmp_app *snmp_app = NULL; |
struct snmp_app *snmp_app = NULL; |
|
|
|
|
|
|
if (pledge("stdio inet dns", NULL) == -1) |
if (pledge("stdio inet dns", NULL) == -1) |
err(1, "pledge"); |
err(1, "pledge"); |
|
|
if (argc <= 1) |
if (argc <= 1) |
usage(); |
usage(); |
|
|
|
|
smi_print_hint = 0; |
smi_print_hint = 0; |
break; |
break; |
case 'v': |
case 'v': |
print_varbind_only = 1; |
print_varbind_only = 1; |
break; |
break; |
case 'x': |
case 'x': |
output_string = smi_os_hex; |
output_string = smi_os_hex; |
|
|
snmpc_printerror((enum snmp_error) errorstatus, oidstr); |
snmpc_printerror((enum snmp_error) errorstatus, oidstr); |
} |
} |
|
|
for (;varbind != NULL; varbind = varbind->be_next) { |
for (; varbind != NULL; varbind = varbind->be_next) { |
(void) ber_scanf_elements(varbind, "{oe}", &noid, |
(void) ber_scanf_elements(varbind, "{oe}", &noid, |
&value); |
&value); |
if (value->be_class == BER_CLASS_CONTEXT && |
if (value->be_class == BER_CLASS_CONTEXT && |
|
|
printf("%s %s\n", oids, value); |
printf("%s %s\n", oids, value); |
} |
} |
free(value); |
free(value); |
|
|
return 1; |
return 1; |
} |
} |
|
|
__dead void |
__dead void |
snmpc_printerror(enum snmp_error error, char *oid) |
snmpc_printerror(enum snmp_error error, char *oid) |
{ |
{ |
switch (error) |
switch (error) { |
{ |
|
case SNMP_ERROR_NONE: |
case SNMP_ERROR_NONE: |
errx(1, "No error, how did I get here?"); |
errx(1, "No error, how did I get here?"); |
case SNMP_ERROR_TOOBIG: |
case SNMP_ERROR_TOOBIG: |