socklen_t
inet6_rth_space(
int
, int
)
void *
inet6_rth_init(
void *
, socklen_t
, int
, int
)
int
inet6_rth_add(
void *
, const struct in6_addr *
)
int
inet6_rth_reverse(
const void *
, void *
)
int
inet6_rth_segments(
const void *
)
struct in6_addr *
inet6_rth_getaddr(
const void *
, int
)
The functions in the API are split into two groups, those that build a routing header and those that parse a received routing header. We will describe the builder functions followed by the parser functions.
)
function returns the number of bytes required to hold a Routing Header
of the type, specified in the
type
argument and containing the number of addresses specified in the
segments
argumment.
When the type is
IPV6_RTHDR_TYPE_0
the number of segments must be from 0 through 127.
Routing headers of type
IPV6_RTHDR_TYPE_2
contain only one segment, and are only used with Mobile IPv6.
The return value from this function is the number of bytes required to
store the routing header.
If the value 0 is returned then either the
route header type was not recognized or another error occurred.
)
function initializes the pre-allocated buffer pointed to by
bp
to contain a routing header of the specified type The
bp_len
argument is used to verify that the buffer is large enough.
The caller must allocate the buffer pointed to by bp.
The necessary buffer size should be determined by calling
inet6_rth_space(
)
described in the previous sections.
The
inet6_rth_init()
function returns a pointer to
bp
on success and
NULL
when there is an error.
)
function adds the IPv6 address pointed to by
addr
to the end of the routing header being constructed.
A successful addition results in the function returning 0, otherwise -1 is returned.
)
function takes a routing header, pointed to by the
argument
in
,
and writes a new routing header into the argument pointed to by
out
.
The routing header at that sends datagrams along the reverse of that
route.
Both arguments are allowed to point to the same buffer meaning
that the reversal can occur in place.
The return value of the function is 0 on success, or -1 when there is an error.
The next set of functions operate on a routing header that the application wants to parse. In the usual case such a routing header is received from the network, although these functions can also be used with routing headers that the application itself created.
)
function returns the number of segments contained in the
routing header pointed to by
bp
.
The return value is the number of segments contained in the routing
header, or -1 if an error occurred.
It is not an error for 0 to be
returned as a routing header may contain 0 segments.
)
function is used to retrieve a single address from a routing header.
The
index
is the location in the routing header from which the application wants
to retrieve an address.
The
index
parameter must have a value between 0 and one less than the number of
segments present in the routing header.
The
inet6_rth_segments(
)
function, described in the last section, should be used to determine
the total number of segments in the routing header.
The
inet6_rth_getaddr(
)
function returns a pointer to an IPv6 address on success or
NULL
when an error has occurred.
)
and
inet6_rth_getaddr(
)
functions return 0 on errors.
The
inet6_rthdr_init()
function returns
NULL
on error.
The
inet6_rth_add()
and
inet6_rth_reverse(
)
functions return 0 on success, or -1 upon an error.
KAME also provides examples in the advapitest directory of its kit.