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 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" From: @(#)inet.3 8.1 (Berkeley) 6/4/93
33 .\" $FreeBSD: src/lib/libc/net/inet.3,v 1.29 2004/07/02 23:52:11 ru Exp $
48 .Nd Internet address manipulation routines
60 .Fa "struct in_addr *pin"
64 .Fa "struct in_addr in"
73 .Fa "struct in_addr in"
81 .Fa "struct in_addr in"
86 .Fa "const void *restrict src"
87 .Fa "char *restrict dst"
93 .Fa "const char *restrict src"
94 .Fa "void *restrict dst"
102 interpret character strings representing
103 numbers expressed in the Internet standard
109 function converts a presentation format address (that is, printable form
110 as held in a character string) to network format (usually a
112 or some other internal binary representation, in network byte order).
113 It returns 1 if the address was valid for the specified address family, or
114 0 if the address wasn't parseable in the specified address family, or -1
115 if some system error occurred (in which case
118 This function is presently valid for
125 routine interprets the specified character string as an Internet address,
126 placing the address into the structure provided.
127 It returns 1 if the string was successfully interpreted,
128 or 0 if the string is invalid.
133 functions return numbers suitable for use
134 as Internet addresses and Internet network
135 numbers, respectively.
144 or some other binary form, in network byte order) to presentation format
145 (suitable for external display purposes).
148 argument specifies the size, in bytes, of the buffer
150 It returns NULL if a system error occurs (in which case,
152 will have been set), or it returns a pointer to the destination string.
153 This function is presently valid for
160 takes an Internet address and returns an
162 string representing the address in
167 takes an Internet network number and a local
168 network address and constructs an Internet address
174 break apart Internet host addresses, returning
175 the network number and local network address part,
178 All Internet addresses are returned in network
179 order (bytes ordered from left to right).
180 All network numbers and local address parts are
181 returned as machine byte order integer values.
182 .Sh INTERNET ADDRESSES
183 Values specified using the
186 of the following forms:
187 .Bd -literal -offset indent
194 When four parts are specified, each is interpreted
195 as a byte of data and assigned, from left to right,
196 to the four bytes of an Internet address.
198 that when an Internet address is viewed as a 32-bit
199 integer quantity on the
201 the bytes referred to
207 ordered from right to left.
209 When a three part address is specified, the last
210 part is interpreted as a 16-bit quantity and placed
211 in the right-most two bytes of the network address.
212 This makes the three part address format convenient
213 for specifying Class B network addresses as
214 .Dq Li 128.net.host .
216 When a two part address is supplied, the last part
217 is interpreted as a 24-bit quantity and placed in
218 the right most three bytes of the network address.
219 This makes the two part address format convenient
220 for specifying Class A network addresses as
223 When only one part is given, the value is stored
224 directly in the network address without any byte
227 All numbers supplied as
232 may be decimal, octal, or hexadecimal, as specified
233 in the C language (i.e., a leading 0x or 0X implies
234 hexadecimal; otherwise, a leading 0 implies octal;
235 otherwise, the number is interpreted as decimal).
241 functions are semi-deprecated in favor of the
244 However, since those functions are not yet widely implemented,
245 portable programs cannot rely on their presence and will continue
248 functions for some time.
256 for malformed requests.
262 .It Bq Er EAFNOSUPPORT
271 was not large enough to store the presentation form of the address.
274 .Fd #include <sys/types.h>
275 .Fd #include <sys/socket.h>
276 .Fd #include <sys/netinet/in.h>
277 .Fd #include <sys/arpa/inet.h>
279 These include files are necessary for all functions.
283 .Xr gethostbyname 3 ,
293 .%T "IP Version 6 Addressing Architecture"
304 does not accept 1-, 2-, or 3-part dotted addresses; all four parts
305 must be specified and are interpreted only as decimal values.
306 This is a narrower input set than that accepted by
310 functions appeared in
315 (0xffffffff) is a valid broadcast address, but
317 cannot return that value without indicating failure.
320 function does not share this problem.
321 The problem of host byte ordering versus network byte ordering is
323 The string returned by
325 resides in a static memory area.
327 Inet_addr should return a