INET6_RTHDR_SPACE(3) | Library Functions Manual | INET6_RTHDR_SPACE(3) |
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);
Four functions deal with a returned Routing header:
The function prototypes for these functions are all in the <netinet/in.h> header.
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.
Note: This function returns the size but does not allocate the space required for the ancillary data. This allows an application to allocate a larger buffer, if other ancillary data objects are desired, since all the ancillary data objects must be specified to sendmsg(2) as a single msg_control
buffer.
cmsghdr
structure followed by a Routing header of the specified type. The cmsg_len
member of the cmsghdr
structure is initialized to the size of the structure plus the amount of space required by the Routing header. The cmsg_level
and cmsg_type
members are also initialized as required.The caller must allocate the buffer and its size can be determined by calling inet6_rthdr_space().
Upon success the return value is the pointer to the cmsghdr
structure, and this is then used as the first argument to the next two functions. Upon an error the return value is NULL.
If successful, the cmsg_len
member of the cmsghdr
structure 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.
The return value of the function is 0 upon success, or -1 upon an error.
Notice that a Routing header specifying N
intermediate nodes requires N+1
Strict/Loose flags. This requires N
calls to inet6_rthdr_add() followed by one call to inet6_rthdr_lasthop().
The return value of the function is 0 on success, or -1 upon an error.
Upon an error the return value of the function is NULL.
Upon an error the return value of the function is -1.
Note: Addresses are indexed starting at 1, and flags starting at 0, to maintain consistency with the terminology and figures in RFC 2460.
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.
S. Deering and R. Hinden, Internet Protocol, Version 6 (IPv6) Specification, RFC 2460, December 1998.
inet6_rthdr_reverse() is not implemented yet.
December 10, 1999 | NetBSD 7.2 |