From 4b760f4f3d3bb82ec054bc4479cc5829298ea3e5 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Wed, 8 Mar 2023 06:53:22 -0500 Subject: add ipv6 support in --net.print --- src/fnet/interface.c | 17 +++++++++++++++++ test/network/netstats.exp | 13 ++++++------- test/network/network.sh | 5 ++--- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/fnet/interface.c b/src/fnet/interface.c index ca7c744ed..50e1beaa0 100644 --- a/src/fnet/interface.c +++ b/src/fnet/interface.c @@ -213,6 +213,23 @@ void net_ifprint(int scan) { fmessage("%-17.17s%-19.19s%-17.17s%-17.17s%-6.6s\n", ifa->ifa_name, macstr, ipstr, maskstr, status); + // print ipv6 address + if (!scan) { + struct ifaddrs *ptr = ifa->ifa_next; + while (ptr) { + if (ptr->ifa_addr->sa_family == AF_INET6 && strcmp(ifa->ifa_name, ptr->ifa_name) == 0) { + struct sockaddr_in6 *s6 = (struct sockaddr_in6 *)ptr->ifa_addr; + struct in6_addr *in_addr = &s6->sin6_addr; + char buf[64]; + if(inet_ntop(ptr->ifa_addr->sa_family, in_addr, buf, sizeof(buf))) { + fmessage("%-35.35s %s\n", " ", buf); + break; + } + } + ptr = ptr->ifa_next; + } + } + // network scanning if (!scan) // scanning disabled continue; diff --git a/test/network/netstats.exp b/test/network/netstats.exp index a8b28bed8..0d1bc4c2c 100755 --- a/test/network/netstats.exp +++ b/test/network/netstats.exp @@ -20,12 +20,11 @@ expect { timeout {puts "TESTING ERROR 2\n";exit} "statistics only for sandboxes using a new network namespace" } -# not supported on github workflows - not a tty! -#expect { -# timeout {puts "TESTING ERROR 3\n";exit} -# "firejail --name=test --net=br0" -#} -#after 500 -#send -- "\r" +sleep 4 + +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "firejail --name=test --net=br0" +} after 500 puts "\nall done\n" diff --git a/test/network/network.sh b/test/network/network.sh index 5e320cc2f..dad1ed42d 100755 --- a/test/network/network.sh +++ b/test/network/network.sh @@ -42,9 +42,8 @@ echo "TESTING: ipv6 (ip6.exp)" echo "TESTING: ipv6 netfilter (ip6_netfilter.exp)" ./ip6_netfilter.exp -# not supported on github workflows - not a tty! -#echo "TESTING: netstats (netstats.exp)" -#./netstats.exp +echo "TESTING: netstats (netstats.exp)" +./netstats.exp echo "TESTING: firemon arp (firemon-arp.exp)" ./firemon-arp.exp -- cgit v1.2.3-54-g00ecf