From f1fbeca8af5a3dea7bf59704e5500054d4938098 Mon Sep 17 00:00:00 2001 From: Hugues Morisset Date: Sun, 11 May 2025 19:47:15 +0200 Subject: [PATCH] Display IP6 addr infos in getifaddrs viz tool --- tool/viz/getifaddrs.c | 74 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/tool/viz/getifaddrs.c b/tool/viz/getifaddrs.c index 67e3a4e4b..142e8005e 100644 --- a/tool/viz/getifaddrs.c +++ b/tool/viz/getifaddrs.c @@ -81,6 +81,80 @@ int main(int argc, char *argv[]) { tinyprint(1, "dstaddr: ", buf, "\n", NULL); } + if (ifa->ifa_addr->sa_family == AF_INET6) { + int scope = ((int *)ifa->ifa_data)[0]; + int aflags = ((int *)ifa->ifa_data)[1]; + // #define IPV6_ADDR_LOOPBACK 0x0010U + // #define IPV6_ADDR_LINKLOCAL 0x0020U + // #define IPV6_ADDR_SITELOCAL 0x0040U + + // #define IFA_F_TEMPORARY 0x01 + // #define IFA_F_NODAD 0x02 + // #define IFA_F_OPTIMISTIC 0x04 + // #define IFA_F_DADFAILED 0x08 + // #define IFA_F_HOMEADDRESS 0x10 + // #define IFA_F_DEPRECATED 0x20 + // #define IFA_F_TENTATIVE 0x40 + // #define IFA_F_PERMANENT 0x80 + // #define IFA_F_MANAGETEMPADDR 0x100 + // #define IFA_F_NOPREFIXROUTE 0x200 + // #define IFA_F_MCAUTOJOIN 0x400 + // #define IFA_F_STABLE_PRIVACY 0x800 + tinyprint(1, "scope:", NULL); + if (scope == 0x10) { + tinyprint(1, " loopback", NULL); + } + if (scope == 0x20) { + tinyprint(1, " linklocal", NULL); + } + if (scope == 0x40) { + tinyprint(1, " sitelocal", NULL); + } + if (scope == 0x00) { + tinyprint(1, " global", NULL); + } + tinyprint(1, "\n", NULL); + + tinyprint(1, "addr flags:", NULL); + if (aflags & 0x01) { + tinyprint(1, " temporary", NULL); + } + if (aflags & 0x02) { + tinyprint(1, " nodad", NULL); + } + if (aflags & 0x04) { + tinyprint(1, " optimistic", NULL); + } + if (aflags & 0x08) { + tinyprint(1, " dadfailed", NULL); + } + if (aflags & 0x10) { + tinyprint(1, " homeaddress", NULL); + } + if (aflags & 0x20) { + tinyprint(1, " deprecated", NULL); + } + if (aflags & 0x40) { + tinyprint(1, " tentative", NULL); + } + if (aflags & 0x80) { + tinyprint(1, " permanent", NULL); + } + if (aflags & 0x100) { + tinyprint(1, " managetempaddr", NULL); + } + if (aflags & 0x200) { + tinyprint(1, " noprefixroute", NULL); + } + if (aflags & 0x400) { + tinyprint(1, " mcautojoin", NULL); + } + if (aflags & 0x800) { + tinyprint(1, " stable_privacy", NULL); + } + tinyprint(1, "\n", NULL); + } + tinyprint(1, "flags:", NULL); if (ifa->ifa_flags & IFF_UP) { tinyprint(1, " IFF_UP", NULL);