Blame SOURCES/net-snmp-5.7.2-clientaddr-port.patch

8a419f
833013 - The port number specified with clientaddr is not used for trap udp socket
8a419f
8a419f
commit 521b4e28b4c794a9d6d929858478d13875246ce3
8a419f
Author: Ivosh <ivosh@users.sourceforge.net>
8a419f
Date:   Mon Jul 30 10:53:22 2012 -0700
8a419f
8a419f
    CHANGES: libnetsnmp: PATCH 3404876: from hardaker: ability to specify local-bound port in addition to address
8a419f
    
8a419f
    Signed-off-by: Wes Hardaker <hardaker@users.sourceforge.net>
8a419f
8a419f
diff -up net-snmp-5.7.2/include/net-snmp/library/default_store.h.port net-snmp-5.7.2/include/net-snmp/library/default_store.h
8a419f
--- net-snmp-5.7.2/include/net-snmp/library/default_store.h.port	2012-10-10 00:28:58.000000000 +0200
8a419f
+++ net-snmp-5.7.2/include/net-snmp/library/default_store.h	2012-11-13 10:51:34.528804796 +0100
8a419f
@@ -94,6 +94,7 @@ extern          "C" {
8a419f
 #define NETSNMP_DS_LIB_TSM_USE_PREFIX      39 /* TSM's simple security name mapping */
8a419f
 #define NETSNMP_DS_LIB_DONT_LOAD_HOST_FILES 40 /* don't read host.conf files */
8a419f
 #define NETSNMP_DS_LIB_DNSSEC_WARN_ONLY     41 /* tread DNSSEC errors as warnings */
8a419f
+#define NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT 42 /* NETSNMP_DS_LIB_CLIENT_ADDR includes address and also port */
8a419f
 #define NETSNMP_DS_LIB_MAX_BOOL_ID          48 /* match NETSNMP_DS_MAX_SUBIDS */
8a419f
 
8a419f
     /*
8a419f
diff -up net-snmp-5.7.2/perl/default_store/default_store.pm.port net-snmp-5.7.2/perl/default_store/default_store.pm
8a419f
--- net-snmp-5.7.2/perl/default_store/default_store.pm.port	2012-10-10 00:28:58.000000000 +0200
8a419f
+++ net-snmp-5.7.2/perl/default_store/default_store.pm	2012-11-13 10:51:34.679804190 +0100
8a419f
@@ -63,6 +63,7 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK
8a419f
 				   NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD
8a419f
 				   NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE
8a419f
 				   NETSNMP_DS_LIB_APPEND_LOGFILES
8a419f
+                                   NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT
8a419f
 				   NETSNMP_DS_LIB_MIB_WARNINGS
8a419f
 				   NETSNMP_DS_LIB_SECLEVEL
8a419f
 				   NETSNMP_DS_LIB_SNMPVERSION
8a419f
@@ -161,6 +162,7 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK
8a419f
 				   NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD
8a419f
 				   NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE
8a419f
 				   NETSNMP_DS_LIB_APPEND_LOGFILES
8a419f
+                                   NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT
8a419f
 				   NETSNMP_DS_LIB_MIB_WARNINGS
8a419f
 				   NETSNMP_DS_LIB_SECLEVEL
8a419f
 				   NETSNMP_DS_LIB_SNMPVERSION
8a419f
@@ -299,6 +301,7 @@ None by default.
8a419f
 				   NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD
8a419f
 				   NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE
8a419f
 				   NETSNMP_DS_LIB_APPEND_LOGFILES
8a419f
+                                   NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT
8a419f
 				   NETSNMP_DS_LIB_MIB_WARNINGS
8a419f
 				   NETSNMP_DS_LIB_SECLEVEL
8a419f
 				   NETSNMP_DS_LIB_SNMPVERSION
8a419f
diff -up net-snmp-5.7.2/perl/default_store/default_store.xs.port net-snmp-5.7.2/perl/default_store/default_store.xs
8a419f
--- net-snmp-5.7.2/perl/default_store/default_store.xs.port	2012-10-10 00:28:58.000000000 +0200
8a419f
+++ net-snmp-5.7.2/perl/default_store/default_store.xs	2012-11-13 10:51:35.154802043 +0100
8a419f
@@ -1238,6 +1238,17 @@ __END__
8a419f
 #endif
8a419f
     }
8a419f
     break;
8a419f
+  case 36:
8a419f
+    if (memEQ(name, "NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT", 36)) {
8a419f
+#ifdef NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT
8a419f
+      *iv_return = NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT;
8a419f
+      return PERL_constant_ISIV;
8a419f
+#else
8a419f
+      return PERL_constant_NOTDEF;
8a419f
+#endif
8a419f
+    }
8a419f
+    break;
8a419f
+
8a419f
   case 38:
8a419f
     return constant_38 (aTHX_ name, iv_return);
8a419f
     break;
8a419f
@@ -1245,8 +1256,6 @@ __END__
8a419f
   return PERL_constant_NOTFOUND;
8a419f
 }
8a419f
 
8a419f
-
8a419f
-
8a419f
 /* autogenerated by "gen" from const-xs.inc */
8a419f
 
8a419f
 MODULE = NetSNMP::default_store         PACKAGE = NetSNMP::default_store
8a419f
diff -up net-snmp-5.7.2/perl/default_store/test.pl.port net-snmp-5.7.2/perl/default_store/test.pl
8a419f
--- net-snmp-5.7.2/perl/default_store/test.pl.port	2012-10-10 00:28:58.000000000 +0200
8a419f
+++ net-snmp-5.7.2/perl/default_store/test.pl	2012-11-13 10:51:35.185801918 +0100
8a419f
@@ -52,6 +52,7 @@ BEGIN { $| = 1;
8a419f
                   "NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD" => 35,
8a419f
                   "NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE" => 36,
8a419f
                   "NETSNMP_DS_LIB_APPEND_LOGFILES"         => 37,
8a419f
+                  "NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT"   => 42,
8a419f
                   "NETSNMP_DS_LIB_MIB_WARNINGS"            => 0,
8a419f
                   "NETSNMP_DS_LIB_SECLEVEL"                => 1,
8a419f
                   "NETSNMP_DS_LIB_SNMPVERSION"             => 2,
8a419f
diff -up net-snmp-5.7.2/snmplib/snmp_api.c.port net-snmp-5.7.2/snmplib/snmp_api.c
8a419f
--- net-snmp-5.7.2/snmplib/snmp_api.c.port	2012-10-10 00:28:58.000000000 +0200
8a419f
+++ net-snmp-5.7.2/snmplib/snmp_api.c	2012-11-13 10:51:35.188801906 +0100
8a419f
@@ -769,6 +769,8 @@ register_default_handlers(void)
8a419f
 	              NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_16BIT_IDS);
8a419f
     netsnmp_ds_register_premib(ASN_OCTET_STR, "snmp", "clientaddr",
8a419f
                       NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR);
8a419f
+    netsnmp_ds_register_premib(ASN_BOOLEAN, "snmp", "clientaddrUsesPort",
8a419f
+                      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT);
8a419f
     netsnmp_ds_register_config(ASN_INTEGER, "snmp", "serverSendBuf",
8a419f
 		      NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_SERVERSENDBUF);
8a419f
     netsnmp_ds_register_config(ASN_INTEGER, "snmp", "serverRecvBuf",
8a419f
diff -up net-snmp-5.7.2/snmplib/transports/snmpUDPIPv4BaseDomain.c.port net-snmp-5.7.2/snmplib/transports/snmpUDPIPv4BaseDomain.c
8a419f
--- net-snmp-5.7.2/snmplib/transports/snmpUDPIPv4BaseDomain.c.port	2012-11-13 10:51:32.781812675 +0100
8a419f
+++ net-snmp-5.7.2/snmplib/transports/snmpUDPIPv4BaseDomain.c	2012-11-13 10:51:35.190801898 +0100
71d9c0
@@ -183,8 +183,29 @@ netsnmp_udpipv4base_transport(struct soc
8a419f
                                               NETSNMP_DS_LIB_CLIENT_ADDR);
8a419f
         if (client_socket) {
8a419f
             struct sockaddr_in client_addr;
8a419f
-            netsnmp_sockaddr_in2(&client_addr, client_socket, NULL);
71d9c0
-            client_addr.sin_port = 0;
8a419f
+
8a419f
+            char *client_address = client_socket;
8a419f
+            int uses_port = netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID,
8a419f
+                                                   NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT);
8a419f
+            if ((uses_port == 1) && (strchr(client_socket, ':') == NULL)) {
8a419f
+                client_address = malloc(strlen(client_socket) + 3);
8a419f
+                if (client_address == NULL) {
8a419f
+                    netsnmp_socketbase_close(t);
8a419f
+                    netsnmp_transport_free(t);
8a419f
+                    return NULL;
8a419f
+                }                                      /* if NETSNMP_DS_LIB_CLIENT_ADDR */
8a419f
+                strcpy(client_address, client_socket); /* expects a port but there is none */
8a419f
+                strcat(client_address, ":0");          /* specified then provide ephemeral one */
8a419f
+            }
8a419f
+
8a419f
+            netsnmp_sockaddr_in2(&client_addr, client_address, NULL);
8a419f
+            if (uses_port == 0) {
8a419f
+                client_addr.sin_port = 0;
8a419f
+            }
8a419f
+            if (client_address != client_socket) {
8a419f
+                free(client_address);
8a419f
+            }
8a419f
+
8a419f
             DEBUGMSGTL(("netsnmp_udpbase", "binding socket: %d\n", t->sock));
8a419f
             rc = bind(t->sock, (struct sockaddr *)&client_addr,
71d9c0
                   sizeof(struct sockaddr));
8a419f
commit 9e00fff692081e36c9d883fab7b6bd8881c670fc
8a419f
Author: Jan Safranek <jsafranek@users.sourceforge.net>
8a419f
Date:   Tue Aug 7 12:27:18 2012 +0200
8a419f
                                   
8a419f
    Document new clientaddrUsesPort option.
8a419f
                                   
8a419f
diff --git a/man/snmp.conf.5.def b/man/snmp.conf.5.def
8a419f
index 9c7c55b..904635b 100644
8a419f
--- a/man/snmp.conf.5.def
8a419f
+++ b/man/snmp.conf.5.def
8a419f
@@ -127,6 +127,10 @@ This value is also used by \fBsnmpd\fR when generating notifications.
8a419f
 .\"  But not responses to an incoming request?
8a419f
 .\"  What about snmptrapd?
8a419f
 .\"
8a419f
+.IP "clientaddrUsesPort no"
8a419f
+specifies, if clientaddr option contains a port number. Set this option
8a419f
+to "yes", if clientaddr contains a port number and this port should
8a419f
+be used for sending outgoing SNMP requests.
8a419f
 .IP "clientRecvBuf INTEGER"
8a419f
 specifies the desired size of the buffer to be used when receiving
8a419f
 responses to SNMP requests.
8a419f