diff options
author | itojun <> | 2005-01-06 03:50:46 +0000 |
---|---|---|
committer | itojun <> | 2005-01-06 03:50:46 +0000 |
commit | 5cd91abe22e27dff54bafd3c933875170e8050b3 (patch) | |
tree | f7183ae01ae9185706105a0d04b95df5c1ebd270 | |
parent | a245c0c3e4906a7edc9c51d13b92a181df2b6d8d (diff) | |
download | openbsd-5cd91abe22e27dff54bafd3c933875170e8050b3.tar.gz openbsd-5cd91abe22e27dff54bafd3c933875170e8050b3.tar.bz2 openbsd-5cd91abe22e27dff54bafd3c933875170e8050b3.zip |
IPv6 manpage, wrote from scratch. deraadt ok
-rw-r--r-- | src/lib/libc/net/gai_strerror.3 | 3 | ||||
-rw-r--r-- | src/lib/libc/net/getaddrinfo.3 | 18 | ||||
-rw-r--r-- | src/lib/libc/net/getnameinfo.3 | 20 | ||||
-rw-r--r-- | src/lib/libc/net/inet6_option_space.3 | 434 | ||||
-rw-r--r-- | src/lib/libc/net/inet6_rthdr_space.3 | 305 |
5 files changed, 764 insertions, 16 deletions
diff --git a/src/lib/libc/net/gai_strerror.3 b/src/lib/libc/net/gai_strerror.3 index 06caac0993..d0a636ee03 100644 --- a/src/lib/libc/net/gai_strerror.3 +++ b/src/lib/libc/net/gai_strerror.3 | |||
@@ -1,4 +1,5 @@ | |||
1 | .\" $OpenBSD: gai_strerror.3,v 1.4 2004/12/20 23:04:53 millert Exp $ | 1 | .\" $OpenBSD: gai_strerror.3,v 1.5 2005/01/06 03:50:46 itojun Exp $ |
2 | .\" $KAME: gai_strerror.3,v 1.1 2005/01/05 03:04:47 itojun Exp $ | ||
2 | .\" | 3 | .\" |
3 | .\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") | 4 | .\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") |
4 | .\" Copyright (C) 2000, 2001 Internet Software Consortium. | 5 | .\" Copyright (C) 2000, 2001 Internet Software Consortium. |
diff --git a/src/lib/libc/net/getaddrinfo.3 b/src/lib/libc/net/getaddrinfo.3 index 4fba44bb73..64f317c010 100644 --- a/src/lib/libc/net/getaddrinfo.3 +++ b/src/lib/libc/net/getaddrinfo.3 | |||
@@ -1,4 +1,5 @@ | |||
1 | .\" $OpenBSD: getaddrinfo.3,v 1.35 2004/12/21 03:40:31 jaredy Exp $ | 1 | .\" $OpenBSD: getaddrinfo.3,v 1.36 2005/01/06 03:50:46 itojun Exp $ |
2 | .\" $KAME: getaddrinfo.3,v 1.36 2005/01/05 03:23:05 itojun Exp $ | ||
2 | .\" | 3 | .\" |
3 | .\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") | 4 | .\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") |
4 | .\" Copyright (C) 2000, 2001 Internet Software Consortium. | 5 | .\" Copyright (C) 2000, 2001 Internet Software Consortium. |
@@ -222,7 +223,8 @@ member points to a filled-in socket address structure of length | |||
222 | .Pp | 223 | .Pp |
223 | This implementation of | 224 | This implementation of |
224 | .Fn getaddrinfo | 225 | .Fn getaddrinfo |
225 | allows experimental numeric IPv6 address notation with scope identifiers. | 226 | allows numeric IPv6 address notation with scope identifier, |
227 | as documented in chapter 11 of draft-ietf-ipv6-scoping-arch-02.txt. | ||
226 | By appending the percent character and scope identifier to addresses, | 228 | By appending the percent character and scope identifier to addresses, |
227 | one can fill the | 229 | one can fill the |
228 | .Li sin6_scope_id | 230 | .Li sin6_scope_id |
@@ -248,7 +250,6 @@ on the link associated with the | |||
248 | interface | 250 | interface |
249 | .Dc . | 251 | .Dc . |
250 | .Pp | 252 | .Pp |
251 | The IPv6 implementation is still very experimental and non-standard. | ||
252 | The current implementation assumes a one-to-one relationship between | 253 | The current implementation assumes a one-to-one relationship between |
253 | the interface and link, which is not necessarily true from the specification. | 254 | the interface and link, which is not necessarily true from the specification. |
254 | .Pp | 255 | .Pp |
@@ -403,11 +404,14 @@ freeaddrinfo(res0); | |||
403 | .%D February 2003 | 404 | .%D February 2003 |
404 | .Re | 405 | .Re |
405 | .Rs | 406 | .Rs |
406 | .%A Tatsuya Jinmei | 407 | .%A S. Deering |
407 | .%A Atsushi Onoe | 408 | .%A B. Haberman |
408 | .%T "An Extension of Format for IPv6 Scoped Addresses" | 409 | .%A T. Jinmei |
410 | .%A E. Nordmark | ||
411 | .%A B. Zill | ||
412 | .%T "IPv6 Scoped Address Architecture" | ||
409 | .%R internet draft | 413 | .%R internet draft |
410 | .%N draft-ietf-ipngwg-scopedaddr-format-02.txt | 414 | .%N draft-ietf-ipv6-scoping-arch-02.txt |
411 | .%O work in progress material | 415 | .%O work in progress material |
412 | .Re | 416 | .Re |
413 | .Rs | 417 | .Rs |
diff --git a/src/lib/libc/net/getnameinfo.3 b/src/lib/libc/net/getnameinfo.3 index a6f2c63a91..39f9b8e14e 100644 --- a/src/lib/libc/net/getnameinfo.3 +++ b/src/lib/libc/net/getnameinfo.3 | |||
@@ -1,4 +1,5 @@ | |||
1 | .\" $OpenBSD: getnameinfo.3,v 1.36 2004/12/21 09:48:20 jmc Exp $ | 1 | .\" $OpenBSD: getnameinfo.3,v 1.37 2005/01/06 03:50:46 itojun Exp $ |
2 | .\" $KAME: getnameinfo.3,v 1.37 2005/01/05 03:23:05 itojun Exp $ | ||
2 | .\" | 3 | .\" |
3 | .\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") | 4 | .\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") |
4 | .\" Copyright (C) 2000, 2001 Internet Software Consortium. | 5 | .\" Copyright (C) 2000, 2001 Internet Software Consortium. |
@@ -115,8 +116,8 @@ and | |||
115 | .Tn TCP . | 116 | .Tn TCP . |
116 | .El | 117 | .El |
117 | .Pp | 118 | .Pp |
118 | This implementation allows experimental numeric IPv6 address notation with | 119 | This implementation allows numeric IPv6 address notation with scope identifier, |
119 | scope identifier. | 120 | as documented in chapter 11 of draft-ietf-ipv6-scoping-arch-02.txt. |
120 | IPv6 link-local address will appear as a string like | 121 | IPv6 link-local address will appear as a string like |
121 | .Dq Li fe80::1%ne0 . | 122 | .Dq Li fe80::1%ne0 . |
122 | Refer to | 123 | Refer to |
@@ -177,11 +178,14 @@ printf("host=%s\en", hbuf); | |||
177 | .%D March 1999 | 178 | .%D March 1999 |
178 | .Re | 179 | .Re |
179 | .Rs | 180 | .Rs |
180 | .%A Tatsuya Jinmei | 181 | .%A S. Deering |
181 | .%A Atsushi Onoe | 182 | .%A B. Haberman |
182 | .%T "An Extension of Format for IPv6 Scoped Addresses" | 183 | .%A T. Jinmei |
184 | .%A E. Nordmark | ||
185 | .%A B. Zill | ||
186 | .%T "IPv6 Scoped Address Architecture" | ||
183 | .%R internet draft | 187 | .%R internet draft |
184 | .%N draft-ietf-ipngwg-scopedaddr-format-02.txt | 188 | .%N draft-ietf-ipv6-scoping-arch-02.txt |
185 | .%O work in progress material | 189 | .%O work in progress material |
186 | .Re | 190 | .Re |
187 | .Rs | 191 | .Rs |
@@ -255,7 +259,7 @@ if (error == 0) { | |||
255 | .Ed | 259 | .Ed |
256 | .Sh BUGS | 260 | .Sh BUGS |
257 | The implementation of | 261 | The implementation of |
258 | .Fn getaddrinfo | 262 | .Fn getnameinfo |
259 | is not thread-safe. | 263 | is not thread-safe. |
260 | .Pp | 264 | .Pp |
261 | .Ox | 265 | .Ox |
diff --git a/src/lib/libc/net/inet6_option_space.3 b/src/lib/libc/net/inet6_option_space.3 new file mode 100644 index 0000000000..9b5cac95e8 --- /dev/null +++ b/src/lib/libc/net/inet6_option_space.3 | |||
@@ -0,0 +1,434 @@ | |||
1 | .\" $OpenBSD: inet6_option_space.3,v 1.15 2005/01/06 03:50:46 itojun Exp $ | ||
2 | .\" $KAME: inet6_option_space.3,v 1.11 2005/01/05 03:00:44 itojun Exp $ | ||
3 | .\" | ||
4 | .\" Copyright (C) 2004 WIDE Project. | ||
5 | .\" 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 project 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 PROJECT 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 PROJECT 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 23, 2004 | ||
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 Option Manipulation | ||
43 | .\" | ||
44 | .Sh LIBRARY | ||
45 | .Lb libc | ||
46 | .Sh SYNOPSIS | ||
47 | .In sys/types.h | ||
48 | .In netinet/in.h | ||
49 | .Ft "int" | ||
50 | .Fn inet6_option_space "int nbytes" | ||
51 | .Ft "int" | ||
52 | .Fn inet6_option_init "void *bp" "struct cmsghdr **cmsgp" "int type" | ||
53 | .Ft "int" | ||
54 | .Fn inet6_option_append "struct cmsghdr *cmsg" "const u_int8_t *typep" "int multx" "int plusy" | ||
55 | .Ft "u_int8_t *" | ||
56 | .Fn inet6_option_alloc "struct cmsghdr *cmsg" "int datalen" "int multx" "int plusy" | ||
57 | .Ft "int" | ||
58 | .Fn inet6_option_next "const struct cmsghdr *cmsg" "u_int8_t **tptrp" | ||
59 | .Ft "int" | ||
60 | .Fn inet6_option_find "const struct cmsghdr *cmsg" "u_int8_t **tptrp" "int type" | ||
61 | .\" | ||
62 | .Sh DESCRIPTION | ||
63 | .\" | ||
64 | Manipulating and parsing IPv6's Hop-by-Hop and Destination options is | ||
65 | complicated by the need to properly align and pad data as well as the | ||
66 | need to manipulate ancillary information that is not part of the data | ||
67 | stream. | ||
68 | RFC2292 defines a set of functions, which are implemented as | ||
69 | part of the Kame libraries, to support help developers create, change, | ||
70 | and parse Hop-by-Hope and Destination options. | ||
71 | All of the prototypes | ||
72 | for the option functions are defined in the | ||
73 | .In netinet/in.h | ||
74 | header file. | ||
75 | .\" | ||
76 | .Ss inet6_option_space | ||
77 | In order to determine the amount of space necessary to hold any option | ||
78 | the | ||
79 | .Fn inet6_option_space | ||
80 | function is called. | ||
81 | It returns the number of bytes required to hold | ||
82 | an option when it is stored as ancillary data, including the | ||
83 | .Li cmsghdr | ||
84 | structure at the beginning, and any necessary padding at the end. | ||
85 | The | ||
86 | .Li nbytes | ||
87 | argument indicates the size of the structure defining the option, | ||
88 | and must include any pad bytes at the beginning (the value | ||
89 | .Li y | ||
90 | in the alignment term | ||
91 | .Dq Li "xn + y" ) , | ||
92 | the type byte, the length byte, and the option data. | ||
93 | .Pp | ||
94 | Note: If multiple options are stored in a single ancillary data | ||
95 | object, which is the recommended technique, the | ||
96 | .Fn inet6_option_space | ||
97 | function overestimates the amount of space required by the size of | ||
98 | .Li N-1 | ||
99 | .Li cmsghdr | ||
100 | structures, where | ||
101 | .Li N | ||
102 | is the number of options to be stored in the object. | ||
103 | Usually this has | ||
104 | no impact because it is assumed that most Hop-by-Hop and Destination | ||
105 | option headers carry only one option as indicated in appendix B of RFC2460. | ||
106 | .\" | ||
107 | .Ss inet6_option_init | ||
108 | The | ||
109 | .Fn inet6_option_init | ||
110 | function is called to initialize any ancillary data object that will contain | ||
111 | a Hop-by-Hop or Destination option. | ||
112 | It returns | ||
113 | .Li 0 | ||
114 | on success and | ||
115 | .Li -1 | ||
116 | when an error occurs. | ||
117 | .Pp | ||
118 | The | ||
119 | .Fa bp | ||
120 | argument points to a previously allocated area of memory which must be | ||
121 | large enough to contain all the arguments that the application indents | ||
122 | to add later via | ||
123 | .Fn inet6_option_append | ||
124 | and | ||
125 | .Fn inet6_option_alloc | ||
126 | routines. | ||
127 | .Pp | ||
128 | The | ||
129 | .Fa cmsgp | ||
130 | argument is a pointer to a pointer to a | ||
131 | .Li cmsghdr | ||
132 | structure. | ||
133 | The | ||
134 | .Fa *cmsgp | ||
135 | argument | ||
136 | points to a | ||
137 | .Li cmsghdr | ||
138 | structure which is constructed by this function and stored in the | ||
139 | area of memory pointed to by | ||
140 | .Fa bp . | ||
141 | .Pp | ||
142 | The | ||
143 | .Fa type | ||
144 | is either | ||
145 | .Dv IPV6_HOPOPTS | ||
146 | or | ||
147 | .Dv IPV6_DSTOPTS | ||
148 | and is stored in the | ||
149 | .Li cmsg_type | ||
150 | member of the | ||
151 | .Li cmsghdr | ||
152 | structure mentioned above. | ||
153 | .\" | ||
154 | .Ss inet6_option_append | ||
155 | This function appends a Hop-by-Hop option or a Destination option into | ||
156 | an ancillary data object previously initialized by a call to | ||
157 | .Fn inet6_option_init . | ||
158 | The | ||
159 | .Fn inet6_option_append function returns | ||
160 | .Li 0 | ||
161 | if it succeeds or | ||
162 | .Li -1 | ||
163 | when an error occurs. | ||
164 | .Pp | ||
165 | The | ||
166 | .Fa cmsg | ||
167 | argument is a pointer to the | ||
168 | .Li cmsghdr | ||
169 | structure that was initialized by a call to | ||
170 | .Fn inet6_option_init . | ||
171 | .Pp | ||
172 | The | ||
173 | .Fa typep | ||
174 | argument is a pointer to the 8-bit option type. | ||
175 | All options are | ||
176 | encoded as type-length-value tuples and it is assumed that | ||
177 | the | ||
178 | .Fa typep | ||
179 | field is immediately followed by the 8-bit option data length field, | ||
180 | which is then followed by the option data. | ||
181 | .Pp | ||
182 | The option types of | ||
183 | .Li 0 | ||
184 | and | ||
185 | .Li 1 are reserved for the | ||
186 | .Li Pad1 | ||
187 | and | ||
188 | .Li PadN | ||
189 | options respectively. | ||
190 | All other values from | ||
191 | .Li 2 | ||
192 | through | ||
193 | .Li 255 | ||
194 | are available for applications to use. | ||
195 | .Pp | ||
196 | The option data length, since it is stored in 8 bites, must have a | ||
197 | value between | ||
198 | .Li 0 | ||
199 | and | ||
200 | .Li 255 , | ||
201 | inclusive. | ||
202 | .Pp | ||
203 | The | ||
204 | .Fa multx | ||
205 | argument | ||
206 | is the value | ||
207 | .Li x | ||
208 | in the alignment term | ||
209 | .Dq Li xn + y | ||
210 | and indicates the byte alignment necessary for the data. | ||
211 | Alignments may be specified as | ||
212 | .Li 1 , | ||
213 | .Li 2 , | ||
214 | .Li 4 , | ||
215 | or | ||
216 | .Li 8 | ||
217 | bytes, which is no alignment, 16 bit, 32 bit and 64 bit alignments | ||
218 | respectively. | ||
219 | .Pp | ||
220 | The | ||
221 | .Fa plusy | ||
222 | argument | ||
223 | is the value | ||
224 | .Li y | ||
225 | in the alignment term | ||
226 | .Dq Li xn + y | ||
227 | and must have a value between | ||
228 | .Li 0 | ||
229 | and | ||
230 | .Li 7 , | ||
231 | inclusive, indicating the amount of padding that is necessary for an | ||
232 | option. | ||
233 | .\" | ||
234 | .Ss inet6_option_alloc | ||
235 | The | ||
236 | .Fn inet6_option_alloc | ||
237 | function appends a Hop-by-Hop option or a Destination option into an | ||
238 | ancillary data object that has previously been initialized by a call to | ||
239 | .Fn inet6_option_init . | ||
240 | The | ||
241 | .Fn inet6_option_alloc | ||
242 | function returns a pointer to the 8-bit option type field that at the | ||
243 | beginning of the allocated the option on success, or | ||
244 | .Dv NULL | ||
245 | on an error. | ||
246 | .Pp | ||
247 | The difference between the | ||
248 | .Fn inet6_option_alloc | ||
249 | and | ||
250 | .Fn inet6_option_append | ||
251 | functions is that the latter copies the contents of a previously built | ||
252 | option into the ancillary data object while the former returns a | ||
253 | pointer to the place in the data object where the option's TLV must | ||
254 | then be built by the application. | ||
255 | .Pp | ||
256 | The | ||
257 | .Fa cmsg | ||
258 | argument is a pointer to a | ||
259 | .Li cmsghdr | ||
260 | structure that was initialized by | ||
261 | .Fn inet6_option_init . | ||
262 | .Pp | ||
263 | The | ||
264 | .Fa datalen | ||
265 | argument is the value of the option data length byte for this option. | ||
266 | This value is required as an argument to allow the function to | ||
267 | determine if padding must be appended at the end of the option. | ||
268 | (The | ||
269 | .Fn inet6_option_append | ||
270 | function does not need a data length argument | ||
271 | since the option data length must already be stored by the caller) | ||
272 | .Pp | ||
273 | The | ||
274 | .Fa multx | ||
275 | and | ||
276 | .Fa plusy | ||
277 | arguments | ||
278 | are identical to the arguments of the same name described in the | ||
279 | .Fn inet6_option_init | ||
280 | function above. | ||
281 | .\" | ||
282 | .Ss inet6_option_next | ||
283 | The | ||
284 | .Fn inet6_option_next | ||
285 | function is used to process Hop-by-Hop and Destination options that | ||
286 | are present in an ancillary data object. | ||
287 | When an option remains to | ||
288 | be processed, the return value of the | ||
289 | .Fn inet6_option_next | ||
290 | function is | ||
291 | .Li 0 | ||
292 | and the | ||
293 | .Fa *tptrp | ||
294 | argument points to the 8-bit option type field, which is followed by | ||
295 | the 8-bit option data length, and then the option data. | ||
296 | When no more | ||
297 | options remain to be processed, the return value is | ||
298 | .Li -1 | ||
299 | and | ||
300 | .Fa *tptrp | ||
301 | is | ||
302 | .Dv NULL | ||
303 | and when an error occurs, the return value is | ||
304 | .Li -1 | ||
305 | but the | ||
306 | .Fa *tptrp | ||
307 | argument is not | ||
308 | .Dv NULL . | ||
309 | This set of return values allows a program to easily loop through all | ||
310 | the options in an ancillary data object, checking for the error and | ||
311 | end of stream conditions along the way. | ||
312 | .Pp | ||
313 | When a valid option is returned the | ||
314 | .Fa cmsg | ||
315 | argument points to a | ||
316 | .Li cmsghdr | ||
317 | where the | ||
318 | .Li cmsg_level | ||
319 | equals | ||
320 | .Dv IPPROTO_IPV6 | ||
321 | and | ||
322 | .Li cmsg_type | ||
323 | is either | ||
324 | .Dv IPV6_HOPOPTS | ||
325 | or | ||
326 | .Dv IPV6_DSTOPTS . | ||
327 | .Pp | ||
328 | The | ||
329 | .Fa tptrp | ||
330 | argument is a pointer to a pointer to an 8-bit byte and | ||
331 | .Fa *tptrp | ||
332 | is used by the function to remember its place in the ancillary data | ||
333 | object each time the function is called. | ||
334 | When the | ||
335 | .Fn inet6_option_next | ||
336 | function is called for the first time on a given ancillary data object, | ||
337 | .Fa *tptrp | ||
338 | must be set to | ||
339 | .Dv NULL . | ||
340 | .Pp | ||
341 | Each time the function returns success, | ||
342 | the | ||
343 | .Fa *tptrp | ||
344 | argument points to the 8-bit option type field for the next option to | ||
345 | be processed. | ||
346 | .\" | ||
347 | .Ss inet6_option_find | ||
348 | The | ||
349 | .Fn inet6_option_find | ||
350 | function allows an application to search for a particular option type | ||
351 | in an ancillary data object. | ||
352 | The | ||
353 | .Fa cmsg | ||
354 | argument is a pointer to | ||
355 | .Li cmsghdr | ||
356 | structure in which the | ||
357 | .Li cmsg_level | ||
358 | element equals | ||
359 | .Dv IPPROTO_IPV6 | ||
360 | and the | ||
361 | .Li cmsg_type | ||
362 | element is either | ||
363 | .Dv IPV6_HOPOPTS | ||
364 | or | ||
365 | .Dv IPV6_DSTOPTS . | ||
366 | .Pp | ||
367 | The | ||
368 | .Fa tptrp | ||
369 | argument is handled exactly as in the | ||
370 | .Fn inet6_option_next | ||
371 | function described above. | ||
372 | .Pa | ||
373 | The | ||
374 | .fn inet6_option_find | ||
375 | function starts searching for an option of the specified type | ||
376 | beginning after the value of | ||
377 | .Fa *tptrp . | ||
378 | .\" | ||
379 | .Sh DIAGNOSTICS | ||
380 | The | ||
381 | .Fn inet6_option_init | ||
382 | and | ||
383 | .Fn inet6_option_append | ||
384 | functions return | ||
385 | .Li 0 | ||
386 | on success or | ||
387 | .Li -1 | ||
388 | on an error. | ||
389 | .Pp | ||
390 | The | ||
391 | .Fn inet6_option_alloc | ||
392 | function returns | ||
393 | .Dv NULL | ||
394 | on an error. | ||
395 | .Pp | ||
396 | When | ||
397 | .Fn inet6_option_next | ||
398 | or | ||
399 | .Fn inet6_option_find | ||
400 | detect an error they return | ||
401 | .Li -1 | ||
402 | setting | ||
403 | .Fa *tptrp | ||
404 | to non | ||
405 | .Dv NULL | ||
406 | value. | ||
407 | .\" | ||
408 | .Sh EXAMPLES | ||
409 | RFC2292 gives comprehensive examples in chapter 6. | ||
410 | .\" | ||
411 | .Sh SEE ALSO | ||
412 | .Rs | ||
413 | .%A W. Stevens | ||
414 | .%A M. Thomas | ||
415 | .%T "Advanced Sockets API for IPv6" | ||
416 | .%N RFC2292 | ||
417 | .%D February 1998 | ||
418 | .Re | ||
419 | .Rs | ||
420 | .%A S. Deering | ||
421 | .%A R. Hinden | ||
422 | .%T "Internet Protocol, Version 6 (IPv6) Specification" | ||
423 | .%N RFC2460 | ||
424 | .%D December 1998 | ||
425 | .Re | ||
426 | .\" | ||
427 | .Sh HISTORY | ||
428 | The implementation first appeared in KAME advanced networking kit. | ||
429 | .\" | ||
430 | .Sh STANDARDS | ||
431 | The functions are documented in | ||
432 | .Dq Advanced Sockets API for IPv6 | ||
433 | (RFC2292). | ||
434 | .\" | ||
diff --git a/src/lib/libc/net/inet6_rthdr_space.3 b/src/lib/libc/net/inet6_rthdr_space.3 new file mode 100644 index 0000000000..77dbd64e3c --- /dev/null +++ b/src/lib/libc/net/inet6_rthdr_space.3 | |||
@@ -0,0 +1,305 @@ | |||
1 | .\" $OpenBSD: inet6_rthdr_space.3,v 1.15 2005/01/06 03:50:46 itojun Exp $ | ||
2 | .\" $KAME: inet6_rthdr_space.3,v 1.11 2005/01/05 03:00:44 itojun Exp $ | ||
3 | .\" | ||
4 | .\" Copyright (C) 2004 WIDE Project. | ||
5 | .\" 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 project 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 PROJECT 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 PROJECT 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 27, 2004 | ||
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 LIBRARY | ||
47 | .Lb libc | ||
48 | .Sh SYNOPSIS | ||
49 | .In sys/types.h | ||
50 | .In netinet/in.h | ||
51 | .Ft size_t | ||
52 | .Fn inet6_rthdr_space "int type" "int segments" | ||
53 | .Ft "struct cmsghdr *" | ||
54 | .Fn inet6_rthdr_init "void *bp" "int type" | ||
55 | .Ft int | ||
56 | .Fn inet6_rthdr_add "struct cmsghdr *cmsg" "const struct in6_addr *addr" "unsigned int flags" | ||
57 | .Ft int | ||
58 | .Fn inet6_rthdr_lasthop "struct cmsghdr *cmsg" "unsigned int flags" | ||
59 | .Ft int | ||
60 | .Fn inet6_rthdr_reverse "const struct cmsghdr *in" "struct cmsghdr *out" | ||
61 | .Ft int | ||
62 | .Fn inet6_rthdr_segments "const struct cmsghdr *cmsg" | ||
63 | .Ft "struct in6_addr *" | ||
64 | .Fn inet6_rthdr_getaddr "struct cmsghdr *cmsg" "int index" | ||
65 | .Ft int | ||
66 | .Fn inet6_rthdr_getflags "const struct cmsghdr *cmsg" "int index" | ||
67 | .\" | ||
68 | .Sh DESCRIPTION | ||
69 | .\"The RFC 2292 IPv6 Advanced API has been deprecated in favor of the | ||
70 | .\"newer, RFC 3542 APIs. | ||
71 | .\"On platforms that support it, currently only | ||
72 | .\"FreeBSD, please use the newer API to manipulate routing header | ||
73 | .\"options. | ||
74 | .\".Pp | ||
75 | The RFC 2292 IPv6 Advanced API defined eight functions for | ||
76 | applications to use for building and parsing routing headers. | ||
77 | The | ||
78 | eight functions are split into two groups, the first of which builds | ||
79 | the header and the second of which can parse it. | ||
80 | The function prototypes for these functions are all in the | ||
81 | .In netinet/in.h | ||
82 | header. | ||
83 | Although direct manipulation of a routing header is possible | ||
84 | this set of APIs make it unnecessary and such direct manipulation | ||
85 | should be avoided so that changes to the underlying structures do not | ||
86 | break applications. | ||
87 | .Pp | ||
88 | Please note that RFC 2292 uses the term | ||
89 | .Dq segments | ||
90 | instead of the term | ||
91 | .Dq addresses | ||
92 | but they are considered equivalent for this manual page. | ||
93 | .\" | ||
94 | .Ss inet6_rthdr_space | ||
95 | The | ||
96 | .Fn inet6_rthdr_space | ||
97 | function returns the number of bytes required to hold a routing header | ||
98 | of the specified | ||
99 | .Fa type | ||
100 | and containing the specified number of | ||
101 | .Fa segments . | ||
102 | Only one | ||
103 | .Fa type | ||
104 | is supported, | ||
105 | .Dv IPV6_RTHDR_TYPE_0 , | ||
106 | and it can hold from 1 to 23 segments. | ||
107 | The return value includes the | ||
108 | size of the cmsghdr structure that precedes the routing header, and | ||
109 | any required padding. | ||
110 | .Pp | ||
111 | A return value of 0 indicates an error. | ||
112 | Either the type was specified | ||
113 | incorrectly, or the number of segments was less than one or greater | ||
114 | than 23. | ||
115 | .Pp | ||
116 | Note: The | ||
117 | .Fn inet6_rthdr_space | ||
118 | function only returns the size required by the routing header and does | ||
119 | not allocate memory for the caller. | ||
120 | .\" | ||
121 | .Ss inet6_rthdr_init | ||
122 | The | ||
123 | .Fn inet6_rthdr_init | ||
124 | function initializes a buffer, pointed to by | ||
125 | .Fa bp | ||
126 | with an appropriate | ||
127 | .Li cmsghdr | ||
128 | structure followed by a routing header of the specified | ||
129 | .Fa type . | ||
130 | .Pp | ||
131 | The caller must use the | ||
132 | .Fn inet6_rthdr_space | ||
133 | function to determine the size of the buffer, and then allocate that | ||
134 | buffer before calling | ||
135 | .Fn inet6_rthdr_init . | ||
136 | .Pp | ||
137 | The return value is a pointer to a | ||
138 | .Li cmsghdr | ||
139 | structure, which is used as the first argument to the | ||
140 | .Fn inet6_rthdr_add | ||
141 | and | ||
142 | .Fn inet6_rthdr_lasthop | ||
143 | functions in order to construct the routing header. | ||
144 | When an error occurs the return value is | ||
145 | .Dv NULL . | ||
146 | .\" | ||
147 | .Ss inet6_rthdr_add | ||
148 | The | ||
149 | .Fn inet6_rthdr_add | ||
150 | function adds the IPv6 address pointed to by | ||
151 | .Fa addr | ||
152 | to the end of the | ||
153 | routing header being constructed and sets the type of this address to the | ||
154 | value of | ||
155 | .Fa flags . | ||
156 | The | ||
157 | .Fa flags | ||
158 | must be either | ||
159 | .Dv IPV6_RTHDR_LOOSE | ||
160 | or | ||
161 | .Dv IPV6_RTHDR_STRICT | ||
162 | indicating whether loose or strict source routing is required. | ||
163 | .Pp | ||
164 | When the function succeeds it returns 0, otherwise \-1 is returned. | ||
165 | .\" | ||
166 | .Ss inet6_rthdr_lasthop | ||
167 | The | ||
168 | .Fn inet6_rthdr_lasthop | ||
169 | function specifies the strict or loose flag for the final hop of a | ||
170 | routing header. | ||
171 | The | ||
172 | .Fa flags | ||
173 | must be either | ||
174 | .Dv IPV6_RTHDR_LOOSE | ||
175 | or | ||
176 | .Dv IPV6_RTHDR_STRICT . | ||
177 | .Pp | ||
178 | The return value of the function is 0 upon success, and \-1 when an | ||
179 | error has occurred. | ||
180 | .Pp | ||
181 | Please note that a routing header specifying | ||
182 | .Li N | ||
183 | intermediate nodes requires | ||
184 | .Li N+1 | ||
185 | strict or loose flags meaning that | ||
186 | .Fn inet6_rthdr_add | ||
187 | must be called | ||
188 | .Li N | ||
189 | times and then | ||
190 | .Fn inet6_rthdr_lasthop | ||
191 | must be called once. | ||
192 | .\" | ||
193 | .Ss inet6_rthdr_reverse | ||
194 | This function was never implemented. | ||
195 | .Pp | ||
196 | The following four functions provide an API for parsing a received | ||
197 | routing header. | ||
198 | .\" | ||
199 | .Ss inet6_rthdr_segments | ||
200 | The | ||
201 | .Fn inet6_rthdr_segments | ||
202 | function returns the number of segments contained in the Routing | ||
203 | header pointed to by the | ||
204 | .Fa cmsg | ||
205 | argument. | ||
206 | On success the return value is from 1 to 23. | ||
207 | When an error occurs \-1 is returned. | ||
208 | .\" | ||
209 | .Ss inet6_rthdr_getaddr | ||
210 | The | ||
211 | .Fn inet6_rthdr_getaddr | ||
212 | function returns a pointer to the IPv6 address specified by the | ||
213 | .Fa index | ||
214 | argument from the routing header pointed to by | ||
215 | .Fa cmsg . | ||
216 | The index must be between 1 and the number returned by | ||
217 | .Fn inet6_rthdr_segments | ||
218 | described above. | ||
219 | An application must call | ||
220 | .Fn inet6_rthdr_segments | ||
221 | to obtain the number of segments in the routing header. | ||
222 | .Pp | ||
223 | If an error occurs the | ||
224 | .Dv NULL | ||
225 | is returned. | ||
226 | .\" | ||
227 | .Ss inet6_rthdr_getflags | ||
228 | The | ||
229 | .Fn inet6_rthdr_getflags | ||
230 | function returns the flags value of the segment specified by | ||
231 | .Fa index | ||
232 | of the routing header pointed to by | ||
233 | .Fa cmsg . | ||
234 | The | ||
235 | .Fa index | ||
236 | argument must be between 0 and the value returned by | ||
237 | .Fn inet6_rthdr_segments . | ||
238 | The return value will be either | ||
239 | .Dv IPV6_RTHDR_LOOSE | ||
240 | or | ||
241 | .Dv IPV6_RTHDR_STRICT | ||
242 | indicating whether loose or strict source routing was requested for | ||
243 | that segment. | ||
244 | .Pp | ||
245 | When an error occurs \-1 is returned. | ||
246 | .Pp | ||
247 | Note: Flags begin at index 0 while segments begin at index 1, to | ||
248 | maintain consistency with the terminology and figures in RFC2460. | ||
249 | .\" | ||
250 | .Sh DIAGNOSTICS | ||
251 | The | ||
252 | .Fn inet6_rthdr_space | ||
253 | function returns 0 when an error occurs. | ||
254 | .Pp | ||
255 | The | ||
256 | .Fn inet6_rthdr_add , | ||
257 | .Fn inet6_rthdr_lasthop | ||
258 | functions return 0 on success, and \-1 on error. | ||
259 | .Pp | ||
260 | The | ||
261 | .Fn inet6_rthdr_init | ||
262 | and | ||
263 | .Fn inet6_rthdr_getaddr | ||
264 | functions | ||
265 | return | ||
266 | .Dv NULL | ||
267 | on error. | ||
268 | .Pp | ||
269 | The | ||
270 | .Fn inet6_rthdr_segments | ||
271 | and | ||
272 | .Fn inet6_rthdr_getflags | ||
273 | functions return -1 on error. | ||
274 | .\" | ||
275 | .Sh EXAMPLES | ||
276 | RFC2292 gives comprehensive examples in chapter 8. | ||
277 | .\" | ||
278 | .Sh SEE ALSO | ||
279 | .Rs | ||
280 | .%A W. Stevens | ||
281 | .%A M. Thomas | ||
282 | .%T "Advanced Sockets API for IPv6" | ||
283 | .%N RFC2292 | ||
284 | .%D February 1998 | ||
285 | .Re | ||
286 | .Rs | ||
287 | .%A S. Deering | ||
288 | .%A R. Hinden | ||
289 | .%T "Internet Protocol, Version 6 (IPv6) Specification" | ||
290 | .%N RFC2460 | ||
291 | .%D December 1998 | ||
292 | .Re | ||
293 | .\" | ||
294 | .Sh HISTORY | ||
295 | The implementation first appeared in KAME advanced networking kit. | ||
296 | .\" | ||
297 | .Sh BUGS | ||
298 | The | ||
299 | .Fn inet6_rthdr_reverse | ||
300 | function was never implemented. | ||
301 | .\".Pp | ||
302 | .\"This API is deprecated in favor of | ||
303 | .\".Xr inet6_rth_space 3 | ||
304 | .\".Sh SEE ALSO | ||
305 | .\".Xr inet6_rth_space 3 | ||