1 .\" Copyright (c) 1983, 1990, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 4. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" From: @(#)inet.3 8.1 (Berkeley) 6/4/93
29 .\" $FreeBSD: src/lib/libc/net/inet.3,v 1.36 2007/06/14 07:13:28 delphij Exp $
45 .Nd Internet address manipulation routines
57 .Fa "struct in_addr *pin"
61 .Fa "struct in_addr in"
70 .Fa "struct in_addr in"
78 .Fa "struct in_addr in"
82 .Fa "struct in_addr in"
89 .Fa "const void * restrict src"
90 .Fa "char * restrict dst"
96 .Fa "const char * restrict src"
97 .Fa "void * restrict dst"
105 interpret character strings representing
106 numbers expressed in the Internet standard
112 function converts a presentation format address (that is, printable form
113 as held in a character string) to network format (usually a
115 or some other internal binary representation, in network byte order).
116 It returns 1 if the address was valid for the specified address family, or
117 0 if the address was not parseable in the specified address family, or -1
118 if some system error occurred (in which case
121 This function is presently valid for
128 routine interprets the specified character string as an Internet address,
129 placing the address into the structure provided.
130 It returns 1 if the string was successfully interpreted,
131 or 0 if the string is invalid.
136 functions return numbers suitable for use
137 as Internet addresses and Internet network
138 numbers, respectively.
147 or some other binary form, in network byte order) to presentation format
148 (suitable for external display purposes).
151 argument specifies the size, in bytes, of the buffer
156 define the maximum size required to convert an address of the respective
158 It returns NULL if a system error occurs (in which case,
160 will have been set), or it returns a pointer to the destination string.
161 This function is presently valid for
168 takes an Internet address and returns an
170 string representing the address in
175 is the reentrant version of
179 takes an Internet network number and a local
180 network address and constructs an Internet address
186 break apart Internet host addresses, returning
187 the network number and local network address part,
190 All Internet addresses are returned in network
191 order (bytes ordered from left to right).
192 All network numbers and local address parts are
193 returned as machine byte order integer values.
194 .Sh INTERNET ADDRESSES
195 Values specified using the
198 of the following forms:
199 .Bd -literal -offset indent
206 When four parts are specified, each is interpreted
207 as a byte of data and assigned, from left to right,
208 to the four bytes of an Internet address.
210 that when an Internet address is viewed as a 32-bit
211 integer quantity on the
213 the bytes referred to
219 ordered from right to left.
221 When a three part address is specified, the last
222 part is interpreted as a 16-bit quantity and placed
223 in the right-most two bytes of the network address.
224 This makes the three part address format convenient
225 for specifying Class B network addresses as
226 .Dq Li 128.net.host .
228 When a two part address is supplied, the last part
229 is interpreted as a 24-bit quantity and placed in
230 the right most three bytes of the network address.
231 This makes the two part address format convenient
232 for specifying Class A network addresses as
235 When only one part is given, the value is stored
236 directly in the network address without any byte
239 All numbers supplied as
244 may be decimal, octal, or hexadecimal, as specified
245 in the C language (i.e., a leading 0x or 0X implies
246 hexadecimal; otherwise, a leading 0 implies octal;
247 otherwise, the number is interpreted as decimal).
255 for malformed requests.
261 .It Bq Er EAFNOSUPPORT
270 was not large enough to store the presentation form of the address.
273 .Fd #include <sys/types.h>
274 .Fd #include <sys/socket.h>
275 .Fd #include <netinet/in.h>
276 .Fd #include <arpa/inet.h>
278 These include files are necessary for all functions.
282 .Xr gethostbyname 3 ,
292 .%T "IP Version 6 Addressing Architecture"
303 does not accept 1-, 2-, or 3-part dotted addresses; all four parts
304 must be specified and are interpreted only as decimal values.
305 This is a narrower input set than that accepted by
309 functions appeared in
314 (0xffffffff) is a valid broadcast address, but
316 cannot return that value without indicating failure.
319 function does not share this problem.
320 The problem of host byte ordering versus network byte ordering is
322 The string returned by
324 resides in a static memory area.
328 function should return a