1/* Test lookup of IPv4 mapped addresses in files database (bug 25457)
2
3 Copyright (C) 2023-2024 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If
18 not, see <https://www.gnu.org/licenses/>. */
19
20#include <stdio.h>
21#include <arpa/inet.h>
22#include <netdb.h>
23
24static int
25do_test (void)
26{
27 struct sockaddr_in6 s6 = { .sin6_family = AF_INET6 };
28 inet_pton (AF_INET6, "::ffff:192.168.0.1", &s6.sin6_addr);
29
30 char node[NI_MAXHOST];
31 int res = getnameinfo ((struct sockaddr *) &s6, sizeof (s6), node,
32 sizeof (node), NULL, 0, NI_NAMEREQD);
33 if (res)
34 printf (format: "%d %s\n", res, gai_strerror (res));
35 else
36 printf (format: "node=%s\n", node);
37
38 return res != 0;
39}
40
41#include <support/test-driver.c>
42

source code of glibc/nss/tst-nss-files-hosts-v4mapped.c