summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/inet.3
diff options
context:
space:
mode:
authorderaadt <>1995-10-18 08:42:23 +0000
committerderaadt <>1995-10-18 08:42:23 +0000
commit0527d29da443886d92e9a418180c5b25a5f8d270 (patch)
tree86b3a64928451a669cefa27900e5884036b4e349 /src/lib/libc/net/inet.3
downloadopenbsd-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.3197
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
67The routines
68.Fn inet_aton ,
69.Fn inet_addr
70and
71.Fn inet_network
72interpret character strings representing
73numbers expressed in the Internet standard
74.Ql \&.
75notation.
76The
77.Fn inet_aton
78routine interprets the specified character string as an Internet address,
79placing the address into the structure provided.
80It returns 1 if the string was successfully interpreted,
81or 0 if the string is invalid.
82The
83.Fn inet_addr
84and
85.Fn inet_network
86functions return numbers suitable for use
87as Internet addresses and Internet network
88numbers, respectively.
89The routine
90.Fn inet_ntoa
91takes an Internet address and returns an
92.Tn ASCII
93string representing the address in
94.Ql \&.
95notation. The routine
96.Fn inet_makeaddr
97takes an Internet network number and a local
98network address and constructs an Internet address
99from it. The routines
100.Fn inet_netof
101and
102.Fn inet_lnaof
103break apart Internet host addresses, returning
104the network number and local network address part,
105respectively.
106.Pp
107All Internet addresses are returned in network
108order (bytes ordered from left to right).
109All network numbers and local address parts are
110returned as machine format integer values.
111.Sh INTERNET ADDRESSES
112Values specified using the
113.Ql \&.
114notation take one
115of the following forms:
116.Bd -literal -offset indent
117a.b.c.d
118a.b.c
119a.b
120a
121.Ed
122.Pp
123When four parts are specified, each is interpreted
124as a byte of data and assigned, from left to right,
125to the four bytes of an Internet address. Note
126that when an Internet address is viewed as a 32-bit
127integer quantity on the
128.Tn VAX
129the bytes referred to
130above appear as
131.Dq Li d.c.b.a .
132That is,
133.Tn VAX
134bytes are
135ordered from right to left.
136.Pp
137When a three part address is specified, the last
138part is interpreted as a 16-bit quantity and placed
139in the right-most two bytes of the network address.
140This makes the three part address format convenient
141for specifying Class B network addresses as
142.Dq Li 128.net.host .
143.Pp
144When a two part address is supplied, the last part
145is interpreted as a 24-bit quantity and placed in
146the right most three bytes of the network address.
147This makes the two part address format convenient
148for specifying Class A network addresses as
149.Dq Li net.host .
150.Pp
151When only one part is given, the value is stored
152directly in the network address without any byte
153rearrangement.
154.Pp
155All numbers supplied as
156.Dq parts
157in a
158.Ql \&.
159notation
160may be decimal, octal, or hexadecimal, as specified
161in the C language (i.e., a leading 0x or 0X implies
162hexadecimal; otherwise, a leading 0 implies octal;
163otherwise, the number is interpreted as decimal).
164.Sh DIAGNOSTICS
165The constant
166.Dv INADDR_NONE
167is returned by
168.Fn inet_addr
169and
170.Fn inet_network
171for 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
178These
179functions appeared in
180.Bx 4.2 .
181.Sh BUGS
182The value
183.Dv INADDR_NONE
184(0xffffffff) is a valid broadcast address, but
185.Fn inet_addr
186cannot return that value without indicating failure.
187The newer
188.Fn inet_aton
189function does not share this problem.
190The problem of host byte ordering versus network byte ordering is
191confusing.
192The string returned by
193.Fn inet_ntoa
194resides in a static memory area.
195.Pp
196Inet_addr should return a
197.Fa struct in_addr .