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

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