From 2ff7c474b768a2c2e2d397a377be1f8fc28fad30 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 21 Oct 2019 13:55:36 +0200 Subject: [PATCH] shell_commands: gnrc_netif: print correct scope for IPv6 addr Previously `ifconfig` would only know link-local addresses (printed as 'local') and everything else would be 'global'. This is wrong for site-local and unique local addresses which were also denoted as global. So use the already existing helper functions to determine the correct type of IPv6 address when printing. --- sys/shell/commands/sc_gnrc_netif.c | 12 +++++++++--- tests/gnrc_ipv6_ext_frag/tests/01-run.py | 2 +- tests/nanocoap_cli/main.c | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/sys/shell/commands/sc_gnrc_netif.c b/sys/shell/commands/sc_gnrc_netif.c index 8a673bf577..02d0e87fbf 100644 --- a/sys/shell/commands/sc_gnrc_netif.c +++ b/sys/shell/commands/sc_gnrc_netif.c @@ -352,11 +352,17 @@ static void _netif_list_ipv6(ipv6_addr_t *addr, uint8_t flags) printf("inet6 addr: "); ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)); printf("%s scope: ", addr_str); - if ((ipv6_addr_is_link_local(addr))) { - printf("local"); + if (ipv6_addr_is_link_local(addr)) { + printf("link"); + } + else if (ipv6_addr_is_site_local(addr)) { + printf("site"); + } + else if (ipv6_addr_is_global(addr)) { + printf("global"); } else { - printf("global"); + printf("unknown"); } if (flags & GNRC_NETIF_IPV6_ADDRS_FLAGS_ANYCAST) { printf(" [anycast]"); diff --git a/tests/gnrc_ipv6_ext_frag/tests/01-run.py b/tests/gnrc_ipv6_ext_frag/tests/01-run.py index d26bc14403..246b9c5324 100755 --- a/tests/gnrc_ipv6_ext_frag/tests/01-run.py +++ b/tests/gnrc_ipv6_ext_frag/tests/01-run.py @@ -371,7 +371,7 @@ def testfunc(child): child.expect("HWaddr: (?P[A-Fa-f:0-9]+)") hwaddr_dst = child.match.group("hwaddr").lower() res = child.expect([ - r"(?Pfe80::[A-Fa-f:0-9]+)\s+scope:\s+local\s+VAL", + r"(?Pfe80::[A-Fa-f:0-9]+)\s+scope:\s+link\s+VAL", pexpect.TIMEOUT ]) count += 1 diff --git a/tests/nanocoap_cli/main.c b/tests/nanocoap_cli/main.c index 26f7d9f734..22084f0062 100644 --- a/tests/nanocoap_cli/main.c +++ b/tests/nanocoap_cli/main.c @@ -50,7 +50,7 @@ static void _print_addr(ipv6_addr_t *addr, uint8_t flags) ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)); printf("%s scope: ", addr_str); if ((ipv6_addr_is_link_local(addr))) { - printf("local"); + printf("link"); } else { printf("global");