Commit | Line | Data |
---|---|---|
fd221ed5 KM |
1 | .\" Copyright (c) 1983 Regents of the University of California. |
2 | .\" All rights reserved. The Berkeley software License Agreement | |
3 | .\" specifies the terms and conditions for redistribution. | |
4 | .\" | |
0dc23afe | 5 | .\" @(#)inet.3 6.1 (Berkeley) %G% |
fd221ed5 | 6 | .\" |
0dc23afe | 7 | .TH INET 3N "" |
fd221ed5 KM |
8 | .UC 5 |
9 | .SH NAME | |
10 | inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof, inet_netof \- Internet address manipulation routines | |
11 | .SH SYNOPSIS | |
12 | .nf | |
13 | .B "#include <sys/socket.h> | |
14 | .B "#include <netinet/in.h> | |
15 | .B "#include <arpa/inet.h> | |
16 | .PP | |
0dc23afe | 17 | .B "unsigned long inet_addr(cp) |
fd221ed5 KM |
18 | .B "char *cp; |
19 | .PP | |
20 | .B "int inet_network(cp) | |
21 | .B "char *cp; | |
22 | .PP | |
23 | .B "char *inet_ntoa(in) | |
0dc23afe | 24 | .B "struct in_addr in; |
fd221ed5 KM |
25 | .PP |
26 | .B "struct in_addr inet_makeaddr(net, lna) | |
27 | .B "int net, lna; | |
28 | .PP | |
29 | .B "int inet_lnaof(in) | |
30 | .B "struct in_addr in; | |
31 | .PP | |
32 | .B "int inet_netof(in) | |
33 | .B "struct in_addr in; | |
34 | .fi | |
35 | .SH DESCRIPTION | |
36 | The routines | |
37 | .I inet_addr | |
38 | and | |
39 | .I inet_network | |
40 | each interpret character strings representing | |
41 | numbers expressed in the Internet standard \*(lq.\*(rq | |
42 | notation, returning numbers suitable for use | |
43 | as Internet addresses and Internet network | |
44 | numbers, respectively. The routine | |
45 | .I inet_ntoa | |
46 | takes an Internet address and returns an ASCII | |
47 | string representing the address in \*(lq.\*(rq | |
48 | notation. The routine | |
49 | .I inet_makeaddr | |
50 | takes an Internet network number and a local | |
51 | network address and constructs an Internet address | |
52 | from it. The routines | |
53 | .I inet_netof | |
54 | and | |
55 | .I inet_lnaof | |
56 | break apart Internet host addresses, returning | |
57 | the network number and local network address part, | |
58 | respectively. | |
59 | .PP | |
60 | All Internet address are returned in network | |
61 | order (bytes ordered from left to right). | |
62 | All network numbers and local address parts are | |
63 | returned as machine format integer values. | |
64 | .SH "INTERNET ADDRESSES" | |
65 | Values specified using the \*(lq.\*(rq notation take one | |
66 | of the following forms: | |
67 | .RS | |
68 | .nf | |
69 | a.b.c.d | |
70 | a.b.c | |
71 | a.b | |
72 | a | |
73 | .RE | |
74 | .fi | |
75 | When four parts are specified, each is interpreted | |
76 | as a byte of data and assigned, from left to right, | |
77 | to the four bytes of an Internet address. Note | |
78 | that when an Internet address is viewed as a 32-bit | |
79 | integer quantity on the VAX the bytes referred to | |
80 | above appear as \*(lqd.c.b.a\*(rq. That is, VAX bytes are | |
81 | ordered from right to left. | |
82 | .PP | |
83 | When a three part address is specified, the last | |
84 | part is interpreted as a 16-bit quantity and placed | |
85 | in the right most two bytes of the network address. | |
86 | This makes the three part address format convenient | |
87 | for specifying Class B network addresses as | |
88 | \*(lq128.net.host\*(rq. | |
89 | .PP | |
90 | When a two part address is supplied, the last part | |
91 | is interpreted as a 24-bit quantity and placed in | |
92 | the right most three bytes of the network address. | |
93 | This makes the two part address format convenient | |
94 | for specifying Class A network addresses as | |
95 | \*(lqnet.host\*(rq. | |
96 | .PP | |
97 | When only one part is given, the value is stored | |
98 | directly in the network address without any byte | |
99 | rearrangement. | |
100 | .PP | |
101 | All numbers supplied as \*(lqparts\*(rq in a \*(lq.\*(rq notation | |
102 | may be decimal, octal, or hexadecimal, as specified | |
103 | in the C language (i.e. a leading 0x or 0X implies | |
104 | hexadecimal; otherwise, a leading 0 implies octal; | |
105 | otherwise, the number is interpreted as decimal). | |
106 | .SH "SEE ALSO" | |
107 | gethostent(3N), getnetent(3N), hosts(5), networks(5), | |
108 | .SH DIAGNOSTICS | |
109 | The value \-1 is returned by | |
110 | .I inet_addr | |
111 | and | |
112 | .I inet_network | |
113 | for malformed requests. | |
114 | .SH BUGS | |
115 | The problem of host byte ordering versus network byte ordering is | |
116 | confusing. A simple way to specify Class C network addresses in a manner | |
117 | similar to that for Class B and Class A is needed. | |
118 | The string returned by | |
119 | .I inet_ntoa | |
120 | resides in a static memory area. | |
0dc23afe KM |
121 | .br |
122 | Inet_addr should return a struct in_addr. |