diff options
Diffstat (limited to 'src/lib/libc/net/inet_net_ntop.3')
-rw-r--r-- | src/lib/libc/net/inet_net_ntop.3 | 195 |
1 files changed, 0 insertions, 195 deletions
diff --git a/src/lib/libc/net/inet_net_ntop.3 b/src/lib/libc/net/inet_net_ntop.3 deleted file mode 100644 index 4212af3bb6..0000000000 --- a/src/lib/libc/net/inet_net_ntop.3 +++ /dev/null | |||
@@ -1,195 +0,0 @@ | |||
1 | .\" $OpenBSD: inet_net_ntop.3,v 1.4 2022/09/11 06:38:10 jmc 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 | .\" | ||
19 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | ||
20 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | ||
21 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
22 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE | ||
23 | .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
24 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
25 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
26 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
27 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
28 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
29 | .\" POSSIBILITY OF SUCH DAMAGE. | ||
30 | .\" | ||
31 | .Dd $Mdocdate: September 11 2022 $ | ||
32 | .Dt INET_NET_NTOP 3 | ||
33 | .Os | ||
34 | .Sh NAME | ||
35 | .Nm inet_net_ntop , | ||
36 | .Nm inet_net_pton | ||
37 | .Nd Internet network number manipulation routines | ||
38 | .Sh SYNOPSIS | ||
39 | .In sys/socket.h | ||
40 | .In arpa/inet.h | ||
41 | .Ft char * | ||
42 | .Fn inet_net_ntop "int af" "const void *src" "int bits" "char *dst" "size_t size" | ||
43 | .Ft int | ||
44 | .Fn inet_net_pton "int af" "const char *src" "void *dst" "size_t size" | ||
45 | .Sh DESCRIPTION | ||
46 | The | ||
47 | .Fn inet_net_ntop | ||
48 | function converts an Internet network number from network format (usually a | ||
49 | .Vt struct in_addr | ||
50 | or some other binary form, in network byte order) to CIDR presentation format | ||
51 | (suitable for external display purposes). | ||
52 | .Fa bits | ||
53 | is the number of bits in | ||
54 | .Fa src | ||
55 | that are the network number. | ||
56 | It returns | ||
57 | .Dv NULL | ||
58 | if a system error occurs (in which case, | ||
59 | .Va errno | ||
60 | will have been set), or it returns a pointer to the destination string. | ||
61 | .Pp | ||
62 | The | ||
63 | .Fn inet_net_pton | ||
64 | function converts a presentation format Internet network number (that is, | ||
65 | printable form as held in a character string) to network format (usually a | ||
66 | .Vt struct in_addr | ||
67 | or some other internal binary representation, in network byte order). | ||
68 | It returns the number of bits (either computed based on the class, or | ||
69 | specified with /CIDR), or \-1 if a failure occurred | ||
70 | (in which case | ||
71 | .Va errno | ||
72 | will have been set. | ||
73 | It will be set to | ||
74 | .Er ENOENT | ||
75 | if the Internet network number was not valid). | ||
76 | .Pp | ||
77 | Caution: | ||
78 | The | ||
79 | .Fa dst | ||
80 | field should be zeroed before calling | ||
81 | .Fn inet_net_pton | ||
82 | as the function will only fill the number of bytes necessary to | ||
83 | encode the network number in network byte order. | ||
84 | .Pp | ||
85 | The only values for | ||
86 | .Fa af | ||
87 | currently supported are | ||
88 | .Dv AF_INET | ||
89 | and | ||
90 | .Dv AF_INET6 . | ||
91 | .Fa size | ||
92 | is the size of the result buffer | ||
93 | .Fa dst . | ||
94 | .Sh NETWORK NUMBERS (IP VERSION 4) | ||
95 | The external representation of Internet network numbers may be specified in | ||
96 | one of the following forms: | ||
97 | .Bd -literal -offset indent | ||
98 | a | ||
99 | a.b | ||
100 | a.b.c | ||
101 | a.b.c.d | ||
102 | .Ed | ||
103 | .Pp | ||
104 | Any of the above four forms may have | ||
105 | .Dq Li /bits | ||
106 | appended where | ||
107 | .Dq Li bits | ||
108 | is in the range | ||
109 | .Li 0-32 | ||
110 | and is used to explicitly specify the number of bits in the network address. | ||
111 | When | ||
112 | .Dq Li /bits | ||
113 | is not specified, the number of bits in the network address is calculated | ||
114 | as the larger of the number of bits in the class to which the address | ||
115 | belongs and the number of bits provided rounded up modulo 8. | ||
116 | Examples: | ||
117 | .Pp | ||
118 | .Bl -tag -width 10.1.2.3/24 -offset indent -compact | ||
119 | .It Li 10 | ||
120 | an 8-bit network number (class A), value | ||
121 | .Li 10.0.0.0 . | ||
122 | .It Li 192 | ||
123 | a 24-bit network number (class C), value | ||
124 | .Li 192.0.0.0 . | ||
125 | .It Li 10.10 | ||
126 | a 16-bit network number, value | ||
127 | .Li 10.10.0.0 . | ||
128 | .It Li 10.1.2 | ||
129 | a 24-bit network number, value | ||
130 | .Li 10.1.2.0 . | ||
131 | .It Li 10.1.2.3 | ||
132 | a 32-bit network number, value | ||
133 | .Li 10.1.2.3 . | ||
134 | .It Li 10.1.2.3/24 | ||
135 | a 24-bit network number (explicit), value | ||
136 | .Li 10.1.2.3 . | ||
137 | .El | ||
138 | .Pp | ||
139 | Note that when the number of bits is specified using | ||
140 | .Dq Li /bits | ||
141 | notation, the value of the address still includes all bits supplied | ||
142 | in the external representation, even those bits which are the host | ||
143 | part of an Internet address. | ||
144 | Also, unlike | ||
145 | .Xr inet_pton 3 | ||
146 | where the external representation is assumed to be a host address, the | ||
147 | external representation for | ||
148 | .Fn inet_net_pton | ||
149 | is assumed to be a network address. | ||
150 | Thus | ||
151 | .Dq Li 10.1 | ||
152 | is assumed to be | ||
153 | .Dq Li 10.1.0.0 | ||
154 | not | ||
155 | .Dq Li 10.0.0.1 | ||
156 | .Pp | ||
157 | All numbers supplied as | ||
158 | .Dq parts | ||
159 | in a | ||
160 | .Ql \&. | ||
161 | notation | ||
162 | may be decimal, octal, or hexadecimal, as specified | ||
163 | in the C language (i.e., a leading 0x or 0X implies | ||
164 | hexadecimal; otherwise, a leading 0 implies octal; | ||
165 | otherwise, the number is interpreted as decimal). | ||
166 | .Sh NETWORK NUMBERS (IP VERSION 6) | ||
167 | See | ||
168 | .Xr inet_pton 3 | ||
169 | for valid external representations of IP version 6 addresses. | ||
170 | A valid external representation may have | ||
171 | .Dq Li /bits | ||
172 | appended where | ||
173 | .Dq Li bits | ||
174 | is in the range | ||
175 | .Li 0-128 | ||
176 | and is used to explicitly specify the number of bits in the network address. | ||
177 | When | ||
178 | .Dq Li /bits | ||
179 | is not specified, 128 is used. | ||
180 | Note that when the number of bits is specified using | ||
181 | .Dq Li /bits | ||
182 | notation, the value of the address still includes all bits supplied | ||
183 | in the external representation, even those bits which are the host | ||
184 | part of an Internet address. | ||
185 | .Sh SEE ALSO | ||
186 | .Xr htonl 3 , | ||
187 | .Xr inet_pton 3 , | ||
188 | .Xr inet 4 , | ||
189 | .Xr hosts 5 | ||
190 | .Sh HISTORY | ||
191 | The | ||
192 | .Nm inet_net_ntop | ||
193 | and | ||
194 | .Nm inet_net_pton | ||
195 | functions first appeared in BIND 4.9.4. | ||