1 .\" Copyright (c) 1983, 1987, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" $Id: inet6_rthdr_space.3,v 1.1 2001/12/18 01:21:22 bbraun Exp $
33 .\" $FreeBSD: src/lib/libc/net/inet6_rthdr_space.3,v 1.8 2001/10/01 16:08:55 ru Exp $
36 .Dt INET6_RTHDR_SPACE 3
40 .Nm inet6_rthdr_space ,
41 .Nm inet6_rthdr_init ,
43 .Nm inet6_rthdr_lasthop ,
44 .Nm inet6_rthdr_reverse ,
45 .Nm inet6_rthdr_segments ,
46 .Nm inet6_rthdr_getaddr ,
47 .Nm inet6_rthdr_getflags
48 .Nd IPv6 Routing Header Options manipulation
56 .Fn inet6_rthdr_space "int type" "int segments"
57 .Ft "struct cmsghdr *"
58 .Fn inet6_rthdr_init "void *bp" "int type"
60 .Fn inet6_rthdr_add "struct cmsghdr *cmsg" "const struct in6_addr *addr" "unsigned int flags"
62 .Fn inet6_rthdr_lasthop "struct cmsghdr *cmsg" "unsigned int flags"
64 .Fn inet6_rthdr_reverse "const struct cmsghdr *in" "struct cmsghdr *out"
66 .Fn inet6_rthdr_segments "const struct cmsghdr *cmsg"
67 .Ft "struct in6_addr *"
68 .Fn inet6_rthdr_getaddr "struct cmsghdr *cmsg" "int index"
70 .Fn inet6_rthdr_getflags "const struct cmsghdr *cmsg" "int index"
73 RFC2292 IPv6 advanced API defines eight
74 functions that the application calls to build and examine a Routing
75 header. Four functions build a Routing header:
77 .It Fn inet6_rthdr_space
78 return #bytes required for ancillary data
79 .It Fn inet6_rthdr_init
80 initialize ancillary data for Routing header
81 .It Fn inet6_rthdr_add
82 add IPv6 address & flags to Routing header
83 .It Fn inet6_rthdr_lasthop
84 specify the flags for the final hop
87 Four functions deal with a returned Routing header:
89 .It Fn inet6_rthdr_reverse
90 reverse a Routing header
91 .It Fn inet6_rthdr_segments
92 return #segments in a Routing header
93 .It Fn inet6_rthdr_getaddr
94 fetch one address from a Routing header
95 .It Fn inet6_rthdr_getflags
96 fetch one flag from a Routing header
99 The function prototypes for these functions are all in the
103 .Ss inet6_rthdr_space
104 This function returns the number of bytes required to hold a Routing
105 header of the specified
107 containing the specified number of
110 For an IPv6 Type 0 Routing header, the number
111 of segments must be between 1 and 23, inclusive. The return value
112 includes the size of the cmsghdr structure that precedes the Routing
113 header, and any required padding.
115 If the return value is 0, then either the type of the Routing header
116 is not supported by this implementation or the number of segments is
117 invalid for this type of Routing header.
119 Note: This function returns the size but does not allocate the space
120 required for the ancillary data.
121 This allows an application to
122 allocate a larger buffer, if other ancillary data objects are
123 desired, since all the ancillary data objects must be specified to
130 This function initializes the buffer pointed to by
134 structure followed by a Routing header of the specified
140 structure is initialized to the
141 size of the structure plus the amount of space required by the
147 members are also initialized as required.
149 The caller must allocate the buffer and its size can be determined by
151 .Fn inet6_rthdr_space .
153 Upon success the return value is the pointer to the
155 structure, and this is then used as the first argument to the next
157 Upon an error the return value is
161 This function adds the address pointed to by
164 Routing header being constructed and sets the type of this hop to the
167 For an IPv6 Type 0 Routing header,
173 .Dv IPV6_RTHDR_STRICT .
180 updated to account for the new address in the Routing header and the
181 return value of the function is 0.
182 Upon an error the return value of
185 .Ss inet6_rthdr_lasthop
186 This function specifies the Strict/Loose flag for the final hop of a
188 For an IPv6 Type 0 Routing header,
193 .Dv IPV6_RTHDR_STRICT .
195 The return value of the function is 0 upon success, or -1 upon an error.
197 Notice that a Routing header specifying
199 intermediate nodes requires
206 followed by one call to
207 .Fn inet6_rthdr_lasthop .
209 .Ss inet6_rthdr_reverse
210 This function is not yet implemented.
211 When implemented, this should behave as follows.
213 This function takes a Routing header that was received as ancillary
215 (pointed to by the first argument,
217 and writes a new Routing
218 header that sends datagrams along the reverse of that route.
220 arguments are allowed to point to the same buffer
221 (that is, the reversal can occur in place).
223 The return value of the function is 0 on success, or -1 upon an
226 .Ss inet6_rthdr_segments
227 This function returns the number of segments
230 the Routing header described by
232 On success the return value is
233 between 1 and 23, inclusive.
234 The return value of the function is -1 upon an error.
236 .Ss inet6_rthdr_getaddr
237 This function returns a pointer to the IPv6 address specified by
239 (which must have a value between 1 and the value returned by
240 .Fn inet6_rthdr_segments )
241 in the Routing header described by
244 application should first call
245 .Fn inet6_rthdr_segments
246 to obtain the number of segments in the Routing header.
248 Upon an error the return value of the function is
251 .Ss inet6_rthdr_getflags
252 This function returns the flags value specified by
255 have a value between 0 and the value returned by
256 .Fn inet6_rthdr_segments )
257 in the Routing header described by
259 For an IPv6 Type 0 Routing header the return value will be either
262 .Dv IPV6_RTHDR_STRICT .
264 Upon an error the return value of the function is -1.
266 Note: Addresses are indexed starting at 1, and flags starting at 0,
267 to maintain consistency with the terminology and figures in RFC2460.
270 .Fn inet6_rthdr_space
273 .Fn inet6_rthdr_add ,
274 .Fn inet6_rthdr_lasthop
276 .Fn inet6_rthdr_reverse
277 return 0 on success, and returns -1 on error.
281 .Fn inet6_rthdr_getaddr
286 .Fn inet6_rthdr_segments
288 .Fn inet6_rthdr_getflags
292 RFC2292 gives comprehensive examples in chapter 8.
298 .%T "Advanced Sockets API for IPv6"
305 .%T "Internet Protocol, Version 6 (IPv6) Specification"
311 The implementation first appeared in KAME advanced networking kit.
316 .Dq Advanced Sockets API for IPv6
320 The text was shamelessly copied from RFC2292.
322 .Fn inet6_rthdr_reverse
323 is not implemented yet.