inet6_rthdr_space3
Ipv6 routing header options manipulation
Usage
#include <sys/types.h>
#include <netinet/in.h>
size_t
inet6_rthdr_space(int type, int segments);
struct cmsghdr *
inet6_rthdr_init(void *bp, int type);
int
inet6_rthdr_add(struct cmsghdr *cmsg, const struct in6_addr *addr, unsigned int flags);
int
inet6_rthdr_lasthop(struct cmsghdr *cmsg, unsigned int flags);
int
inet6_rthdr_reverse(const struct cmsghdr *in, struct cmsghdr *out);
int
inet6_rthdr_segments(const struct cmsghdr *cmsg);
struct in6_addr *
inet6_rthdr_getaddr(struct cmsghdr *cmsg, int index);
int
inet6_rthdr_getflags(const struct cmsghdr *cmsg, int index);
Library
Standard C Library (libc, -lc)
Overview
RFC2292 IPv6 advanced API defines eight functions that the application calls to build and examine a Routing header. Four functions build a Routing header:
inet6_rthdr_space()-
return #bytes required for ancillary data
inet6_rthdr_init()-
initialize ancillary data for Routing header
inet6_rthdr_add()-
add IPv6 address & flags to Routing header
inet6_rthdr_lasthop()-
specify the flags for the final hop
Four functions deal with a returned Routing header:
inet6_rthdr_reverse()-
reverse a Routing header
inet6_rthdr_segments()-
return #segments in a Routing header
inet6_rthdr_getaddr()-
fetch one address from a Routing header
inet6_rthdr_getflags()-
fetch one flag from a Routing header
The function prototypes for these functions are all in the ⟨netinet/in.h⟩ header.
The full description of these functions is available in RFC2292.
Diagnostics
inet6_rthdr_space() returns 0 on errors.
inet6_rthdr_add(), inet6_rthdr_lasthop() and inet6_rthdr_reverse() return 0 on success, and returns -1 on error.
inet6_rthdr_init() and inet6_rthdr_getaddr() return NULL on error.
inet6_rthdr_segments() and inet6_rthdr_getflags() return -1 on error.
Examples
RFC2292 gives comprehensive examples in chapter 8.
Releases
155 releases since Mac OS X 10.2; the text changed 1 time.