summaryrefslogtreecommitdiffstats
path: root/man0p/in.h.0p
blob: e0a6a8c901068d3ed3da2f2625cf6192ec15774e (plain) (blame)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "<netinet/in.h>" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" <netinet/in.h> 
.SH NAME
netinet/in.h \- Internet address family
.SH SYNOPSIS
.LP
\fB#include <netinet/in.h>\fP
.SH DESCRIPTION
.LP
The \fI<netinet/in.h>\fP header shall define the following types:
.TP 7
\fBin_port_t\fP
Equivalent to the type \fBuint16_t\fP as defined in \fI<inttypes.h>\fP
\&.
.TP 7
\fBin_addr_t\fP
Equivalent to the type \fBuint32_t\fP as defined in \fI<inttypes.h>\fP
\&.
.sp
.LP
The \fBsa_family_t\fP type shall be defined as described in \fI<sys/socket.h>\fP
\&.
.LP
The \fBuint8_t\fP and \fBuint32_t\fP type shall be defined as described
in \fI<inttypes.h>\fP. Inclusion of the \fI<netinet/in.h>\fP header
may also make
visible all symbols from \fI<inttypes.h>\fP and \fI<sys/socket.h>\fP.
.LP
The \fI<netinet/in.h>\fP header shall define the \fBin_addr\fP structure
that includes at least the following
member:
.sp
.RS
.nf

\fBin_addr_t  s_addr
\fP
.fi
.RE
.LP
The \fI<netinet/in.h>\fP header shall define the \fBsockaddr_in\fP
structure that includes at least the following
members (all in network byte order):
.sp
.RS
.nf

\fBsa_family_t     sin_family  \fP AF_INET. \fB
in_port_t       sin_port    \fP Port number. \fB
struct in_addr  sin_addr    \fP IP address. \fB
\fP
.fi
.RE
.LP
The \fBsockaddr_in\fP structure is used to store addresses for the
Internet address family. Values of this type shall be cast
by applications to \fBstruct sockaddr\fP for use with socket functions.
.LP
The \fI<netinet/in.h>\fP header shall define the \fBin6_addr\fP structure
that contains at least the following
member:
.sp
.RS
.nf

\fBuint8_t s6_addr[16]
\fP
.fi
.RE
.LP
This array is used to contain a 128-bit IPv6 address, stored in network
byte order.
.LP
The \fI<netinet/in.h>\fP header shall define the \fBsockaddr_in6\fP
structure that includes at least the following
members (all in network byte order):
.sp
.RS
.nf

\fBsa_family_t      sin6_family   \fP AF_INET6. \fB
in_port_t        sin6_port     \fP Port number. \fB
uint32_t         sin6_flowinfo \fP IPv6 traffic class and flow information. \fB
struct in6_addr  sin6_addr     \fP IPv6 address. \fB
uint32_t         sin6_scope_id \fP Set of interfaces for a scope. \fB
\fP
.fi
.RE
.LP
The \fBsockaddr_in6\fP structure shall be set to zero by an application
prior to using it, since implementations are free to
have additional, implementation-defined fields in \fBsockaddr_in6\fP.
.LP
The \fIsin6_scope_id\fP field is a 32-bit integer that identifies
a set of interfaces as appropriate for the scope of the
address carried in the \fIsin6_addr\fP field. For a link scope \fIsin6_addr\fP,
the application shall ensure that
\fIsin6_scope_id\fP is a link index. For a site scope \fIsin6_addr\fP,
the application shall ensure that \fIsin6_scope_id\fP is
a site index. The mapping of \fIsin6_scope_id\fP to an interface or
set of interfaces is implementation-defined.
.LP
The \fI<netinet/in.h>\fP header shall declare the following external
variable:
.sp
.RS
.nf

\fBconst struct in6_addr in6addr_any
\fP
.fi
.RE
.LP
This variable is initialized by the system to contain the wildcard
IPv6 address. The \fI<netinet/in.h>\fP header also
defines the IN6ADDR_ANY_INIT macro. This macro must be constant at
compile time and can be used to initialize a variable of type
\fBstruct in6_addr\fP to the IPv6 wildcard address.
.LP
The \fI<netinet/in.h>\fP header shall declare the following external
variable:
.sp
.RS
.nf

\fBconst struct in6_addr in6addr_loopback
\fP
.fi
.RE
.LP
This variable is initialized by the system to contain the loopback
IPv6 address. The \fI<netinet/in.h>\fP header also
defines the IN6ADDR_LOOPBACK_INIT macro. This macro must be constant
at compile time and can be used to initialize a variable of
type \fBstruct in6_addr\fP to the IPv6 loopback address.
.LP
The \fI<netinet/in.h>\fP header shall define the \fBipv6_mreq\fP structure
that includes at least the following
members:
.sp
.RS
.nf

