1 .\" $NetBSD: inet6_rthdr_space.3,v 1.2 2010/03/22 19:30:54 joerg Exp $
2 .\" $KAME: inet6_rthdr_space.3,v 1.8 2000/05/17 14:30:15 itojun Exp $
4 .\" Copyright (c) 1983, 1987, 1991, 1993
5 .\" The Regents of the University of California. All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
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.
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
32 .Dt INET6_RTHDR_SPACE 3
36 .Nm inet6_rthdr_space ,
37 .Nm inet6_rthdr_init ,
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
49 .Fn inet6_rthdr_space "int type" "int segments"
50 .Ft "struct cmsghdr *"
51 .Fn inet6_rthdr_init "void *bp" "int type"
53 .Fn inet6_rthdr_add "struct cmsghdr *cmsg" "const struct in6_addr *addr" "unsigned int flags"
55 .Fn inet6_rthdr_lasthop "struct cmsghdr *cmsg" "unsigned int flags"
57 .Fn inet6_rthdr_reverse "const struct cmsghdr *in" "struct cmsghdr *out"
59 .Fn inet6_rthdr_segments "const struct cmsghdr *cmsg"
60 .Ft "struct in6_addr *"
61 .Fn inet6_rthdr_getaddr "struct cmsghdr *cmsg" "int index"
63 .Fn inet6_rthdr_getflags "const struct cmsghdr *cmsg" "int index"
66 RFC 2292 IPv6 advanced API defines eight
67 functions that the application calls to build and examine a Routing
69 Four functions build a Routing header:
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 \*[Am] flags to Routing header
77 .It Fn inet6_rthdr_lasthop
78 specify the flags for the final hop
81 Four functions deal with a returned Routing header:
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
93 The function prototypes for these functions are all in the
98 This function returns the number of bytes required to hold a Routing
99 header of the specified
101 containing the specified number of
104 For an IPv6 Type 0 Routing header, the number
105 of segments must be between 1 and 23, inclusive.
107 includes the size of the cmsghdr structure that precedes the Routing
108 header, and any required padding.
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.
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
125 This function initializes the buffer pointed to by
129 structure followed by a Routing header of the specified
135 structure is initialized to the
136 size of the structure plus the amount of space required by the
142 members are also initialized as required.
144 The caller must allocate the buffer and its size can be determined by
146 .Fn inet6_rthdr_space .
148 Upon success the return value is the pointer to the
150 structure, and this is then used as the first argument to the next
152 Upon an error the return value is
156 This function adds the address pointed to by
159 Routing header being constructed and sets the type of this hop to the
162 For an IPv6 Type 0 Routing header,
168 .Dv IPV6_RTHDR_STRICT .
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
180 .Ss inet6_rthdr_lasthop
181 This function specifies the Strict/Loose flag for the final hop of a
183 For an IPv6 Type 0 Routing header,
188 .Dv IPV6_RTHDR_STRICT .
190 The return value of the function is 0 upon success, or -1 upon an error.
192 Notice that a Routing header specifying
194 intermediate nodes requires
201 followed by one call to
202 .Fn inet6_rthdr_lasthop .
204 .Ss inet6_rthdr_reverse
205 This function takes a Routing header that was received as ancillary
208 pointed to by the first argument,
211 and writes a new Routing
212 header that sends datagrams along the reverse of that route.
214 arguments are allowed to point to the same buffer
215 .Pq that is, the reversal can occur in place .
217 The return value of the function is 0 on success, or -1 upon an
220 .Ss inet6_rthdr_segments
221 This function returns the number of segments
224 the Routing header described by
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.
230 .Ss inet6_rthdr_getaddr
231 This function returns a pointer to the IPv6 address specified by
234 which must have a value between 1 and the value returned by
235 .Fn inet6_rthdr_segments
237 in the Routing header described by
240 application should first call
241 .Fn inet6_rthdr_segments
242 to obtain the number of segments in the Routing header.
244 Upon an error the return value of the function is
247 .Ss inet6_rthdr_getflags
248 This function returns the flags value specified by
252 have a value between 0 and the value returned by
253 .Fn inet6_rthdr_segments
255 in the Routing header described by
257 For an IPv6 Type 0 Routing header the return value will be either
260 .Dv IPV6_RTHDR_STRICT .
262 Upon an error the return value of the function is -1.
264 Note: Addresses are indexed starting at 1, and flags starting at 0,
265 to maintain consistency with the terminology and figures in RFC 2460.
268 RFC 2292 gives comprehensive examples in chapter 8.
271 .Fn inet6_rthdr_space
274 .Fn inet6_rthdr_add ,
275 .Fn inet6_rthdr_lasthop
277 .Fn inet6_rthdr_reverse
278 return 0 on success, and returns -1 on error.
282 .Fn inet6_rthdr_getaddr
287 .Fn inet6_rthdr_segments
289 .Fn inet6_rthdr_getflags
296 .%T "Advanced Sockets API for IPv6"
303 .%T "Internet Protocol, Version 6 (IPv6) Specification"
311 .Dq Advanced Sockets API for IPv6
315 The implementation first appeared in KAME advanced networking kit.
318 The text was shamelessly copied from RFC 2292.
320 .Fn inet6_rthdr_reverse
321 is not implemented yet.