summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/inet6_rthdr_space.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/net/inet6_rthdr_space.3')
-rw-r--r--src/lib/libc/net/inet6_rthdr_space.3308
1 files changed, 308 insertions, 0 deletions
diff --git a/src/lib/libc/net/inet6_rthdr_space.3 b/src/lib/libc/net/inet6_rthdr_space.3
new file mode 100644
index 0000000000..7c00c42e42
--- /dev/null
+++ b/src/lib/libc/net/inet6_rthdr_space.3
@@ -0,0 +1,308 @@
1.\" $OpenBSD: inet6_rthdr_space.3,v 1.17 2005/01/11 17:45:41 jaredy 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 December 27, 2004
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.\"The RFC 2292 IPv6 Advanced API has been deprecated in favor of the
68.\"newer, RFC 3542 APIs.
69.\"On platforms that support it, currently only
70.\"FreeBSD, please use the newer API to manipulate routing header
71.\"options.
72.\".Pp
73The RFC 2292 IPv6 Advanced API defined eight functions for
74applications to use for building and parsing routing headers.
75The
76eight functions are split into two groups, the first of which builds
77the header and the second of which can parse it.
78The function prototypes for these functions are all in the
79.Aq Pa netinet/in.h
80header.
81Although direct manipulation of a routing header is possible,
82this set of APIs make it unnecessary and such direct manipulation
83should be avoided so that changes to the underlying structures do not
84break applications.
85.Pp
86Please note that RFC 2292 uses the term
87.Dq segments
88instead of the term
89.Dq addresses
90but they are considered equivalent for this manual page.
91.\"
92.Ss inet6_rthdr_space
93The
94.Fn inet6_rthdr_space
95function returns the number of bytes required to hold a routing header
96of the specified
97.Fa type
98and containing the specified number of
99.Fa segments .
100Only one
101.Fa type
102is supported,
103.Dv IPV6_RTHDR_TYPE_0 ,
104and it can hold from 1 to 23 segments.
105The return value includes the
106size of the
107.Vt cmsghdr
108structure that precedes the routing header and
109any required padding.
110.Pp
111A return value of 0 indicates an error.
112Either the type was specified
113incorrectly, or the number of segments was less than one or greater
114than 23.
115.Pp
116Note: The
117.Fn inet6_rthdr_space
118function only returns the size required by the routing header and does
119not allocate memory for the caller.
120.\"
121.Ss inet6_rthdr_init
122The
123.Fn inet6_rthdr_init
124function initializes a buffer, pointed to by
125.Fa bp
126with an appropriate
127.Li cmsghdr
128structure followed by a routing header of the specified
129.Fa type .
130.Pp
131The caller must use the
132.Fn inet6_rthdr_space
133function to determine the size of the buffer, and then allocate that
134buffer before calling
135.Fn inet6_rthdr_init .
136.Pp
137The return value is a pointer to a
138.Li cmsghdr
139structure, which is used as the first argument to the
140.Fn inet6_rthdr_add
141and
142.Fn inet6_rthdr_lasthop
143functions in order to construct the routing header.
144When an error occurs the return value is
145.Dv NULL .
146.\"
147.Ss inet6_rthdr_add
148The
149.Fn inet6_rthdr_add
150function adds the IPv6 address pointed to by
151.Fa addr
152to the end of the
153routing header being constructed and sets the type of this address to the
154value of
155.Fa flags .
156The
157.Fa flags
158must be either
159.Dv IPV6_RTHDR_LOOSE
160or
161.Dv IPV6_RTHDR_STRICT
162indicating whether loose or strict source routing is required.
163.Pp
164When the function succeeds it returns 0, otherwise \-1 is returned.
165.\"
166.Ss inet6_rthdr_lasthop
167The
168.Fn inet6_rthdr_lasthop
169function specifies the strict or loose flag for the final hop of a
170routing header.
171The
172.Fa flags
173argument must be either
174.Dv IPV6_RTHDR_LOOSE
175or
176.Dv IPV6_RTHDR_STRICT .
177.Pp
178The return value of the function is 0 upon success, and \-1 when an
179error has occurred.
180.Pp
181Please note that a routing header specifying
182.Li N
183intermediate nodes requires
184.Li N+1
185strict or loose flags meaning that
186.Fn inet6_rthdr_add
187must be called
188.Li N
189times and then
190.Fn inet6_rthdr_lasthop
191must be called once.
192.\"
193.Ss inet6_rthdr_reverse
194This function was never implemented.
195.Pp
196The following three functions provide an API for parsing a received
197routing header:
198.\"
199.Ss inet6_rthdr_segments
200The
201.Fn inet6_rthdr_segments
202function returns the number of segments contained in the routing
203header pointed to by the
204.Fa cmsg
205argument.
206On success the return value is from 1 to 23.
207When an error occurs, \-1 is returned.
208.\"
209.Ss inet6_rthdr_getaddr
210The
211.Fn inet6_rthdr_getaddr
212function returns a pointer to the IPv6 address specified by the
213.Fa index
214argument from the routing header pointed to by
215.Fa cmsg .
216The index must be between 1 and the number returned by
217.Fn inet6_rthdr_segments ,
218described above.
219An application must call
220.Fn inet6_rthdr_segments
221to obtain the number of segments in the routing header.
222.Pp
223If an error occurs,
224.Dv NULL
225is returned.
226.\"
227.Ss inet6_rthdr_getflags
228The
229.Fn inet6_rthdr_getflags
230function returns the flags value of the segment specified by
231.Fa index
232of the routing header pointed to by
233.Fa cmsg .
234The
235.Fa index
236argument must be between 0 and the value returned by
237.Fn inet6_rthdr_segments .
238The return value will be either
239.Dv IPV6_RTHDR_LOOSE
240or
241.Dv IPV6_RTHDR_STRICT
242indicating whether loose or strict source routing was requested for
243that segment.
244.Pp
245When an error occurs, \-1 is returned.
246.Pp
247Note: Flags begin at index 0 while segments begin at index 1, to
248maintain consistency with the terminology and figures in RFC 2460.
249.\"
250.Sh EXAMPLES
251RFC 2292 gives comprehensive examples in chapter 8.
252.\"
253.Sh DIAGNOSTICS
254The
255.Fn inet6_rthdr_space
256function returns 0 when an error occurs.
257.Pp
258The
259.Fn inet6_rthdr_add
260and
261.Fn inet6_rthdr_lasthop
262functions return 0 on success, and \-1 on error.
263.Pp
264The
265.Fn inet6_rthdr_init
266and
267.Fn inet6_rthdr_getaddr
268functions
269return
270.Dv NULL
271on error.
272.Pp
273The
274.Fn inet6_rthdr_segments
275and
276.Fn inet6_rthdr_getflags
277functions return \-1 on error.
278.\"
279.Sh SEE ALSO
280.Xr inet6 4 ,
281.Xr ip6 4
282.Rs
283.%A W. Stevens
284.%A M. Thomas
285.%T "Advanced Sockets API for IPv6"
286.%N RFC 2292
287.%D February 1998
288.Re
289.Rs
290.%A S. Deering
291.%A R. Hinden
292.%T "Internet Protocol, Version 6 (IPv6) Specification"
293.%N RFC 2460
294.%D December 1998
295.Re
296.\"
297.Sh HISTORY
298This implementation first appeared in the KAME advanced networking kit.
299.\"
300.Sh BUGS
301The
302.Fn inet6_rthdr_reverse
303function was never implemented.
304.\".Pp
305.\"This API is deprecated in favor of
306.\".Xr inet6_rth_space 3
307.\".Sh SEE ALSO
308.\".Xr inet6_rth_space 3