]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Hey Emacs! This file is -*- nroff -*- source. |
2 | .\" | |
3 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) | |
4 | .\" | |
5 | .\" Permission is granted to make and distribute verbatim copies of this | |
6 | .\" manual provided the copyright notice and this permission notice are | |
7 | .\" preserved on all copies. | |
8 | .\" | |
9 | .\" Permission is granted to copy and distribute modified versions of this | |
10 | .\" manual under the conditions for verbatim copying, provided that the | |
11 | .\" entire resulting derived work is distributed under the terms of a | |
12 | .\" permission notice identical to this one. | |
c13182ef | 13 | .\" |
fea681da MK |
14 | .\" Since the Linux kernel and libraries are constantly changing, this |
15 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
16 | .\" responsibility for errors or omissions, or for damages resulting from | |
17 | .\" the use of the information contained herein. The author(s) may not | |
18 | .\" have taken the same level of care in the production of this manual, | |
19 | .\" which is licensed free of charge, as they might when working | |
20 | .\" professionally. | |
c13182ef | 21 | .\" |
fea681da MK |
22 | .\" Formatted or processed versions of this manual, if unaccompanied by |
23 | .\" the source, must acknowledge the copyright and authors of this work. | |
24 | .\" | |
25 | .\" References consulted: | |
26 | .\" Linux libc source code | |
27 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
28 | .\" 386BSD man pages | |
29 | .\" libc.info (from glibc distribution) | |
30 | .\" Modified Sat Jul 24 19:12:00 1993 by Rik Faith <faith@cs.unc.edu> | |
31 | .\" Modified Sun Sep 3 20:29:36 1995 by Jim Van Zandt <jrv@vanzandt.mv.com> | |
32 | .\" Changed network into host byte order (for inet_network), | |
33 | .\" Andreas Jaeger <aj@arthur.rhein-neckar.de>, 980130. | |
34 | .\" | |
35 | .TH INET 3 2001-07-25 "BSD" "Linux Programmer's Manual" | |
36 | .SH NAME | |
c13182ef | 37 | inet_aton, inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof, |
fea681da MK |
38 | inet_netof \- Internet address manipulation routines |
39 | .SH SYNOPSIS | |
40 | .nf | |
41 | .B #include <sys/socket.h> | |
42 | .B #include <netinet/in.h> | |
43 | .B #include <arpa/inet.h> | |
44 | .sp | |
45 | .BI "int inet_aton(const char *" cp ", struct in_addr *" inp ); | |
46 | .sp | |
47 | .BI "in_addr_t inet_addr(const char *" cp ); | |
48 | .sp | |
49 | .BI "in_addr_t inet_network(const char *" cp ); | |
50 | .sp | |
51 | .BI "char *inet_ntoa(struct in_addr " in ); | |
52 | .sp | |
53 | .BI "struct in_addr inet_makeaddr(int " net ", int " host ); | |
54 | .sp | |
55 | .BI "in_addr_t inet_lnaof(struct in_addr " in ); | |
56 | .sp | |
57 | .BI "in_addr_t inet_netof(struct in_addr " in ); | |
58 | .fi | |
59 | .SH DESCRIPTION | |
63aa9df0 | 60 | \fBinet_aton\fP() converts the Internet host address \fIcp\fP from the |
fea681da | 61 | standard numbers-and-dots notation into binary data and stores it in |
e511ffb6 | 62 | the structure that \fIinp\fP points to. \fBinet_aton\fP() returns |
f59a3f19 | 63 | non-zero if the address is valid, zero if not. |
fea681da | 64 | .PP |
63aa9df0 | 65 | The \fBinet_addr\fP() function converts the Internet host address |
fea681da | 66 | \fIcp\fP from numbers-and-dots notation into binary data in network |
c13182ef MK |
67 | byte order. |
68 | If the input is invalid, INADDR_NONE (usually \-1) is returned. | |
e511ffb6 | 69 | This is an \fIobsolete\fP interface to \fBinet_aton\fP(), described |
fea681da | 70 | immediately above; it is obsolete because \-1 is a valid address |
e511ffb6 | 71 | (255.255.255.255), and \fBinet_aton\fP() provides a cleaner way |
fea681da MK |
72 | to indicate error return. |
73 | .PP | |
7cc028fb MK |
74 | The \fBinet_network\fP() function extracts |
75 | a number in host byte order suitable for use as an Internet address | |
c13182ef | 76 | from \fIcp\fP, which is a string in numbers-and-dots notation. |
7cc028fb | 77 | If the input is invalid, \-1 is returned. |
fea681da | 78 | .PP |
63aa9df0 | 79 | The \fBinet_ntoa\fP() function converts the Internet host address |
fea681da | 80 | \fIin\fP given in network byte order to a string in standard |
c13182ef MK |
81 | numbers-and-dots notation. |
82 | The string is returned in a statically | |
fea681da MK |
83 | allocated buffer, which subsequent calls will overwrite. |
84 | .PP | |
63aa9df0 | 85 | The \fBinet_makeaddr\fP() function makes an Internet host address |
fea681da MK |
86 | in network byte order by combining the network number \fInet\fP |
87 | with the local address \fIhost\fP in network \fInet\fP, both in | |
88 | local host byte order. | |
89 | .PP | |
63aa9df0 | 90 | The \fBinet_lnaof\fP() function returns the local host address part |
c13182ef MK |
91 | of the Internet address \fIin\fP. |
92 | The local host address is returned | |
fea681da MK |
93 | in local host byte order. |
94 | .PP | |
63aa9df0 | 95 | The \fBinet_netof\fP() function returns the network number part of |
c13182ef MK |
96 | the Internet Address \fIin\fP. |
97 | The network number is returned in | |
fea681da MK |
98 | local host byte order. |
99 | .PP | |
63aa9df0 MK |
100 | The structure \fIin_addr\fP as used in \fBinet_ntoa\fP(), |
101 | \fBinet_makeaddr\fP(), \fBinet_lnoaf\fP() and \fBinet_netof\fP() | |
fea681da MK |
102 | is defined in \fInetinet/in.h\fP as: |
103 | .sp | |
104 | .RS | |
105 | .nf | |
fea681da | 106 | struct in_addr { |
cf0a9ace | 107 | unsigned long int s_addr; |
fea681da | 108 | } |
fea681da MK |
109 | .fi |
110 | .RE | |
111 | .PP | |
112 | Note that on the i80x86 the host byte order is Least Significant Byte | |
9559eb50 MK |
113 | first (little endian), whereas the network byte order, as used on the |
114 | Internet, is Most Significant Byte first (big endian). | |
115 | .SH NOTE | |
116 | When you using numbers-and-dots notation for addresses, | |
117 | be aware that each number will be interpreted as octal | |
c13182ef | 118 | if preceded by a 0 and as hexadecimal if preceded by 0x. |
9559eb50 | 119 | For example, \fBinet_aton("226.000.000.037", &t)\fP will |
688abfbe | 120 | interpret the address as \fI226.0.0.31\fP and not \fI226.0.0.37\fP. |
9b7116b1 | 121 | .SH "GLIBC NOTES" |
c13182ef | 122 | In order to expose the declaration of |
9b7116b1 | 123 | .BR inet_aton (), |
c13182ef | 124 | one of the feature test macros _BSD_SOURCE, _SVID_SOURCE, or |
803ef335 | 125 | _GNU_SOURCE must be defined. |
fea681da | 126 | .SH "CONFORMING TO" |
68e1685c MK |
127 | 4.3BSD. |
128 | .BR inet_addr (), | |
129 | .BR inet_aton (), | |
130 | and | |
131 | .BR inet_ntoa () | |
132 | are specified in POSIX.1-2001. | |
fea681da MK |
133 | .SH "SEE ALSO" |
134 | .BR gethostbyname (3), | |
135 | .BR getnetent (3), | |
136 | .BR inet_ntop (3), | |
137 | .BR inet_pton (3), | |
138 | .BR hosts (5), | |
139 | .BR networks (5) |