1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/shell/gnrc_netif: print v6 addresses based on ipv6 module

To support lwIP better (dont require gnrc_ipv6)

Also don't require IPv6 for printing link type

With this sc_gnrc_netif can compile and work when using lwIP
(with l2util module added):

```
> ifconfig
Iface  ET1  HWaddr: 24:0A:C4:E6:0E:9C  Channel: 6  Link: up
          L2-PDU:1500  Source address length: 6
          Link type: wireless
          inet6 addr: fe80::260a:c4ff:fee6:e9c  scope: link
          inet6 addr: 2001:db8::260a:c4ff:fee6:e9c  scope: global

Iface  ET0  HWaddr: 24:0A:C4:E6:0E:9F  Link: up
          L2-PDU:1500  Source address length: 6
          Link type: wired
          inet6 addr: fe80::260a:c4ff:fee6:e9f  scope: link
          inet6 addr: 2001:db8::260a:c4ff:fee6:e9f  scope: global

>
```

Still works in gnrc_networking example:

```
> ifconfig
Iface  8  HWaddr: 24:0A:C4:E6:0E:9F  Link: up
          L2-PDU:1500  MTU:1500  HL:64  RTR
          RTR_ADV
          Source address length: 6
          Link type: wired
          inet6 addr: fe80::260a:c4ff:fee6:e9f  scope: link  VAL
          inet6 group: ff02::2
          inet6 group: ff02::1
          inet6 group: ff02::1:ffe6:e9f
          inet6 group: ff02::1a
```
This commit is contained in:
Erik Ekman 2021-10-11 22:44:05 +02:00
parent 7bc783e7af
commit 28b8536063

View File

@ -580,7 +580,7 @@ static unsigned _netif_list_flag(netif_t *iface, netopt_t opt, char *str,
return line_thresh;
}
#ifdef MODULE_GNRC_IPV6
#ifdef MODULE_IPV6
static void _netif_list_ipv6(ipv6_addr_t *addr, uint8_t flags)
{
char addr_str[IPV6_ADDR_MAX_STR_LEN];
@ -600,6 +600,7 @@ static void _netif_list_ipv6(ipv6_addr_t *addr, uint8_t flags)
else {
printf("unknown");
}
#if MODULE_GNRC_IPV6
if (flags & GNRC_NETIF_IPV6_ADDRS_FLAGS_ANYCAST) {
printf(" [anycast]");
}
@ -620,6 +621,7 @@ static void _netif_list_ipv6(ipv6_addr_t *addr, uint8_t flags)
break;
}
}
#endif
_newline(0U, _LINE_THRESHOLD);
}
@ -636,7 +638,7 @@ static void _netif_list_groups(ipv6_addr_t *addr)
static void _netif_list(netif_t *iface)
{
#ifdef MODULE_GNRC_IPV6
#ifdef MODULE_IPV6
ipv6_addr_t ipv6_addrs[CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF];
ipv6_addr_t ipv6_groups[GNRC_NETIF_IPV6_GROUPS_NUMOF];
#endif
@ -892,11 +894,11 @@ static void _netif_list(netif_t *iface)
line_thresh++;
}
line_thresh = _newline(0U, line_thresh);
#ifdef MODULE_GNRC_IPV6
printf("Link type: %s",
(netif_get_opt(iface, NETOPT_IS_WIRED, 0, &u16, sizeof(u16)) > 0) ?
"wired" : "wireless");
_newline(0U, ++line_thresh);
#ifdef MODULE_IPV6
res = netif_get_opt(iface, NETOPT_IPV6_ADDR, 0, ipv6_addrs,
sizeof(ipv6_addrs));
if (res >= 0) {