• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *  * Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *  * Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in
12  *    the documentation and/or other materials provided with the
13  *    distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 #include <netinet/in.h>
30 
31 #include "header_checks.h"
32 
netinet_in_h()33 static void netinet_in_h() {
34   TYPE(in_port_t);
35   TYPE(in_addr_t);
36   TYPE(sa_family_t);
37   TYPE(uint8_t);
38   TYPE(uint32_t);
39 
40   TYPE(struct in_addr);
41   STRUCT_MEMBER(struct in_addr, in_addr_t, s_addr);
42 
43   TYPE(struct sockaddr_in);
44   STRUCT_MEMBER(struct sockaddr_in, sa_family_t, sin_family);
45   STRUCT_MEMBER(struct sockaddr_in, in_port_t, sin_port);
46   STRUCT_MEMBER(struct sockaddr_in, struct in_addr, sin_addr);
47 
48   TYPE(struct in6_addr);
49   STRUCT_MEMBER_ARRAY(struct in6_addr, uint8_t/*[]*/, s6_addr);
50 
51   TYPE(struct sockaddr_in6);
52   STRUCT_MEMBER(struct sockaddr_in6, sa_family_t, sin6_family);
53   STRUCT_MEMBER(struct sockaddr_in6, in_port_t, sin6_port);
54   STRUCT_MEMBER(struct sockaddr_in6, uint32_t, sin6_flowinfo);
55   STRUCT_MEMBER(struct sockaddr_in6, struct in6_addr, sin6_addr);
56   STRUCT_MEMBER(struct sockaddr_in6, uint32_t, sin6_scope_id);
57 
58   struct in6_addr any_global = in6addr_any;
59   struct in6_addr any_macro = IN6ADDR_ANY_INIT;
60   struct in6_addr loop_global = in6addr_loopback;
61   struct in6_addr loop_macro = IN6ADDR_LOOPBACK_INIT;
62 
63   TYPE(struct ipv6_mreq);
64   STRUCT_MEMBER(struct ipv6_mreq, struct in6_addr, ipv6mr_multiaddr);
65 #if defined(__BIONIC__) // Currently comes from uapi header.
66   STRUCT_MEMBER(struct ipv6_mreq, int, ipv6mr_interface);
67 #else
68   STRUCT_MEMBER(struct ipv6_mreq, unsigned, ipv6mr_interface);
69 #endif
70 
71   MACRO(IPPROTO_IP);
72   MACRO(IPPROTO_IPV6);
73   MACRO(IPPROTO_ICMP);
74   MACRO(IPPROTO_RAW);
75   MACRO(IPPROTO_TCP);
76   MACRO(IPPROTO_UDP);
77 
78   MACRO(INADDR_ANY);
79   MACRO(INADDR_BROADCAST);
80 
81   MACRO_VALUE(INET_ADDRSTRLEN, 16);
82 
83   FUNCTION(htonl, uint32_t (*f)(uint32_t));
84   FUNCTION(htons, uint16_t (*f)(uint16_t));
85   FUNCTION(ntohl, uint32_t (*f)(uint32_t));
86   FUNCTION(ntohs, uint16_t (*f)(uint16_t));
87 
88   MACRO_VALUE(INET6_ADDRSTRLEN, 46);
89 
90   MACRO(IPV6_JOIN_GROUP);
91   MACRO(IPV6_LEAVE_GROUP);
92   MACRO(IPV6_MULTICAST_HOPS);
93   MACRO(IPV6_MULTICAST_IF);
94   MACRO(IPV6_MULTICAST_LOOP);
95   MACRO(IPV6_UNICAST_HOPS);
96   MACRO(IPV6_V6ONLY);
97 
98 #if !defined(IN6_IS_ADDR_UNSPECIFIED)
99 #error IN6_IS_ADDR_UNSPECIFIED
100 #endif
101 #if !defined(IN6_IS_ADDR_LOOPBACK)
102 #error IN6_IS_ADDR_LOOPBACK
103 #endif
104 #if !defined(IN6_IS_ADDR_MULTICAST)
105 #error IN6_IS_ADDR_MULTICAST
106 #endif
107 #if !defined(IN6_IS_ADDR_LINKLOCAL)
108 #error IN6_IS_ADDR_LINKLOCAL
109 #endif
110 #if !defined(IN6_IS_ADDR_SITELOCAL)
111 #error IN6_IS_ADDR_SITELOCAL
112 #endif
113 #if !defined(IN6_IS_ADDR_V4MAPPED)
114 #error IN6_IS_ADDR_V4MAPPED
115 #endif
116 #if !defined(IN6_IS_ADDR_V4COMPAT)
117 #error IN6_IS_ADDR_V4COMPAT
118 #endif
119 #if !defined(IN6_IS_ADDR_MC_NODELOCAL)
120 #error IN6_IS_ADDR_MC_NODELOCAL
121 #endif
122 #if !defined(IN6_IS_ADDR_MC_LINKLOCAL)
123 #error IN6_IS_ADDR_MC_LINKLOCAL
124 #endif
125 #if !defined(IN6_IS_ADDR_MC_SITELOCAL)
126 #error IN6_IS_ADDR_MC_SITELOCAL
127 #endif
128 #if !defined(IN6_IS_ADDR_MC_ORGLOCAL)
129 #error IN6_IS_ADDR_MC_ORGLOCAL
130 #endif
131 #if !defined(IN6_IS_ADDR_MC_GLOBAL)
132 #error IN6_IS_ADDR_MC_GLOBAL
133 #endif
134 }
135