summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormillert <>1997-06-23 03:37:26 +0000
committermillert <>1997-06-23 03:37:26 +0000
commit21b19e643bd28ad9e897d913fd2ce5c9dcfea686 (patch)
tree41260bf97c2defacc9712aee20bf6c70bd964494
parentc3e30a5029a7be2fa6f7521f978a5fcb45134113 (diff)
downloadopenbsd-21b19e643bd28ad9e897d913fd2ce5c9dcfea686.tar.gz
openbsd-21b19e643bd28ad9e897d913fd2ce5c9dcfea686.tar.bz2
openbsd-21b19e643bd28ad9e897d913fd2ce5c9dcfea686.zip
Add man page for inet_net_ntop(3) and inet_net_pton(3) from NetBSD (lukem)
-rw-r--r--src/lib/libc/net/Makefile.inc6
-rw-r--r--src/lib/libc/net/inet_net.3149
2 files changed, 152 insertions, 3 deletions
diff --git a/src/lib/libc/net/Makefile.inc b/src/lib/libc/net/Makefile.inc
index 4272b1ddde..e1adae4693 100644
--- a/src/lib/libc/net/Makefile.inc
+++ b/src/lib/libc/net/Makefile.inc
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile.inc,v 1.10 1997/04/13 22:37:17 provos Exp $ 1# $OpenBSD: Makefile.inc,v 1.11 1997/06/23 03:37:24 millert Exp $
2 2
3# net sources 3# net sources
4.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/net ${.CURDIR}/net 4.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/net ${.CURDIR}/net
@@ -20,8 +20,8 @@ SRCS+= base64.c gethostnamadr.c getnetbyaddr.c getnetbyname.c getnetent.c \
20.include "${.CURDIR}/arch/${MACHINE_ARCH}/net/Makefile.inc" 20.include "${.CURDIR}/arch/${MACHINE_ARCH}/net/Makefile.inc"
21 21
22MAN+= byteorder.3 ethers.3 gethostbyname.3 getnetent.3 getprotoent.3 \ 22MAN+= byteorder.3 ethers.3 gethostbyname.3 getnetent.3 getprotoent.3 \
23 getservent.3 inet.3 iso_addr.3 link_addr.3 ns.3 ipx.3 rcmd.3 rcmdsh.3 \ 23 getservent.3 inet.3 inet_net.3 iso_addr.3 link_addr.3 ns.3 ipx.3 \
24 resolver.3 24 rcmd.3 rcmdsh.3 resolver.3
25 25
26MLINKS+=byteorder.3 htonl.3 byteorder.3 htons.3 byteorder.3 ntohl.3 \ 26MLINKS+=byteorder.3 htonl.3 byteorder.3 htons.3 byteorder.3 ntohl.3 \
27 byteorder.3 ntohs.3 27 byteorder.3 ntohs.3
diff --git a/src/lib/libc/net/inet_net.3 b/src/lib/libc/net/inet_net.3
new file mode 100644
index 0000000000..1a42aff6ea
--- /dev/null
+++ b/src/lib/libc/net/inet_net.3
@@ -0,0 +1,149 @@
1.\" $OpenBSD: inet_net.3,v 1.1 1997/06/23 03:37:26 millert Exp $
2.\" $NetBSD: inet_net.3,v 1.1 1997/06/18 02:25:27 lukem Exp $
3.\"
4.\" Copyright (c) 1997 The NetBSD Foundation, Inc.
5.\" All rights reserved.
6.\"
7.\" This code is derived from software contributed to The NetBSD Foundation
8.\" by Luke Mewburn.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in the
17.\" documentation and/or other materials provided with the distribution.
18.\" 3. All advertising materials mentioning features or use of this software
19.\" must display the following acknowledgement:
20.\" This product includes software developed by the NetBSD
21.\" Foundation, Inc. and its contributors.
22.\" 4. Neither the name of The NetBSD Foundation nor the names of its
23.\" contributors may be used to endorse or promote products derived
24.\" from this software without specific prior written permission.
25.\"
26.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
30.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36.\" POSSIBILITY OF SUCH DAMAGE.
37.\"
38.Dd June 18, 1997
39.Dt INET_NET 3
40.Os
41.Sh NAME
42.Nm inet_net_ntop ,
43.Nm inet_net_pton
44.Nd Internet network number manipulation routines
45.Sh SYNOPSIS
46.Fd #include <sys/socket.h>
47.Fd #include <netinet/in.h>
48.Fd #include <arpa/inet.h>
49.Ft char *
50.Fn inet_net_ntop "int af" "const void *src" "int bits" "char *dst" "size_t size"
51.Ft int
52.Fn inet_net_pton "int af" "const char *src" "void *dst" "size_t size"
53.Sh DESCRIPTION
54The
55.Fn inet_net_ntop
56function converts an Internet network number from network format (usually a
57.Ft struct in_addr
58or some other binary form, in network byte order) to CIDR presentation format
59(suitable for external display purposes).
60.Fa bits
61is the number of bits in
62.Fa src
63that are the network number.
64It returns NULL if a system error occurs (in which case,
65.Va errno
66will have been set), or it returns a pointer to the destination string.
67.Pp
68The
69.Fn inet_net_pton
70function converts a presentation format Internet network number (that is,
71printable form as held in a character string) to network format (usually a
72.Ft struct in_addr
73or some other internal binary representation, in network byte order).
74It returns the number of bits (either computed based on the class, or
75specified with /CIDR), or -1 if a failure occurred
76(in which case
77.Va errno
78will have been set.
79It will be set to
80.Er ENOENT
81if the Internet network number was not valid).
82.Pp
83The currently supported value for
84.Fa af
85is: AF_INET.
86.Fa size
87is the size of the result buffer
88.Fa dst .
89.Pp
90.Sh NETWORK NUMBERS (IP VERSION 4)
91Internet network numbers may be specified in one of the following forms:
92.Bd -literal -offset indent
93a.b.c.d/bits
94a.b.c.d
95a.b.c
96a.b
97a
98.Ed
99.Pp
100When four parts are specified, each is interpreted
101as a byte of data and assigned, from left to right,
102to the four bytes of an Internet network number. Note
103that when an Internet network number is viewed as a 32-bit
104integer quantity on a system that uses little-endian
105byte order (such as the
106.Tn Intel 386, 486
107and
108.Tn Pentium
109processors) the bytes referred to above appear as
110.Dq Li d.c.b.a .
111That is, little-endian bytes are ordered from right to left.
112.Pp
113When a three part number is specified, the last
114part is interpreted as a 16-bit quantity and placed
115in the right-most two bytes of the Internet network number.
116This makes the three part number format convenient
117for specifying Class B network numbers as
118.Dq Li 128.net.host .
119.Pp
120When a two part number is supplied, the last part
121is interpreted as a 24-bit quantity and placed in
122the right most three bytes of the Internet network number.
123This makes the two part number format convenient
124for specifying Class A network numbers as
125.Dq Li net.host .
126.Pp
127When only one part is given, the value is stored
128directly in the Internet network number without any byte
129rearrangement.
130.Pp
131All numbers supplied as
132.Dq parts
133in a
134.Ql \&.
135notation
136may be decimal, octal, or hexadecimal, as specified
137in the C language (i.e., a leading 0x or 0X implies
138hexadecimal; otherwise, a leading 0 implies octal;
139otherwise, the number is interpreted as decimal).
140.Sh SEE ALSO
141.Xr byteorder 3 ,
142.Xr inet 3 ,
143.Xr networks 5
144.Sh HISTORY
145The
146.Nm inet_net_ntop
147and
148.Nm inet_net_pton
149functions first appeared in BIND 4.9.4.