1#ifndef	_NETINET_IN_H
2#define	_NETINET_IN_H	1
3
4#include "glibc-bugs.h"
5#include <sys/socket.h>
6#include <sys/types.h>
7#include <linux/in.h>
8#include <linux/in6.h>
9#include <linux/ipv6.h>
10
11#define SOL_IP	0
12
13#define INET_ADDRSTRLEN 16
14#define INET6_ADDRSTRLEN 46
15
16#ifndef htonl
17#define ___htonl(x) __cpu_to_be32(x)
18#define ___htons(x) __cpu_to_be16(x)
19#define ___ntohl(x) __be32_to_cpu(x)
20#define ___ntohs(x) __be16_to_cpu(x)
21
22#define htonl(x) ___htonl(x)
23#define ntohl(x) ___ntohl(x)
24#define htons(x) ___htons(x)
25#define ntohs(x) ___ntohs(x)
26#endif
27
28#define IN6_IS_ADDR_UNSPECIFIED(a) \
29	(((__const uint32_t *) (a))[0] == 0				      \
30	 && ((__const uint32_t *) (a))[1] == 0				      \
31	 && ((__const uint32_t *) (a))[2] == 0				      \
32	 && ((__const uint32_t *) (a))[3] == 0)
33
34#define IN6_IS_ADDR_LOOPBACK(a) \
35	(((__const uint32_t *) (a))[0] == 0				      \
36	 && ((__const uint32_t *) (a))[1] == 0				      \
37	 && ((__const uint32_t *) (a))[2] == 0				      \
38	 && ((__const uint32_t *) (a))[3] == htonl (1))
39
40#define IN6_IS_ADDR_MULTICAST(a) (((__const uint8_t *) (a))[0] == 0xff)
41
42#define IN6_IS_ADDR_LINKLOCAL(a) \
43	((((__const uint32_t *) (a))[0] & htonl (0xffc00000))		      \
44	 == htonl (0xfe800000))
45
46#define IN6_IS_ADDR_SITELOCAL(a) \
47	((((__const uint32_t *) (a))[0] & htonl (0xffc00000))		      \
48	 == htonl (0xfec00000))
49
50#define IN6_IS_ADDR_V4MAPPED(a) \
51	((((__const uint32_t *) (a))[0] == 0)				      \
52	 && (((__const uint32_t *) (a))[1] == 0)			      \
53	 && (((__const uint32_t *) (a))[2] == htonl (0xffff)))
54
55#define IN6_IS_ADDR_V4COMPAT(a) \
56	((((__const uint32_t *) (a))[0] == 0)				      \
57	 && (((__const uint32_t *) (a))[1] == 0)			      \
58	 && (((__const uint32_t *) (a))[2] == 0)			      \
59	 && (ntohl (((__const uint32_t *) (a))[3]) > 1))
60
61#define IN6_ARE_ADDR_EQUAL(a,b) \
62	((((__const uint32_t *) (a))[0] == ((__const uint32_t *) (b))[0])     \
63	 && (((__const uint32_t *) (a))[1] == ((__const uint32_t *) (b))[1])  \
64	 && (((__const uint32_t *) (a))[2] == ((__const uint32_t *) (b))[2])  \
65	 && (((__const uint32_t *) (a))[3] == ((__const uint32_t *) (b))[3]))
66
67
68#endif	/* netinet/in.h */
69