]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3p/inet_addr.3p
Import of man-pages 1.70
[thirdparty/man-pages.git] / man3p / inet_addr.3p
1 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
2 .TH "INET_ADDR" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
3 .\" inet_addr
4 .SH NAME
5 inet_addr, inet_ntoa \- IPv4 address manipulation
6 .SH SYNOPSIS
7 .LP
8 \fB#include <arpa/inet.h>
9 .br
10 .sp
11 in_addr_t inet_addr(const char *\fP\fIcp\fP\fB);
12 .br
13 char *inet_ntoa(struct in_addr\fP \fIin\fP\fB);
14 .br
15 \fP
16 .SH DESCRIPTION
17 .LP
18 The \fIinet_addr\fP() function shall convert the string pointed to
19 by \fIcp\fP, in the standard IPv4 dotted decimal notation,
20 to an integer value suitable for use as an Internet address.
21 .LP
22 The \fIinet_ntoa\fP() function shall convert the Internet host address
23 specified by \fIin\fP to a string in the Internet
24 standard dot notation.
25 .LP
26 The \fIinet_ntoa\fP() function need not be reentrant. A function that
27 is not required to be reentrant is not required to be
28 thread-safe.
29 .LP
30 All Internet addresses shall be returned in network order (bytes ordered
31 from left to right).
32 .LP
33 Values specified using IPv4 dotted decimal notation take one of the
34 following forms:
35 .TP 7
36 \fBa.b.c.d\fP
37 When four parts are specified, each shall be interpreted as a byte
38 of data and assigned, from left to right, to the four bytes
39 of an Internet address.
40 .TP 7
41 \fBa.b.c\fP
42 When a three-part address is specified, the last part shall be interpreted
43 as a 16-bit quantity and placed in the rightmost two
44 bytes of the network address. This makes the three-part address format
45 convenient for specifying Class B network addresses as
46 \fB"128.net.host"\fP .
47 .TP 7
48 \fBa.b\fP
49 When a two-part address is supplied, the last part shall be interpreted
50 as a 24-bit quantity and placed in the rightmost three
51 bytes of the network address. This makes the two-part address format
52 convenient for specifying Class A network addresses as
53 \fB"net.host"\fP .
54 .TP 7
55 \fBa\fP
56 When only one part is given, the value shall be stored directly in
57 the network address without any byte rearrangement.
58 .sp
59 .LP
60 All numbers supplied as parts in IPv4 dotted decimal notation may
61 be decimal, octal, or hexadecimal, as specified in the
62 ISO\ C standard (that is, a leading 0x or 0X implies hexadecimal;
63 otherwise, a leading \fB'0'\fP implies octal; otherwise,
64 the number is interpreted as decimal).
65 .SH RETURN VALUE
66 .LP
67 Upon successful completion, \fIinet_addr\fP() shall return the Internet
68 address. Otherwise, it shall return (
69 \fBin_addr_t\fP)(-1).
70 .LP
71 The \fIinet_ntoa\fP() function shall return a pointer to the network
72 address in Internet standard dot notation.
73 .SH ERRORS
74 .LP
75 No errors are defined.
76 .LP
77 \fIThe following sections are informative.\fP
78 .SH EXAMPLES
79 .LP
80 None.
81 .SH APPLICATION USAGE
82 .LP
83 The return value of \fIinet_ntoa\fP() may point to static data that
84 may be overwritten by subsequent calls to
85 \fIinet_ntoa\fP().
86 .SH RATIONALE
87 .LP
88 None.
89 .SH FUTURE DIRECTIONS
90 .LP
91 None.
92 .SH SEE ALSO
93 .LP
94 \fIendhostent\fP() , \fIendnetent\fP() , the Base Definitions
95 volume of IEEE\ Std\ 1003.1-2001, \fI<arpa/inet.h>\fP
96 .SH COPYRIGHT
97 Portions of this text are reprinted and reproduced in electronic form
98 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
99 -- Portable Operating System Interface (POSIX), The Open Group Base
100 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
101 Electrical and Electronics Engineers, Inc and The Open Group. In the
102 event of any discrepancy between this version and the original IEEE and
103 The Open Group Standard, the original IEEE and The Open Group Standard
104 is the referee document. The original Standard can be obtained online at
105 http://www.opengroup.org/unix/online.html .