diff options
author | deraadt <> | 1995-10-18 08:42:23 +0000 |
---|---|---|
committer | deraadt <> | 1995-10-18 08:42:23 +0000 |
commit | 0527d29da443886d92e9a418180c5b25a5f8d270 (patch) | |
tree | 86b3a64928451a669cefa27900e5884036b4e349 /src/lib/libc/net/inet.3 | |
download | openbsd-0527d29da443886d92e9a418180c5b25a5f8d270.tar.gz openbsd-0527d29da443886d92e9a418180c5b25a5f8d270.tar.bz2 openbsd-0527d29da443886d92e9a418180c5b25a5f8d270.zip |
initial import of NetBSD tree
Diffstat (limited to 'src/lib/libc/net/inet.3')
-rw-r--r-- | src/lib/libc/net/inet.3 | 197 |
1 files changed, 197 insertions, 0 deletions
diff --git a/src/lib/libc/net/inet.3 b/src/lib/libc/net/inet.3 new file mode 100644 index 0000000000..49bac97e96 --- /dev/null +++ b/src/lib/libc/net/inet.3 | |||
@@ -0,0 +1,197 @@ | |||
1 | .\" $NetBSD: inet.3,v 1.4 1995/02/27 09:45:26 chopps Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1983, 1990, 1991, 1993 | ||
4 | .\" The Regents of the University of California. All rights reserved. | ||
5 | .\" | ||
6 | .\" Redistribution and use in source and binary forms, with or without | ||
7 | .\" modification, are permitted provided that the following conditions | ||
8 | .\" are met: | ||
9 | .\" 1. Redistributions of source code must retain the above copyright | ||
10 | .\" notice, this list of conditions and the following disclaimer. | ||
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
12 | .\" notice, this list of conditions and the following disclaimer in the | ||
13 | .\" documentation and/or other materials provided with the distribution. | ||
14 | .\" 3. All advertising materials mentioning features or use of this software | ||
15 | .\" must display the following acknowledgement: | ||
16 | .\" This product includes software developed by the University of | ||
17 | .\" California, Berkeley and its contributors. | ||
18 | .\" 4. Neither the name of the University nor the names of its contributors | ||
19 | .\" may be used to endorse or promote products derived from this software | ||
20 | .\" without specific prior written permission. | ||
21 | .\" | ||
22 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
23 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
24 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
25 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
26 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
27 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
28 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
29 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
30 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
31 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
32 | .\" SUCH DAMAGE. | ||
33 | .\" | ||
34 | .\" @(#)inet.3 8.1 (Berkeley) 6/4/93 | ||
35 | .\" | ||
36 | .Dd June 4, 1993 | ||
37 | .Dt INET 3 | ||
38 | .Os BSD 4.2 | ||
39 | .Sh NAME | ||
40 | .Nm inet_aton , | ||
41 | .Nm inet_addr , | ||
42 | .Nm inet_network , | ||
43 | .Nm inet_ntoa , | ||
44 | .Nm inet_makeaddr , | ||
45 | .Nm inet_lnaof , | ||
46 | .Nm inet_netof | ||
47 | .Nd Internet address manipulation routines | ||
48 | .Sh SYNOPSIS | ||
49 | .Fd #include <sys/socket.h> | ||
50 | .Fd #include <netinet/in.h> | ||
51 | .Fd #include <arpa/inet.h> | ||
52 | .Ft int | ||
53 | .Fn inet_aton "const char *cp" "struct in_addr *pin" | ||
54 | .Ft unsigned long | ||
55 | .Fn inet_addr "const char *cp" | ||
56 | .Ft unsigned long | ||
57 | .Fn inet_network "const char *cp" | ||
58 | .Ft char * | ||
59 | .Fn inet_ntoa "struct in_addr in" | ||
60 | .Ft struct in_addr | ||
61 | .Fn inet_makeaddr "int net" "int lna" | ||
62 | .Ft unsigned long | ||
63 | .Fn inet_lnaof "struct in_addr in" | ||
64 | .Ft unsigned long | ||
65 | .Fn inet_netof "struct in_addr in" | ||
66 | .Sh DESCRIPTION | ||
67 | The routines | ||
68 | .Fn inet_aton , | ||
69 | .Fn inet_addr | ||
70 | and | ||
71 | .Fn inet_network | ||
72 | interpret character strings representing | ||
73 | numbers expressed in the Internet standard | ||
74 | .Ql \&. | ||
75 | notation. | ||
76 | The | ||
77 | .Fn inet_aton | ||
78 | routine interprets the specified character string as an Internet address, | ||
79 | placing the address into the structure provided. | ||
80 | It returns 1 if the string was successfully interpreted, | ||
81 | or 0 if the string is invalid. | ||
82 | The | ||
83 | .Fn inet_addr | ||
84 | and | ||
85 | .Fn inet_network | ||
86 | functions return numbers suitable for use | ||
87 | as Internet addresses and Internet network | ||
88 | numbers, respectively. | ||
89 | The routine | ||
90 | .Fn inet_ntoa | ||
91 | takes an Internet address and returns an | ||
92 | .Tn ASCII | ||
93 | string representing the address in | ||
94 | .Ql \&. | ||
95 | notation. The routine | ||
96 | .Fn inet_makeaddr | ||
97 | takes an Internet network number and a local | ||
98 | network address and constructs an Internet address | ||
99 | from it. The routines | ||
100 | .Fn inet_netof | ||
101 | and | ||
102 | .Fn inet_lnaof | ||
103 | break apart Internet host addresses, returning | ||
104 | the network number and local network address part, | ||
105 | respectively. | ||
106 | .Pp | ||
107 | All Internet addresses are returned in network | ||
108 | order (bytes ordered from left to right). | ||
109 | All network numbers and local address parts are | ||
110 | returned as machine format integer values. | ||
111 | .Sh INTERNET ADDRESSES | ||
112 | Values specified using the | ||
113 | .Ql \&. | ||
114 | notation take one | ||
115 | of the following forms: | ||
116 | .Bd -literal -offset indent | ||
117 | a.b.c.d | ||
118 | a.b.c | ||
119 | a.b | ||
120 | a | ||
121 | .Ed | ||
122 | .Pp | ||
123 | When four parts are specified, each is interpreted | ||
124 | as a byte of data and assigned, from left to right, | ||
125 | to the four bytes of an Internet address. Note | ||
126 | that when an Internet address is viewed as a 32-bit | ||
127 | integer quantity on the | ||
128 | .Tn VAX | ||
129 | the bytes referred to | ||
130 | above appear as | ||
131 | .Dq Li d.c.b.a . | ||
132 | That is, | ||
133 | .Tn VAX | ||
134 | bytes are | ||
135 | ordered from right to left. | ||
136 | .Pp | ||
137 | When a three part address is specified, the last | ||
138 | part is interpreted as a 16-bit quantity and placed | ||
139 | in the right-most two bytes of the network address. | ||
140 | This makes the three part address format convenient | ||
141 | for specifying Class B network addresses as | ||
142 | .Dq Li 128.net.host . | ||
143 | .Pp | ||
144 | When a two part address is supplied, the last part | ||
145 | is interpreted as a 24-bit quantity and placed in | ||
146 | the right most three bytes of the network address. | ||
147 | This makes the two part address format convenient | ||
148 | for specifying Class A network addresses as | ||
149 | .Dq Li net.host . | ||
150 | .Pp | ||
151 | When only one part is given, the value is stored | ||
152 | directly in the network address without any byte | ||
153 | rearrangement. | ||
154 | .Pp | ||
155 | All numbers supplied as | ||
156 | .Dq parts | ||
157 | in a | ||
158 | .Ql \&. | ||
159 | notation | ||
160 | may be decimal, octal, or hexadecimal, as specified | ||
161 | in the C language (i.e., a leading 0x or 0X implies | ||
162 | hexadecimal; otherwise, a leading 0 implies octal; | ||
163 | otherwise, the number is interpreted as decimal). | ||
164 | .Sh DIAGNOSTICS | ||
165 | The constant | ||
166 | .Dv INADDR_NONE | ||
167 | is returned by | ||
168 | .Fn inet_addr | ||
169 | and | ||
170 | .Fn inet_network | ||
171 | for malformed requests. | ||
172 | .Sh SEE ALSO | ||
173 | .Xr gethostbyname 3 , | ||
174 | .Xr getnetent 3 , | ||
175 | .Xr hosts 5 , | ||
176 | .Xr networks 5 , | ||
177 | .Sh HISTORY | ||
178 | These | ||
179 | functions appeared in | ||
180 | .Bx 4.2 . | ||
181 | .Sh BUGS | ||
182 | The value | ||
183 | .Dv INADDR_NONE | ||
184 | (0xffffffff) is a valid broadcast address, but | ||
185 | .Fn inet_addr | ||
186 | cannot return that value without indicating failure. | ||
187 | The newer | ||
188 | .Fn inet_aton | ||
189 | function does not share this problem. | ||
190 | The problem of host byte ordering versus network byte ordering is | ||
191 | confusing. | ||
192 | The string returned by | ||
193 | .Fn inet_ntoa | ||
194 | resides in a static memory area. | ||
195 | .Pp | ||
196 | Inet_addr should return a | ||
197 | .Fa struct in_addr . | ||