\fBstruct in6_addr  ipv6mr_multiaddr \fP IPv6 multicast address. \fB
unsigned         ipv6mr_interface \fP Interface index. \fB
\fP
.fi
.RE
.LP
The \fI<netinet/in.h>\fP header shall define the following macros
for use as values of the \fIlevel\fP argument of \fIgetsockopt\fP()
and \fIsetsockopt\fP():
.TP 7
IPPROTO_IP
Internet protocol.
.TP 7
IPPROTO_IPV6
Internet Protocol Version 6. 
.TP 7
IPPROTO_ICMP
Control message protocol.
.TP 7
IPPROTO_RAW
Raw IP Packets Protocol. 
.TP 7
IPPROTO_TCP
Transmission control protocol.
.TP 7
IPPROTO_UDP
User datagram protocol.
.sp
.LP
The \fI<netinet/in.h>\fP header shall define the following macros
for use as destination addresses for \fIconnect\fP(), \fIsendmsg\fP(),
and \fIsendto\fP():
.TP 7
INADDR_ANY
IPv4 local host address.
.TP 7
INADDR_BROADCAST
IPv4 broadcast address.
.sp
.LP
The \fI<netinet/in.h>\fP header shall define the following macro to
help applications declare buffers of the proper size
to store IPv4 addresses in string form:
.TP 7
INET_ADDRSTRLEN
16. Length of the string form for IP.
.sp
.LP
The \fIhtonl\fP(), \fIhtons\fP(), \fIntohl\fP(), and \fIntohs\fP()
functions shall be
available as defined in \fI<arpa/inet.h>\fP . Inclusion of the
\fI<netinet/in.h>\fP header may also make visible all symbols from
\fI<arpa/inet.h>\fP .
.LP
The \fI<netinet/in.h>\fP header shall define the following macro to
help applications declare buffers of the proper
size to store IPv6 addresses in string form:
.TP 7
INET6_ADDRSTRLEN
46. Length of the string form for IPv6.
.sp
.LP
The \fI<netinet/in.h>\fP header shall define the following macros,
with distinct integer values, for use in the
\fIoption_name\fP argument in the \fIgetsockopt\fP() or \fIsetsockopt\fP()
functions at protocol level IPPROTO_IPV6:
.TP 7
IPV6_JOIN_GROUP
Join a multicast group.
.TP 7
IPV6_LEAVE_GROUP
Quit a multicast group.
.TP 7
IPV6_MULTICAST_HOPS
.sp
Multicast hop limit.
.TP 7
IPV6_MULTICAST_IF
Interface to use for outgoing multicast packets.
.TP 7
IPV6_MULTICAST_LOOP
.sp
Multicast packets are delivered back to the local application.
.TP 7
IPV6_UNICAST_HOPS
Unicast hop limit.
.TP 7
IPV6_V6ONLY
Restrict AF_INET6 socket to IPv6 communications only.
.sp
.LP
The \fI<netinet/in.h>\fP header shall define the following macros
that test for special IPv6 addresses. Each macro is of
type \fBint\fP and takes a single argument of type \fBconst struct
in6_addr *\fP:
.TP 7
IN6_IS_ADDR_UNSPECIFIED
.sp
Unspecified address.
.TP 7
IN6_IS_ADDR_LOOPBACK
.sp
Loopback address.
.TP 7
IN6_IS_ADDR_MULTICAST
.sp
Multicast address.
.TP 7
IN6_IS_ADDR_LINKLOCAL
.sp
Unicast link-local address.
.TP 7
IN6_IS_ADDR_SITELOCAL
.sp
Unicast site-local address.
.TP 7
IN6_IS_ADDR_V4MAPPED
.sp
IPv4 mapped address.
.TP 7
IN6_IS_ADDR_V4COMPAT
.sp
IPv4-compatible address.
.TP 7
IN6_IS_ADDR_MC_NODELOCAL
.sp
Multicast node-local address.
.TP 7
IN6_IS_ADDR_MC_LINKLOCAL
.sp
Multicast link-local address.
.TP 7
IN6_IS_ADDR_MC_SITELOCAL
.sp
Multicast site-local address.
.TP 7
IN6_IS_ADDR_MC_ORGLOCAL
.sp
Multicast organization-local address.
.TP 7
IN6_IS_ADDR_MC_GLOBAL
.sp
Multicast global address. 
.sp
.LP
\fIThe following sections are informative.\fP
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIHost and Network Byte Orders\fP , \fI<arpa/inet.h>\fP , \fI<inttypes.h>\fP
, \fI<sys/socket.h>\fP , the System Interfaces volume of IEEE\ Std\ 1003.1-2001,
\fIconnect\fP(), \fIgetsockopt\fP(), \fIhtonl\fP(), \fIhtons\fP(),
\fIntohl\fP(), \fIntohs\fP(), \fIsendmsg\fP(), \fIsendto\fP(), \fIsetsockopt\fP()
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .