In the process of doing interoperability tests with SNMP research for
the DTLS work we noticed a misbehaviour in our snmpinform application
(or snmptrap -Ci).

INFORMs, though delivered with a securityEngineID of the remote host,
should always be using a local contextEngineID.  The patch below fixes
this.

I'll apply this to all the trees, but it requires a CFV for 5.6.1.

[RUNTESTS -r inform and RUNTESTS -r trap still succeed]


diff --git a/net-snmp/apps/snmptrap.c b/net-snmp/apps/snmptrap.c
index a0b80ba..7c086db 100644
--- a/net-snmp/apps/snmptrap.c
+++ b/net-snmp/apps/snmptrap.c
@@ -161,6 +161,20 @@ main(int argc, char *argv[])
     session.callback = snmp_input;
     session.callback_magic = NULL;
 
+    /*
+     * setup the local engineID which may be for either or both of the
+     * contextEngineID and/or the securityEngineID.
+     */
+    setup_engineID(NULL, NULL);
+
+    /* if we don't have a contextEngineID set via command line
+       arguments, use our internal engineID as the context. */
+    if (session.contextEngineIDLen == 0 ||
+        session.contextEngineID == NULL) {
+        session.contextEngineID =
+            snmpv3_generate_engineID(&session.contextEngineIDLen);
+    }
+
     if (session.version == SNMP_VERSION_3 && !inform) {
         /*
          * for traps, we use ourselves as the authoritative engine
@@ -180,13 +194,6 @@ main(int argc, char *argv[])
          */
 
         /*
-         * setup the engineID based on IP addr.  Need a different
-         * algorthim here.  This will cause problems with agents on the
-         * same machine sending traps. 
-         */
-        setup_engineID(NULL, NULL);
-
-        /*
          * pick our own engineID 
          */
         if (session.securityEngineIDLen == 0 ||
@@ -194,11 +201,6 @@ main(int argc, char *argv[])
             session.securityEngineID =
                 snmpv3_generate_engineID(&session.securityEngineIDLen);
         }
-        if (session.contextEngineIDLen == 0 ||
-            session.contextEngineID == NULL) {
-            session.contextEngineID =
-                snmpv3_generate_engineID(&session.contextEngineIDLen);
-        }
 
         /*
          * set boots and time, which will cause problems if this


-- 
Wes Hardaker
Please mail all replies to [email protected]

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to