|
|
1.1 root 1: .\" Copyright (c) 1983, 1990 The Regents of the University of California.
2: .\" All rights reserved.
3: .\"
4: .\" Redistribution and use in source and binary forms are permitted provided
5: .\" that: (1) source distributions retain this entire copyright notice and
6: .\" comment, and (2) distributions including binaries display the following
7: .\" acknowledgement: ``This product includes software developed by the
8: .\" University of California, Berkeley and its contributors'' in the
9: .\" documentation or other materials provided with the distribution and in
10: .\" all advertising materials mentioning features or use of this software.
11: .\" Neither the name of the University nor the names of its contributors may
12: .\" be used to endorse or promote products derived from this software without
13: .\" specific prior written permission.
14: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
15: .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
16: .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17: .\"
18: .\" @(#)inet.3 6.9 (Berkeley) 6/23/90
19: .\"
20: .TH INET 3 "June 23, 1990"
21: .UC 5
22: .SH NAME
23: inet_aton, inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof, inet_netof \- Internet address manipulation routines
24: .SH SYNOPSIS
25: .nf
26: .B "#include <sys/socket.h>
27: .B "#include <netinet/in.h>
28: .B "#include <arpa/inet.h>
29: .PP
30: .B "int inet_aton(cp, pin)
31: .B "char *cp;
32: .B "struct in_addr *pin;
33: .PP
34: .B "unsigned long inet_addr(cp)
35: .B "char *cp;
36: .PP
37: .B "unsigned long inet_network(cp)
38: .B "char *cp;
39: .PP
40: .B "char *inet_ntoa(in)
41: .B "struct in_addr in;
42: .PP
43: .B "struct in_addr inet_makeaddr(net, lna)
44: .B "int net, lna;
45: .PP
46: .B "unsigned long inet_lnaof(in)
47: .B "struct in_addr in;
48: .PP
49: .B "unsigned long inet_netof(in)
50: .B "struct in_addr in;
51: .fi
52: .SH DESCRIPTION
53: The routines
54: .IR inet_aton ,
55: .I inet_addr
56: and
57: .I inet_network
58: interpret character strings representing
59: numbers expressed in the Internet standard \*(lq.\*(rq
60: notation.
61: The
62: .I inet_aton
63: routine interprets the specified character string as an Internet address,
64: placing the address into the structure provided.
65: It returns 1 if the string was successfully interpreted,
66: or 0 if the string is invalid.
67: The
68: .I inet_addr
69: and
70: .I inet_network
71: functions return numbers suitable for use
72: as Internet addresses and Internet network
73: numbers, respectively.
74: The routine
75: .I inet_ntoa
76: takes an Internet address and returns an ASCII
77: string representing the address in \*(lq.\*(rq
78: notation. The routine
79: .I inet_makeaddr
80: takes an Internet network number and a local
81: network address and constructs an Internet address
82: from it. The routines
83: .I inet_netof
84: and
85: .I inet_lnaof
86: break apart Internet host addresses, returning
87: the network number and local network address part,
88: respectively.
89: .PP
90: All Internet addresses are returned in network
91: order (bytes ordered from left to right).
92: All network numbers and local address parts are
93: returned as machine format integer values.
94: .SH "INTERNET ADDRESSES"
95: Values specified using the \*(lq.\*(rq notation take one
96: of the following forms:
97: .RS
98: .nf
99: a.b.c.d
100: a.b.c
101: a.b
102: a
103: .RE
104: .fi
105: When four parts are specified, each is interpreted
106: as a byte of data and assigned, from left to right,
107: to the four bytes of an Internet address. Note
108: that when an Internet address is viewed as a 32-bit
109: integer quantity on the VAX the bytes referred to
110: above appear as \*(lqd.c.b.a\*(rq. That is, VAX bytes are
111: ordered from right to left.
112: .PP
113: When a three part address is specified, the last
114: part is interpreted as a 16-bit quantity and placed
115: in the right-most two bytes of the network address.
116: This makes the three part address format convenient
117: for specifying Class B network addresses as
118: \*(lq128.net.host\*(rq.
119: .PP
120: When a two part address is supplied, the last part
121: is interpreted as a 24-bit quantity and placed in
122: the right most three bytes of the network address.
123: This makes the two part address format convenient
124: for specifying Class A network addresses as
125: \*(lqnet.host\*(rq.
126: .PP
127: When only one part is given, the value is stored
128: directly in the network address without any byte
129: rearrangement.
130: .PP
131: All numbers supplied as \*(lqparts\*(rq in a \*(lq.\*(rq notation
132: may be decimal, octal, or hexadecimal, as specified
133: in the C language (i.e., a leading 0x or 0X implies
134: hexadecimal; otherwise, a leading 0 implies octal;
135: otherwise, the number is interpreted as decimal).
136: .SH "SEE ALSO"
137: gethostbyname(3), getnetent(3), hosts(5), networks(5),
138: .SH DIAGNOSTICS
139: The constant \fBINADDR_NONE\fP is returned by
140: .I inet_addr
141: and
142: .I inet_network
143: for malformed requests.
144: .SH BUGS
145: The value INADDR_NONE (0xffffffff) is a valid broadcast address, but
146: .I inet_addr
147: cannot return that value without indicating failure.
148: The newer
149: .I inet_aton
150: function does not share this problem.
151: The problem of host byte ordering versus network byte ordering is
152: confusing.
153: The string returned by
154: .I inet_ntoa
155: resides in a static memory area.
156: .br
157: Inet_addr should return a struct in_addr.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.