summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrisz <>2014-06-11 16:59:47 +0000
committerchrisz <>2014-06-11 16:59:47 +0000
commit1c4dd1c47cc7993d6396c8ca22a949110f10a0d6 (patch)
tree8484bcd1854d9b9088446a9ec91cf714a2d025d8
parentad76fc8ee191ac27c7614f9a37b6a8c1cc615aca (diff)
downloadopenbsd-1c4dd1c47cc7993d6396c8ca22a949110f10a0d6.tar.gz
openbsd-1c4dd1c47cc7993d6396c8ca22a949110f10a0d6.tar.bz2
openbsd-1c4dd1c47cc7993d6396c8ca22a949110f10a0d6.zip
Remove manpages about deprecated RFC2292 ancillary data convenience functions.
They are obsoleted by the RFC3542 api. ok mpi@
-rw-r--r--src/lib/libc/net/Makefile.inc15
-rw-r--r--src/lib/libc/net/inet6_option_space.3442
-rw-r--r--src/lib/libc/net/inet6_rth_space.36
-rw-r--r--src/lib/libc/net/inet6_rthdr_space.3310
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
76MLINKS+=getrrsetbyname.3 freerrset.3 75MLINKS+=getrrsetbyname.3 freerrset.3
77MLINKS+=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
82MLINKS+=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
89MLINKS+=inet6_opt_init.3 inet6_opt_append.3 \ 76MLINKS+=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.\"
62Note:
63RFC 2292 has been superseded by RFC 3542.
64The use of functions described in this page is deprecated.
65See
66.Xr inet6_opt_init 3 .
67.Pp
68Manipulating and parsing IPv6's Hop-by-Hop and Destination options is
69complicated by the need to properly align and pad data as well as the
70need to manipulate ancillary information that is not part of the data
71stream.
72RFC 2292 defines a set of functions, which are implemented as
73part of the Kame libraries, to help developers create, change,
74and parse Hop-by-Hop and Destination options.
75All of the prototypes
76for the option functions are defined in the
77.In netinet/in.h
78header file.
79.\"
80.Ss inet6_option_space
81In order to determine the amount of space necessary to hold any option
82the
83.Fn inet6_option_space
84function is called.
85It returns the number of bytes required to hold
86an option when it is stored as ancillary data, including the
87.Li cmsghdr
88structure at the beginning, and any necessary padding at the end.
89The
90.Fa nbytes
91argument indicates the size of the structure defining the option,
92and must include any pad bytes at the beginning (the value
93.Li y
94in the alignment term
95.Dq Li "xn + y" ) ,
96the type byte, the length byte, and the option data.
97.Pp
98Note: If multiple options are stored in a single ancillary data
99object, which is the recommended technique, the
100.Fn inet6_option_space
101function overestimates the amount of space required by the size of
102.Li N-1
103.Li cmsghdr
104structures, where
105.Li N
106is the number of options to be stored in the object.
107Usually this has
108no impact because it is assumed that most Hop-by-Hop and Destination
109option headers carry only one option as indicated in appendix B of RFC 2460.
110.\"
111.Ss inet6_option_init
112The
113.Fn inet6_option_init
114function is called to initialize any ancillary data object that will contain
115a Hop-by-Hop or Destination option.
116It returns
117.Li 0
118on success and
119.Li \-1
120when an error occurs.
121.Pp
122The
123.Fa bp
124argument points to a previously allocated area of memory which must be
125large enough to contain all the arguments that the application intends
126to add later via the
127.Fn inet6_option_append
128and
129.Fn inet6_option_alloc
130routines.
131.Pp
132The
133.Fa cmsgp
134argument is a pointer to a pointer to a
135.Li cmsghdr
136structure.
137The
138.Fa *cmsgp
139argument
140points to a
141.Li cmsghdr
142structure which is constructed by this function and stored in the
143area of memory pointed to by
144.Fa bp .
145.Pp
146The
147.Fa type
148is either
149.Dv IPV6_HOPOPTS
150or
151.Dv IPV6_DSTOPTS
152and is stored in the
153.Li cmsg_type
154member of the
155.Li cmsghdr
156structure mentioned above.
157.\"
158.Ss inet6_option_append
159This function appends a Hop-by-Hop option or a Destination option into
160an ancillary data object previously initialized by a call to
161.Fn inet6_option_init .
162The
163.Fn inet6_option_append
164function returns
165.Li 0
166if it succeeds or
167.Li \-1
168when an error occurs.
169.Pp
170The
171.Fa cmsg
172argument is a pointer to the
173.Li cmsghdr
174structure that was initialized by a call to
175.Fn inet6_option_init .
176.Pp
177The
178.Fa typep
179argument is a pointer to the 8-bit option type.
180All options are
181encoded as type-length-value tuples and it is assumed that
182the
183.Fa typep
184field is immediately followed by the 8-bit option data length field,
185which is then followed by the option data.
186.Pp
187The option types of
188.Li 0
189and
190.Li 1
191are reserved for the
192.Li Pad1
193and
194.Li PadN
195options respectively.
196All other values from
197.Li 2
198through
199.Li 255
200are available for applications to use.
201.Pp
202The option data length, since it is stored in 8 bites, must have a
203value between
204.Li 0
205and
206.Li 255 ,
207inclusive.
208.Pp
209The
210.Fa multx
211argument
212is the value
213.Li x
214in the alignment term
215.Dq Li xn + y
216and indicates the byte alignment necessary for the data.
217Alignments may be specified as
218.Li 1 ,
219.Li 2 ,
220.Li 4 ,
221or
222.Li 8
223bytes, which is no alignment, 16-bit, 32-bit and 64-bit alignments
224respectively.
225.Pp
226The
227.Fa plusy
228argument
229is the value
230.Li y
231in the alignment term
232.Dq Li xn + y
233and must have a value between
234.Li 0
235and
236.Li 7 ,
237inclusive, indicating the amount of padding that is necessary for an
238option.
239.\"
240.Ss inet6_option_alloc
241The
242.Fn inet6_option_alloc
243function appends a Hop-by-Hop option or a Destination option into an
244ancillary data object that has previously been initialized by a call to
245.Fn inet6_option_init .
246A successful call to the
247.Fn inet6_option_alloc
248function returns a pointer to the 8-bit option type field,
249which is at the beginning of the allocated region.
250.Fn inet6_option_alloc
251returns
252.Dv NULL
253when an error has occurred.
254.Pp
255The difference between the
256.Fn inet6_option_alloc
257and
258.Fn inet6_option_append
259functions is that the latter copies the contents of a previously built
260option into the ancillary data object while the former returns a
261pointer to the place in the data object where the option's TLV must
262then be built by the application.
263.Pp
264The
265.Fa cmsg
266argument is a pointer to a
267.Li cmsghdr
268structure that was initialized by
269.Fn inet6_option_init .
270.Pp
271The
272.Fa datalen
273argument is the value of the option data length byte for this option.
274This value is required as an argument to allow the function to
275determine if padding must be appended at the end of the option.
276(The
277.Fn inet6_option_append
278function does not need a data length argument
279since the option data length must already be stored by the caller.)
280.Pp
281The
282.Fa multx
283and
284.Fa plusy
285arguments
286are identical to the arguments of the same name described in the
287.Fn inet6_option_init
288function above.
289.\"
290.Ss inet6_option_next
291The
292.Fn inet6_option_next
293function is used to process Hop-by-Hop and Destination options that
294are present in an ancillary data object.
295When an option remains to
296be processed, the return value of the
297.Fn inet6_option_next
298function is
299.Li 0
300and the
301.Fa *tptrp
302argument points to the 8-bit option type field, which is followed by
303the 8-bit option data length, and then the option data.
304When no more
305options remain to be processed, the return value is
306.Li \-1
307and
308.Fa *tptrp
309is
310.Dv NULL .
311When an error occurs, the return value is
312.Li \-1 ,
313but the
314.Fa *tptrp
315argument is not
316.Dv NULL .
317This set of return values allows a program to easily loop through all
318the options in an ancillary data object, checking for the error and
319end of stream conditions along the way.
320.Pp
321When a valid option is returned, the
322.Fa cmsg
323argument points to a
324.Li cmsghdr
325where the
326.Li cmsg_level
327element equals
328.Dv IPPROTO_IPV6
329and the
330.Li cmsg_type
331element is either
332.Dv IPV6_HOPOPTS
333or
334.Dv IPV6_DSTOPTS .
335.Pp
336The
337.Fa tptrp
338argument is a pointer to a pointer to an 8-bit byte and
339.Fa *tptrp
340is used by the function to remember its place in the ancillary data
341object each time the function is called.
342When the
343.Fn inet6_option_next
344function is called for the first time on a given ancillary data object,
345.Fa *tptrp
346must be set to
347.Dv NULL .
348.Pp
349Each time the function returns success,
350the
351.Fa *tptrp
352argument points to the 8-bit option type field for the next option to
353be processed.
354.\"
355.Ss inet6_option_find
356The
357.Fn inet6_option_find
358function allows an application to search for a particular option type
359in an ancillary data object.
360The
361.Fa cmsg
362argument is a pointer to a
363.Li cmsghdr
364structure in which the
365.Li cmsg_level
366element equals
367.Dv IPPROTO_IPV6
368and the
369.Li cmsg_type
370element is either
371.Dv IPV6_HOPOPTS
372or
373.Dv IPV6_DSTOPTS .
374.Pp
375The
376.Fa tptrp
377argument is handled exactly as in the
378.Fn inet6_option_next
379function described above.
380.Pp
381The
382.Fn inet6_option_find
383function starts searching for an option of the specified type
384beginning after the value of
385.Fa *tptrp .
386.\"
387.Sh EXAMPLES
388RFC 2292 gives comprehensive examples in chapter 6.
389.\"
390.Sh DIAGNOSTICS
391The
392.Fn inet6_option_init
393and
394.Fn inet6_option_append
395functions return
396.Li 0
397on success or
398.Li \-1
399on an error.
400.Pp
401The
402.Fn inet6_option_alloc
403function returns
404.Dv NULL
405on an error.
406.Pp
407When
408.Fn inet6_option_next
409or
410.Fn inet6_option_find
411detect an error they return
412.Li \-1 ,
413setting
414.Fa *tptrp
415to a non
416.Dv NULL
417value.
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
441This 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
188functions return 0 on errors. 188functions return 0 on errors.
189.Pp 189.Pp
190The 190The
191.Fn inet6_rthdr_init 191.Fn inet6_rth_init
192function returns 192function returns
193.Dv NULL 193.Dv NULL
194on error. 194on 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
67Note:
68RFC 2292 has been superseded by RFC 3542.
69The use of functions described in this page is deprecated.
70See
71.Xr inet6_rth_space 3 .
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.In 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.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
300This implementation first appeared in the KAME advanced networking kit.
301.\"
302.Sh BUGS
303The
304.Fn inet6_rthdr_reverse
305function 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