diff options
author | millert <> | 1997-06-23 03:37:26 +0000 |
---|---|---|
committer | millert <> | 1997-06-23 03:37:26 +0000 |
commit | 21b19e643bd28ad9e897d913fd2ce5c9dcfea686 (patch) | |
tree | 41260bf97c2defacc9712aee20bf6c70bd964494 | |
parent | c3e30a5029a7be2fa6f7521f978a5fcb45134113 (diff) | |
download | openbsd-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.inc | 6 | ||||
-rw-r--r-- | src/lib/libc/net/inet_net.3 | 149 |
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 | ||
22 | MAN+= byteorder.3 ethers.3 gethostbyname.3 getnetent.3 getprotoent.3 \ | 22 | MAN+= 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 | ||
26 | MLINKS+=byteorder.3 htonl.3 byteorder.3 htons.3 byteorder.3 ntohl.3 \ | 26 | MLINKS+=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 | ||
54 | The | ||
55 | .Fn inet_net_ntop | ||
56 | function converts an Internet network number from network format (usually a | ||
57 | .Ft struct in_addr | ||
58 | or some other binary form, in network byte order) to CIDR presentation format | ||
59 | (suitable for external display purposes). | ||
60 | .Fa bits | ||
61 | is the number of bits in | ||
62 | .Fa src | ||
63 | that are the network number. | ||
64 | It returns NULL if a system error occurs (in which case, | ||
65 | .Va errno | ||
66 | will have been set), or it returns a pointer to the destination string. | ||
67 | .Pp | ||
68 | The | ||
69 | .Fn inet_net_pton | ||
70 | function converts a presentation format Internet network number (that is, | ||
71 | printable form as held in a character string) to network format (usually a | ||
72 | .Ft struct in_addr | ||
73 | or some other internal binary representation, in network byte order). | ||
74 | It returns the number of bits (either computed based on the class, or | ||
75 | specified with /CIDR), or -1 if a failure occurred | ||
76 | (in which case | ||
77 | .Va errno | ||
78 | will have been set. | ||
79 | It will be set to | ||
80 | .Er ENOENT | ||
81 | if the Internet network number was not valid). | ||
82 | .Pp | ||
83 | The currently supported value for | ||
84 | .Fa af | ||
85 | is: AF_INET. | ||
86 | .Fa size | ||
87 | is the size of the result buffer | ||
88 | .Fa dst . | ||
89 | .Pp | ||
90 | .Sh NETWORK NUMBERS (IP VERSION 4) | ||
91 | Internet network numbers may be specified in one of the following forms: | ||
92 | .Bd -literal -offset indent | ||
93 | a.b.c.d/bits | ||
94 | a.b.c.d | ||
95 | a.b.c | ||
96 | a.b | ||
97 | a | ||
98 | .Ed | ||
99 | .Pp | ||
100 | When four parts are specified, each is interpreted | ||
101 | as a byte of data and assigned, from left to right, | ||
102 | to the four bytes of an Internet network number. Note | ||
103 | that when an Internet network number is viewed as a 32-bit | ||
104 | integer quantity on a system that uses little-endian | ||
105 | byte order (such as the | ||
106 | .Tn Intel 386, 486 | ||
107 | and | ||
108 | .Tn Pentium | ||
109 | processors) the bytes referred to above appear as | ||
110 | .Dq Li d.c.b.a . | ||
111 | That is, little-endian bytes are ordered from right to left. | ||
112 | .Pp | ||
113 | When a three part number is specified, the last | ||
114 | part is interpreted as a 16-bit quantity and placed | ||
115 | in the right-most two bytes of the Internet network number. | ||
116 | This makes the three part number format convenient | ||
117 | for specifying Class B network numbers as | ||
118 | .Dq Li 128.net.host . | ||
119 | .Pp | ||
120 | When a two part number is supplied, the last part | ||
121 | is interpreted as a 24-bit quantity and placed in | ||
122 | the right most three bytes of the Internet network number. | ||
123 | This makes the two part number format convenient | ||
124 | for specifying Class A network numbers as | ||
125 | .Dq Li net.host . | ||
126 | .Pp | ||
127 | When only one part is given, the value is stored | ||
128 | directly in the Internet network number without any byte | ||
129 | rearrangement. | ||
130 | .Pp | ||
131 | All numbers supplied as | ||
132 | .Dq parts | ||
133 | in a | ||
134 | .Ql \&. | ||
135 | notation | ||
136 | may be decimal, octal, or hexadecimal, as specified | ||
137 | in the C language (i.e., a leading 0x or 0X implies | ||
138 | hexadecimal; otherwise, a leading 0 implies octal; | ||
139 | otherwise, 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 | ||
145 | The | ||
146 | .Nm inet_net_ntop | ||
147 | and | ||
148 | .Nm inet_net_pton | ||
149 | functions first appeared in BIND 4.9.4. | ||