diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libc/net/Makefile.inc | 15 | ||||
| -rw-r--r-- | src/lib/libc/net/inet6_option_space.3 | 442 | ||||
| -rw-r--r-- | src/lib/libc/net/inet6_rth_space.3 | 6 | ||||
| -rw-r--r-- | src/lib/libc/net/inet6_rthdr_space.3 | 310 |
4 files changed, 4 insertions, 769 deletions
diff --git a/src/lib/libc/net/Makefile.inc b/src/lib/libc/net/Makefile.inc index fce4d536da..b3acad72bf 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.53 2014/04/19 13:51:05 deraadt Exp $ | 1 | # $OpenBSD: Makefile.inc,v 1.54 2014/06/11 16:59:47 chrisz Exp $ |
| 2 | 2 | ||
| 3 | # net sources | 3 | # net sources |
| 4 | .PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/net ${LIBCSRCDIR}/net | 4 | .PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/net ${LIBCSRCDIR}/net |
| @@ -29,7 +29,6 @@ MAN+= byteorder.3 ethers.3 gai_strerror.3 getaddrinfo.3 gethostbyname.3 \ | |||
| 29 | getifaddrs.3 getnameinfo.3 getnetent.3 getpeereid.3 getprotoent.3 \ | 29 | getifaddrs.3 getnameinfo.3 getnetent.3 getpeereid.3 getprotoent.3 \ |
| 30 | getrrsetbyname.3 getservent.3 if_indextoname.3 \ | 30 | getrrsetbyname.3 getservent.3 if_indextoname.3 \ |
| 31 | inet_addr.3 inet_lnaof.3 inet_net.3 inet_ntop.3 \ | 31 | inet_addr.3 inet_lnaof.3 inet_net.3 inet_ntop.3 \ |
| 32 | inet6_option_space.3 inet6_rthdr_space.3 \ | ||
| 33 | inet6_opt_init.3 inet6_rth_space.3 link_addr.3 \ | 32 | inet6_opt_init.3 inet6_rth_space.3 link_addr.3 \ |
| 34 | rcmd.3 rcmdsh.3 resolver.3 | 33 | rcmd.3 rcmdsh.3 resolver.3 |
| 35 | 34 | ||
| @@ -74,18 +73,6 @@ MLINKS+=resolver.3 dn_comp.3 resolver.3 dn_expand.3 resolver.3 res_init.3 \ | |||
| 74 | resolver.3 res_mkquery.3 resolver.3 res_send.3 resolver.3 res_query.3 \ | 73 | resolver.3 res_mkquery.3 resolver.3 res_send.3 resolver.3 res_query.3 \ |
| 75 | resolver.3 res_search.3 | 74 | resolver.3 res_search.3 |
| 76 | MLINKS+=getrrsetbyname.3 freerrset.3 | 75 | MLINKS+=getrrsetbyname.3 freerrset.3 |
| 77 | MLINKS+=inet6_option_space.3 inet6_option_init.3 \ | ||
| 78 | inet6_option_space.3 inet6_option_append.3 \ | ||
| 79 | inet6_option_space.3 inet6_option_alloc.3 \ | ||
| 80 | inet6_option_space.3 inet6_option_next.3 \ | ||
| 81 | inet6_option_space.3 inet6_option_find.3 | ||
| 82 | MLINKS+=inet6_rthdr_space.3 inet6_rthdr_init.3 \ | ||
| 83 | inet6_rthdr_space.3 inet6_rthdr_add.3 \ | ||
| 84 | inet6_rthdr_space.3 inet6_rthdr_lasthop.3 \ | ||
| 85 | inet6_rthdr_space.3 inet6_rthdr_reverse.3 \ | ||
| 86 | inet6_rthdr_space.3 inet6_rthdr_segments.3 \ | ||
| 87 | inet6_rthdr_space.3 inet6_rthdr_getaddr.3 \ | ||
| 88 | inet6_rthdr_space.3 inet6_rthdr_getflags.3 | ||
| 89 | MLINKS+=inet6_opt_init.3 inet6_opt_append.3 \ | 76 | MLINKS+=inet6_opt_init.3 inet6_opt_append.3 \ |
| 90 | inet6_opt_init.3 inet6_opt_finish.3 \ | 77 | inet6_opt_init.3 inet6_opt_finish.3 \ |
| 91 | inet6_opt_init.3 inet6_opt_set_val.3 \ | 78 | inet6_opt_init.3 inet6_opt_set_val.3 \ |
diff --git a/src/lib/libc/net/inet6_option_space.3 b/src/lib/libc/net/inet6_option_space.3 index 4b156636f7..e69de29bb2 100644 --- a/src/lib/libc/net/inet6_option_space.3 +++ b/src/lib/libc/net/inet6_option_space.3 | |||
| @@ -1,442 +0,0 @@ | |||
| 1 | .\" $OpenBSD: inet6_option_space.3,v 1.24 2014/01/21 03:15:45 schwarze 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: January 21 2014 $ | ||
| 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 | .In 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 | .\" | ||
| 423 | .Sh STANDARDS | ||
| 424 | .Rs | ||
| 425 | .%A W. Stevens | ||
| 426 | .%A M. Thomas | ||
| 427 | .%D February 1998 | ||
| 428 | .%R RFC 2292 | ||
| 429 | .%T Advanced Sockets API for IPv6 | ||
| 430 | .Re | ||
| 431 | .Pp | ||
| 432 | .Rs | ||
| 433 | .%A S. Deering | ||
| 434 | .%A R. Hinden | ||
| 435 | .%D December 1998 | ||
| 436 | .%R RFC 2460 | ||
| 437 | .%T Internet Protocol, Version 6 (IPv6) Specification | ||
| 438 | .Re | ||
| 439 | .\" | ||
| 440 | .Sh HISTORY | ||
| 441 | This implementation first appeared in the KAME advanced networking kit. | ||
| 442 | .\" | ||
diff --git a/src/lib/libc/net/inet6_rth_space.3 b/src/lib/libc/net/inet6_rth_space.3 index fcd023481f..fd69da2455 100644 --- a/src/lib/libc/net/inet6_rth_space.3 +++ b/src/lib/libc/net/inet6_rth_space.3 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | .\" $OpenBSD: inet6_rth_space.3,v 1.6 2014/01/21 03:15:45 schwarze Exp $ | 1 | .\" $OpenBSD: inet6_rth_space.3,v 1.7 2014/06/11 16:59:47 chrisz Exp $ |
| 2 | .\" $KAME: inet6_rth_space.3,v 1.7 2005/01/05 03:00:44 itojun Exp $ | 2 | .\" $KAME: inet6_rth_space.3,v 1.7 2005/01/05 03:00:44 itojun Exp $ |
| 3 | .\" | 3 | .\" |
| 4 | .\" Copyright (C) 2004 WIDE Project. | 4 | .\" Copyright (C) 2004 WIDE Project. |
| @@ -28,7 +28,7 @@ | |||
| 28 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 28 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 29 | .\" SUCH DAMAGE. | 29 | .\" SUCH DAMAGE. |
| 30 | .\" | 30 | .\" |
| 31 | .Dd $Mdocdate: January 21 2014 $ | 31 | .Dd $Mdocdate: June 11 2014 $ |
| 32 | .Dt INET6_RTH_SPACE 3 | 32 | .Dt INET6_RTH_SPACE 3 |
| 33 | .Os | 33 | .Os |
| 34 | .\" | 34 | .\" |
| @@ -188,7 +188,7 @@ and | |||
| 188 | functions return 0 on errors. | 188 | functions return 0 on errors. |
| 189 | .Pp | 189 | .Pp |
| 190 | The | 190 | The |
| 191 | .Fn inet6_rthdr_init | 191 | .Fn inet6_rth_init |
| 192 | function returns | 192 | function returns |
| 193 | .Dv NULL | 193 | .Dv NULL |
| 194 | on error. | 194 | on error. |
diff --git a/src/lib/libc/net/inet6_rthdr_space.3 b/src/lib/libc/net/inet6_rthdr_space.3 index c72e84ff1a..e69de29bb2 100644 --- a/src/lib/libc/net/inet6_rthdr_space.3 +++ b/src/lib/libc/net/inet6_rthdr_space.3 | |||
| @@ -1,310 +0,0 @@ | |||
| 1 | .\" $OpenBSD: inet6_rthdr_space.3,v 1.23 2014/01/21 03:15:45 schwarze 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 $Mdocdate: January 21 2014 $ | ||
| 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 | .In sys/types.h | ||
| 48 | .In netinet/in.h | ||
| 49 | .Ft size_t | ||
| 50 | .Fn inet6_rthdr_space "int type" "int segments" | ||
| 51 | .Ft "struct cmsghdr *" | ||
| 52 | .Fn inet6_rthdr_init "void *bp" "int type" | ||
| 53 | .Ft int | ||
| 54 | .Fn inet6_rthdr_add "struct cmsghdr *cmsg" "const struct in6_addr *addr" "unsigned int flags" | ||
| 55 | .Ft int | ||
| 56 | .Fn inet6_rthdr_lasthop "struct cmsghdr *cmsg" "unsigned int flags" | ||
| 57 | .Ft int | ||
| 58 | .Fn inet6_rthdr_reverse "const struct cmsghdr *in" "struct cmsghdr *out" | ||
| 59 | .Ft int | ||
| 60 | .Fn inet6_rthdr_segments "const struct cmsghdr *cmsg" | ||
| 61 | .Ft "struct in6_addr *" | ||
| 62 | .Fn inet6_rthdr_getaddr "struct cmsghdr *cmsg" "int index" | ||
| 63 | .Ft int | ||
| 64 | .Fn inet6_rthdr_getflags "const struct cmsghdr *cmsg" "int index" | ||
| 65 | .\" | ||
| 66 | .Sh DESCRIPTION | ||
| 67 | Note: | ||
| 68 | RFC 2292 has been superseded by RFC 3542. | ||
| 69 | The use of functions described in this page is deprecated. | ||
| 70 | See | ||
| 71 | .Xr inet6_rth_space 3 . | ||
| 72 | .Pp | ||
| 73 | The RFC 2292 IPv6 Advanced API defined eight functions for | ||
| 74 | applications to use for building and parsing routing headers. | ||
| 75 | The | ||
| 76 | eight functions are split into two groups, the first of which builds | ||
| 77 | the header and the second of which can parse it. | ||
| 78 | The function prototypes for these functions are all in the | ||
| 79 | .In netinet/in.h | ||
| 80 | header. | ||
| 81 | Although direct manipulation of a routing header is possible, | ||
| 82 | this set of APIs make it unnecessary and such direct manipulation | ||
| 83 | should be avoided so that changes to the underlying structures do not | ||
| 84 | break applications. | ||
| 85 | .Pp | ||
| 86 | Please note that RFC 2292 uses the term | ||
| 87 | .Dq segments | ||
| 88 | instead of the term | ||
| 89 | .Dq addresses | ||
| 90 | but they are considered equivalent for this manual page. | ||
| 91 | .\" | ||
| 92 | .Ss inet6_rthdr_space | ||
| 93 | The | ||
| 94 | .Fn inet6_rthdr_space | ||
| 95 | function returns the number of bytes required to hold a routing header | ||
| 96 | of the specified | ||
| 97 | .Fa type | ||
| 98 | and containing the specified number of | ||
| 99 | .Fa segments . | ||
| 100 | Only one | ||
| 101 | .Fa type | ||
| 102 | is supported, | ||
| 103 | .Dv IPV6_RTHDR_TYPE_0 , | ||
| 104 | and it can hold from 1 to 23 segments. | ||
| 105 | The return value includes the | ||
| 106 | size of the | ||
| 107 | .Vt cmsghdr | ||
| 108 | 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 | argument 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 three 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, | ||
| 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 RFC 2460. | ||
| 249 | .\" | ||
| 250 | .Sh EXAMPLES | ||
| 251 | RFC 2292 gives comprehensive examples in chapter 8. | ||
| 252 | .\" | ||
| 253 | .Sh DIAGNOSTICS | ||
| 254 | The | ||
| 255 | .Fn inet6_rthdr_space | ||
| 256 | function returns 0 when an error occurs. | ||
| 257 | .Pp | ||
| 258 | The | ||
| 259 | .Fn inet6_rthdr_add | ||
| 260 | and | ||
| 261 | .Fn inet6_rthdr_lasthop | ||
| 262 | functions return 0 on success, and \-1 on error. | ||
| 263 | .Pp | ||
| 264 | The | ||
| 265 | .Fn inet6_rthdr_init | ||
| 266 | and | ||
| 267 | .Fn inet6_rthdr_getaddr | ||
| 268 | functions | ||
| 269 | return | ||
| 270 | .Dv NULL | ||
| 271 | on error. | ||
| 272 | .Pp | ||
| 273 | The | ||
| 274 | .Fn inet6_rthdr_segments | ||
| 275 | and | ||
| 276 | .Fn inet6_rthdr_getflags | ||
| 277 | functions return \-1 on error. | ||
| 278 | .\" | ||
| 279 | .Sh SEE ALSO | ||
| 280 | .Xr inet6 4 , | ||
| 281 | .Xr ip6 4 | ||
| 282 | .Sh STANDARDS | ||
| 283 | .Rs | ||
| 284 | .%A W. Stevens | ||
| 285 | .%A M. Thomas | ||
| 286 | .%D February 1998 | ||
| 287 | .%R RFC 2292 | ||
| 288 | .%T Advanced Sockets API for IPv6 | ||
| 289 | .Re | ||
| 290 | .Pp | ||
| 291 | .Rs | ||
| 292 | .%A S. Deering | ||
| 293 | .%A R. Hinden | ||
| 294 | .%D December 1998 | ||
| 295 | .%R RFC 2460 | ||
| 296 | .%T Internet Protocol, Version 6 (IPv6) Specification | ||
| 297 | .Re | ||
| 298 | .\" | ||
| 299 | .Sh HISTORY | ||
| 300 | This implementation first appeared in the KAME advanced networking kit. | ||
| 301 | .\" | ||
| 302 | .Sh BUGS | ||
| 303 | The | ||
| 304 | .Fn inet6_rthdr_reverse | ||
| 305 | function was never implemented. | ||
| 306 | .\".Pp | ||
| 307 | .\"This API is deprecated in favor of | ||
| 308 | .\".Xr inet6_rth_space 3 | ||
| 309 | .\".Sh SEE ALSO | ||
| 310 | .\".Xr inet6_rth_space 3 | ||
