Commit | Line | Data |
---|---|---|
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 | 11 | inet_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 | |
41 | The routines | |
52d539f9 | 42 | .IR inet_aton , |
fd221ed5 KM |
43 | .I inet_addr |
44 | and | |
45 | .I inet_network | |
52d539f9 | 46 | interpret character strings representing |
fd221ed5 | 47 | numbers expressed in the Internet standard \*(lq.\*(rq |
52d539f9 MK |
48 | notation. |
49 | The | |
50 | .I inet_aton | |
51 | routine interprets the specified character string as an Internet address, | |
52 | placing the address into the structure provided. | |
53 | It returns 1 if the string was successfully interpreted, | |
54 | or 0 if the string is invalid. | |
55 | The | |
56 | .I inet_addr | |
57 | and | |
58 | .I inet_network | |
59 | functions return numbers suitable for use | |
fd221ed5 | 60 | as Internet addresses and Internet network |
52d539f9 MK |
61 | numbers, respectively. |
62 | The routine | |
fd221ed5 KM |
63 | .I inet_ntoa |
64 | takes an Internet address and returns an ASCII | |
65 | string representing the address in \*(lq.\*(rq | |
66 | notation. The routine | |
67 | .I inet_makeaddr | |
68 | takes an Internet network number and a local | |
69 | network address and constructs an Internet address | |
70 | from it. The routines | |
71 | .I inet_netof | |
72 | and | |
73 | .I inet_lnaof | |
74 | break apart Internet host addresses, returning | |
75 | the network number and local network address part, | |
76 | respectively. | |
77 | .PP | |
52d539f9 | 78 | All Internet addresses are returned in network |
fd221ed5 KM |
79 | order (bytes ordered from left to right). |
80 | All network numbers and local address parts are | |
81 | returned as machine format integer values. | |
82 | .SH "INTERNET ADDRESSES" | |
83 | Values specified using the \*(lq.\*(rq notation take one | |
84 | of the following forms: | |
85 | .RS | |
86 | .nf | |
87 | a.b.c.d | |
88 | a.b.c | |
89 | a.b | |
90 | a | |
91 | .RE | |
92 | .fi | |
93 | When four parts are specified, each is interpreted | |
94 | as a byte of data and assigned, from left to right, | |
95 | to the four bytes of an Internet address. Note | |
96 | that when an Internet address is viewed as a 32-bit | |
97 | integer quantity on the VAX the bytes referred to | |
98 | above appear as \*(lqd.c.b.a\*(rq. That is, VAX bytes are | |
99 | ordered from right to left. | |
100 | .PP | |
101 | When a three part address is specified, the last | |
102 | part is interpreted as a 16-bit quantity and placed | |
52d539f9 | 103 | in the right-most two bytes of the network address. |
fd221ed5 KM |
104 | This makes the three part address format convenient |
105 | for specifying Class B network addresses as | |
106 | \*(lq128.net.host\*(rq. | |
107 | .PP | |
108 | When a two part address is supplied, the last part | |
109 | is interpreted as a 24-bit quantity and placed in | |
110 | the right most three bytes of the network address. | |
111 | This makes the two part address format convenient | |
112 | for specifying Class A network addresses as | |
113 | \*(lqnet.host\*(rq. | |
114 | .PP | |
115 | When only one part is given, the value is stored | |
116 | directly in the network address without any byte | |
117 | rearrangement. | |
118 | .PP | |
119 | All numbers supplied as \*(lqparts\*(rq in a \*(lq.\*(rq notation | |
120 | may be decimal, octal, or hexadecimal, as specified | |
1453a430 | 121 | in the C language (i.e., a leading 0x or 0X implies |
fd221ed5 KM |
122 | hexadecimal; otherwise, a leading 0 implies octal; |
123 | otherwise, the number is interpreted as decimal). | |
124 | .SH "SEE ALSO" | |
56e6bd55 | 125 | gethostbyname(3), getnetent(3), hosts(5), networks(5), |
fd221ed5 | 126 | .SH DIAGNOSTICS |
a02e9915 | 127 | The constant \fBINADDR_NONE\fP is returned by |
fd221ed5 KM |
128 | .I inet_addr |
129 | and | |
130 | .I inet_network | |
131 | for malformed requests. | |
132 | .SH BUGS | |
52d539f9 MK |
133 | The value INADDR_NONE (0xffffffff) is a valid broadcast address, but |
134 | .I inet_addr | |
135 | cannot return that value without indicating failure. | |
136 | The newer | |
137 | .I inet_aton | |
138 | function does not share this problem. | |
fd221ed5 | 139 | The problem of host byte ordering versus network byte ordering is |
52d539f9 | 140 | confusing. |
fd221ed5 KM |
141 | The string returned by |
142 | .I inet_ntoa | |
143 | resides in a static memory area. | |
0dc23afe KM |
144 | .br |
145 | Inet_addr should return a struct in_addr. |