Currently we only support noSuchObject by overloading BER_TYPE_EOC.
This is wrong.

Diff below adds support for all 3 exception cases.

OK?

martijn@

Index: smi.c
===================================================================
RCS file: /cvs/src/usr.bin/snmp/smi.c,v
retrieving revision 1.6
diff -u -p -r1.6 smi.c
--- smi.c       24 Oct 2019 12:39:26 -0000      1.6
+++ smi.c       13 Jan 2020 13:48:18 -0000
@@ -365,9 +365,19 @@ smi_print_element(struct ber_element *ro
                            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])) {
Index: snmp.h
===================================================================
RCS file: /cvs/src/usr.bin/snmp/snmp.h,v
retrieving revision 1.6
diff -u -p -r1.6 snmp.h
--- snmp.h      3 Oct 2019 11:02:26 -0000       1.6
+++ snmp.h      13 Jan 2020 13:48:18 -0000
@@ -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 {

Reply via email to