]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
IPv6 MADDR LOG: Wrap IPv6 addresses in square brackets and print port when the port...
authorMarco Baffo <marco@mandelbit.com>
Fri, 17 Jan 2025 11:04:22 +0000 (12:04 +0100)
committerGert Doering <gert@greenie.muc.de>
Fri, 17 Jan 2025 11:17:52 +0000 (12:17 +0100)
  Updated the mroute_addr_print_ex() function to wrap IPv6 addresses in square
  brackets and printing the port when the port is specified, e.g., [2001:db8::1]:8080 .
  When the port is not specified the IPv6 address formatting remain the same, e.g., 2001:db8::1 .

Change-Id: Ia58cff107d14e29e51df0a988e8337cbb70ebfbb
Signed-off-by: Marco Baffo <marco@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250117110422.921-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30480.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/mroute.c

index f4539dcf518d5251960e03ae911099998752daf4..80e18b7cecb168a2bd25a0af9444b46b00bc46fc 100644 (file)
@@ -430,18 +430,19 @@ mroute_addr_print_ex(const struct mroute_addr *ma,
                 {
                     buf_printf(&out, "%s", print_in_addr_t(maddr.v4mappedv6.addr,
                                                            IA_NET_ORDER, gc));
-                    /* we only print port numbers for v4mapped v6 as of
-                     * today, because "v6addr:port" is too ambiguous
-                     */
-                    if (maddr.type & MR_WITH_PORT)
-                    {
-                        buf_printf(&out, ":%d", ntohs(maddr.v6.port));
-                    }
+                }
+                else if (maddr.type & MR_WITH_PORT)
+                {
+                    buf_printf(&out, "[%s]", print_in6_addr(maddr.v6.addr, 0, gc));
                 }
                 else
                 {
                     buf_printf(&out, "%s", print_in6_addr(maddr.v6.addr, 0, gc));
                 }
+                if (maddr.type & MR_WITH_PORT)
+                {
+                    buf_printf(&out, ":%d", ntohs(maddr.v6.port));
+                }
                 if (maddr.type & MR_WITH_NETBITS)
                 {
                     buf_printf(&out, "/%d", maddr.netbits);