From 88ef7e164c17e8d3616ab5230bcd9246279631e4 Mon Sep 17 00:00:00 2001 From: zhanghongyu Date: Wed, 1 Mar 2023 15:59:30 +0800 Subject: [PATCH] getifaddrs: set sin6_scope_id when IPv6 enable ifindex is also returned when obtain NIC information through getifaddrs. Signed-off-by: zhanghongyu --- libs/libc/net/lib_getifaddrs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/libc/net/lib_getifaddrs.c b/libs/libc/net/lib_getifaddrs.c index ced90587fc..49f6f2ec40 100644 --- a/libs/libc/net/lib_getifaddrs.c +++ b/libs/libc/net/lib_getifaddrs.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -233,6 +234,7 @@ int getifaddrs(FAR struct ifaddrs **addrs) myaddrs->addrs.ifa_addr = (FAR struct sockaddr *)&myaddrs->addr; memcpy(&myaddrs->addr, &req.lifr_addr, sizeof(req.lifr_addr)); + ((struct sockaddr_in6 *)&myaddrs->addr)->sin6_scope_id = i; if (ioctl(sockfd, SIOCGLIFNETMASK, (unsigned long)&req) >= 0) {