1570af302Sopenharmony_ci// commit: 1cd417bdf10366d63cc875e285c6418709a58c17 2013-07-25
2570af302Sopenharmony_ci// inet_ntop should use ipv4 notation for v4mapped addresses
3570af302Sopenharmony_ci#include <string.h>
4570af302Sopenharmony_ci#include <arpa/inet.h>
5570af302Sopenharmony_ci#include "test.h"
6570af302Sopenharmony_ci
7570af302Sopenharmony_ciint main(void)
8570af302Sopenharmony_ci{
9570af302Sopenharmony_ci	char *expect = "::ffff:192.168.0.1";
10570af302Sopenharmony_ci	char buf[100];
11570af302Sopenharmony_ci	char addr[16];
12570af302Sopenharmony_ci	if (inet_pton(AF_INET6, expect, addr) == 1) {
13570af302Sopenharmony_ci		if (!inet_ntop(AF_INET6, addr, buf, sizeof buf))
14570af302Sopenharmony_ci			t_error("inet_ntop failed\n");
15570af302Sopenharmony_ci		else if (!strchr(buf, '.'))
16570af302Sopenharmony_ci			t_error("inet_ntop produced %s instead of %s\n", buf, expect);
17570af302Sopenharmony_ci	} else {
18570af302Sopenharmony_ci		t_error("inet_pton failed\n");
19570af302Sopenharmony_ci	}
20570af302Sopenharmony_ci	return t_status;
21570af302Sopenharmony_ci}
22