Is this a bug in inet_pton with IPv6?

When trying to resolve the numerical IP address of Facebook as a test 2620:0:1cfe:face:b00c::3:, if I leave the trailing one 0with the address, inet_pton()barfs. If I return it, everything will work.

Running ubuntu 9.10:

rc = inet_pton(AF_INET6, "2620:0:1cfe:face:b00c::3:0", &ip); -> OK
rc = inet_pton(AF_INET6, "2620:0:1cfe:face:b00c::3:", &ip); -> returns -2

ping6 -n www.v6.facebook.com returns an IP address without a trailing 0.

+3
source share
1 answer

It seems that ping, it has great wisdom, adds a colon after the IP address, for example:

PING maclawran.ca (173.230.128.18) 56(84) bytes of data.
64 bytes from ns.maclawran.ca (173.230.128.18): icmp_seq=1 ttl=51 time=50.3 ms

Of course, if you ping an IPv6 address, it already has many colons:

PING 2620:0:1cfe:face:b00c::3(2620:0:1cfe:face:b00c::3) 56 data bytes
64 bytes from 2620:0:1cfe:face:b00c::3: icmp_seq=1 ttl=52 time=9.44 ms
======================================^ << THANKS PING
+2
source

Source: https://habr.com/ru/post/1788346/


All Articles