diff options
Diffstat (limited to 'src/lib/libc/net/inet6_option_space.3')
| -rw-r--r-- | src/lib/libc/net/inet6_option_space.3 | 444 |
1 files changed, 0 insertions, 444 deletions
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 8aa79a6d0b..0000000000 --- a/src/lib/libc/net/inet6_option_space.3 +++ /dev/null | |||
| @@ -1,444 +0,0 @@ | |||
| 1 | .\" $OpenBSD: inet6_option_space.3,v 1.21 2007/05/31 19:19:30 jmc 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 $Mdocdate: May 31 2007 $ | ||
| 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 SYNOPSIS | ||
| 45 | .In sys/types.h | ||
| 46 | .In netinet/in.h | ||
| 47 | .Ft "int" | ||
| 48 | .Fn inet6_option_space "int nbytes" | ||
| 49 | .Ft "int" | ||
| 50 | .Fn inet6_option_init "void *bp" "struct cmsghdr **cmsgp" "int type" | ||
| 51 | .Ft "int" | ||
| 52 | .Fn inet6_option_append "struct cmsghdr *cmsg" "const u_int8_t *typep" "int multx" "int plusy" | ||
| 53 | .Ft "u_int8_t *" | ||
| 54 | .Fn inet6_option_alloc "struct cmsghdr *cmsg" "int datalen" "int multx" "int plusy" | ||
| 55 | .Ft "int" | ||
| 56 | .Fn inet6_option_next "const struct cmsghdr *cmsg" "u_int8_t **tptrp" | ||
| 57 | .Ft "int" | ||
| 58 | .Fn inet6_option_find "const struct cmsghdr *cmsg" "u_int8_t **tptrp" "int type" | ||
| 59 | .\" | ||
| 60 | .Sh DESCRIPTION | ||
| 61 | .\" | ||
| 62 | Note: | ||
| 63 | RFC 2292 has been superseded by RFC 3542. | ||
| 64 | The use of functions described in this page is deprecated. | ||
| 65 | See | ||
| 66 | .Xr inet6_opt_init 3 . | ||
| 67 | .Pp | ||
| 68 | Manipulating and parsing IPv6's Hop-by-Hop and Destination options is | ||
| 69 | complicated by the need to properly align and pad data as well as the | ||
| 70 | need to manipulate ancillary information that is not part of the data | ||
| 71 | stream. | ||
| 72 | RFC 2292 defines a set of functions, which are implemented as | ||
| 73 | part of the Kame libraries, to help developers create, change, | ||
| 74 | and parse Hop-by-Hop and Destination options. | ||
| 75 | All of the prototypes | ||
| 76 | for the option functions are defined in the | ||
| 77 | .Aq Pa netinet/in.h | ||
| 78 | header file. | ||
| 79 | .\" | ||
| 80 | .Ss inet6_option_space | ||
| 81 | In order to determine the amount of space necessary to hold any option | ||
| 82 | the | ||
| 83 | .Fn inet6_option_space | ||
| 84 | function is called. | ||
| 85 | It returns the number of bytes required to hold | ||
| 86 | an option when it is stored as ancillary data, including the | ||
| 87 | .Li cmsghdr | ||
| 88 | structure at the beginning, and any necessary padding at the end. | ||
| 89 | The | ||
| 90 | .Fa nbytes | ||
| 91 | argument indicates the size of the structure defining the option, | ||
| 92 | and must include any pad bytes at the beginning (the value | ||
| 93 | .Li y | ||
| 94 | in the alignment term | ||
| 95 | .Dq Li "xn + y" ) , | ||
| 96 | the type byte, the length byte, and the option data. | ||
| 97 | .Pp | ||
| 98 | Note: If multiple options are stored in a single ancillary data | ||
| 99 | object, which is the recommended technique, the | ||
| 100 | .Fn inet6_option_space | ||
| 101 | function overestimates the amount of space required by the size of | ||
| 102 | .Li N-1 | ||
| 103 | .Li cmsghdr | ||
| 104 | structures, where | ||
| 105 | .Li N | ||
| 106 | is the number of options to be stored in the object. | ||
| 107 | Usually this has | ||
| 108 | no impact because it is assumed that most Hop-by-Hop and Destination | ||
| 109 | option headers carry only one option as indicated in appendix B of RFC 2460. | ||
| 110 | .\" | ||
| 111 | .Ss inet6_option_init | ||
| 112 | The | ||
| 113 | .Fn inet6_option_init | ||
| 114 | function is called to initialize any ancillary data object that will contain | ||
| 115 | a Hop-by-Hop or Destination option. | ||
| 116 | It returns | ||
| 117 | .Li 0 | ||
| 118 | on success and | ||
| 119 | .Li \-1 | ||
| 120 | when an error occurs. | ||
| 121 | .Pp | ||
| 122 | The | ||
| 123 | .Fa bp | ||
| 124 | argument points to a previously allocated area of memory which must be | ||
| 125 | large enough to contain all the arguments that the application intends | ||
| 126 | to add later via the | ||
| 127 | .Fn inet6_option_append | ||
| 128 | and | ||
| 129 | .Fn inet6_option_alloc | ||
| 130 | routines. | ||
| 131 | .Pp | ||
| 132 | The | ||
| 133 | .Fa cmsgp | ||
| 134 | argument is a pointer to a pointer to a | ||
| 135 | .Li cmsghdr | ||
| 136 | structure. | ||
| 137 | The | ||
| 138 | .Fa *cmsgp | ||
| 139 | argument | ||
| 140 | points to a | ||
| 141 | .Li cmsghdr | ||
| 142 | structure which is constructed by this function and stored in the | ||
| 143 | area of memory pointed to by | ||
| 144 | .Fa bp . | ||
| 145 | .Pp | ||
| 146 | The | ||
| 147 | .Fa type | ||
| 148 | is either | ||
| 149 | .Dv IPV6_HOPOPTS | ||
| 150 | or | ||
| 151 | .Dv IPV6_DSTOPTS | ||
| 152 | and is stored in the | ||
| 153 | .Li cmsg_type | ||
| 154 | member of the | ||
| 155 | .Li cmsghdr | ||
| 156 | structure mentioned above. | ||
| 157 | .\" | ||
| 158 | .Ss inet6_option_append | ||
| 159 | This function appends a Hop-by-Hop option or a Destination option into | ||
| 160 | an ancillary data object previously initialized by a call to | ||
| 161 | .Fn inet6_option_init . | ||
| 162 | The | ||
| 163 | .Fn inet6_option_append | ||
| 164 | function returns | ||
| 165 | .Li 0 | ||
| 166 | if it succeeds or | ||
| 167 | .Li \-1 | ||
| 168 | when an error occurs. | ||
| 169 | .Pp | ||
| 170 | The | ||
| 171 | .Fa cmsg | ||
| 172 | argument is a pointer to the | ||
| 173 | .Li cmsghdr | ||
| 174 | structure that was initialized by a call to | ||
| 175 | .Fn inet6_option_init . | ||
| 176 | .Pp | ||
| 177 | The | ||
| 178 | .Fa typep | ||
| 179 | argument is a pointer to the 8-bit option type. | ||
| 180 | All options are | ||
| 181 | encoded as type-length-value tuples and it is assumed that | ||
| 182 | the | ||
| 183 | .Fa typep | ||
| 184 | field is immediately followed by the 8-bit option data length field, | ||
| 185 | which is then followed by the option data. | ||
| 186 | .Pp | ||
| 187 | The option types of | ||
| 188 | .Li 0 | ||
| 189 | and | ||
| 190 | .Li 1 | ||
| 191 | are reserved for the | ||
| 192 | .Li Pad1 | ||
| 193 | and | ||
| 194 | .Li PadN | ||
| 195 | options respectively. | ||
| 196 | All other values from | ||
| 197 | .Li 2 | ||
| 198 | through | ||
| 199 | .Li 255 | ||
| 200 | are available for applications to use. | ||
| 201 | .Pp | ||
| 202 | The option data length, since it is stored in 8 bites, must have a | ||
| 203 | value between | ||
| 204 | .Li 0 | ||
| 205 | and | ||
| 206 | .Li 255 , | ||
| 207 | inclusive. | ||
| 208 | .Pp | ||
| 209 | The | ||
| 210 | .Fa multx | ||
| 211 | argument | ||
| 212 | is the value | ||
| 213 | .Li x | ||
| 214 | in the alignment term | ||
| 215 | .Dq Li xn + y | ||
| 216 | and indicates the byte alignment necessary for the data. | ||
| 217 | Alignments may be specified as | ||
| 218 | .Li 1 , | ||
| 219 | .Li 2 , | ||
| 220 | .Li 4 , | ||
| 221 | or | ||
| 222 | .Li 8 | ||
| 223 | bytes, which is no alignment, 16-bit, 32-bit and 64-bit alignments | ||
| 224 | respectively. | ||
| 225 | .Pp | ||
| 226 | The | ||
| 227 | .Fa plusy | ||
| 228 | argument | ||
| 229 | is the value | ||
| 230 | .Li y | ||
| 231 | in the alignment term | ||
| 232 | .Dq Li xn + y | ||
| 233 | and must have a value between | ||
| 234 | .Li 0 | ||
| 235 | and | ||
| 236 | .Li 7 , | ||
| 237 | inclusive, indicating the amount of padding that is necessary for an | ||
| 238 | option. | ||
| 239 | .\" | ||
| 240 | .Ss inet6_option_alloc | ||
| 241 | The | ||
| 242 | .Fn inet6_option_alloc | ||
| 243 | function appends a Hop-by-Hop option or a Destination option into an | ||
| 244 | ancillary data object that has previously been initialized by a call to | ||
| 245 | .Fn inet6_option_init . | ||
| 246 | A successful call to the | ||
| 247 | .Fn inet6_option_alloc | ||
| 248 | function returns a pointer to the 8-bit option type field, | ||
| 249 | which is at the beginning of the allocated region. | ||
| 250 | .Fn inet6_option_alloc | ||
| 251 | returns | ||
| 252 | .Dv NULL | ||
| 253 | when an error has occurred. | ||
| 254 | .Pp | ||
| 255 | The difference between the | ||
| 256 | .Fn inet6_option_alloc | ||
| 257 | and | ||
| 258 | .Fn inet6_option_append | ||
| 259 | functions is that the latter copies the contents of a previously built | ||
| 260 | option into the ancillary data object while the former returns a | ||
| 261 | pointer to the place in the data object where the option's TLV must | ||
| 262 | then be built by the application. | ||
| 263 | .Pp | ||
| 264 | The | ||
| 265 | .Fa cmsg | ||
| 266 | argument is a pointer to a | ||
| 267 | .Li cmsghdr | ||
| 268 | structure that was initialized by | ||
| 269 | .Fn inet6_option_init . | ||
| 270 | .Pp | ||
| 271 | The | ||
| 272 | .Fa datalen | ||
| 273 | argument is the value of the option data length byte for this option. | ||
| 274 | This value is required as an argument to allow the function to | ||
| 275 | determine if padding must be appended at the end of the option. | ||
| 276 | (The | ||
| 277 | .Fn inet6_option_append | ||
| 278 | function does not need a data length argument | ||
| 279 | since the option data length must already be stored by the caller.) | ||
| 280 | .Pp | ||
| 281 | The | ||
| 282 | .Fa multx | ||
| 283 | and | ||
| 284 | .Fa plusy | ||
| 285 | arguments | ||
| 286 | are identical to the arguments of the same name described in the | ||
| 287 | .Fn inet6_option_init | ||
| 288 | function above. | ||
| 289 | .\" | ||
| 290 | .Ss inet6_option_next | ||
| 291 | The | ||
| 292 | .Fn inet6_option_next | ||
| 293 | function is used to process Hop-by-Hop and Destination options that | ||
| 294 | are present in an ancillary data object. | ||
| 295 | When an option remains to | ||
| 296 | be processed, the return value of the | ||
| 297 | .Fn inet6_option_next | ||
| 298 | function is | ||
| 299 | .Li 0 | ||
| 300 | and the | ||
| 301 | .Fa *tptrp | ||
| 302 | argument points to the 8-bit option type field, which is followed by | ||
| 303 | the 8-bit option data length, and then the option data. | ||
| 304 | When no more | ||
| 305 | options remain to be processed, the return value is | ||
| 306 | .Li \-1 | ||
| 307 | and | ||
| 308 | .Fa *tptrp | ||
| 309 | is | ||
| 310 | .Dv NULL . | ||
| 311 | When an error occurs, the return value is | ||
| 312 | .Li \-1 , | ||
| 313 | but the | ||
| 314 | .Fa *tptrp | ||
| 315 | argument is not | ||
| 316 | .Dv NULL . | ||
| 317 | This set of return values allows a program to easily loop through all | ||
| 318 | the options in an ancillary data object, checking for the error and | ||
| 319 | end of stream conditions along the way. | ||
| 320 | .Pp | ||
| 321 | When a valid option is returned, the | ||
| 322 | .Fa cmsg | ||
| 323 | argument points to a | ||
| 324 | .Li cmsghdr | ||
| 325 | where the | ||
| 326 | .Li cmsg_level | ||
| 327 | element equals | ||
| 328 | .Dv IPPROTO_IPV6 | ||
| 329 | and the | ||
| 330 | .Li cmsg_type | ||
| 331 | element is either | ||
| 332 | .Dv IPV6_HOPOPTS | ||
| 333 | or | ||
| 334 | .Dv IPV6_DSTOPTS . | ||
| 335 | .Pp | ||
| 336 | The | ||
| 337 | .Fa tptrp | ||
| 338 | argument is a pointer to a pointer to an 8-bit byte and | ||
| 339 | .Fa *tptrp | ||
| 340 | is used by the function to remember its place in the ancillary data | ||
| 341 | object each time the function is called. | ||
| 342 | When the | ||
| 343 | .Fn inet6_option_next | ||
| 344 | function is called for the first time on a given ancillary data object, | ||
| 345 | .Fa *tptrp | ||
| 346 | must be set to | ||
| 347 | .Dv NULL . | ||
| 348 | .Pp | ||
| 349 | Each time the function returns success, | ||
| 350 | the | ||
| 351 | .Fa *tptrp | ||
| 352 | argument points to the 8-bit option type field for the next option to | ||
| 353 | be processed. | ||
| 354 | .\" | ||
| 355 | .Ss inet6_option_find | ||
| 356 | The | ||
| 357 | .Fn inet6_option_find | ||
| 358 | function allows an application to search for a particular option type | ||
| 359 | in an ancillary data object. | ||
| 360 | The | ||
| 361 | .Fa cmsg | ||
| 362 | argument is a pointer to a | ||
| 363 | .Li cmsghdr | ||
| 364 | structure in which the | ||
| 365 | .Li cmsg_level | ||
| 366 | element equals | ||
| 367 | .Dv IPPROTO_IPV6 | ||
| 368 | and the | ||
| 369 | .Li cmsg_type | ||
| 370 | element is either | ||
| 371 | .Dv IPV6_HOPOPTS | ||
| 372 | or | ||
| 373 | .Dv IPV6_DSTOPTS . | ||
| 374 | .Pp | ||
| 375 | The | ||
| 376 | .Fa tptrp | ||
| 377 | argument is handled exactly as in the | ||
| 378 | .Fn inet6_option_next | ||
| 379 | function described above. | ||
| 380 | .Pp | ||
| 381 | The | ||
| 382 | .Fn inet6_option_find | ||
| 383 | function starts searching for an option of the specified type | ||
| 384 | beginning after the value of | ||
| 385 | .Fa *tptrp . | ||
| 386 | .\" | ||
| 387 | .Sh EXAMPLES | ||
| 388 | RFC 2292 gives comprehensive examples in chapter 6. | ||
| 389 | .\" | ||
| 390 | .Sh DIAGNOSTICS | ||
| 391 | The | ||
| 392 | .Fn inet6_option_init | ||
| 393 | and | ||
| 394 | .Fn inet6_option_append | ||
| 395 | functions return | ||
| 396 | .Li 0 | ||
| 397 | on success or | ||
| 398 | .Li \-1 | ||
| 399 | on an error. | ||
| 400 | .Pp | ||
| 401 | The | ||
| 402 | .Fn inet6_option_alloc | ||
| 403 | function returns | ||
| 404 | .Dv NULL | ||
| 405 | on an error. | ||
| 406 | .Pp | ||
| 407 | When | ||
| 408 | .Fn inet6_option_next | ||
| 409 | or | ||
| 410 | .Fn inet6_option_find | ||
| 411 | detect an error they return | ||
| 412 | .Li \-1 , | ||
| 413 | setting | ||
| 414 | .Fa *tptrp | ||
| 415 | to a non | ||
| 416 | .Dv NULL | ||
| 417 | value. | ||
| 418 | .\" | ||
| 419 | .Sh SEE ALSO | ||
| 420 | .Xr inet6 4 , | ||
| 421 | .Xr ip6 4 | ||
| 422 | .Rs | ||
| 423 | .%A W. Stevens | ||
| 424 | .%A M. Thomas | ||
| 425 | .%T "Advanced Sockets API for IPv6" | ||
| 426 | .%N RFC 2292 | ||
| 427 | .%D February 1998 | ||
| 428 | .Re | ||
| 429 | .Rs | ||
| 430 | .%A S. Deering | ||
| 431 | .%A R. Hinden | ||
| 432 | .%T "Internet Protocol, Version 6 (IPv6) Specification" | ||
| 433 | .%N RFC 2460 | ||
| 434 | .%D December 1998 | ||
| 435 | .Re | ||
| 436 | .\" | ||
| 437 | .Sh STANDARDS | ||
| 438 | The functions are documented in | ||
| 439 | .Dq Advanced Sockets API for IPv6 | ||
| 440 | (RFC 2292). | ||
| 441 | .\" | ||
| 442 | .Sh HISTORY | ||
| 443 | This implementation first appeared in the KAME advanced networking kit. | ||
| 444 | .\" | ||
