mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 11:26:12 +08:00
getifaddrs: set sin6_scope_id when IPv6 enable
ifindex is also returned when obtain NIC information through getifaddrs. Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ifaddrs.h>
|
#include <ifaddrs.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -233,6 +234,7 @@ int getifaddrs(FAR struct ifaddrs **addrs)
|
|||||||
|
|
||||||
myaddrs->addrs.ifa_addr = (FAR struct sockaddr *)&myaddrs->addr;
|
myaddrs->addrs.ifa_addr = (FAR struct sockaddr *)&myaddrs->addr;
|
||||||
memcpy(&myaddrs->addr, &req.lifr_addr, sizeof(req.lifr_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)
|
if (ioctl(sockfd, SIOCGLIFNETMASK, (unsigned long)&req) >= 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user