This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 88ef7e164c getifaddrs: set sin6_scope_id when IPv6 enable
88ef7e164c is described below

commit 88ef7e164c17e8d3616ab5230bcd9246279631e4
Author: zhanghongyu <[email protected]>
AuthorDate: Wed Mar 1 15:59:30 2023 +0800

    getifaddrs: set sin6_scope_id when IPv6 enable
    
    ifindex is also returned when obtain NIC information through getifaddrs.
    
    Signed-off-by: zhanghongyu <[email protected]>
---
 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 <errno.h>
 #include <ifaddrs.h>
 #include <net/if.h>
+#include <netinet/in.h>
 #include <sys/ioctl.h>
 #include <string.h>
 #include <unistd.h>
@@ -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)
             {

Reply via email to