netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ss: Enclose IPv6 address in brackets
@ 2017-07-29 12:29 Florian Lehner
  2017-07-29 15:26 ` Stephen Hemminger
                   ` (6 more replies)
  0 siblings, 7 replies; 19+ messages in thread
From: Florian Lehner @ 2017-07-29 12:29 UTC (permalink / raw)
  To: netdev

This patch adds support for RFC2732 IPv6 address format with brackets
for the tool ss. So output for ss changes from
2a00:1450:400a:804::200e:443 to [2a00:1450:400a:804::200e]:443 for IPv6
addresses with attached port number.

Signed-off-by: Lehner Florian <dev@der-flo.net>
---
 misc/ss.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/misc/ss.c b/misc/ss.c
index 12763c9..db39c93 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1059,7 +1059,11 @@ static void inet_addr_print(const inet_prefix *a,
int port, unsigned int ifindex
 			ap = format_host(AF_INET, 4, a->data);
 		}
 	} else {
-		ap = format_host(a->family, 16, a->data);
+		if (a->family == AF_INET6) {
+			sprintf(buf, "[%s]", format_host(a->family, 16, a->data));
+		} else {
+			ap = format_host(a->family, 16, a->data);
+		}
 		est_len = strlen(ap);
 		if (est_len <= addr_width)
 			est_len = addr_width;
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2017-08-04 22:13 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-29 12:29 [PATCH] ss: Enclose IPv6 address in brackets Florian Lehner
2017-07-29 15:26 ` Stephen Hemminger
2017-07-31 10:30 ` Phil Sutter
2017-07-31 16:27   ` Stephen Hemminger
2017-07-31 16:43     ` Phil Sutter
2017-07-31 18:17   ` Florian Lehner
2017-07-31 19:50 ` [PATCH v2] " Florian Lehner
2017-07-31 20:27   ` Phil Sutter
2017-08-01 10:05 ` [PATCH v3] " Florian Lehner
2017-08-01 14:11   ` Phil Sutter
2017-08-01 16:07     ` Florian Lehner
2017-08-01 11:11 ` [PATCH] " David Laight
2017-08-01 14:41   ` Stephen Hemminger
2017-08-01 16:54 ` [PATCH v4] " Florian Lehner
2017-08-03 22:54   ` Stephen Hemminger
2017-08-04 18:02 ` [PATCH v5] " Florian Lehner
2017-08-04 19:05   ` Stephen Hemminger
2017-08-04 20:46     ` Eric Dumazet
2017-08-04 22:13       ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).