[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [task #15393] Support scoped literal IPv6 addresses in geta
From: |
Ashley Duncan |
Subject: |
[lwip-devel] [task #15393] Support scoped literal IPv6 addresses in getaddrinfo |
Date: |
Thu, 19 Sep 2019 18:49:45 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0 |
Follow-up Comment #4, task #15393 (project lwip):
Yes, correct. getaddrinfo works as expected under linux. For example:
#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
int main(int argc, char **argv)
{
struct addrinfo hints = {0};
struct addrinfo * res = NULL;
if (getaddrinfo("fe80::8831:ba34:ba2e:667f%wlp5s0", "1234", &hints, &res)
== 0)
{
struct addrinfo * info = res;
while (info)
{
if (info->ai_family == AF_INET6)
{
struct sockaddr_in6 * pI6 = (struct sockaddr_in6
*)info->ai_addr;
if (IN6_IS_ADDR_LINKLOCAL(&(pI6->sin6_addr)))
{
char buf[64];
printf("IP6 Addr: %s%%%d\n",
inet_ntop(AF_INET6, &pI6->sin6_addr, buf,
sizeof(buf)), pI6->sin6_scope_id);
}
}
info = info->ai_next;
}
}
freeaddrinfo(res);
return 0;
}
Gives the following result for "fe80::8831:ba34:ba2e:667f%wlp5s0" :
IP6 Addr: fe80::8831:ba34:ba2e:667f%3
IP6 Addr: fe80::8831:ba34:ba2e:667f%3
IP6 Addr: fe80::8831:ba34:ba2e:667f%3
Or for "fe80::a8e0:d579:be00:72ab%enp4s0" :
IP6 Addr: fe80::a8e0:d579:be00:72ab%2
IP6 Addr: fe80::a8e0:d579:be00:72ab%2
IP6 Addr: fe80::a8e0:d579:be00:72ab%2
_______________________________________________________
Reply to this item at:
<https://savannah.nongnu.org/task/?15393>
_______________________________________________
Message sent via Savannah
https://savannah.nongnu.org/