inet_pton tests, fix regression test case
[libc-test.git] / src / regression / inet_ntop-v4mapped.c
blobcd9023c79636f05f78ea63c3465893a88d9bf0c9
1 // commit: 1cd417bdf10366d63cc875e285c6418709a58c17 2013-07-25
2 // inet_ntop should use ipv4 notation for v4mapped addresses
3 #include <string.h>
4 #include <arpa/inet.h>
5 #include "test.h"
7 int main(void)
9 char *expect = "::ffff:192.168.0.1";
10 char buf[100];
11 char addr[16];
12 if (inet_pton(AF_INET6, expect, addr) == 1) {
13 if (!inet_ntop(AF_INET6, addr, buf, sizeof buf))
14 t_error("inet_ntop failed\n");
15 else if (!strchr(buf, '.'))
16 t_error("inet_ntop produced %s instead of %s\n", buf, expect);
17 } else {
18 t_error("inet_pton failed\n");
20 return t_status;