summaryrefslogtreecommitdiff
path: root/mcon/U/d_ipv6.U
blob: 94a0a8044482741406b4afb9858b506c1d8d52cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
?RCS: $Id: d_ipv6.U 167 2013-05-08 17:58:00Z rmanfredi $
?RCS:
?RCS: Copyright (c) 2006, Christian Biere
?RCS:
?RCS: You may redistribute only under the terms of the Artistic License,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
?RCS: that same Artistic License; a copy of which may be found at the root
?RCS: of the source tree for dist 4.0.
?RCS:
?MAKE:d_ipv6: Assert Trylink cat i_arpainet i_netdb i_syssock i_niin \
	i_winsock2 i_ws2tcpip
?MAKE:	-pick add $@ %<
?S:d_ipv6:
?S: This variable conditionally defines HAS_IPV6.
?S:.
?C:HAS_IPV6:
?C:  This symbol is defined when IPv6 can be used
?C:.
?H:#$d_ipv6 HAS_IPV6	/**/
?H:.
?LINT:set d_ipv6
: determine whether IPv6 can be used
case "$d_ipv6" in
"$undef") 
	echo "IPv6 support is disabled." >&4
;;
*)
	$cat >try.c <<EOC
#$i_syssock I_SYS_SOCKET
#$i_winsock2 I_WINSOCK2
#$i_ws2tcpip I_WS2TCPIP
#$i_niin I_NETINET_IN
#$i_arpainet I_ARPA_INET
#$i_netdb I_NETDB
#include <sys/types.h>
#ifdef I_SYS_SOCKET
#include <sys/socket.h>
#endif
#ifdef I_NETINET_IN
#include <netinet/in.h>
#endif
#ifdef I_ARPA_INET
#include <arpa/inet.h>
#endif
#ifdef I_NETDB
#include <netdb.h>
#endif
#ifdef I_WINSOCK2
#include <Winsock2.h>
#endif
#ifdef I_WS2TCPIP
#include <Ws2tcpip.h>
#endif
#include "static_assert.h"

int main(void)
{
	struct sockaddr_storage ss;
	struct sockaddr_in6 sin6;
	static struct in6_addr in6;

	ss.ss_family = PF_INET6;

	sin6.sin6_family = AF_INET6;
	sin6.sin6_port = 6346;
	sin6.sin6_flowinfo = 23UL;
	sin6.sin6_scope_id = 42UL;
	sin6.sin6_addr = in6;
	sin6.sin6_addr.s6_addr[0] = in6.s6_addr[0];

	STATIC_ASSERT(AF_INET6 == PF_INET6);
	STATIC_ASSERT(sizeof in6 == sizeof sin6.sin6_addr);
	STATIC_ASSERT(16 == sizeof sin6.sin6_addr.s6_addr);
	STATIC_ASSERT(2 == sizeof sin6.sin6_port);
	STATIC_ASSERT(4 == sizeof sin6.sin6_flowinfo);
	STATIC_ASSERT(4 == sizeof sin6.sin6_scope_id);

	(void) sin6;
	(void) in6;

	return 0;
}
EOC

	cyn="whether IPv6 support is available"
	set d_ipv6
	eval $trylink
	;;
esac