1<netinet/in.h>(P) POSIX Programmer's Manual <netinet/in.h>(P)
2
3
4
6 netinet/in.h - Internet address family
7
9 #include <netinet/in.h>
10
12 The <netinet/in.h> header shall define the following types:
13
14 in_port_t
15 Equivalent to the type uint16_t as defined in <inttypes.h> .
16
17 in_addr_t
18 Equivalent to the type uint32_t as defined in <inttypes.h> .
19
20
21 The sa_family_t type shall be defined as described in <sys/socket.h> .
22
23 The uint8_t and uint32_t type shall be defined as described in <int‐
24 types.h>. Inclusion of the <netinet/in.h> header may also make visible
25 all symbols from <inttypes.h> and <sys/socket.h>.
26
27 The <netinet/in.h> header shall define the in_addr structure that
28 includes at least the following member:
29
30
31 in_addr_t s_addr
32
33 The <netinet/in.h> header shall define the sockaddr_in structure that
34 includes at least the following members (all in network byte order):
35
36
37 sa_family_t sin_family AF_INET.
38 in_port_t sin_port Port number.
39 struct in_addr sin_addr IP address.
40
41 The sockaddr_in structure is used to store addresses for the Internet
42 address family. Values of this type shall be cast by applications to
43 struct sockaddr for use with socket functions.
44
45 The <netinet/in.h> header shall define the in6_addr structure that con‐
46 tains at least the following member:
47
48
49 uint8_t s6_addr[16]
50
51 This array is used to contain a 128-bit IPv6 address, stored in network
52 byte order.
53
54 The <netinet/in.h> header shall define the sockaddr_in6 structure that
55 includes at least the following members (all in network byte order):
56
57
58 sa_family_t sin6_family AF_INET6.
59 in_port_t sin6_port Port number.
60 uint32_t sin6_flowinfo IPv6 traffic class and flow information.
61 struct in6_addr sin6_addr IPv6 address.
62 uint32_t sin6_scope_id Set of interfaces for a scope.
63
64 The sockaddr_in6 structure shall be set to zero by an application prior
65 to using it, since implementations are free to have additional, imple‐
66 mentation-defined fields in sockaddr_in6.
67
68 The sin6_scope_id field is a 32-bit integer that identifies a set of
69 interfaces as appropriate for the scope of the address carried in the
70 sin6_addr field. For a link scope sin6_addr, the application shall
71 ensure that sin6_scope_id is a link index. For a site scope sin6_addr,
72 the application shall ensure that sin6_scope_id is a site index. The
73 mapping of sin6_scope_id to an interface or set of interfaces is imple‐
74 mentation-defined.
75
76 The <netinet/in.h> header shall declare the following external vari‐
77 able:
78
79
80 const struct in6_addr in6addr_any
81
82 This variable is initialized by the system to contain the wildcard IPv6
83 address. The <netinet/in.h> header also defines the IN6ADDR_ANY_INIT
84 macro. This macro must be constant at compile time and can be used to
85 initialize a variable of type struct in6_addr to the IPv6 wildcard
86 address.
87
88 The <netinet/in.h> header shall declare the following external vari‐
89 able:
90
91
92 const struct in6_addr in6addr_loopback
93
94 This variable is initialized by the system to contain the loopback IPv6
95 address. The <netinet/in.h> header also defines the IN6ADDR_LOOP‐
96 BACK_INIT macro. This macro must be constant at compile time and can be
97 used to initialize a variable of type struct in6_addr to the IPv6 loop‐
98 back address.
99
100 The <netinet/in.h> header shall define the ipv6_mreq structure that
101 includes at least the following members:
102
103
104 struct in6_addr ipv6mr_multiaddr IPv6 multicast address.
105 unsigned ipv6mr_interface Interface index.
106
107 The <netinet/in.h> header shall define the following macros for use as
108 values of the level argument of getsockopt() and setsockopt():
109
110 IPPROTO_IP
111 Internet protocol.
112
113 IPPROTO_IPV6
114 Internet Protocol Version 6.
115
116 IPPROTO_ICMP
117 Control message protocol.
118
119 IPPROTO_RAW
120 Raw IP Packets Protocol.
121
122 IPPROTO_TCP
123 Transmission control protocol.
124
125 IPPROTO_UDP
126 User datagram protocol.
127
128
129 The <netinet/in.h> header shall define the following macros for use as
130 destination addresses for connect(), sendmsg(), and sendto():
131
132 INADDR_ANY
133 IPv4 local host address.
134
135 INADDR_BROADCAST
136 IPv4 broadcast address.
137
138
139 The <netinet/in.h> header shall define the following macro to help
140 applications declare buffers of the proper size to store IPv4 addresses
141 in string form:
142
143 INET_ADDRSTRLEN
144 16. Length of the string form for IP.
145
146
147 The htonl(), htons(), ntohl(), and ntohs() functions shall be available
148 as defined in <arpa/inet.h> . Inclusion of the <netinet/in.h> header
149 may also make visible all symbols from <arpa/inet.h> .
150
151 The <netinet/in.h> header shall define the following macro to help
152 applications declare buffers of the proper size to store IPv6 addresses
153 in string form:
154
155 INET6_ADDRSTRLEN
156 46. Length of the string form for IPv6.
157
158
159 The <netinet/in.h> header shall define the following macros, with dis‐
160 tinct integer values, for use in the option_name argument in the get‐
161 sockopt() or setsockopt() functions at protocol level IPPROTO_IPV6:
162
163 IPV6_JOIN_GROUP
164 Join a multicast group.
165
166 IPV6_LEAVE_GROUP
167 Quit a multicast group.
168
169 IPV6_MULTICAST_HOPS
170
171 Multicast hop limit.
172
173 IPV6_MULTICAST_IF
174 Interface to use for outgoing multicast packets.
175
176 IPV6_MULTICAST_LOOP
177
178 Multicast packets are delivered back to the local application.
179
180 IPV6_UNICAST_HOPS
181 Unicast hop limit.
182
183 IPV6_V6ONLY
184 Restrict AF_INET6 socket to IPv6 communications only.
185
186
187 The <netinet/in.h> header shall define the following macros that test
188 for special IPv6 addresses. Each macro is of type int and takes a sin‐
189 gle argument of type const struct in6_addr *:
190
191 IN6_IS_ADDR_UNSPECIFIED
192
193 Unspecified address.
194
195 IN6_IS_ADDR_LOOPBACK
196
197 Loopback address.
198
199 IN6_IS_ADDR_MULTICAST
200
201 Multicast address.
202
203 IN6_IS_ADDR_LINKLOCAL
204
205 Unicast link-local address.
206
207 IN6_IS_ADDR_SITELOCAL
208
209 Unicast site-local address.
210
211 IN6_IS_ADDR_V4MAPPED
212
213 IPv4 mapped address.
214
215 IN6_IS_ADDR_V4COMPAT
216
217 IPv4-compatible address.
218
219 IN6_IS_ADDR_MC_NODELOCAL
220
221 Multicast node-local address.
222
223 IN6_IS_ADDR_MC_LINKLOCAL
224
225 Multicast link-local address.
226
227 IN6_IS_ADDR_MC_SITELOCAL
228
229 Multicast site-local address.
230
231 IN6_IS_ADDR_MC_ORGLOCAL
232
233 Multicast organization-local address.
234
235 IN6_IS_ADDR_MC_GLOBAL
236
237 Multicast global address.
238
239
240 The following sections are informative.
241
243 None.
244
246 None.
247
249 None.
250
252 Host and Network Byte Orders , <arpa/inet.h> , <inttypes.h> ,
253 <sys/socket.h> , the System Interfaces volume of IEEE Std 1003.1-2001,
254 connect(), getsockopt(), htonl(), htons(), ntohl(), ntohs(), sendmsg(),
255 sendto(), setsockopt()
256
258 Portions of this text are reprinted and reproduced in electronic form
259 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
260 -- Portable Operating System Interface (POSIX), The Open Group Base
261 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
262 Electrical and Electronics Engineers, Inc and The Open Group. In the
263 event of any discrepancy between this version and the original IEEE and
264 The Open Group Standard, the original IEEE and The Open Group Standard
265 is the referee document. The original Standard can be obtained online
266 at http://www.opengroup.org/unix/online.html .
267
268
269
270IEEE/The Open Group 2003 <netinet/in.h>(P)