Date: Wed, 9 Dec 2015 19:51:47 +0300 From: "Andrey V. Elsukov" <bu7cher@yandex.ru> To: Ken Moore <ken@pcbsd.org>, Hiroki Sato <hrs@FreeBSD.org> Cc: freebsd-net@freebsd.org Subject: Re: IPv6 Address as text (C) Message-ID: <56685C23.600@yandex.ru> In-Reply-To: <566847F3.7060900@pcbsd.org> References: <5668369F.9020309@pcbsd.org> <20151209.233515.1592617248580059512.hrs@allbsd.org> <566847F3.7060900@pcbsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --1bsEEwJBHPTohNj7ncfRsJ17QrMhGb6gw Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 09.12.15 18:25, Ken Moore wrote: Simple example: #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> #include <err.h> #include <ifaddrs.h> #include <netdb.h> #include <stdio.h> #include <string.h> int main(int argc, char **argv) { char buf[INET6_ADDRSTRLEN]; struct ifaddrs *ifap, *ifa; int error; if (getifaddrs(&ifap) !=3D 0) err(1, "getifaddrs"); for (ifa =3D ifap; ifa; ifa =3D ifa->ifa_next) if (ifa->ifa_addr->sa_family =3D=3D AF_INET6) { error =3D getnameinfo(ifa->ifa_addr, ifa->ifa_addr->sa_len, buf, sizeof(buf), NULL, 0, NI_NUMERICHOST); if (error !=3D 0) err(1, "%s", gai_strerror(error)); printf("%s\n", buf); } freeifaddrs(ifap); return (0); } --=20 WBR, Andrey V. Elsukov --1bsEEwJBHPTohNj7ncfRsJ17QrMhGb6gw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWaFwmAAoJEAHF6gQQyKF6+x0IALRhJeeoUOAjElj5vctkSv7H q10R82pc2w7c+5u+ZwsKkofgkpQIxDdTI6XmTMFDG4YJzVfSfBKpzFnEwghc3r5f sn78fEc0hk5mlBImAMiHVb3Uo+xeWkKLJxMIE1jvKF7gfI5SxVM6mMmoL7YLIy5S bqdU3Rk4jFIz6PjPA6M3gid+8qyvbc9GfFxsrzgCmAvrZPFeg7X/UHmC7BxJDSQl pRZDZFYPPeAN4ppW/lL6FZTWN6TAXMm85Anqp/iCIJXQXKAKDFCJAw8kSdKUptMZ HS6lAXm/FITXRAzVVBGP7/UoasV/E+t/7y4yCI/4kKH1imRZHGPSOANBFJevBT4= =uVxP -----END PGP SIGNATURE----- --1bsEEwJBHPTohNj7ncfRsJ17QrMhGb6gw--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?56685C23.600>