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