1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
12 >inet6_rthdr_space</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE="TCP/IP Library Reference"
23 HREF="tcpip-library-reference.html"><LINK
25 TITLE="inet6_option_space"
26 HREF="net-common-tcpip-manpages-inet6-option-space.html"><LINK
29 HREF="net-common-tcpip-manpages-inet-net.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="net-common-tcpip-manpages-inet6-option-space.html"
65 >Chapter 38. TCP/IP Library Reference</TD
71 HREF="net-common-tcpip-manpages-inet-net.html"
85 NAME="NET-COMMON-TCPIP-MANPAGES-INET6-RTHDR-SPACE">inet6_rthdr_space</H1
94 >INET6_RTHDR_SPACE(3) System Library Functions Manual INET6_RTHDR_SPACE(3)
97 inet6_rthdr_space, inet6_rthdr_init, inet6_rthdr_add,
98 inet6_rthdr_lasthop, inet6_rthdr_reverse, inet6_rthdr_segments,
99 inet6_rthdr_getaddr, inet6_rthdr_getflags - IPv6 Routing Header Options
103 #include <netinet/in.h>
106 inet6_rthdr_space(int type, int segments);
109 inet6_rthdr_init(void *bp, int type);
112 inet6_rthdr_add(struct cmsghdr *cmsg, const struct in6_addr *addr,
116 inet6_rthdr_lasthop(struct cmsghdr *cmsg, unsigned int flags);
119 inet6_rthdr_reverse(const struct cmsghdr *in, struct cmsghdr *out);
122 inet6_rthdr_segments(const struct cmsghdr *cmsg);
125 inet6_rthdr_getaddr(struct cmsghdr *cmsg, int index);
128 inet6_rthdr_getflags(const struct cmsghdr *cmsg, int index);
131 RFC2292 IPv6 advanced API defines eight functions that the application
132 calls to build and examine a Routing header. Four functions build a
135 inet6_rthdr_space() return #bytes required for ancillary data
137 inet6_rthdr_init() initialize ancillary data for Routing header
139 inet6_rthdr_add() add IPv6 address & flags to Routing header
141 inet6_rthdr_lasthop() specify the flags for the final hop
143 Four functions deal with a returned Routing header:
145 inet6_rthdr_reverse() reverse a Routing header
147 inet6_rthdr_segments() return #segments in a Routing header
149 inet6_rthdr_getaddr() fetch one address from a Routing header
151 inet6_rthdr_getflags() fetch one flag from a Routing header
153 The function prototypes for these functions are all in the <netinet/in.h>
157 This function returns the number of bytes required to hold a Routing
158 header of the specified type containing the specified number of segments
159 (addresses). For an IPv6 Type 0 Routing header, the number of segments
160 must be between 1 and 23, inclusive. The return value includes the size
161 of the cmsghdr structure that precedes the Routing header, and any
164 If the return value is 0, then either the type of the Routing header is
165 not supported by this implementation or the number of segments is invalid
166 for this type of Routing header.
168 Note: This function returns the size but does not allocate the space
169 required for the ancillary data. This allows an application to allocate
170 a larger buffer, if other ancillary data objects are desired, since all
171 the ancillary data objects must be specified to sendmsg(2) as a single
175 This function initializes the buffer pointed to by bp to contain a
176 cmsghdr structure followed by a Routing header of the specified type.
177 The cmsg_len member of the cmsghdr structure is initialized to the size
178 of the structure plus the amount of space required by the Routing header.
179 The cmsg_level and cmsg_type members are also initialized as required.
181 The caller must allocate the buffer and its size can be determined by
182 calling inet6_rthdr_space().
184 Upon success the return value is the pointer to the cmsghdr structure,
185 and this is then used as the first argument to the next two functions.
186 Upon an error the return value is NULL.
189 This function adds the address pointed to by addr to the end of the Rout-
190 ing header being constructed and sets the type of this hop to the value
191 of flags. For an IPv6 Type 0 Routing header, flags must be either
192 IPV6_RTHDR_LOOSE or IPV6_RTHDR_STRICT.
194 If successful, the cmsg_len member of the cmsghdr structure is updated to
195 account for the new address in the Routing header and the return value of
196 the function is 0. Upon an error the return value of the function is -1.
199 This function specifies the Strict/Loose flag for the final hop of a
200 Routing header. For an IPv6 Type 0 Routing header, flags must be either
201 IPV6_RTHDR_LOOSE or IPV6_RTHDR_STRICT.
203 The return value of the function is 0 upon success, or -1 upon an error.
205 Notice that a Routing header specifying N intermediate nodes requires N+1
206 Strict/Loose flags. This requires N calls to inet6_rthdr_add() followed
207 by one call to inet6_rthdr_lasthop().
210 This function takes a Routing header that was received as ancillary data
211 (pointed to by the first argument, in) and writes a new Routing header
212 that sends datagrams along the reverse of that route. Both arguments are
213 allowed to point to the same buffer (that is, the reversal can occur in
216 The return value of the function is 0 on success, or -1 upon an error.
219 This function returns the number of segments (addresses) contained in the
220 Routing header described by cmsg. On success the return value is between
221 1 and 23, inclusive. The return value of the function is -1 upon an
225 This function returns a pointer to the IPv6 address specified by index
226 (which must have a value between 1 and the value returned by
227 inet6_rthdr_segments()) in the Routing header described by cmsg. An
228 application should first call inet6_rthdr_segments() to obtain the number
229 of segments in the Routing header.
231 Upon an error the return value of the function is NULL.
234 This function returns the flags value specified by index (which must have
235 a value between 0 and the value returned by inet6_rthdr_segments()) in
236 the Routing header described by cmsg. For an IPv6 Type 0 Routing header
237 the return value will be either IPV6_RTHDR_LOOSE or IPV6_RTHDR_STRICT.
239 Upon an error the return value of the function is -1.
241 Note: Addresses are indexed starting at 1, and flags starting at 0, to
242 maintain consistency with the terminology and figures in RFC2460.
245 inet6_rthdr_space() returns 0 on errors.
247 inet6_rthdr_add(), inet6_rthdr_lasthop() and inet6_rthdr_reverse() return
248 0 on success, and returns -1 on error.
250 inet6_rthdr_init() and inet6_rthdr_getaddr() return NULL on error.
252 inet6_rthdr_segments() and inet6_rthdr_getflags() return -1 on error.
255 RFC2292 gives comprehensive examples in chapter 8.
258 W. Stevens and M. Thomas, Advanced Sockets API for IPv6, RFC2292,
261 S. Deering and R. Hinden, Internet Protocol, Version 6 (IPv6)
262 Specification, RFC2460, December 1998.
265 The implementation first appeared in KAME advanced networking kit.
268 The functions are documented in ``Advanced Sockets API for IPv6''
272 The text was shamelessly copied from RFC2292.
274 inet6_rthdr_reverse() is not implemented yet.
276 BSD December 10, 1999 BSD
287 SUMMARY="Footer navigation table"
298 HREF="net-common-tcpip-manpages-inet6-option-space.html"
316 HREF="net-common-tcpip-manpages-inet-net.html"
326 >inet6_option_space</TD
332 HREF="tcpip-library-reference.html"