1 |
27 |
unneback |
.\" $OpenBSD: inet6_rthdr_space.3,v 1.8 2001/06/23 05:57:04 deraadt Exp $
|
2 |
|
|
.\" $KAME: inet6_rthdr_space.3,v 1.8 2000/05/17 14:30:15 itojun Exp $
|
3 |
|
|
.\"
|
4 |
|
|
.\" Copyright (c) 1983, 1987, 1991, 1993
|
5 |
|
|
.\" The Regents of the University of California. 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. All advertising materials mentioning features or use of this software
|
16 |
|
|
.\" must display the following acknowledgement:
|
17 |
|
|
.\" This product includes software developed by the University of
|
18 |
|
|
.\" California, Berkeley and its contributors.
|
19 |
|
|
.\" 4. Neither the name of the University nor the names of its contributors
|
20 |
|
|
.\" may be used to endorse or promote products derived from this software
|
21 |
|
|
.\" without specific prior written permission.
|
22 |
|
|
.\"
|
23 |
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
24 |
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25 |
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
26 |
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
27 |
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
28 |
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
29 |
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
30 |
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
31 |
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
32 |
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
33 |
|
|
.\" SUCH DAMAGE.
|
34 |
|
|
.\"
|
35 |
|
|
.Dd December 10, 1999
|
36 |
|
|
.Dt INET6_RTHDR_SPACE 3
|
37 |
|
|
.Os
|
38 |
|
|
.\"
|
39 |
|
|
.Sh NAME
|
40 |
|
|
.Nm inet6_rthdr_space ,
|
41 |
|
|
.Nm inet6_rthdr_init ,
|
42 |
|
|
.Nm inet6_rthdr_add ,
|
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
|
49 |
|
|
.\"
|
50 |
|
|
.Sh SYNOPSIS
|
51 |
|
|
.Fd #include
|
52 |
|
|
.Ft size_t
|
53 |
|
|
.Fn inet6_rthdr_space "int type" "int segments"
|
54 |
|
|
.Ft "struct cmsghdr *"
|
55 |
|
|
.Fn inet6_rthdr_init "void *bp" "int type"
|
56 |
|
|
.Ft int
|
57 |
|
|
.Fn inet6_rthdr_add "struct cmsghdr *cmsg" "const struct in6_addr *addr" "unsigned int flags"
|
58 |
|
|
.Ft int
|
59 |
|
|
.Fn inet6_rthdr_lasthop "struct cmsghdr *cmsg" "unsigned int flags"
|
60 |
|
|
.Ft int
|
61 |
|
|
.Fn inet6_rthdr_reverse "const struct cmsghdr *in" "struct cmsghdr *out"
|
62 |
|
|
.Ft int
|
63 |
|
|
.Fn inet6_rthdr_segments "const struct cmsghdr *cmsg"
|
64 |
|
|
.Ft "struct in6_addr *"
|
65 |
|
|
.Fn inet6_rthdr_getaddr "struct cmsghdr *cmsg" "int index"
|
66 |
|
|
.Ft int
|
67 |
|
|
.Fn inet6_rthdr_getflags "const struct cmsghdr *cmsg" "int index"
|
68 |
|
|
.\"
|
69 |
|
|
.Sh DESCRIPTION
|
70 |
|
|
RFC2292 IPv6 advanced API defines eight
|
71 |
|
|
functions that the application calls to build and examine a Routing
|
72 |
|
|
header.
|
73 |
|
|
Four functions build a Routing header:
|
74 |
|
|
.Bl -hang
|
75 |
|
|
.It Fn inet6_rthdr_space
|
76 |
|
|
return #bytes required for ancillary data
|
77 |
|
|
.It Fn inet6_rthdr_init
|
78 |
|
|
initialize ancillary data for Routing header
|
79 |
|
|
.It Fn inet6_rthdr_add
|
80 |
|
|
add IPv6 address & flags to Routing header
|
81 |
|
|
.It Fn inet6_rthdr_lasthop
|
82 |
|
|
specify the flags for the final hop
|
83 |
|
|
.El
|
84 |
|
|
.Pp
|
85 |
|
|
Four functions deal with a returned Routing header:
|
86 |
|
|
.Bl -hang
|
87 |
|
|
.It Fn inet6_rthdr_reverse
|
88 |
|
|
reverse a Routing header
|
89 |
|
|
.It Fn inet6_rthdr_segments
|
90 |
|
|
return #segments in a Routing header
|
91 |
|
|
.It Fn inet6_rthdr_getaddr
|
92 |
|
|
fetch one address from a Routing header
|
93 |
|
|
.It Fn inet6_rthdr_getflags
|
94 |
|
|
fetch one flag from a Routing header
|
95 |
|
|
.El
|
96 |
|
|
.Pp
|
97 |
|
|
The function prototypes for these functions are all in the
|
98 |
|
|
.Aq Li netinet/in.h
|
99 |
|
|
header.
|
100 |
|
|
.\"
|
101 |
|
|
.Ss inet6_rthdr_space
|
102 |
|
|
This function returns the number of bytes required to hold a Routing
|
103 |
|
|
header of the specified
|
104 |
|
|
.Fa type
|
105 |
|
|
containing the specified number of
|
106 |
|
|
.Fa segments
|
107 |
|
|
.Pq addresses .
|
108 |
|
|
For an IPv6 Type 0 Routing header, the number
|
109 |
|
|
of segments must be between 1 and 23, inclusive.
|
110 |
|
|
The return value
|
111 |
|
|
includes the size of the cmsghdr structure that precedes the Routing
|
112 |
|
|
header, and any required padding.
|
113 |
|
|
.Pp
|
114 |
|
|
If the return value is 0, then either the type of the Routing header
|
115 |
|
|
is not supported by this implementation or the number of segments is
|
116 |
|
|
invalid for this type of Routing header.
|
117 |
|
|
.Pp
|
118 |
|
|
Note: This function returns the size but does not allocate the space
|
119 |
|
|
required for the ancillary data.
|
120 |
|
|
This allows an application to
|
121 |
|
|
allocate a larger buffer, if other ancillary data objects are
|
122 |
|
|
desired, since all the ancillary data objects must be specified to
|
123 |
|
|
.Xr sendmsg 2
|
124 |
|
|
as a single
|
125 |
|
|
.Li msg_control
|
126 |
|
|
buffer.
|
127 |
|
|
.\"
|
128 |
|
|
.Ss inet6_rthdr_init
|
129 |
|
|
This function initializes the buffer pointed to by
|
130 |
|
|
.Fa bp
|
131 |
|
|
to contain a
|
132 |
|
|
.Li cmsghdr
|
133 |
|
|
structure followed by a Routing header of the specified
|
134 |
|
|
.Fa type .
|
135 |
|
|
The
|
136 |
|
|
.Li cmsg_len
|
137 |
|
|
member of the
|
138 |
|
|
.Li cmsghdr
|
139 |
|
|
structure is initialized to the
|
140 |
|
|
size of the structure plus the amount of space required by the
|
141 |
|
|
Routing header.
|
142 |
|
|
The
|
143 |
|
|
.Li cmsg_level
|
144 |
|
|
and
|
145 |
|
|
.Li cmsg_type
|
146 |
|
|
members are also initialized as required.
|
147 |
|
|
.Pp
|
148 |
|
|
The caller must allocate the buffer and its size can be determined by
|
149 |
|
|
calling
|
150 |
|
|
.Fn inet6_rthdr_space .
|
151 |
|
|
.Pp
|
152 |
|
|
Upon success the return value is the pointer to the
|
153 |
|
|
.Li cmsghdr
|
154 |
|
|
structure, and this is then used as the first argument to the next
|
155 |
|
|
two functions.
|
156 |
|
|
Upon an error the return value is
|
157 |
|
|
.Dv NULL .
|
158 |
|
|
.\"
|
159 |
|
|
.Ss inet6_rthdr_add
|
160 |
|
|
This function adds the address pointed to by
|
161 |
|
|
.Fa addr
|
162 |
|
|
to the end of the
|
163 |
|
|
Routing header being constructed and sets the type of this hop to the
|
164 |
|
|
value of
|
165 |
|
|
.Fa flags .
|
166 |
|
|
For an IPv6 Type 0 Routing header,
|
167 |
|
|
.Fa flags
|
168 |
|
|
must be
|
169 |
|
|
either
|
170 |
|
|
.Dv IPV6_RTHDR_LOOSE
|
171 |
|
|
or
|
172 |
|
|
.Dv IPV6_RTHDR_STRICT .
|
173 |
|
|
.Pp
|
174 |
|
|
If successful, the
|
175 |
|
|
.Li cmsg_len
|
176 |
|
|
member of the
|
177 |
|
|
.Li cmsghdr
|
178 |
|
|
structure is
|
179 |
|
|
updated to account for the new address in the Routing header and the
|
180 |
|
|
return value of the function is 0.
|
181 |
|
|
Upon an error the return value of
|
182 |
|
|
the function is -1.
|
183 |
|
|
.\"
|
184 |
|
|
.Ss inet6_rthdr_lasthop
|
185 |
|
|
This function specifies the Strict/Loose flag for the final hop of a
|
186 |
|
|
Routing header.
|
187 |
|
|
For an IPv6 Type 0 Routing header,
|
188 |
|
|
.Fa flags
|
189 |
|
|
must be either
|
190 |
|
|
.Dv IPV6_RTHDR_LOOSE
|
191 |
|
|
or
|
192 |
|
|
.Dv IPV6_RTHDR_STRICT .
|
193 |
|
|
.Pp
|
194 |
|
|
The return value of the function is 0 upon success, or -1 upon an error.
|
195 |
|
|
.Pp
|
196 |
|
|
Notice that a Routing header specifying
|
197 |
|
|
.Li N
|
198 |
|
|
intermediate nodes requires
|
199 |
|
|
.Li N+1
|
200 |
|
|
Strict/Loose flags.
|
201 |
|
|
This requires
|
202 |
|
|
.Li N
|
203 |
|
|
calls to
|
204 |
|
|
.Fn inet6_rthdr_add
|
205 |
|
|
followed by one call to
|
206 |
|
|
.Fn inet6_rthdr_lasthop .
|
207 |
|
|
.\"
|
208 |
|
|
.Ss inet6_rthdr_reverse
|
209 |
|
|
This function takes a Routing header that was received as ancillary
|
210 |
|
|
data
|
211 |
|
|
.Po
|
212 |
|
|
pointed to by the first argument,
|
213 |
|
|
.Fa in
|
214 |
|
|
.Pc
|
215 |
|
|
and writes a new Routing
|
216 |
|
|
header that sends datagrams along the reverse of that route.
|
217 |
|
|
Both
|
218 |
|
|
arguments are allowed to point to the same buffer
|
219 |
|
|
.Pq that is, the reversal can occur in place .
|
220 |
|
|
.Pp
|
221 |
|
|
The return value of the function is 0 on success, or -1 upon an
|
222 |
|
|
error.
|
223 |
|
|
.\"
|
224 |
|
|
.Ss inet6_rthdr_segments
|
225 |
|
|
This function returns the number of segments
|
226 |
|
|
.Pq addresses
|
227 |
|
|
contained in
|
228 |
|
|
the Routing header described by
|
229 |
|
|
.Fa cmsg .
|
230 |
|
|
On success the return value is
|
231 |
|
|
between 1 and 23, inclusive.
|
232 |
|
|
The return value of the function is -1 upon an error.
|
233 |
|
|
.\"
|
234 |
|
|
.Ss inet6_rthdr_getaddr
|
235 |
|
|
This function returns a pointer to the IPv6 address specified by
|
236 |
|
|
.Fa index
|
237 |
|
|
.Po
|
238 |
|
|
which must have a value between 1 and the value returned by
|
239 |
|
|
.Fn inet6_rthdr_segments
|
240 |
|
|
.Pc
|
241 |
|
|
in the Routing header described by
|
242 |
|
|
.Fa cmsg .
|
243 |
|
|
An
|
244 |
|
|
application should first call
|
245 |
|
|
.Fn inet6_rthdr_segments
|
246 |
|
|
to obtain the number of segments in the Routing header.
|
247 |
|
|
.Pp
|
248 |
|
|
Upon an error the return value of the function is
|
249 |
|
|
.Dv NULL .
|
250 |
|
|
.\"
|
251 |
|
|
.Ss inet6_rthdr_getflags
|
252 |
|
|
This function returns the flags value specified by
|
253 |
|
|
.Fa index
|
254 |
|
|
.Po
|
255 |
|
|
which must
|
256 |
|
|
have a value between 0 and the value returned by
|
257 |
|
|
.Fn inet6_rthdr_segments
|
258 |
|
|
.Pc
|
259 |
|
|
in the Routing header described by
|
260 |
|
|
.Fa cmsg .
|
261 |
|
|
For an IPv6 Type 0 Routing header the return value will be either
|
262 |
|
|
.Dv IPV6_RTHDR_LOOSE
|
263 |
|
|
or
|
264 |
|
|
.Dv IPV6_RTHDR_STRICT .
|
265 |
|
|
.Pp
|
266 |
|
|
Upon an error the return value of the function is -1.
|
267 |
|
|
.Pp
|
268 |
|
|
Note: Addresses are indexed starting at 1, and flags starting at 0,
|
269 |
|
|
to maintain consistency with the terminology and figures in RFC2460.
|
270 |
|
|
.\"
|
271 |
|
|
.Sh DIAGNOSTICS
|
272 |
|
|
.Fn inet6_rthdr_space
|
273 |
|
|
returns 0 on errors.
|
274 |
|
|
.Pp
|
275 |
|
|
.Fn inet6_rthdr_add ,
|
276 |
|
|
.Fn inet6_rthdr_lasthop
|
277 |
|
|
and
|
278 |
|
|
.Fn inet6_rthdr_reverse
|
279 |
|
|
return 0 on success, and returns -1 on error.
|
280 |
|
|
.Pp
|
281 |
|
|
.Fn inet6_rthdr_init
|
282 |
|
|
and
|
283 |
|
|
.Fn inet6_rthdr_getaddr
|
284 |
|
|
return
|
285 |
|
|
.Dv NULL
|
286 |
|
|
on error.
|
287 |
|
|
.Pp
|
288 |
|
|
.Fn inet6_rthdr_segments
|
289 |
|
|
and
|
290 |
|
|
.Fn inet6_rthdr_getflags
|
291 |
|
|
return -1 on error.
|
292 |
|
|
.\"
|
293 |
|
|
.Sh EXAMPLES
|
294 |
|
|
RFC2292 gives comprehensive examples in chapter 8.
|
295 |
|
|
.\"
|
296 |
|
|
.Sh SEE ALSO
|
297 |
|
|
.Rs
|
298 |
|
|
.%A W. Stevens
|
299 |
|
|
.%A M. Thomas
|
300 |
|
|
.%T "Advanced Sockets API for IPv6"
|
301 |
|
|
.%N RFC2292
|
302 |
|
|
.%D February 1998
|
303 |
|
|
.Re
|
304 |
|
|
.Rs
|
305 |
|
|
.%A S. Deering
|
306 |
|
|
.%A R. Hinden
|
307 |
|
|
.%T "Internet Protocol, Version 6 (IPv6) Specification"
|
308 |
|
|
.%N RFC2460
|
309 |
|
|
.%D December 1998
|
310 |
|
|
.Re
|
311 |
|
|
.\"
|
312 |
|
|
.Sh HISTORY
|
313 |
|
|
The implementation first appeared in KAME advanced networking kit.
|
314 |
|
|
.\"
|
315 |
|
|
.Sh STANDARDS
|
316 |
|
|
The functions
|
317 |
|
|
are documented in
|
318 |
|
|
.Dq Advanced Sockets API for IPv6
|
319 |
|
|
.Pq RFC2292 .
|
320 |
|
|
.\"
|
321 |
|
|
.Sh BUGS
|
322 |
|
|
The text was shamelessly copied from RFC2292.
|
323 |
|
|
.Pp
|
324 |
|
|
.Fn inet6_rthdr_reverse
|
325 |
|
|
is not implemented yet.
|