summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormarc <>2002-10-26 22:01:15 +0000
committermarc <>2002-10-26 22:01:15 +0000
commitdcd173929c160a1b0b50e92ba7c83d94bea3d2b2 (patch)
tree0ae29f404f774a9ebb2be81e32ebabb06d1bda68 /src
parent39bf6988a4040725ab1edbf3af976135c611ab6f (diff)
downloadopenbsd-dcd173929c160a1b0b50e92ba7c83d94bea3d2b2.tar.gz
openbsd-dcd173929c160a1b0b50e92ba7c83d94bea3d2b2.tar.bz2
openbsd-dcd173929c160a1b0b50e92ba7c83d94bea3d2b2.zip
Describe the actual operation of inet_net_pton with a few examples.
Also add caution regarding dst field initialization. operation text OK millert@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/net/inet_net.397
1 files changed, 65 insertions, 32 deletions
diff --git a/src/lib/libc/net/inet_net.3 b/src/lib/libc/net/inet_net.3
index 5c32aecd86..fcdca84ec2 100644
--- a/src/lib/libc/net/inet_net.3
+++ b/src/lib/libc/net/inet_net.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: inet_net.3,v 1.6 2000/04/21 15:38:17 aaron Exp $ 1.\" $OpenBSD: inet_net.3,v 1.7 2002/10/26 22:01:15 marc Exp $
2.\" $NetBSD: inet_net.3,v 1.1 1997/06/18 02:25:27 lukem Exp $ 2.\" $NetBSD: inet_net.3,v 1.1 1997/06/18 02:25:27 lukem Exp $
3.\" 3.\"
4.\" Copyright (c) 1997 The NetBSD Foundation, Inc. 4.\" Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -82,6 +82,14 @@ It will be set to
82.Er ENOENT 82.Er ENOENT
83if the Internet network number was not valid). 83if the Internet network number was not valid).
84.Pp 84.Pp
85Caution:
86The
87.Fa dst
88field should be zeroed before calling
89.Fn inet_net_pton
90as the function will only fill the number of bytes necessary to
91encode the network number in network byte order.
92.Pp
85The only value for 93The only value for
86.Fa af 94.Fa af
87currently supported is 95currently supported is
@@ -90,42 +98,66 @@ currently supported is
90is the size of the result buffer 98is the size of the result buffer
91.Fa dst . 99.Fa dst .
92.Sh NETWORK NUMBERS (IP VERSION 4) 100.Sh NETWORK NUMBERS (IP VERSION 4)
93Internet network numbers may be specified in one of the following forms: 101The external representation of Internet network numbers may be specified in
102one of the following forms:
94.Bd -literal -offset indent 103.Bd -literal -offset indent
95a.b.c.d/bits
96a.b.c.d
97a.b.c
98a.b
99a 104a
105a.b
106a.b.c
107a.b.c.d
100.Ed 108.Ed
101.Pp 109.Pp
102When four parts are specified, each is interpreted 110Any of the above four forms may have
103as a byte of data and assigned, from left to right, 111.Dq Li /bits
104to the four bytes of an Internet network number. 112appended where
105Note that when an Internet network number is viewed as a 32-bit 113.Dq Li bits
106integer quantity on a system that uses little-endian 114is in the range
107byte order (such as the Intel 386, 486, and Pentium processors) 115.Li 0-32
108the bytes referred to above appear as 116and is used to explicitly specify the number of bits in the network address.
109.Dq Li d.c.b.a . 117When
110That is, little-endian bytes are ordered from right to left. 118.Dq Li /bits
119is not specified the number of bits in the network address is calculated
120as the larger of the number of bits in the class to which the address
121belongs and the number of bits provided rounded up modulo 8.
122Examples:
123.Bl -tag -width 10.1.2.3/24
124.It Li 10
125an 8 bit network number (class A), value
126.Li 10.0.0.0 .
127.It Li 192
128a 24 bit network number (class C), value
129.Li 192.0.0.0 .
130.It Li 10.10
131a 16 bit network number, value
132.Li 10.10.0.0 .
133.It Li 10.1.2.0
134a 24 bit network number, value
135.Li 10.1.2.0 .
136.It Li 10.1.2.3
137a 32 bit network number, value
138.Li 10.1.2.3 .
139.It Li 10.1.2.3/24
140a 24 bit network number (explicit), value
141.Li 10.1.2.3 .
142.El
111.Pp 143.Pp
112When a three part number is specified, the last 144Note that when the number of bits is especified using
113part is interpreted as a 16-bit quantity and placed 145.Dq Li /bits
114in the rightmost two bytes of the Internet network number. 146notation the value of the address still includes all bits suplied
115This makes the three part number format convenient 147in the external representation, even those bits which are the host
116for specifying Class B network numbers as 148part of an internet address.
117.Dq Li 128.net.host . 149Also, unlike
118.Pp 150.Xr inet_pton 3
119When a two part number is supplied, the last part 151where the external representation is assumed to be an internet address, the
120is interpreted as a 24-bit quantity and placed in 152external representation for
121the rightmost three bytes of the Internet network number. 153.Fn inet_net_pton
122This makes the two part number format convenient 154is assumed to be a network address.
123for specifying Class A network numbers as 155Thus
124.Dq Li net.host . 156.Dq Li 10.1
125.Pp 157is assumed to be
126When only one part is given, the value is stored 158.Dq Li 10.1.0.0
127directly in the Internet network number without any byte 159not
128rearrangement. 160.Dq Li 10.0.0.1
129.Pp 161.Pp
130All numbers supplied as 162All numbers supplied as
131.Dq parts 163.Dq parts
@@ -139,6 +171,7 @@ otherwise, the number is interpreted as decimal).
139.Sh SEE ALSO 171.Sh SEE ALSO
140.Xr byteorder 3 , 172.Xr byteorder 3 ,
141.Xr inet 3 , 173.Xr inet 3 ,
174.Xr inet_pton 3,
142.Xr networks 5 175.Xr networks 5
143.Sh HISTORY 176.Sh HISTORY
144The 177The