Skip to content

Commit 5cea4bc

Browse files
mrbffcron2
authored andcommitted
IPv6 MADDR LOG: Wrap IPv6 addresses in square brackets and print port when the port is specified
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>
1 parent 6d91eda commit 5cea4bc

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/openvpn/mroute.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -430,18 +430,19 @@ mroute_addr_print_ex(const struct mroute_addr *ma,
430430
{
431431
buf_printf(&out, "%s", print_in_addr_t(maddr.v4mappedv6.addr,
432432
IA_NET_ORDER, gc));
433-
/* we only print port numbers for v4mapped v6 as of
434-
* today, because "v6addr:port" is too ambiguous
435-
*/
436-
if (maddr.type & MR_WITH_PORT)
437-
{
438-
buf_printf(&out, ":%d", ntohs(maddr.v6.port));
439-
}
433+
}
434+
else if (maddr.type & MR_WITH_PORT)
435+
{
436+
buf_printf(&out, "[%s]", print_in6_addr(maddr.v6.addr, 0, gc));
440437
}
441438
else
442439
{
443440
buf_printf(&out, "%s", print_in6_addr(maddr.v6.addr, 0, gc));
444441
}
442+
if (maddr.type & MR_WITH_PORT)
443+
{
444+
buf_printf(&out, ":%d", ntohs(maddr.v6.port));
445+
}
445446
if (maddr.type & MR_WITH_NETBITS)
446447
{
447448
buf_printf(&out, "/%d", maddr.netbits);

0 commit comments

Comments
 (0)