aboutsummaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-protocols/net-snmp/net-snmp/0001-BUG-a2584-Fix-snmptrap-to-use-clientaddr-from-snmp.c.patch
blob: b14b76128aaf765db5ce30ea59181051c31a39e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From a92628a163ebf1ea62220684736300461c003875 Mon Sep 17 00:00:00 2001
From: Niels Baggesen <nba@users.sourceforge.net>
Date: Mon, 26 Jan 2015 20:26:06 +0100
Subject: [PATCH] BUG#a2584: Fix snmptrap to use clientaddr from snmp.conf.
 Thanks to rizwan

Upstream-Status: backport

Signed-off-by: Li Zhou <li.zhou@windriver.com>
---
 snmplib/transports/snmpUDPIPv6Domain.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Index: net-snmp-5.7.3/snmplib/transports/snmpUDPIPv6Domain.c
===================================================================
--- net-snmp-5.7.3.orig/snmplib/transports/snmpUDPIPv6Domain.c
+++ net-snmp-5.7.3/snmplib/transports/snmpUDPIPv6Domain.c
@@ -286,6 +286,27 @@ netsnmp_udp6_transport(struct sockaddr_i
         return NULL;
 #endif /* NETSNMP_NO_LISTEN_SUPPORT */
     } else {
+        char           *client_socket = NULL;
+        /*
+         * This is a client session.  If we've been given a
+         * client address to send from, then bind to that.
+         * Otherwise the send will use "something sensible".
+         */
+
+        client_socket = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
+                                    NETSNMP_DS_LIB_CLIENT_ADDR);
+        if (client_socket) {
+            struct sockaddr_in6 client_addr;
+            netsnmp_sockaddr_in6_2(&client_addr, client_socket, NULL);
+            rc = bind(t->sock, (struct sockaddr *)&client_addr,
+                              sizeof(struct sockaddr_in6));
+            if ( rc != 0 ) {
+                DEBUGMSGTL(("netsnmp_udp6", "failed to bind for clientaddr: %d %s\n",
+                                 errno, strerror(errno)));
+                netsnmp_socketbase_close(t);
+                netsnmp_transport_free(t);
+            }
+        }
         /*
          * This is a client session.  Save the address in the
          * transport-specific data pointer for later use by netsnmp_udp6_send.