Sockets Library Functions inet6rth(3SOCKET)
NAME
inet6rth, inet6rthspace, inet6rthinit, inet6rthadd,
inet6rthreverse, inet6rthsegments, inet6rthgetaddr -
Routing header manipulation
SYNOPSIS
cc [ flag ... ] file ... -lsocket [library]
#include
socklent inet6rthspace(int type, int segments);
void *inet6rthinit(void *bp, socklent bplen, int type, int segments);
int inet6rthadd(void *bp, const struct, in6addr *addr);
int inet6rthreverse(const void *in, void *out);
int inet6rthsegments(const void *bp);
struct in6addr *inet6rthgetaddr(const void *bp, int index);
DESCRIPTION
The inet6rth functions enable users to manipulate routing
headers without having knowledge of their structure.
The iet6rthinit() function initializes the buffer pointed
to by bp to contain a routing header of the specified type
and sets ip6rlen based on the segments parameter. The
bplen argument is used only to verify that the buffer is
large enough. The ip6rsegleft field is set to zero and
inet6rthadd() increments it. The caller allocates the
buffer and its size can be determined by calling
inet6rthspace().
The inet6rthadd() function adds the IPv6 address pointed
to by addr to the end of the routing header that is being
constructed.
The inet6rthreverse() function takes a routing header
extension header pointed to by the first argument and writes
a new routing header that sends datagrams along the reverse
of the route. The function reverses the order of the
addresses and sets the segleft member in the new routing
SunOS 5.11 Last change: 15 Feb 2007 1
Sockets Library Functions inet6rth(3SOCKET)
header to the number of segments. Both arguments can point
to the same buffer (that is, the reversal can occur in
place).
The inet6rthsegments() function returns the number of seg-
ments (addresses) contained in the routing header described
by bp.
The inet6rthgetaddr() function returns a pointer to the
IPv6 address specified by index, which must have a value
between 0 and one less than the value returned by
inet6rthsegments() in the routing header described by bp.
Applications should first call inet6rthsegments() to
obtain the number of segments in the routing header.
The inet6rthspace() function returns the size, but the
function does not allocate the space required for the ancil-
lary data routing header.
ROUTING HEADERS
To receive a routing header, the application must enable the
IPV6RECVRTHDR socket option:
int on = 1;
setsockopt (fd, IPROTOIPV6, IPV6RECVRTHDR, &on, sizeof(on));
Each received routing header is returned as one ancillary
data object described by a cmsghdr structure with cmsgtype
set to IPV6RTHDR.
To send a routing header, the application specifies it
either as ancillary data in a call to sendmsg() or by using
setsockopt(). For the sending side, this API assumes the
number of occurrences of the routing header as described in
RFC-2460. Applications can specify no more than one outgoing
routing header.
The application can remove any sticky routing header by cal-
ling setsockopt() for IPV6RTHDR with a zero option length.
When using ancillary data, a routing header is passed
between the application and the kernel as follows: The
cmsglevel member has a value of IPROTOIPV6 and the
cmsgtype member has a value of IPV6RTHDR. The contents of
SunOS 5.11 Last change: 15 Feb 2007 2
Sockets Library Functions inet6rth(3SOCKET)
the cmsgdata member is implementation-dependent and should
not be accessed directly by the application, but should be
accessed using the inet6rth functions.
The following constant is defined as a result of including
the :
#define IPV6RTHDRTYPE0 0 /* IPv6 Routing header type 0 */
ROUTING HEADER OPTION
Source routing in IPv6 is accomplished by specifying a rout-
ing header as an extension header. There are a number of
different routing headers, but IPv6 currently defines only
the Type 0 header. See RFC-2460. The Type 0 header supports
up to 127 intermediate nodes, limited by the length field in
the extension header. With this maximum number of intermedi-
ate nodes, a source, and a destination, there are 128 hops.
RETURN VALUES
The inet6rthinit() function returns a pointer to the
buffer (bp) upon success.
For the inet6rthadd() function, the segleft member of the
routing header is updated to account for the new address in
the routing header. The function returns 0 upon success and
-1 upon failure.
The inet6rthreverse() function returns 0 upon success or
-1 upon an error.
The inet6rthsegments() function returns 0 or greater upon
success and -1 upon an error.
The inet6rthgetaddr() function returns NUL upon an error.
The inet6rthspace() function returns the size of the
buffer needed for the routing header.
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
SunOS 5.11 Last change: 15 Feb 2007 3
Sockets Library Functions inet6rth(3SOCKET)
ATRIBUTE TYPE ATRIBUTE VALUE
Interface Stability Standard
MT-Level Safe
SEE ALSO
RFC 3542- Advanced Sockets Application Programming Interface
(API) for IPv6, The Internet Society. May 2003
SunOS 5.11 Last change: 15 Feb 2007 4
|