date and time created 91/03/06 18:09:53 by bostic
[unix-history] / usr / src / lib / libc / net / inet.3
CommitLineData
52d539f9 1.\" Copyright (c) 1983, 1990 The Regents of the University of California.
56e6bd55 2.\" All rights reserved.
fd221ed5 3.\"
91cff1e1 4.\" %sccs.include.redist.man%
fd221ed5 5.\"
91cff1e1 6.\" @(#)inet.3 6.9 (Berkeley) %G%
56e6bd55
KB
7.\"
8.TH INET 3 ""
fd221ed5
KM
9.UC 5
10.SH NAME
52d539f9 11inet_aton, inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof, inet_netof \- Internet address manipulation routines
fd221ed5
KM
12.SH SYNOPSIS
13.nf
14.B "#include <sys/socket.h>
15.B "#include <netinet/in.h>
16.B "#include <arpa/inet.h>
17.PP
52d539f9
MK
18.B "int inet_aton(cp, pin)
19.B "char *cp;
20.B "struct in_addr *pin;
21.PP
0dc23afe 22.B "unsigned long inet_addr(cp)
fd221ed5
KM
23.B "char *cp;
24.PP
c4ed5884 25.B "unsigned long inet_network(cp)
fd221ed5
KM
26.B "char *cp;
27.PP
28.B "char *inet_ntoa(in)
0dc23afe 29.B "struct in_addr in;
fd221ed5
KM
30.PP
31.B "struct in_addr inet_makeaddr(net, lna)
32.B "int net, lna;
33.PP
ed2be010 34.B "unsigned long inet_lnaof(in)
fd221ed5
KM
35.B "struct in_addr in;
36.PP
ed2be010 37.B "unsigned long inet_netof(in)
fd221ed5
KM
38.B "struct in_addr in;
39.fi
40.SH DESCRIPTION
41The routines
52d539f9 42.IR inet_aton ,
fd221ed5
KM
43.I inet_addr
44and
45.I inet_network
52d539f9 46interpret character strings representing
fd221ed5 47numbers expressed in the Internet standard \*(lq.\*(rq
52d539f9
MK
48notation.
49The
50.I inet_aton
51routine interprets the specified character string as an Internet address,
52placing the address into the structure provided.
53It returns 1 if the string was successfully interpreted,
54or 0 if the string is invalid.
55The
56.I inet_addr
57and
58.I inet_network
59functions return numbers suitable for use
fd221ed5 60as Internet addresses and Internet network
52d539f9
MK
61numbers, respectively.
62The routine
fd221ed5
KM
63.I inet_ntoa
64takes an Internet address and returns an ASCII
65string representing the address in \*(lq.\*(rq
66notation. The routine
67.I inet_makeaddr
68takes an Internet network number and a local
69network address and constructs an Internet address
70from it. The routines
71.I inet_netof
72and
73.I inet_lnaof
74break apart Internet host addresses, returning
75the network number and local network address part,
76respectively.
77.PP
52d539f9 78All Internet addresses are returned in network
fd221ed5
KM
79order (bytes ordered from left to right).
80All network numbers and local address parts are
81returned as machine format integer values.
82.SH "INTERNET ADDRESSES"
83Values specified using the \*(lq.\*(rq notation take one
84of the following forms:
85.RS
86.nf
87a.b.c.d
88a.b.c
89a.b
90a
91.RE
92.fi
93When four parts are specified, each is interpreted
94as a byte of data and assigned, from left to right,
95to the four bytes of an Internet address. Note
96that when an Internet address is viewed as a 32-bit
97integer quantity on the VAX the bytes referred to
98above appear as \*(lqd.c.b.a\*(rq. That is, VAX bytes are
99ordered from right to left.
100.PP
101When a three part address is specified, the last
102part is interpreted as a 16-bit quantity and placed
52d539f9 103in the right-most two bytes of the network address.
fd221ed5
KM
104This makes the three part address format convenient
105for specifying Class B network addresses as
106\*(lq128.net.host\*(rq.
107.PP
108When a two part address is supplied, the last part
109is interpreted as a 24-bit quantity and placed in
110the right most three bytes of the network address.
111This makes the two part address format convenient
112for specifying Class A network addresses as
113\*(lqnet.host\*(rq.
114.PP
115When only one part is given, the value is stored
116directly in the network address without any byte
117rearrangement.
118.PP
119All numbers supplied as \*(lqparts\*(rq in a \*(lq.\*(rq notation
120may be decimal, octal, or hexadecimal, as specified
1453a430 121in the C language (i.e., a leading 0x or 0X implies
fd221ed5
KM
122hexadecimal; otherwise, a leading 0 implies octal;
123otherwise, the number is interpreted as decimal).
124.SH "SEE ALSO"
56e6bd55 125gethostbyname(3), getnetent(3), hosts(5), networks(5),
fd221ed5 126.SH DIAGNOSTICS
a02e9915 127The constant \fBINADDR_NONE\fP is returned by
fd221ed5
KM
128.I inet_addr
129and
130.I inet_network
131for malformed requests.
132.SH BUGS
52d539f9
MK
133The value INADDR_NONE (0xffffffff) is a valid broadcast address, but
134.I inet_addr
135cannot return that value without indicating failure.
136The newer
137.I inet_aton
138function does not share this problem.
fd221ed5 139The problem of host byte ordering versus network byte ordering is
52d539f9 140confusing.
fd221ed5
KM
141The string returned by
142.I inet_ntoa
143resides in a static memory area.
0dc23afe
KM
144.br
145Inet_addr should return a struct in_addr.