Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > I

inet6_rth_space(3N)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

inet6_rth_add(), inet6_rth_getaddr(), inet6_rth_init(), inet6_rth_reverse(), inet6_rth_segments(), inet6_rth_space() — IPv6 Routing header options manipulation functions.

SYNOPSIS

#include <netinet/in.h> size_t inet6_rth_space(int type, int segments); void *inet6_rth_init(void *bp, int bp_len, int type, int segments); int inet6_rth_add(void *bp, const struct in6_addr *addr); int inet6_rth_reverse(const void *in, void *out); int inet6_rth_segments(const void *bp); struct in6_addr *inet6_rth_getaddr(const void *bp, int index);

DESCRIPTION

These functions can be used by an application to build and examine an IPv6 Routing header. The Routing header can be used by an IPv6 source to list one or more intermediate nodes to be visited on the way to a packet's destination.

These three functions build a Routing header:

inet6_rth_space()

returns the number of bytes required for a Routing header.

inet6_rth_init()

initializes the buffer data for a Routing header.

inet6_rth_add()

adds one IPv6 address to the Routing header.

Three functions deal with a returned Routing header:

inet6_rth_reverse()

reverses a Routing header.

inet6_rth_segments()

returns the number of segments in a Routing header.

inet6_rth_getaddr()

fetches one address from a Routing header.

To receive a Routing header the application must enable the IPV6_RECVRTHDR socket option:

int on = 1; setsockopt(fd, IPPROTO_IPV6, IPV6_RECVRTHDR, &on, sizeof(on));

To send a Routing header the application specifies it either as ancillary data in a call to sendmsg() or using setsockopt() (see send(2) and getsockopt(2), respectively).

inet6_rth_space()

This function returns the number of bytes required to hold a routing header of the specified type containing the specified number of segments (addresses). For an IPv6 Type 0 Routing header, the number of segments must be between 0 and 127, inclusive. The return value is just the space for the Routing header. When the application uses ancillary data, it must pass the returned length to CMSG_LEN() to determine how much memory is needed for the ancillary data object (including the cmsghdr structure).

If the return value is 0, then either the type of the Routing header is not supported by this implementation or the number of segments is invalid for this type of Routing header.

This function returns the size but does not allocate the space required for the ancillary data.

inet6_rth_init()

This function initializes the buffer pointed to by bp to contain a Routing header of the specified type. bp_len is only used to verify if the buffer is large enough.

The caller must allocate the buffer, and its size can be determined by calling inet6_rth_space().

Upon success, the return value is the pointer to the buffer (bp), and the pointer is then used as the first argument to the inet6_rth_add() function. Upon an error, the return value is NULL.

inet6_rth_add()

This function adds the IPv6 address pointed to by addr to the end of the Routing header being constructed.

If successful, the segleft member of the Routing header is updated to account for the new address in the Routing header and the return value of the function is 0. Upon an error the return value of the function is -1.

inet6_rth_reverse()

This function takes a Routing header extension header pointed to by the first argument in and writes a new Routing header. The new Routing header sends datagrams along the reverse of that route. The function reverses the order of the addresses and sets the segleft member in the new routing header to the number of segments. Both arguments are allowed to point to the same buffer (that is, the reversal can occur in place).

The return value of the function is 0 on success, or -1 upon an error.

inet6_rth_segments()

This function returns the number of segments (addresses) contained in the Routing header described by bp which can be 0 or greater.

The return value of the function is -1 upon an error.

inet6_rth_getaddr()

This function returns a pointer to the IPv6 address specified by index (which must be a value between 0 and one less than the value returned by inet6_rth_segments()) in the Routing header described by bp.

An application should first call inet6_rth_segments() to obtain the number of segments in the Routing header.

Upon an error, the return value of the function is NULL.

To use these functions, the application must be compiled with:

  • -D_HPUX_SOURCE -D_XOPEN_SOURCE_EXTENDED -lxnet -lipv6

The APIs are implemented based on internet-draft Advanced Sockets API for IPv6 (draft-ietf-ipngwg-2292bis-02.txt). The APIs may be updated, replaced, or obsoleted based on future changes to the document.

EXAMPLES

Advanced Sockets API for IPv6 (draft-ietf-ipngwg-2292bis-02.txt) gives a comprehensive example in Appendix B.

AUTHOR

The APIs were developed by HP.

SEE ALSO

send(2), getsockopt(2), IPv6(7P).

Advanced Sockets API for IPv6 (draft-ietf-ipngwg-2292bis-02.txt).

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.