date and time created 91/03/07 10:23:53 by bostic
[unix-history] / usr / src / lib / libc / net / inet.3
index eaea5ad..e1f4f78 100644 (file)
@@ -1,47 +1,65 @@
-.\" Copyright (c) 1983 Regents of the University of California.
-.\" All rights reserved.  The Berkeley software License Agreement
-.\" specifies the terms and conditions for redistribution.
+.\" Copyright (c) 1983, 1990 The Regents of the University of California.
+.\" All rights reserved.
 .\"
 .\"
-.\"    @(#)inet.3      5.1 (Berkeley) %G%
+.\" %sccs.include.redist.man%
 .\"
 .\"
-.TH INET 3N "18 July 1983"
+.\"    @(#)inet.3      6.9 (Berkeley) %G%
+.\"
+.TH INET 3 ""
 .UC 5
 .SH NAME
 .UC 5
 .SH NAME
-inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof, inet_netof \- Internet address manipulation routines
+inet_aton, inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof, inet_netof \- Internet address manipulation routines
 .SH SYNOPSIS
 .nf
 .B "#include <sys/socket.h>
 .B "#include <netinet/in.h>
 .B "#include <arpa/inet.h>
 .PP
 .SH SYNOPSIS
 .nf
 .B "#include <sys/socket.h>
 .B "#include <netinet/in.h>
 .B "#include <arpa/inet.h>
 .PP
-.B "struct in_addr inet_addr(cp)
+.B "int inet_aton(cp, pin)
+.B "char *cp;
+.B "struct in_addr *pin;
+.PP
+.B "unsigned long inet_addr(cp)
 .B "char *cp;
 .PP
 .B "char *cp;
 .PP
-.B "int inet_network(cp)
+.B "unsigned long inet_network(cp)
 .B "char *cp;
 .PP
 .B "char *inet_ntoa(in)
 .B "char *cp;
 .PP
 .B "char *inet_ntoa(in)
-.B "struct inet_addr in;
+.B "struct in_addr in;
 .PP
 .B "struct in_addr inet_makeaddr(net, lna)
 .B "int net, lna;
 .PP
 .PP
 .B "struct in_addr inet_makeaddr(net, lna)
 .B "int net, lna;
 .PP
-.B "int inet_lnaof(in)
+.B "unsigned long inet_lnaof(in)
 .B "struct in_addr in;
 .PP
 .B "struct in_addr in;
 .PP
-.B "int inet_netof(in)
+.B "unsigned long inet_netof(in)
 .B "struct in_addr in;
 .fi
 .SH DESCRIPTION
 The routines
 .B "struct in_addr in;
 .fi
 .SH DESCRIPTION
 The routines
+.IR inet_aton ,
 .I inet_addr
 and
 .I inet_network
 .I inet_addr
 and
 .I inet_network
-each interpret character strings representing
+interpret character strings representing
 numbers expressed in the Internet standard \*(lq.\*(rq
 numbers expressed in the Internet standard \*(lq.\*(rq
-notation, returning numbers suitable for use
+notation.
+The
+.I inet_aton
+routine interprets the specified character string as an Internet address,
+placing the address into the structure provided.
+It returns 1 if the string was successfully interpreted,
+or 0 if the string is invalid.
+The
+.I inet_addr
+and
+.I inet_network
+functions return numbers suitable for use
 as Internet addresses and Internet network
 as Internet addresses and Internet network
-numbers, respectively.  The routine
+numbers, respectively.
+The routine
 .I inet_ntoa
 takes an Internet address and returns an ASCII
 string representing the address in \*(lq.\*(rq
 .I inet_ntoa
 takes an Internet address and returns an ASCII
 string representing the address in \*(lq.\*(rq
@@ -57,7 +75,7 @@ break apart Internet host addresses, returning
 the network number and local network address part,
 respectively.
 .PP
 the network number and local network address part,
 respectively.
 .PP
-All Internet address are returned in network
+All Internet addresses are returned in network
 order (bytes ordered from left to right).
 All network numbers and local address parts are
 returned as machine format integer values.
 order (bytes ordered from left to right).
 All network numbers and local address parts are
 returned as machine format integer values.
@@ -82,7 +100,7 @@ ordered from right to left.
 .PP
 When a three part address is specified, the last
 part is interpreted as a 16-bit quantity and placed
 .PP
 When a three part address is specified, the last
 part is interpreted as a 16-bit quantity and placed
-in the right most two bytes of the network address.
+in the right-most two bytes of the network address.
 This makes the three part address format convenient
 for specifying Class B network addresses as
 \*(lq128.net.host\*(rq.
 This makes the three part address format convenient
 for specifying Class B network addresses as
 \*(lq128.net.host\*(rq.
@@ -100,21 +118,28 @@ rearrangement.
 .PP
 All numbers supplied as \*(lqparts\*(rq in a \*(lq.\*(rq notation
 may be decimal, octal, or hexadecimal, as specified
 .PP
 All numbers supplied as \*(lqparts\*(rq in a \*(lq.\*(rq notation
 may be decimal, octal, or hexadecimal, as specified
-in the C language (i.e. a leading 0x or 0X implies
+in the C language (i.e., a leading 0x or 0X implies
 hexadecimal; otherwise, a leading 0 implies octal;
 otherwise, the number is interpreted as decimal).
 .SH "SEE ALSO"
 hexadecimal; otherwise, a leading 0 implies octal;
 otherwise, the number is interpreted as decimal).
 .SH "SEE ALSO"
-gethostent(3N), getnetent(3N), hosts(5), networks(5),
+gethostbyname(3), getnetent(3), hosts(5), networks(5),
 .SH DIAGNOSTICS
 .SH DIAGNOSTICS
-The value \-1 is returned by
+The constant \fBINADDR_NONE\fP is returned by
 .I inet_addr
 and
 .I inet_network
 for malformed requests.
 .SH BUGS
 .I inet_addr
 and
 .I inet_network
 for malformed requests.
 .SH BUGS
+The value INADDR_NONE (0xffffffff) is a valid broadcast address, but
+.I inet_addr
+cannot return that value without indicating failure.
+The newer
+.I inet_aton
+function does not share this problem.
 The problem of host byte ordering versus network byte ordering is
 The problem of host byte ordering versus network byte ordering is
-confusing.  A simple way to specify Class C network addresses in a manner
-similar to that for Class B and Class A is needed.
+confusing.
 The string returned by
 .I inet_ntoa
 resides in a static memory area.
 The string returned by
 .I inet_ntoa
 resides in a static memory area.
+.br
+Inet_addr should return a struct in_addr.