diff options
author | Martijn van Duren <martijn@cvs.openbsd.org> | 2020-01-17 09:52:45 +0000 |
---|---|---|
committer | Martijn van Duren <martijn@cvs.openbsd.org> | 2020-01-17 09:52:45 +0000 |
commit | eef3579a3d0824cdad9cf8138b31bb30a6f04906 (patch) | |
tree | c358f990feb554d76222d05fd74df8d85a78f15a /usr.bin | |
parent | 181e3c60a30276e04af8f3452f21bfdee95ef2df (diff) |
Add better support for exception contexts.
Now we can see proper nosuchinstance and endofmibtree messages.
OK jan@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/snmp/smi.c | 18 | ||||
-rw-r--r-- | usr.bin/snmp/snmp.h | 8 |
2 files changed, 21 insertions, 5 deletions
diff --git a/usr.bin/snmp/smi.c b/usr.bin/snmp/smi.c index 4cd8fa155cd..dc287353b89 100644 --- a/usr.bin/snmp/smi.c +++ b/usr.bin/snmp/smi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smi.c,v 1.6 2019/10/24 12:39:26 tb Exp $ */ +/* $OpenBSD: smi.c,v 1.7 2020/01/17 09:52:44 martijn Exp $ */ /* * Copyright (c) 2019 Martijn van Duren <martijn@openbsd.org> @@ -365,9 +365,19 @@ smi_print_element(struct ber_element *root, int print_hint, print_hint ? "IpAddress: " : "", inet_ntoa(*(struct in_addr *)buf)) == -1) goto fail; - } else if (root->be_class == BER_CLASS_CONTEXT && - root->be_type == BER_TYPE_EOC) { - str = strdup("No Such Object available on this agent at this OID"); + } else if (root->be_class == BER_CLASS_CONTEXT) { + if (root->be_type == SNMP_E_NOSUCHOBJECT) + str = strdup("No Such Object available on this " + "agent at this OID"); + else if (root->be_type == SNMP_E_NOSUCHINSTANCE) + str = strdup("No Such Instance currently " + "exists at this OID"); + else if (root->be_type == SNMP_E_ENDOFMIB) + str = strdup("No more variables left in this " + "MIB View (It is past the end of the MIB " + "tree)"); + else + str = strdup("Unknown status at this OID"); } else { for (i = 0; i < root->be_len; i++) { if (!isprint(buf[i])) { diff --git a/usr.bin/snmp/snmp.h b/usr.bin/snmp/snmp.h index 2dd2e0081e6..554ac592843 100644 --- a/usr.bin/snmp/snmp.h +++ b/usr.bin/snmp/snmp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: snmp.h,v 1.6 2019/10/03 11:02:26 martijn Exp $ */ +/* $OpenBSD: snmp.h,v 1.7 2020/01/17 09:52:44 martijn Exp $ */ /* * Copyright (c) 2019 Martijn van Duren <martijn@openbsd.org> @@ -108,6 +108,12 @@ enum snmp_security_model { SNMP_SEC_TSM = 4 }; +enum snmp_application_exception { + SNMP_E_NOSUCHOBJECT = 0, + SNMP_E_NOSUCHINSTANCE = 1, + SNMP_E_ENDOFMIB = 2 +}; + struct snmp_agent; struct snmp_sec { |