When I provide IPv4 and IPv6 address to constructor, e.g. “0.0.0.0” and “::”, I can only receive traps via IPv4 and not via IPv6. According to the constructor code, this seems to be the expected behaviour, because it copies the provided IPv4 address (addr_v4
) to Snmp::listen_address
.
I my opinion traps should be received via IPv4 and IPv6 if both addresses are provided to the constructor.
Is this a bug or a design decision? If not the following small patch would fix the issue:
From a8ce6ae8cf6e2166b46bbeaabda524e342105dfa Mon Sep 17 00:00:00 2001
From: amartin755 <netnag@mailbox.org>
Date: Tue, 2 Jan 2024 20:32:54 +0100
Subject: [PATCH] receive traps via IPv4 and IPv6 if both are enabled
---
src/uxsnmp.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/uxsnmp.cpp b/src/uxsnmp.cpp
index 4b4e520..24a7e50 100644
--- a/src/uxsnmp.cpp
+++ b/src/uxsnmp.cpp
@@ -686,9 +686,10 @@ Snmp::Snmp( int &status, const UdpAddress& addr_v4,
{
IpAddress *addresses[2];
- listen_address = addr_v4;
+ listen_address = addr_v6;
+ IpAddress address_v4((IpAddress)addr_v4);
IpAddress address_v6((IpAddress)addr_v6);
- addresses[0] = &listen_address;
+ addresses[0] = &address_v4;
addresses[1] = &address_v6;
init(status, addresses, addr_v4.get_port(), addr_v6.get_port());
--
2.43.0
Best regards
Andreas