diff options
author | itojun <> | 2004-12-20 03:27:24 +0000 |
---|---|---|
committer | itojun <> | 2004-12-20 03:27:24 +0000 |
commit | 655d692025086890ec68dab5b54e1a0c7314f020 (patch) | |
tree | 95e8b731a13481a21f8d38ec7aa3c5641eba154e /src/lib | |
parent | 10c6b06b8eb04b679a240d4f3efb6c7a49a92d62 (diff) | |
download | openbsd-655d692025086890ec68dab5b54e1a0c7314f020.tar.gz openbsd-655d692025086890ec68dab5b54e1a0c7314f020.tar.bz2 openbsd-655d692025086890ec68dab5b54e1a0c7314f020.zip |
remove manpages based on RFC. requested by deraadt
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libc/net/Makefile.inc | 8 | ||||
-rw-r--r-- | src/lib/libc/net/gai_strerror.3 | 118 | ||||
-rw-r--r-- | src/lib/libc/net/getaddrinfo.3 | 531 | ||||
-rw-r--r-- | src/lib/libc/net/getnameinfo.3 | 343 | ||||
-rw-r--r-- | src/lib/libc/net/inet6_option_space.3 | 444 | ||||
-rw-r--r-- | src/lib/libc/net/inet6_rthdr_space.3 | 317 |
6 files changed, 4 insertions, 1757 deletions
diff --git a/src/lib/libc/net/Makefile.inc b/src/lib/libc/net/Makefile.inc index 79bfbb6b91..3d959d6be0 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.35 2004/12/06 10:46:35 jmc Exp $ | 1 | # $OpenBSD: Makefile.inc,v 1.36 2004/12/20 03:26:43 itojun Exp $ |
2 | 2 | ||
3 | # net sources | 3 | # net sources |
4 | .PATH: ${LIBCSRCDIR}/arch/${MACHINE_ARCH}/net ${LIBCSRCDIR}/net | 4 | .PATH: ${LIBCSRCDIR}/arch/${MACHINE_ARCH}/net ${LIBCSRCDIR}/net |
@@ -28,10 +28,10 @@ SRCS+= ip6opt.c rthdr.c vars6.c | |||
28 | 28 | ||
29 | .include "${LIBCSRCDIR}/arch/${MACHINE_ARCH}/net/Makefile.inc" | 29 | .include "${LIBCSRCDIR}/arch/${MACHINE_ARCH}/net/Makefile.inc" |
30 | 30 | ||
31 | MAN+= byteorder.3 ethers.3 gai_strerror.3 getaddrinfo.3 gethostbyname.3 \ | 31 | MAN+= byteorder.3 ethers.3 gethostbyname.3 \ |
32 | getifaddrs.3 getnameinfo.3 getnetent.3 getprotoent.3 \ | 32 | getifaddrs.3 getnetent.3 getprotoent.3 \ |
33 | getrrsetbyname.3 getservent.3 if_indextoname.3 inet.3 \ | 33 | getrrsetbyname.3 getservent.3 if_indextoname.3 inet.3 \ |
34 | inet_net.3 inet6_option_space.3 inet6_rthdr_space.3 \ | 34 | inet_net.3 \ |
35 | ipx.3 link_addr.3 net_addrcmp.3 ns.3 \ | 35 | ipx.3 link_addr.3 net_addrcmp.3 ns.3 \ |
36 | rcmd.3 rcmdsh.3 resolver.3 | 36 | rcmd.3 rcmdsh.3 resolver.3 |
37 | 37 | ||
diff --git a/src/lib/libc/net/gai_strerror.3 b/src/lib/libc/net/gai_strerror.3 deleted file mode 100644 index 75eb1517f4..0000000000 --- a/src/lib/libc/net/gai_strerror.3 +++ /dev/null | |||
@@ -1,118 +0,0 @@ | |||
1 | .\" $OpenBSD: gai_strerror.3,v 1.1 2004/12/06 10:46:35 jmc Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1983, 1987, 1991, 1993 | ||
4 | .\" The Regents of the University of California. All rights reserved. | ||
5 | .\" | ||
6 | .\" Redistribution and use in source and binary forms, with or without | ||
7 | .\" modification, are permitted provided that the following conditions | ||
8 | .\" are met: | ||
9 | .\" 1. Redistributions of source code must retain the above copyright | ||
10 | .\" notice, this list of conditions and the following disclaimer. | ||
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
12 | .\" notice, this list of conditions and the following disclaimer in the | ||
13 | .\" documentation and/or other materials provided with the distribution. | ||
14 | .\" 3. Neither the name of the University nor the names of its contributors | ||
15 | .\" may be used to endorse or promote products derived from this software | ||
16 | .\" without specific prior written permission. | ||
17 | .\" | ||
18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
28 | .\" SUCH DAMAGE. | ||
29 | .\" | ||
30 | .Dd December 3, 2004 | ||
31 | .Dt GAI_STRERROR 3 | ||
32 | .Os | ||
33 | .\" | ||
34 | .Sh NAME | ||
35 | .Nm gai_strerror | ||
36 | .Nd return EAI_xxx error message | ||
37 | .\" | ||
38 | .Sh SYNOPSIS | ||
39 | .Fd #include <sys/types.h> | ||
40 | .Fd #include <sys/socket.h> | ||
41 | .Fd #include <netdb.h> | ||
42 | .Ft "char *" | ||
43 | .Fn gai_strerror "int ecode" | ||
44 | .\" | ||
45 | .Sh DESCRIPTION | ||
46 | To aid applications in printing error messages based on the | ||
47 | .Dv EAI_xxx | ||
48 | codes returned by | ||
49 | .Xr getaddrinfo 3 | ||
50 | and | ||
51 | .Xr getnameinfo 3 , | ||
52 | .Fn gai_strerror | ||
53 | is defined. | ||
54 | The argument is one of the | ||
55 | .Dv EAI_xxx | ||
56 | values detailed below | ||
57 | and the return value points to a string describing the error. | ||
58 | If the argument is not one of the | ||
59 | .Dv EAI_xxx | ||
60 | values, | ||
61 | the function still returns a pointer to a string whose contents | ||
62 | indicate an unknown error. | ||
63 | .Pp | ||
64 | The error return status from | ||
65 | .Xr getaddrinfo 3 | ||
66 | and | ||
67 | .Xr getnameinfo 3 | ||
68 | is zero on success and non-zero on errors. | ||
69 | Non-zero error codes are defined in | ||
70 | .Aq Pa netdb.h , | ||
71 | and are as follows: | ||
72 | .Pp | ||
73 | .Bl -tag -width "EAI_ADDRFAMILYXX" -offset indent -compact | ||
74 | .It Dv EAI_ADDRFAMILY | ||
75 | Address family for | ||
76 | .Fa nodename | ||
77 | not supported. | ||
78 | .It Dv EAI_AGAIN | ||
79 | Temporary failure in name resolution. | ||
80 | .It Dv EAI_BADFLAGS | ||
81 | Invalid value for | ||
82 | .Fa ai_flags . | ||
83 | .It Dv EAI_BADHINTS | ||
84 | Invalid value for hints. | ||
85 | .It Dv EAI_FAIL | ||
86 | Non-recoverable failure in name resolution. | ||
87 | .It Dv EAI_FAMILY | ||
88 | .Fa ai_family | ||
89 | not supported. | ||
90 | .It Dv EAI_MEMORY | ||
91 | Memory allocation failure. | ||
92 | .It Dv EAI_NODATA | ||
93 | No address associated with | ||
94 | .Fa nodename . | ||
95 | .It Dv EAI_NONAME | ||
96 | .Fa nodename | ||
97 | nor | ||
98 | .Fa servname | ||
99 | provided, or not known. | ||
100 | .It Dv EAI_PROTOCOL | ||
101 | Resolved protocol is unknown. | ||
102 | .It Dv EAI_SERVICE | ||
103 | .Fa servname | ||
104 | not supported for | ||
105 | .Fa ai_socktype . | ||
106 | .It Dv EAI_SOCKTYPE | ||
107 | .Fa ai_socktype | ||
108 | not supported. | ||
109 | .It Dv EAI_SYSTEM | ||
110 | System error returned in | ||
111 | .Va errno . | ||
112 | .El | ||
113 | .\" | ||
114 | .Sh SEE ALSO | ||
115 | .Xr getaddrinfo 3 , | ||
116 | .Xr getnameinfo 3 | ||
117 | .Sh HISTORY | ||
118 | The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit. | ||
diff --git a/src/lib/libc/net/getaddrinfo.3 b/src/lib/libc/net/getaddrinfo.3 deleted file mode 100644 index e74fdf6ed7..0000000000 --- a/src/lib/libc/net/getaddrinfo.3 +++ /dev/null | |||
@@ -1,531 +0,0 @@ | |||
1 | .\" $OpenBSD: getaddrinfo.3,v 1.29 2004/12/06 10:46:35 jmc Exp $ | ||
2 | .\" $KAME: getaddrinfo.3,v 1.29 2001/02/12 09:24:45 itojun Exp $ | ||
3 | .\" | ||
4 | .\" Copyright (c) 1983, 1987, 1991, 1993 | ||
5 | .\" The Regents of the University of California. All rights reserved. | ||
6 | .\" | ||
7 | .\" Redistribution and use in source and binary forms, with or without | ||
8 | .\" modification, are permitted provided that the following conditions | ||
9 | .\" are met: | ||
10 | .\" 1. Redistributions of source code must retain the above copyright | ||
11 | .\" notice, this list of conditions and the following disclaimer. | ||
12 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
13 | .\" notice, this list of conditions and the following disclaimer in the | ||
14 | .\" documentation and/or other materials provided with the distribution. | ||
15 | .\" 3. Neither the name of the University nor the names of its contributors | ||
16 | .\" may be used to endorse or promote products derived from this software | ||
17 | .\" without specific prior written permission. | ||
18 | .\" | ||
19 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
23 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | .\" SUCH DAMAGE. | ||
30 | .\" | ||
31 | .\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 | ||
32 | .\" | ||
33 | .Dd May 25, 1995 | ||
34 | .Dt GETADDRINFO 3 | ||
35 | .Os | ||
36 | .\" | ||
37 | .Sh NAME | ||
38 | .Nm getaddrinfo , | ||
39 | .Nm freeaddrinfo | ||
40 | .Nd nodename-to-address translation in protocol-independent manner | ||
41 | .\" | ||
42 | .Sh SYNOPSIS | ||
43 | .Fd #include <sys/types.h> | ||
44 | .Fd #include <sys/socket.h> | ||
45 | .Fd #include <netdb.h> | ||
46 | .Ft int | ||
47 | .Fn getaddrinfo "const char *nodename" "const char *servname" \ | ||
48 | "const struct addrinfo *hints" "struct addrinfo **res" | ||
49 | .Ft void | ||
50 | .Fn freeaddrinfo "struct addrinfo *ai" | ||
51 | .\" | ||
52 | .Sh DESCRIPTION | ||
53 | The | ||
54 | .Fn getaddrinfo | ||
55 | function is defined for protocol-independent nodename-to-address translation. | ||
56 | It performs the functionality of | ||
57 | .Xr gethostbyname 3 | ||
58 | and | ||
59 | .Xr getservbyname 3 , | ||
60 | but in a more sophisticated manner. | ||
61 | .Pp | ||
62 | All of the information returned by | ||
63 | .Fn getaddrinfo | ||
64 | is dynamically allocated: | ||
65 | the | ||
66 | .Li addrinfo | ||
67 | structures, the socket address structures, and canonical node name | ||
68 | strings pointed to by the addrinfo structures. | ||
69 | To return this information to the system the function | ||
70 | .Fn freeaddrinfo | ||
71 | is called. | ||
72 | The | ||
73 | .Fa addrinfo | ||
74 | structure pointed to by the | ||
75 | .Fa ai | ||
76 | argument is freed, | ||
77 | along with any dynamic storage pointed to by the structure. | ||
78 | This operation is repeated until a | ||
79 | .Dv NULL | ||
80 | .Fa ai_next | ||
81 | pointer is encountered. | ||
82 | .Pp | ||
83 | To aid applications in printing error messages based on the | ||
84 | .Dv EAI_xxx | ||
85 | codes returned by | ||
86 | .Fn getaddrinfo , | ||
87 | .Fn gai_strerror | ||
88 | is defined. | ||
89 | See | ||
90 | .Xr gai_strerror 3 | ||
91 | for more information. | ||
92 | .Pp | ||
93 | The implementation allows experimental numeric IPv6 address notation with | ||
94 | scope identifier. | ||
95 | By appending the percent character and scope identifier to addresses, | ||
96 | you can fill the | ||
97 | .Li sin6_scope_id | ||
98 | field for addresses. | ||
99 | This would make management of scoped address easier, | ||
100 | and allows cut-and-paste input of scoped address. | ||
101 | .Pp | ||
102 | At this moment the code supports only link-local addresses with the format. | ||
103 | Scope identifier is hardcoded to the name of the hardware interface associated | ||
104 | with the link | ||
105 | .Po | ||
106 | such as | ||
107 | .Li ne0 | ||
108 | .Pc . | ||
109 | An example is | ||
110 | .Dq Li fe80::1%ne0 , | ||
111 | which means | ||
112 | .Do | ||
113 | .Li fe80::1 | ||
114 | on the link associated with the | ||
115 | .Li ne0 | ||
116 | interface | ||
117 | .Dc . | ||
118 | .Pp | ||
119 | The IPv6 implementation is still very experimental and non-standard. | ||
120 | The current implementation assumes a one-to-one relationship between | ||
121 | the interface and link, which is not necessarily true from the specification. | ||
122 | .Pp | ||
123 | The | ||
124 | .Li addrinfo | ||
125 | structure is defined as a result of including the | ||
126 | .Aq Pa netdb.h | ||
127 | header: | ||
128 | .Bd -literal | ||
129 | struct addrinfo { | ||
130 | int ai_flags; /* input flags */ | ||
131 | int ai_family; /* protocol family for socket */ | ||
132 | int ai_socktype; /* socket type */ | ||
133 | int ai_protocol; /* protocol for socket */ | ||
134 | socklen_t ai_addrlen; /* length of socket-address */ | ||
135 | struct sockaddr *ai_addr; /* socket-address for socket */ | ||
136 | char *ai_canonname; /* canonical name for service location */ | ||
137 | struct addrinfo *ai_next; /* pointer to next in list */ | ||
138 | }; | ||
139 | .Ed | ||
140 | .Pp | ||
141 | The | ||
142 | .Fa nodename | ||
143 | and | ||
144 | .Fa servname | ||
145 | arguments are pointers to NUL-terminated strings or | ||
146 | .Dv NULL . | ||
147 | One or both of these two arguments must be a non-null pointer. | ||
148 | In the normal client scenario, both the | ||
149 | .Fa nodename | ||
150 | and | ||
151 | .Fa servname | ||
152 | are specified. | ||
153 | In the normal server scenario, only the | ||
154 | .Fa servname | ||
155 | is specified. | ||
156 | A non-null | ||
157 | .Fa nodename | ||
158 | string can be either a node name or a numeric host address string | ||
159 | (i.e., a dotted-decimal IPv4 address or an IPv6 hex address). | ||
160 | A non-null | ||
161 | .Fa servname | ||
162 | string can be either a service name or a decimal port number. | ||
163 | .Pp | ||
164 | The caller can optionally pass an | ||
165 | .Li addrinfo | ||
166 | structure, pointed to by the third argument, | ||
167 | to provide hints concerning the type of socket that the caller supports. | ||
168 | In this | ||
169 | .Fa hints | ||
170 | structure all members other than | ||
171 | .Fa ai_flags , | ||
172 | .Fa ai_family , | ||
173 | .Fa ai_socktype , | ||
174 | and | ||
175 | .Fa ai_protocol | ||
176 | must be zero or a null pointer. | ||
177 | A value of | ||
178 | .Dv PF_UNSPEC | ||
179 | for | ||
180 | .Fa ai_family | ||
181 | means the caller will accept any protocol family. | ||
182 | A value of 0 for | ||
183 | .Fa ai_socktype | ||
184 | means the caller will accept any socket type. | ||
185 | A value of 0 for | ||
186 | .Fa ai_protocol | ||
187 | means the caller will accept any protocol. | ||
188 | For example, if the caller handles only TCP and not UDP, then the | ||
189 | .Fa ai_socktype | ||
190 | member of the hints structure should be set to | ||
191 | .Dv SOCK_STREAM | ||
192 | when | ||
193 | .Fn getaddrinfo | ||
194 | is called. | ||
195 | If the caller handles only IPv4 and not IPv6, then the | ||
196 | .Fa ai_family | ||
197 | member of the | ||
198 | .Fa hints | ||
199 | structure should be set to | ||
200 | .Dv PF_INET | ||
201 | when | ||
202 | .Fn getaddrinfo | ||
203 | is called. | ||
204 | If the third argument to | ||
205 | .Fn getaddrinfo | ||
206 | is a null pointer, this is the same as if the caller had filled in an | ||
207 | .Li addrinfo | ||
208 | structure initialized to zero with | ||
209 | .Fa ai_family | ||
210 | set to | ||
211 | .Dv PF_UNSPEC . | ||
212 | .Pp | ||
213 | Upon successful return a pointer to a linked list of one or more | ||
214 | .Li addrinfo | ||
215 | structures is returned through the final argument. | ||
216 | The caller can process each | ||
217 | .Li addrinfo | ||
218 | structure in this list by following the | ||
219 | .Fa ai_next | ||
220 | pointer, until a null pointer is encountered. | ||
221 | In each returned | ||
222 | .Li addrinfo | ||
223 | structure the three members | ||
224 | .Fa ai_family , | ||
225 | .Fa ai_socktype , | ||
226 | and | ||
227 | .Fa ai_protocol | ||
228 | are the corresponding arguments for a call to the | ||
229 | .Xr socket 2 | ||
230 | function. | ||
231 | In each | ||
232 | .Li addrinfo | ||
233 | structure the | ||
234 | .Fa ai_addr | ||
235 | member points to a filled-in socket address structure whose length is | ||
236 | specified by the | ||
237 | .Fa ai_addrlen | ||
238 | member. | ||
239 | .Pp | ||
240 | The | ||
241 | .Fa ai_flags | ||
242 | argument can be set to any of the following values, OR'd together: | ||
243 | .Bl -tag -width "AI_NUMERICHOSTXX" | ||
244 | .It AI_PASSIVE | ||
245 | If the | ||
246 | .Dv AI_PASSIVE | ||
247 | bit is set, | ||
248 | the caller plans to use the returned socket address | ||
249 | structure in a call to | ||
250 | .Xr bind 2 . | ||
251 | In this case, if the | ||
252 | .Fa nodename | ||
253 | argument is a null pointer, then the IP address portion of the socket | ||
254 | address structure will be set to | ||
255 | .Dv INADDR_ANY | ||
256 | for an IPv4 address or | ||
257 | .Dv IN6ADDR_ANY_INIT | ||
258 | for an IPv6 address. | ||
259 | .Pp | ||
260 | If the | ||
261 | .Dv AI_PASSIVE | ||
262 | bit is not set, | ||
263 | the returned socket address structure will be ready for a | ||
264 | call to | ||
265 | .Xr connect 2 | ||
266 | .Pq for a connection-oriented protocol | ||
267 | or either | ||
268 | .Xr connect 2 , | ||
269 | .Xr sendto 2 , | ||
270 | or | ||
271 | .Xr sendmsg 2 | ||
272 | .Pq for a connectionless protocol . | ||
273 | In this case, if the | ||
274 | .Fa nodename | ||
275 | argument is a null pointer, then the IP address portion of the | ||
276 | socket address structure will be set to the loopback address. | ||
277 | .It AI_CANONNAME | ||
278 | If the | ||
279 | .Dv AI_CANONNAME | ||
280 | bit is set, | ||
281 | then upon successful return the | ||
282 | .Fa ai_canonname | ||
283 | member of the first | ||
284 | .Li addrinfo | ||
285 | structure in the linked list will point to a NUL-terminated string | ||
286 | containing the canonical name of the specified | ||
287 | .Fa nodename . | ||
288 | .It AI_NUMERICHOST | ||
289 | If the | ||
290 | .Dv AI_NUMERICHOST | ||
291 | bit is set, | ||
292 | then a non-null | ||
293 | .Fa nodename | ||
294 | string must be a numeric host address string. | ||
295 | Otherwise an error of | ||
296 | .Dv EAI_NONAME | ||
297 | is returned. | ||
298 | This flag prevents any type of name resolution service, | ||
299 | such as DNS, | ||
300 | from being called. | ||
301 | .It AI_NUMERICSERV | ||
302 | If the | ||
303 | .Dv AI_NUMERICSERV | ||
304 | bit is set, | ||
305 | then a non-null | ||
306 | .Fa servname | ||
307 | string must be a numeric port string. | ||
308 | Otherwise an error of | ||
309 | .Dv EAI_NONAME | ||
310 | is returned. | ||
311 | This flag prevents any type of name resolution service, | ||
312 | such as NIS, | ||
313 | from being called. | ||
314 | .El | ||
315 | .Pp | ||
316 | The arguments to | ||
317 | .Fn getaddrinfo | ||
318 | must be sufficiently consistent and unambiguous. | ||
319 | Issues to watch out for are: | ||
320 | .Bl -bullet | ||
321 | .It | ||
322 | .Fn getaddrinfo | ||
323 | will raise an error if members of the | ||
324 | .Fa hints | ||
325 | structure are not consistent. | ||
326 | For example, for internet address families, | ||
327 | .Fn getaddrinfo | ||
328 | will raise an error if you specify | ||
329 | .Dv SOCK_STREAM | ||
330 | to | ||
331 | .Fa ai_socktype | ||
332 | while you specify | ||
333 | .Dv IPPROTO_UDP | ||
334 | to | ||
335 | .Fa ai_protocol . | ||
336 | .It | ||
337 | If you specify a | ||
338 | .Fa servname | ||
339 | which is defined only for certain | ||
340 | .Fa ai_socktype , | ||
341 | .Fn getaddrinfo | ||
342 | will raise an error because the arguments are not consistent. | ||
343 | For example, | ||
344 | .Fn getaddrinfo | ||
345 | will raise an error if you ask for | ||
346 | .Dq Li tftp | ||
347 | service on | ||
348 | .Dv SOCK_STREAM . | ||
349 | .It | ||
350 | For internet address families, if you specify | ||
351 | .Fa servname | ||
352 | while you set | ||
353 | .Fa ai_socktype | ||
354 | to | ||
355 | .Dv SOCK_RAW , | ||
356 | .Fn getaddrinfo | ||
357 | will raise an error, because service names are not defined for the internet | ||
358 | .Dv SOCK_RAW | ||
359 | space. | ||
360 | .It | ||
361 | If you specify a numeric | ||
362 | .Fa servname , | ||
363 | while leaving | ||
364 | .Fa ai_socktype | ||
365 | and | ||
366 | .Fa ai_protocol | ||
367 | unspecified, | ||
368 | .Fn getaddrinfo | ||
369 | will raise an error. | ||
370 | This is because the numeric | ||
371 | .Fa servname | ||
372 | does not identify any socket type, and | ||
373 | .Fn getaddrinfo | ||
374 | is not allowed to glob the argument in such case. | ||
375 | .El | ||
376 | .\" | ||
377 | .Sh RETURN VALUES | ||
378 | .Fn getaddrinfo | ||
379 | returns zero on success, and non-zero on errors. | ||
380 | See | ||
381 | .Xr gai_strerror 3 | ||
382 | for a description of the non-zero error codes. | ||
383 | .\" | ||
384 | .Sh EXAMPLES | ||
385 | The following code tries to connect to | ||
386 | .Dq Li www.kame.net | ||
387 | service | ||
388 | .Dq Li http . | ||
389 | via stream socket. | ||
390 | It loops through all the addresses available, regardless of address family. | ||
391 | If the destination resolves to an IPv4 address, it will use | ||
392 | .Dv AF_INET | ||
393 | socket. | ||
394 | Similarly, if it resolves to IPv6, | ||
395 | .Dv AF_INET6 | ||
396 | socket is used. | ||
397 | Observe that there is no hardcoded reference to a particular address family. | ||
398 | The code works even if | ||
399 | .Nm getaddrinfo | ||
400 | returns addresses that are not IPv4/v6. | ||
401 | .Bd -literal -offset indent | ||
402 | struct addrinfo hints, *res, *res0; | ||
403 | int error; | ||
404 | int s; | ||
405 | const char *cause = NULL; | ||
406 | |||
407 | memset(&hints, 0, sizeof(hints)); | ||
408 | hints.ai_family = PF_UNSPEC; | ||
409 | hints.ai_socktype = SOCK_STREAM; | ||
410 | error = getaddrinfo("www.kame.net", "http", &hints, &res0); | ||
411 | if (error) { | ||
412 | errx(1, "%s", gai_strerror(error)); | ||
413 | /*NOTREACHED*/ | ||
414 | } | ||
415 | s = -1; | ||
416 | for (res = res0; res; res = res->ai_next) { | ||
417 | s = socket(res->ai_family, res->ai_socktype, | ||
418 | res->ai_protocol); | ||
419 | if (s < 0) { | ||
420 | cause = "socket"; | ||
421 | continue; | ||
422 | } | ||
423 | |||
424 | if (connect(s, res->ai_addr, res->ai_addrlen) < 0) { | ||
425 | cause = "connect"; | ||
426 | close(s); | ||
427 | s = -1; | ||
428 | continue; | ||
429 | } | ||
430 | |||
431 | break; /* okay we got one */ | ||
432 | } | ||
433 | if (s < 0) { | ||
434 | err(1, "%s", cause); | ||
435 | /*NOTREACHED*/ | ||
436 | } | ||
437 | freeaddrinfo(res0); | ||
438 | .Ed | ||
439 | .Pp | ||
440 | The following example tries to open a wildcard listening socket onto service | ||
441 | .Dq Li http , | ||
442 | for all the address families available. | ||
443 | .Bd -literal -offset indent | ||
444 | struct addrinfo hints, *res, *res0; | ||
445 | int error; | ||
446 | int s[MAXSOCK]; | ||
447 | int nsock; | ||
448 | const char *cause = NULL; | ||
449 | |||
450 | memset(&hints, 0, sizeof(hints)); | ||
451 | hints.ai_family = PF_UNSPEC; | ||
452 | hints.ai_socktype = SOCK_STREAM; | ||
453 | hints.ai_flags = AI_PASSIVE; | ||
454 | error = getaddrinfo(NULL, "http", &hints, &res0); | ||
455 | if (error) { | ||
456 | errx(1, "%s", gai_strerror(error)); | ||
457 | /*NOTREACHED*/ | ||
458 | } | ||
459 | nsock = 0; | ||
460 | for (res = res0; res && nsock < MAXSOCK; res = res->ai_next) { | ||
461 | s[nsock] = socket(res->ai_family, res->ai_socktype, | ||
462 | res->ai_protocol); | ||
463 | if (s[nsock] < 0) { | ||
464 | cause = "socket"; | ||
465 | continue; | ||
466 | } | ||
467 | |||
468 | if (bind(s[nsock], res->ai_addr, res->ai_addrlen) < 0) { | ||
469 | cause = "bind"; | ||
470 | close(s[nsock]); | ||
471 | continue; | ||
472 | } | ||
473 | (void) listen(s[nsock], 5); | ||
474 | |||
475 | nsock++; | ||
476 | } | ||
477 | if (nsock == 0) { | ||
478 | err(1, "%s", cause); | ||
479 | /*NOTREACHED*/ | ||
480 | } | ||
481 | freeaddrinfo(res0); | ||
482 | .Ed | ||
483 | .\" | ||
484 | .Sh SEE ALSO | ||
485 | .Xr gai_strerror 3 , | ||
486 | .Xr gethostbyname 3 , | ||
487 | .Xr getnameinfo 3 , | ||
488 | .Xr getservbyname 3 , | ||
489 | .Xr hosts 5 , | ||
490 | .Xr resolv.conf 5 , | ||
491 | .Xr services 5 , | ||
492 | .Xr hostname 7 , | ||
493 | .Xr named 8 | ||
494 | .Rs | ||
495 | .%A R. Gilligan | ||
496 | .%A S. Thomson | ||
497 | .%A J. Bound | ||
498 | .%A J. McCann | ||
499 | .%A W. Stevens | ||
500 | .%T Basic Socket Interface Extensions for IPv6 | ||
501 | .%R RFC 3493 | ||
502 | .%D February 2003 | ||
503 | .Re | ||
504 | .Rs | ||
505 | .%A Tatsuya Jinmei | ||
506 | .%A Atsushi Onoe | ||
507 | .%T "An Extension of Format for IPv6 Scoped Addresses" | ||
508 | .%R internet draft | ||
509 | .%N draft-ietf-ipngwg-scopedaddr-format-02.txt | ||
510 | .%O work in progress material | ||
511 | .Re | ||
512 | .Rs | ||
513 | .%A Craig Metz | ||
514 | .%T Protocol Independence Using the Sockets API | ||
515 | .%B "Proceedings of the freenix track: 2000 USENIX annual technical conference" | ||
516 | .%D June 2000 | ||
517 | .Re | ||
518 | .\" | ||
519 | .Sh STANDARDS | ||
520 | The | ||
521 | .Fn getaddrinfo | ||
522 | function is defined in IEEE POSIX 1003.1g draft specification, | ||
523 | and documented in | ||
524 | .Dq Basic Socket Interface Extensions for IPv6 | ||
525 | .Pq RFC 3493 . | ||
526 | .\" | ||
527 | .Sh HISTORY | ||
528 | The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit. | ||
529 | .\" | ||
530 | .Sh BUGS | ||
531 | The current implementation is not thread-safe. | ||
diff --git a/src/lib/libc/net/getnameinfo.3 b/src/lib/libc/net/getnameinfo.3 deleted file mode 100644 index c01646c8a7..0000000000 --- a/src/lib/libc/net/getnameinfo.3 +++ /dev/null | |||
@@ -1,343 +0,0 @@ | |||
1 | .\" $OpenBSD: getnameinfo.3,v 1.28 2004/12/06 10:46:35 jmc Exp $ | ||
2 | .\" $KAME: getnameinfo.3,v 1.20 2001/01/05 13:37:37 itojun Exp $ | ||
3 | .\" | ||
4 | .\" Copyright (c) 1983, 1987, 1991, 1993 | ||
5 | .\" The Regents of the University of California. All rights reserved. | ||
6 | .\" | ||
7 | .\" Redistribution and use in source and binary forms, with or without | ||
8 | .\" modification, are permitted provided that the following conditions | ||
9 | .\" are met: | ||
10 | .\" 1. Redistributions of source code must retain the above copyright | ||
11 | .\" notice, this list of conditions and the following disclaimer. | ||
12 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
13 | .\" notice, this list of conditions and the following disclaimer in the | ||
14 | .\" documentation and/or other materials provided with the distribution. | ||
15 | .\" 3. Neither the name of the University nor the names of its contributors | ||
16 | .\" may be used to endorse or promote products derived from this software | ||
17 | .\" without specific prior written permission. | ||
18 | .\" | ||
19 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
23 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | .\" SUCH DAMAGE. | ||
30 | .\" | ||
31 | .\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 | ||
32 | .\" | ||
33 | .Dd May 25, 1995 | ||
34 | .Dt GETNAMEINFO 3 | ||
35 | .Os | ||
36 | .\" | ||
37 | .Sh NAME | ||
38 | .Nm getnameinfo | ||
39 | .Nd address-to-nodename translation in protocol-independent manner | ||
40 | .\" | ||
41 | .Sh SYNOPSIS | ||
42 | .Fd #include <sys/types.h> | ||
43 | .Fd #include <sys/socket.h> | ||
44 | .Fd #include <netdb.h> | ||
45 | .Ft int | ||
46 | .Fn getnameinfo "const struct sockaddr *sa" "socklen_t salen" \ | ||
47 | "char *host" "size_t hostlen" "char *serv" "size_t servlen" "int flags" | ||
48 | .\" | ||
49 | .Sh DESCRIPTION | ||
50 | The | ||
51 | .Fn getnameinfo | ||
52 | function is defined for protocol-independent address-to-nodename translation. | ||
53 | Its functionality is a reverse conversion of | ||
54 | .Xr getaddrinfo 3 , | ||
55 | and implements similar functionality to | ||
56 | .Xr gethostbyaddr 3 | ||
57 | and | ||
58 | .Xr getservbyport 3 | ||
59 | in a more sophisticated manner. | ||
60 | .Pp | ||
61 | This function looks up an IP address and port number provided by the | ||
62 | caller in the DNS and system-specific database, and returns text | ||
63 | strings for both in buffers provided by the caller. | ||
64 | The function indicates successful completion by a zero return value; | ||
65 | a non-zero return value indicates failure. | ||
66 | .Pp | ||
67 | To aid applications in printing error messages based on the | ||
68 | .Dv EAI_xxx | ||
69 | codes returned by | ||
70 | .Fn getnameinfo , | ||
71 | .Fn gai_strerror | ||
72 | is defined. | ||
73 | See | ||
74 | .Xr gai_strerror 3 | ||
75 | for more information. | ||
76 | .Pp | ||
77 | The implementation allows experimental numeric IPv6 address notation with | ||
78 | scope identifier. | ||
79 | IPv6 link-local address will appear as a string like | ||
80 | .Dq Li fe80::1%ne0 . | ||
81 | Refer to | ||
82 | .Xr getaddrinfo 3 | ||
83 | for the notation. | ||
84 | .Pp | ||
85 | The first argument, | ||
86 | .Fa sa , | ||
87 | points to either a | ||
88 | .Li sockaddr_in | ||
89 | structure (for IPv4) or a | ||
90 | .Li sockaddr_in6 | ||
91 | structure (for IPv6) that holds the IP address and port number. | ||
92 | The | ||
93 | .Fa salen | ||
94 | argument gives the length of the | ||
95 | .Li sockaddr_in | ||
96 | or | ||
97 | .Li sockaddr_in6 | ||
98 | structure. | ||
99 | .Pp | ||
100 | The function returns the nodename associated with the IP address in | ||
101 | the buffer pointed to by the | ||
102 | .Fa host | ||
103 | argument. | ||
104 | The caller provides the size of this buffer via the | ||
105 | .Fa hostlen | ||
106 | argument. | ||
107 | The service name associated with the port number is returned in the buffer | ||
108 | pointed to by | ||
109 | .Fa serv , | ||
110 | and the | ||
111 | .Fa servlen | ||
112 | argument gives the length of this buffer. | ||
113 | The caller specifies not to return either string by providing a zero | ||
114 | value for the | ||
115 | .Fa hostlen | ||
116 | or | ||
117 | .Fa servlen | ||
118 | arguments. | ||
119 | Otherwise, the caller must provide buffers large enough to hold the | ||
120 | nodename and the service name, including the terminating null characters. | ||
121 | .Pp | ||
122 | Unfortunately most systems do not provide constants that specify the | ||
123 | maximum size of either a fully-qualified domain name or a service name. | ||
124 | Therefore to aid the application in allocating buffers for these two | ||
125 | returned strings the following constants are defined in | ||
126 | .Aq Pa netdb.h : | ||
127 | .Bd -literal -offset indent | ||
128 | #define NI_MAXHOST MAXHOSTNAMELEN | ||
129 | #define NI_MAXSERV 32 | ||
130 | .Ed | ||
131 | .Pp | ||
132 | The first value is actually defined as the constant | ||
133 | .Dv MAXDNAME | ||
134 | in recent versions of BIND's | ||
135 | .Aq Pa arpa/nameser.h | ||
136 | header (older versions of BIND define this constant to be 256) | ||
137 | and the second is a guess based on the services listed in the current | ||
138 | Assigned Numbers RFC. | ||
139 | .Pp | ||
140 | The final argument is a | ||
141 | .Fa flag | ||
142 | that changes the default actions of this function. | ||
143 | The flags are defined in | ||
144 | .Aq Pa netdb.h | ||
145 | and are as follows: | ||
146 | .Bl -tag -width "NI_NUMERICHOSTXX" | ||
147 | .It Dv NI_NOFQDN | ||
148 | By default the fully-qualified domain name (FQDN) for the host is | ||
149 | looked up using DNS and returned. | ||
150 | If the flag bit | ||
151 | .Dv NI_NOFQDN | ||
152 | is set, only the nodename portion of the FQDN is returned for local hosts. | ||
153 | .It Dv NI_NUMERICHOST | ||
154 | If the | ||
155 | .Fa flag | ||
156 | bit | ||
157 | .Dv NI_NUMERICHOST | ||
158 | is set, or if the host's name cannot be located using DNS, | ||
159 | the numeric form of the host's address is returned instead of its name | ||
160 | .Po | ||
161 | e.g., by calling | ||
162 | .Xr inet_ntop 3 | ||
163 | instead of | ||
164 | .Xr gethostbyaddr 3 | ||
165 | .Pc . | ||
166 | The two | ||
167 | .Dv NI_NUMERICxxx | ||
168 | flags are required to support the | ||
169 | .Fl n | ||
170 | flag that many commands provide. | ||
171 | .It Dv NI_NAMEREQD | ||
172 | If the | ||
173 | .Fa flag | ||
174 | bit | ||
175 | .Dv NI_NAMEREQD | ||
176 | is set, an error is returned if the host's name cannot be located using DNS. | ||
177 | .It Dv NI_NUMERICSERV | ||
178 | If the flag bit | ||
179 | .Dv NI_NUMERICSERV | ||
180 | is set, the numeric form of the service address is returned | ||
181 | .Pq e.g., its port number | ||
182 | instead of its name. | ||
183 | The two | ||
184 | .Dv NI_NUMERICxxx | ||
185 | flags are required to support the | ||
186 | .Fl n | ||
187 | flag that many commands provide. | ||
188 | .It Dv NI_DGRAM | ||
189 | A fifth flag bit, | ||
190 | .Dv NI_DGRAM , | ||
191 | specifies that the service is a datagram service, and causes | ||
192 | .Xr getservbyport 3 | ||
193 | to be called with a second argument of | ||
194 | .Qq udp | ||
195 | instead of its default of | ||
196 | .Qq tcp . | ||
197 | This is required for the few ports (512-514) | ||
198 | that have different services for UDP and TCP. | ||
199 | .El | ||
200 | .\" | ||
201 | .Sh RETURN VALUES | ||
202 | .Fn getnameinfo | ||
203 | returns zero on success, and non-zero on errors. | ||
204 | See | ||
205 | .Xr gai_strerror 3 | ||
206 | for a description of the non-zero error codes. | ||
207 | .\" | ||
208 | .Sh EXAMPLES | ||
209 | The following code tries to get a numeric hostname, and service name, | ||
210 | for a given socket address. | ||
211 | Observe that there is no hardcoded reference to a particular address family. | ||
212 | .Bd -literal -offset indent | ||
213 | struct sockaddr *sa; /* input */ | ||
214 | char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; | ||
215 | |||
216 | if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), sbuf, | ||
217 | sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) { | ||
218 | errx(1, "could not get numeric hostname"); | ||
219 | /*NOTREACHED*/ | ||
220 | } | ||
221 | printf("host=%s, serv=%s\en", hbuf, sbuf); | ||
222 | .Ed | ||
223 | .Pp | ||
224 | The following version checks if the socket address has reverse address mapping: | ||
225 | .Bd -literal -offset indent | ||
226 | struct sockaddr *sa; /* input */ | ||
227 | char hbuf[NI_MAXHOST]; | ||
228 | |||
229 | if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), NULL, 0, | ||
230 | NI_NAMEREQD)) { | ||
231 | errx(1, "could not resolve hostname"); | ||
232 | /*NOTREACHED*/ | ||
233 | } | ||
234 | printf("host=%s\en", hbuf); | ||
235 | .Ed | ||
236 | .\" | ||
237 | .Sh SEE ALSO | ||
238 | .Xr gai_strerror 3 , | ||
239 | .Xr getaddrinfo 3 , | ||
240 | .Xr gethostbyaddr 3 , | ||
241 | .Xr getservbyport 3 , | ||
242 | .Xr hosts 5 , | ||
243 | .Xr resolv.conf 5 , | ||
244 | .Xr services 5 , | ||
245 | .Xr hostname 7 , | ||
246 | .Xr named 8 | ||
247 | .Rs | ||
248 | .%A R. Gilligan | ||
249 | .%A S. Thomson | ||
250 | .%A J. Bound | ||
251 | .%A W. Stevens | ||
252 | .%T Basic Socket Interface Extensions for IPv6 | ||
253 | .%R RFC 2553 | ||
254 | .%D March 1999 | ||
255 | .Re | ||
256 | .Rs | ||
257 | .%A Tatsuya Jinmei | ||
258 | .%A Atsushi Onoe | ||
259 | .%T "An Extension of Format for IPv6 Scoped Addresses" | ||
260 | .%R internet draft | ||
261 | .%N draft-ietf-ipngwg-scopedaddr-format-02.txt | ||
262 | .%O work in progress material | ||
263 | .Re | ||
264 | .Rs | ||
265 | .%A Craig Metz | ||
266 | .%T Protocol Independence Using the Sockets API | ||
267 | .%B "Proceedings of the freenix track: 2000 USENIX annual technical conference" | ||
268 | .%D June 2000 | ||
269 | .Re | ||
270 | .\" | ||
271 | .Sh STANDARDS | ||
272 | The | ||
273 | .Fn getnameinfo | ||
274 | function is defined in IEEE POSIX 1003.1g draft specification, | ||
275 | and documented in | ||
276 | .Dq Basic Socket Interface Extensions for IPv6 | ||
277 | .Pq RFC 2553 . | ||
278 | .\" | ||
279 | .Sh HISTORY | ||
280 | The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit. | ||
281 | .\" | ||
282 | .Sh CAVEATS | ||
283 | .Fn getnameinfo | ||
284 | returns both numeric and FQDN notation of the address specified in | ||
285 | .Fa sa . | ||
286 | There is no return value that indicates if the string returned in | ||
287 | .Fa host | ||
288 | is a result of binary to numeric-text translation (like | ||
289 | .Xr inet_ntop 3 ) , | ||
290 | or the result of DNS reverse lookup. | ||
291 | Therefore, malicious parties could set up a PTR record as below: | ||
292 | .Bd -literal -offset indent | ||
293 | 1.0.0.127.in-addr.arpa. IN PTR 10.1.1.1 | ||
294 | .Ed | ||
295 | .Pp | ||
296 | and trick the caller of | ||
297 | .Fn getnameinfo | ||
298 | into believing that | ||
299 | .Fa sa | ||
300 | is | ||
301 | .Li 10.1.1.1 | ||
302 | when it actually is | ||
303 | .Li 127.0.0.1 . | ||
304 | .Pp | ||
305 | To prevent such attacks, the use of | ||
306 | .Dv NI_NAMEREQD | ||
307 | is recommended when you use the result of | ||
308 | .Fn getnameinfo | ||
309 | for access control purposes: | ||
310 | .Bd -literal -offset indent | ||
311 | struct sockaddr *sa; | ||
312 | socklen_t salen; | ||
313 | char addr[NI_MAXHOST]; | ||
314 | struct addrinfo hints, *res; | ||
315 | int error; | ||
316 | |||
317 | error = getnameinfo(sa, salen, addr, sizeof(addr), | ||
318 | NULL, 0, NI_NAMEREQD); | ||
319 | if (error == 0) { | ||
320 | memset(&hints, 0, sizeof(hints)); | ||
321 | hints.ai_socktype = SOCK_DGRAM; /*dummy*/ | ||
322 | hints.ai_flags = AI_NUMERICHOST; | ||
323 | if (getaddrinfo(addr, "0", &hints, &res) == 0) { | ||
324 | /* malicious PTR record */ | ||
325 | freeaddrinfo(res); | ||
326 | printf("bogus PTR record\\n"); | ||
327 | return -1; | ||
328 | } | ||
329 | /* addr is FQDN as a result of PTR lookup */ | ||
330 | } else { | ||
331 | /* addr is numeric string */ | ||
332 | error = getnameinfo(sa, salen, addr, sizeof(addr), | ||
333 | NULL, 0, NI_NUMERICHOST); | ||
334 | } | ||
335 | .Ed | ||
336 | .\" | ||
337 | .Sh BUGS | ||
338 | The current implementation is not thread-safe. | ||
339 | .Pp | ||
340 | .Ox | ||
341 | intentionally uses a different | ||
342 | .Dv NI_MAXHOST | ||
343 | value from what RFC 2553 suggests, to avoid buffer length handling mistakes. | ||
diff --git a/src/lib/libc/net/inet6_option_space.3 b/src/lib/libc/net/inet6_option_space.3 deleted file mode 100644 index 4e5dc22711..0000000000 --- a/src/lib/libc/net/inet6_option_space.3 +++ /dev/null | |||
@@ -1,444 +0,0 @@ | |||
1 | .\" $OpenBSD: inet6_option_space.3,v 1.13 2003/08/08 09:26:02 jmc Exp $ | ||
2 | .\" $KAME: inet6_option_space.3,v 1.7 2000/05/17 14:32:13 itojun Exp $ | ||
3 | .\" | ||
4 | .\" Copyright (c) 1983, 1987, 1991, 1993 | ||
5 | .\" The Regents of the University of California. All rights reserved. | ||
6 | .\" | ||
7 | .\" Redistribution and use in source and binary forms, with or without | ||
8 | .\" modification, are permitted provided that the following conditions | ||
9 | .\" are met: | ||
10 | .\" 1. Redistributions of source code must retain the above copyright | ||
11 | .\" notice, this list of conditions and the following disclaimer. | ||
12 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
13 | .\" notice, this list of conditions and the following disclaimer in the | ||
14 | .\" documentation and/or other materials provided with the distribution. | ||
15 | .\" 3. Neither the name of the University nor the names of its contributors | ||
16 | .\" may be used to endorse or promote products derived from this software | ||
17 | .\" without specific prior written permission. | ||
18 | .\" | ||
19 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
23 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | .\" SUCH DAMAGE. | ||
30 | .\" | ||
31 | .Dd December 10, 1999 | ||
32 | .Dt INET6_OPTION_SPACE 3 | ||
33 | .Os | ||
34 | .\" | ||
35 | .Sh NAME | ||
36 | .Nm inet6_option_space , | ||
37 | .Nm inet6_option_init , | ||
38 | .Nm inet6_option_append , | ||
39 | .Nm inet6_option_alloc , | ||
40 | .Nm inet6_option_next , | ||
41 | .Nm inet6_option_find | ||
42 | .Nd IPv6 Hop-by-Hop and Destination Options manipulation | ||
43 | .\" | ||
44 | .Sh SYNOPSIS | ||
45 | .Fd #include <netinet/in.h> | ||
46 | .Ft "int" | ||
47 | .Fn inet6_option_space "int nbytes" | ||
48 | .Ft "int" | ||
49 | .Fn inet6_option_init "void *bp" "struct cmsghdr **cmsgp" "int type" | ||
50 | .Ft "int" | ||
51 | .Fn inet6_option_append "struct cmsghdr *cmsg" "const u_int8_t *typep" "int multx" "int plusy" | ||
52 | .Ft "u_int8_t *" | ||
53 | .Fn inet6_option_alloc "struct cmsghdr *cmsg" "int datalen" "int multx" "int plusy" | ||
54 | .Ft "int" | ||
55 | .Fn inet6_option_next "const struct cmsghdr *cmsg" "u_int8_t **tptrp" | ||
56 | .Ft "int" | ||
57 | .Fn inet6_option_find "const struct cmsghdr *cmsg" "u_int8_t **tptrp" "int type" | ||
58 | .\" | ||
59 | .Sh DESCRIPTION | ||
60 | .\" | ||
61 | Building and parsing the Hop-by-Hop and Destination options is | ||
62 | complicated due to alignment constraints, padding and | ||
63 | ancillary data manipulation. | ||
64 | RFC 2292 defines a set of functions to help the application. | ||
65 | The function prototypes for | ||
66 | these functions are all in the | ||
67 | .Aq Pa netinet/in.h | ||
68 | header. | ||
69 | .\" | ||
70 | .Ss inet6_option_space | ||
71 | .Fn inet6_option_space | ||
72 | returns the number of bytes required to hold an option when it is stored as | ||
73 | ancillary data, including the | ||
74 | .Li cmsghdr | ||
75 | structure at the beginning, | ||
76 | and any padding at the end | ||
77 | .Po | ||
78 | to make its size a multiple of 8 bytes | ||
79 | .Pc . | ||
80 | The argument is the size of the structure defining the option, | ||
81 | which must include any pad bytes at the beginning | ||
82 | .Po | ||
83 | the value | ||
84 | .Li y | ||
85 | in the alignment term | ||
86 | .Dq Li xn + y | ||
87 | .Pc , | ||
88 | the type byte, the length byte, and the option data. | ||
89 | .Pp | ||
90 | Note: If multiple options are stored in a single ancillary data | ||
91 | object, which is the recommended technique, this function | ||
92 | overestimates the amount of space required by the size of | ||
93 | .Li N-1 | ||
94 | .Li cmsghdr | ||
95 | structures, | ||
96 | where | ||
97 | .Li N | ||
98 | is the number of options to be stored in the object. | ||
99 | This is of little consequence, since it is assumed that most | ||
100 | Hop-by-Hop option headers and Destination option headers carry only | ||
101 | one option | ||
102 | .Pq appendix B of [RFC 2460] . | ||
103 | .\" | ||
104 | .Ss inet6_option_init | ||
105 | .Fn inet6_option_init | ||
106 | is called once per ancillary data object that will | ||
107 | contain either Hop-by-Hop or Destination options. | ||
108 | It returns | ||
109 | .Li 0 | ||
110 | on success or | ||
111 | .Li -1 | ||
112 | on an error. | ||
113 | .Pp | ||
114 | .Fa bp | ||
115 | is a pointer to previously allocated space that will contain the | ||
116 | ancillary data object. | ||
117 | It must be large enough to contain all the | ||
118 | individual options to be added by later calls to | ||
119 | .Fn inet6_option_append | ||
120 | and | ||
121 | .Fn inet6_option_alloc . | ||
122 | .Pp | ||
123 | .Fa cmsgp | ||
124 | is a pointer to a pointer to a | ||
125 | .Li cmsghdr | ||
126 | structure. | ||
127 | .Fa *cmsgp | ||
128 | is initialized by this function to point to the | ||
129 | .Li cmsghdr | ||
130 | structure constructed by this function in the buffer pointed to by | ||
131 | .Fa bp . | ||
132 | .Pp | ||
133 | .Fa type | ||
134 | is either | ||
135 | .Dv IPV6_HOPOPTS | ||
136 | or | ||
137 | .Dv IPV6_DSTOPTS . | ||
138 | This | ||
139 | .Fa type | ||
140 | is stored in the | ||
141 | .Li cmsg_type | ||
142 | member of the | ||
143 | .Li cmsghdr | ||
144 | structure pointed to by | ||
145 | .Fa *cmsgp . | ||
146 | .\" | ||
147 | .Ss inet6_option_append | ||
148 | This function appends a Hop-by-Hop option or a Destination option | ||
149 | into an ancillary data object that has been initialized by | ||
150 | .Fn inet6_option_init . | ||
151 | This function returns | ||
152 | .Li 0 | ||
153 | if it succeeds or | ||
154 | .Li -1 | ||
155 | on an error. | ||
156 | .Pp | ||
157 | .Fa cmsg | ||
158 | is a pointer to the | ||
159 | .Li cmsghdr | ||
160 | structure that must have been | ||
161 | initialized by | ||
162 | .Fn inet6_option_init . | ||
163 | .Pp | ||
164 | .Fa typep | ||
165 | is a pointer to the 8-bit option type. | ||
166 | It is assumed that this | ||
167 | field is immediately followed by the 8-bit option data length field, | ||
168 | which is then followed immediately by the option data. | ||
169 | The caller | ||
170 | initializes these three fields | ||
171 | .Pq the type-length-value, or TLV | ||
172 | before calling this function. | ||
173 | .Pp | ||
174 | The option type must have a value from | ||
175 | .Li 2 | ||
176 | to | ||
177 | .Li 255 , | ||
178 | inclusive. | ||
179 | .Po | ||
180 | .Li 0 | ||
181 | and | ||
182 | .Li 1 | ||
183 | are reserved for the | ||
184 | .Li Pad1 | ||
185 | and | ||
186 | .Li PadN | ||
187 | options, respectively. | ||
188 | .Pc | ||
189 | .Pp | ||
190 | The option data length must have a value between | ||
191 | .Li 0 | ||
192 | and | ||
193 | .Li 255 , | ||
194 | inclusive, and is the length of the option data that follows. | ||
195 | .Pp | ||
196 | .Fa multx | ||
197 | is the value | ||
198 | .Li x | ||
199 | in the alignment term | ||
200 | .Dq Li xn + y . | ||
201 | It must have a value of | ||
202 | .Li 1 , | ||
203 | .Li 2 , | ||
204 | .Li 4 , | ||
205 | or | ||
206 | .Li 8 . | ||
207 | .Pp | ||
208 | .Fa plusy | ||
209 | is the value | ||
210 | .Li y | ||
211 | in the alignment term | ||
212 | .Dq Li xn + y . | ||
213 | It must have a value between | ||
214 | .Li 0 | ||
215 | and | ||
216 | .Li 7 , | ||
217 | inclusive. | ||
218 | .\" | ||
219 | .Ss inet6_option_alloc | ||
220 | This function appends a Hop-by-Hop option or a Destination option | ||
221 | into an ancillary data object that has been initialized by | ||
222 | .Fn inet6_option_init . | ||
223 | This function returns a pointer to the 8-bit | ||
224 | option type field that starts the option on success, or | ||
225 | .Dv NULL | ||
226 | on an error. | ||
227 | .Pp | ||
228 | The difference between this function and | ||
229 | .Fn inet6_option_append | ||
230 | is that the latter copies the contents of a previously built option into | ||
231 | the ancillary data object while the current function returns a | ||
232 | pointer to the space in the data object where the option's TLV must | ||
233 | then be built by the caller. | ||
234 | .Pp | ||
235 | .Fa cmsg | ||
236 | is a pointer to the | ||
237 | .Li cmsghdr | ||
238 | structure that must have been | ||
239 | initialized by | ||
240 | .Fn inet6_option_init . | ||
241 | .Pp | ||
242 | .Fa datalen | ||
243 | is the value of the option data length byte for this option. | ||
244 | This value is required as an argument to allow the function to | ||
245 | determine if padding must be appended at the end of the option. | ||
246 | (The | ||
247 | .Fn inet6_option_append | ||
248 | function does not need a data length argument | ||
249 | since the option data length must already be stored by the caller.) | ||
250 | .Pp | ||
251 | .Fa multx | ||
252 | is the value | ||
253 | .Li x | ||
254 | in the alignment term | ||
255 | .Dq Li xn + y . | ||
256 | It must have a value of | ||
257 | .Li 1 , | ||
258 | .Li 2 , | ||
259 | .Li 4 , | ||
260 | or | ||
261 | .Li 8 . | ||
262 | .Pp | ||
263 | .Fa plusy | ||
264 | is the value | ||
265 | .Li y | ||
266 | in the alignment term | ||
267 | .Dq Li xn + y . | ||
268 | It must have a value between | ||
269 | .Li 0 | ||
270 | and | ||
271 | .Li 7 , | ||
272 | inclusive. | ||
273 | .\" | ||
274 | .Ss inet6_option_next | ||
275 | This function processes the next Hop-by-Hop option or Destination | ||
276 | option in an ancillary data object. | ||
277 | If another option remains to be | ||
278 | processed, the return value of the function is | ||
279 | .Li 0 | ||
280 | and | ||
281 | .Fa *tptrp | ||
282 | points to | ||
283 | the 8-bit option type field | ||
284 | (which is followed by the 8-bit option | ||
285 | data length, followed by the option data). | ||
286 | If no more options remain | ||
287 | to be processed, the return value is | ||
288 | .Li -1 | ||
289 | and | ||
290 | .Fa *tptrp | ||
291 | is | ||
292 | .Dv NULL . | ||
293 | If an error occurs, the return value is | ||
294 | .Li -1 | ||
295 | and | ||
296 | .Fa *tptrp | ||
297 | is not | ||
298 | .Dv NULL . | ||
299 | .Pp | ||
300 | .Fa cmsg | ||
301 | is a pointer to | ||
302 | .Li cmsghdr | ||
303 | structure of which | ||
304 | .Li cmsg_level | ||
305 | equals | ||
306 | .Dv IPPROTO_IPV6 | ||
307 | and | ||
308 | .Li cmsg_type | ||
309 | equals either | ||
310 | .Dv IPV6_HOPOPTS | ||
311 | or | ||
312 | .Dv IPV6_DSTOPTS . | ||
313 | .Pp | ||
314 | .Fa tptrp | ||
315 | is a pointer to a pointer to an 8-bit byte and | ||
316 | .Fa *tptrp | ||
317 | is used | ||
318 | by the function to remember its place in the ancillary data object | ||
319 | each time the function is called. | ||
320 | The first time this function is | ||
321 | called for a given ancillary data object, | ||
322 | .Fa *tptrp | ||
323 | must be set to | ||
324 | .Dv NULL . | ||
325 | .Pp | ||
326 | Each time this function returns success, | ||
327 | .Fa *tptrp | ||
328 | points to the 8-bit | ||
329 | option type field for the next option to be processed. | ||
330 | .\" | ||
331 | .Ss inet6_option_find | ||
332 | This function is similar to the previously described | ||
333 | .Fn inet6_option_next | ||
334 | function, except this function lets the caller | ||
335 | specify the option type to be searched for, instead of always | ||
336 | returning the next option in the ancillary data object. | ||
337 | .Fa cmsg | ||
338 | is a | ||
339 | pointer to | ||
340 | .Li cmsghdr | ||
341 | structure of which | ||
342 | .Li cmsg_level | ||
343 | equals | ||
344 | .Dv IPPROTO_IPV6 | ||
345 | and | ||
346 | .Li cmsg_type | ||
347 | equals either | ||
348 | .Dv IPV6_HOPOPTS | ||
349 | or | ||
350 | .Dv IPV6_DSTOPTS . | ||
351 | .Pp | ||
352 | .Fa tptrp | ||
353 | is a pointer to a pointer to an 8-bit byte and | ||
354 | .Fa *tptrp | ||
355 | is used | ||
356 | by the function to remember its place in the ancillary data object | ||
357 | each time the function is called. | ||
358 | The first time this function is | ||
359 | called for a given ancillary data object, | ||
360 | .Fa *tptrp | ||
361 | must be set to | ||
362 | .Dv NULL . | ||
363 | .Pp | ||
364 | This function starts searching for an option of the specified type | ||
365 | beginning after the value of | ||
366 | .Fa *tptrp . | ||
367 | If an option of the specified | ||
368 | type is located, this function returns | ||
369 | .Li 0 | ||
370 | and | ||
371 | .Fa *tptrp | ||
372 | points to the 8- | ||
373 | bit option type field for the option of the specified type. | ||
374 | If an | ||
375 | option of the specified type is not located, the return value is | ||
376 | .Li -1 | ||
377 | and | ||
378 | .Fa *tptrp | ||
379 | is | ||
380 | .Dv NULL . | ||
381 | If an error occurs, the return value is | ||
382 | .Li -1 | ||
383 | and | ||
384 | .Fa *tptrp | ||
385 | is not | ||
386 | .Dv NULL . | ||
387 | .\" | ||
388 | .Sh EXAMPLES | ||
389 | RFC 2292 gives comprehensive examples in chapter 6. | ||
390 | .\" | ||
391 | .Sh DIAGNOSTICS | ||
392 | .Fn inet6_option_init | ||
393 | and | ||
394 | .Fn inet6_option_append | ||
395 | return | ||
396 | .Li 0 | ||
397 | on success or | ||
398 | .Li -1 | ||
399 | on an error. | ||
400 | .Pp | ||
401 | .Fn inet6_option_alloc | ||
402 | returns | ||
403 | .Dv NULL | ||
404 | on an error. | ||
405 | .Pp | ||
406 | On errors, | ||
407 | .Fn inet6_option_next | ||
408 | and | ||
409 | .Fn inet6_option_find | ||
410 | return | ||
411 | .Li -1 | ||
412 | setting | ||
413 | .Fa *tptrp | ||
414 | to non | ||
415 | .Dv NULL | ||
416 | value. | ||
417 | .\" | ||
418 | .Sh SEE ALSO | ||
419 | .Rs | ||
420 | .%A W. Stevens | ||
421 | .%A M. Thomas | ||
422 | .%T "Advanced Sockets API for IPv6" | ||
423 | .%N RFC 2292 | ||
424 | .%D February 1998 | ||
425 | .Re | ||
426 | .Rs | ||
427 | .%A S. Deering | ||
428 | .%A R. Hinden | ||
429 | .%T "Internet Protocol, Version 6 (IPv6) Specification" | ||
430 | .%N RFC 2460 | ||
431 | .%D December 1998 | ||
432 | .Re | ||
433 | .\" | ||
434 | .Sh STANDARDS | ||
435 | The functions | ||
436 | are documented in | ||
437 | .Dq Advanced Sockets API for IPv6 | ||
438 | .Pq RFC 2292 . | ||
439 | .\" | ||
440 | .Sh HISTORY | ||
441 | The implementation first appeared in KAME advanced networking kit. | ||
442 | .\" | ||
443 | .Sh BUGS | ||
444 | The text was shamelessly copied from RFC 2292. | ||
diff --git a/src/lib/libc/net/inet6_rthdr_space.3 b/src/lib/libc/net/inet6_rthdr_space.3 deleted file mode 100644 index 33b209af4f..0000000000 --- a/src/lib/libc/net/inet6_rthdr_space.3 +++ /dev/null | |||
@@ -1,317 +0,0 @@ | |||
1 | .\" $OpenBSD: inet6_rthdr_space.3,v 1.13 2003/08/08 09:26:02 jmc Exp $ | ||
2 | .\" $KAME: inet6_rthdr_space.3,v 1.8 2000/05/17 14:30:15 itojun Exp $ | ||
3 | .\" | ||
4 | .\" Copyright (c) 1983, 1987, 1991, 1993 | ||
5 | .\" The Regents of the University of California. All rights reserved. | ||
6 | .\" | ||
7 | .\" Redistribution and use in source and binary forms, with or without | ||
8 | .\" modification, are permitted provided that the following conditions | ||
9 | .\" are met: | ||
10 | .\" 1. Redistributions of source code must retain the above copyright | ||
11 | .\" notice, this list of conditions and the following disclaimer. | ||
12 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
13 | .\" notice, this list of conditions and the following disclaimer in the | ||
14 | .\" documentation and/or other materials provided with the distribution. | ||
15 | .\" 3. Neither the name of the University nor the names of its contributors | ||
16 | .\" may be used to endorse or promote products derived from this software | ||
17 | .\" without specific prior written permission. | ||
18 | .\" | ||
19 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
23 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | .\" SUCH DAMAGE. | ||
30 | .\" | ||
31 | .Dd December 10, 1999 | ||
32 | .Dt INET6_RTHDR_SPACE 3 | ||
33 | .Os | ||
34 | .\" | ||
35 | .Sh NAME | ||
36 | .Nm inet6_rthdr_space , | ||
37 | .Nm inet6_rthdr_init , | ||
38 | .Nm inet6_rthdr_add , | ||
39 | .Nm inet6_rthdr_lasthop , | ||
40 | .Nm inet6_rthdr_reverse , | ||
41 | .Nm inet6_rthdr_segments , | ||
42 | .Nm inet6_rthdr_getaddr , | ||
43 | .Nm inet6_rthdr_getflags | ||
44 | .Nd IPv6 Routing Header Options manipulation | ||
45 | .\" | ||
46 | .Sh SYNOPSIS | ||
47 | .Fd #include <netinet/in.h> | ||
48 | .Ft size_t | ||
49 | .Fn inet6_rthdr_space "int type" "int segments" | ||
50 | .Ft "struct cmsghdr *" | ||
51 | .Fn inet6_rthdr_init "void *bp" "int type" | ||
52 | .Ft int | ||
53 | .Fn inet6_rthdr_add "struct cmsghdr *cmsg" "const struct in6_addr *addr" "unsigned int flags" | ||
54 | .Ft int | ||
55 | .Fn inet6_rthdr_lasthop "struct cmsghdr *cmsg" "unsigned int flags" | ||
56 | .Ft int | ||
57 | .Fn inet6_rthdr_reverse "const struct cmsghdr *in" "struct cmsghdr *out" | ||
58 | .Ft int | ||
59 | .Fn inet6_rthdr_segments "const struct cmsghdr *cmsg" | ||
60 | .Ft "struct in6_addr *" | ||
61 | .Fn inet6_rthdr_getaddr "struct cmsghdr *cmsg" "int index" | ||
62 | .Ft int | ||
63 | .Fn inet6_rthdr_getflags "const struct cmsghdr *cmsg" "int index" | ||
64 | .\" | ||
65 | .Sh DESCRIPTION | ||
66 | RFC 2292 IPv6 advanced API defines eight | ||
67 | functions that the application calls to build and examine a Routing | ||
68 | header. | ||
69 | Four functions build a Routing header: | ||
70 | .Bl -hang | ||
71 | .It Fn inet6_rthdr_space | ||
72 | return #bytes required for ancillary data | ||
73 | .It Fn inet6_rthdr_init | ||
74 | initialize ancillary data for Routing header | ||
75 | .It Fn inet6_rthdr_add | ||
76 | add IPv6 address & flags to Routing header | ||
77 | .It Fn inet6_rthdr_lasthop | ||
78 | specify the flags for the final hop | ||
79 | .El | ||
80 | .Pp | ||
81 | Four functions deal with a returned Routing header: | ||
82 | .Bl -hang | ||
83 | .It Fn inet6_rthdr_reverse | ||
84 | reverse a Routing header | ||
85 | .It Fn inet6_rthdr_segments | ||
86 | return #segments in a Routing header | ||
87 | .It Fn inet6_rthdr_getaddr | ||
88 | fetch one address from a Routing header | ||
89 | .It Fn inet6_rthdr_getflags | ||
90 | fetch one flag from a Routing header | ||
91 | .El | ||
92 | .Pp | ||
93 | The function prototypes for these functions are all in the | ||
94 | .Aq Pa netinet/in.h | ||
95 | header. | ||
96 | .\" | ||
97 | .Ss inet6_rthdr_space | ||
98 | This function returns the number of bytes required to hold a Routing | ||
99 | header of the specified | ||
100 | .Fa type | ||
101 | containing the specified number of | ||
102 | .Fa segments | ||
103 | .Pq addresses . | ||
104 | For an IPv6 Type 0 Routing header, the number | ||
105 | of segments must be between 1 and 23, inclusive. | ||
106 | The return value | ||
107 | includes the size of the cmsghdr structure that precedes the Routing | ||
108 | header, and any required padding. | ||
109 | .Pp | ||
110 | If the return value is 0, then either the type of the Routing header | ||
111 | is not supported by this implementation or the number of segments is | ||
112 | invalid for this type of Routing header. | ||
113 | .Pp | ||
114 | Note: This function returns the size but does not allocate the space | ||
115 | required for the ancillary data. | ||
116 | This allows an application to | ||
117 | allocate a larger buffer, if other ancillary data objects are | ||
118 | desired, since all the ancillary data objects must be specified to | ||
119 | .Xr sendmsg 2 | ||
120 | as a single | ||
121 | .Li msg_control | ||
122 | buffer. | ||
123 | .\" | ||
124 | .Ss inet6_rthdr_init | ||
125 | This function initializes the buffer pointed to by | ||
126 | .Fa bp | ||
127 | to contain a | ||
128 | .Li cmsghdr | ||
129 | structure followed by a Routing header of the specified | ||
130 | .Fa type . | ||
131 | The | ||
132 | .Li cmsg_len | ||
133 | member of the | ||
134 | .Li cmsghdr | ||
135 | structure is initialized to the | ||
136 | size of the structure plus the amount of space required by the | ||
137 | Routing header. | ||
138 | The | ||
139 | .Li cmsg_level | ||
140 | and | ||
141 | .Li cmsg_type | ||
142 | members are also initialized as required. | ||
143 | .Pp | ||
144 | The caller must allocate the buffer and its size can be determined by | ||
145 | calling | ||
146 | .Fn inet6_rthdr_space . | ||
147 | .Pp | ||
148 | Upon success the return value is the pointer to the | ||
149 | .Li cmsghdr | ||
150 | structure, and this is then used as the first argument to the next | ||
151 | two functions. | ||
152 | Upon an error the return value is | ||
153 | .Dv NULL . | ||
154 | .\" | ||
155 | .Ss inet6_rthdr_add | ||
156 | This function adds the address pointed to by | ||
157 | .Fa addr | ||
158 | to the end of the | ||
159 | Routing header being constructed and sets the type of this hop to the | ||
160 | value of | ||
161 | .Fa flags . | ||
162 | For an IPv6 Type 0 Routing header, | ||
163 | .Fa flags | ||
164 | must be | ||
165 | either | ||
166 | .Dv IPV6_RTHDR_LOOSE | ||
167 | or | ||
168 | .Dv IPV6_RTHDR_STRICT . | ||
169 | .Pp | ||
170 | If successful, the | ||
171 | .Li cmsg_len | ||
172 | member of the | ||
173 | .Li cmsghdr | ||
174 | structure is | ||
175 | updated to account for the new address in the Routing header and the | ||
176 | return value of the function is 0. | ||
177 | Upon an error the return value of | ||
178 | the function is -1. | ||
179 | .\" | ||
180 | .Ss inet6_rthdr_lasthop | ||
181 | This function specifies the Strict/Loose flag for the final hop of a | ||
182 | Routing header. | ||
183 | For an IPv6 Type 0 Routing header, | ||
184 | .Fa flags | ||
185 | must be either | ||
186 | .Dv IPV6_RTHDR_LOOSE | ||
187 | or | ||
188 | .Dv IPV6_RTHDR_STRICT . | ||
189 | .Pp | ||
190 | The return value of the function is 0 upon success, or -1 upon an error. | ||
191 | .Pp | ||
192 | Notice that a Routing header specifying | ||
193 | .Li N | ||
194 | intermediate nodes requires | ||
195 | .Li N+1 | ||
196 | Strict/Loose flags. | ||
197 | This requires | ||
198 | .Li N | ||
199 | calls to | ||
200 | .Fn inet6_rthdr_add | ||
201 | followed by one call to | ||
202 | .Fn inet6_rthdr_lasthop . | ||
203 | .\" | ||
204 | .Ss inet6_rthdr_reverse | ||
205 | This function takes a Routing header that was received as ancillary | ||
206 | data | ||
207 | .Po | ||
208 | pointed to by the first argument, | ||
209 | .Fa in | ||
210 | .Pc | ||
211 | and writes a new Routing | ||
212 | header that sends datagrams along the reverse of that route. | ||
213 | Both | ||
214 | arguments are allowed to point to the same buffer | ||
215 | .Pq that is, the reversal can occur in place . | ||
216 | .Pp | ||
217 | The return value of the function is 0 on success, or -1 upon an | ||
218 | error. | ||
219 | .\" | ||
220 | .Ss inet6_rthdr_segments | ||
221 | This function returns the number of segments | ||
222 | .Pq addresses | ||
223 | contained in | ||
224 | the Routing header described by | ||
225 | .Fa cmsg . | ||
226 | On success the return value is | ||
227 | between 1 and 23, inclusive. | ||
228 | The return value of the function is -1 upon an error. | ||
229 | .\" | ||
230 | .Ss inet6_rthdr_getaddr | ||
231 | This function returns a pointer to the IPv6 address specified by | ||
232 | .Fa index | ||
233 | (which must have a value between 1 and the value returned by | ||
234 | .Fn inet6_rthdr_segments ) | ||
235 | in the Routing header described by | ||
236 | .Fa cmsg . | ||
237 | An | ||
238 | application should first call | ||
239 | .Fn inet6_rthdr_segments | ||
240 | to obtain the number of segments in the Routing header. | ||
241 | .Pp | ||
242 | Upon an error the return value of the function is | ||
243 | .Dv NULL . | ||
244 | .\" | ||
245 | .Ss inet6_rthdr_getflags | ||
246 | This function returns the flags value specified by | ||
247 | .Fa index | ||
248 | (which must | ||
249 | have a value between 0 and the value returned by | ||
250 | .Fn inet6_rthdr_segments ) | ||
251 | in the Routing header described by | ||
252 | .Fa cmsg . | ||
253 | For an IPv6 Type 0 Routing header the return value will be either | ||
254 | .Dv IPV6_RTHDR_LOOSE | ||
255 | or | ||
256 | .Dv IPV6_RTHDR_STRICT . | ||
257 | .Pp | ||
258 | Upon an error the return value of the function is -1. | ||
259 | .Pp | ||
260 | Note: Addresses are indexed starting at 1, and flags starting at 0, | ||
261 | to maintain consistency with the terminology and figures in RFC 2460. | ||
262 | .\" | ||
263 | .Sh EXAMPLES | ||
264 | RFC 2292 gives comprehensive examples in chapter 8. | ||
265 | .\" | ||
266 | .Sh DIAGNOSTICS | ||
267 | .Fn inet6_rthdr_space | ||
268 | returns 0 on errors. | ||
269 | .Pp | ||
270 | .Fn inet6_rthdr_add , | ||
271 | .Fn inet6_rthdr_lasthop | ||
272 | and | ||
273 | .Fn inet6_rthdr_reverse | ||
274 | return 0 on success, and returns -1 on error. | ||
275 | .Pp | ||
276 | .Fn inet6_rthdr_init | ||
277 | and | ||
278 | .Fn inet6_rthdr_getaddr | ||
279 | return | ||
280 | .Dv NULL | ||
281 | on error. | ||
282 | .Pp | ||
283 | .Fn inet6_rthdr_segments | ||
284 | and | ||
285 | .Fn inet6_rthdr_getflags | ||
286 | return -1 on error. | ||
287 | .\" | ||
288 | .Sh SEE ALSO | ||
289 | .Rs | ||
290 | .%A W. Stevens | ||
291 | .%A M. Thomas | ||
292 | .%T "Advanced Sockets API for IPv6" | ||
293 | .%N RFC 2292 | ||
294 | .%D February 1998 | ||
295 | .Re | ||
296 | .Rs | ||
297 | .%A S. Deering | ||
298 | .%A R. Hinden | ||
299 | .%T "Internet Protocol, Version 6 (IPv6) Specification" | ||
300 | .%N RFC 2460 | ||
301 | .%D December 1998 | ||
302 | .Re | ||
303 | .\" | ||
304 | .Sh STANDARDS | ||
305 | The functions | ||
306 | are documented in | ||
307 | .Dq Advanced Sockets API for IPv6 | ||
308 | .Pq RFC 2292 . | ||
309 | .\" | ||
310 | .Sh HISTORY | ||
311 | The implementation first appeared in KAME advanced networking kit. | ||
312 | .\" | ||
313 | .Sh BUGS | ||
314 | The text was shamelessly copied from RFC 2292. | ||
315 | .Pp | ||
316 | .Fn inet6_rthdr_reverse | ||
317 | is not implemented yet. | ||