HP-UX Reference (11i v2 03/08) - 3 Library Functions A-M (vol 6)

i
inet6_opt_init(3N) inet6_opt_init(3N)
NAME
inet6_opt_init(), inet6_opt_append(), inet6_opt_find(), inet6_opt_finish(), inet6_opt_get_val(),
inet6_opt_next(), inet6_opt_set_val() - IPv6 Hop-by-Hop and Destination options manipulation functions.
SYNOPSIS
#include <netinet/in.h>
int inet6_opt_append(void *extbuf, size_t extlen, int prevlen,
uint8_t type, size_t len, uint_t align,
void **databufp);
int inet6_opt_find(void *extbuf, size_t extlen, int prevlen,
uint8_t type, size_t *lenp,
void **databufp);
int inet6_opt_finish(void *extbuf, size_t extlen, int prevlen);
int inet6_opt_get_val(void *databuf, size_t offset, void *val,
int vallen);
int inet6_opt_init(void *extbuf, size_t extlen);
int inet6_opt_next(void *extbuf, size_t extlen, int prevlen,
uint8_t *typep, size_t *lenp,
void **databufp);
int inet6_opt_set_val(void *databuf, size_t offset, void *val,
int vallen);
DESCRIPTION
These functions can be used by applications to build and parse the IPv6 Hop-by-Hop and Destination
options header. The Hop-by-Hop option header is used to carry optional information that must be exam-
ined by every node along a packet’s delivery path and the Destination option header is used to carry
optional information that needs to be examined only by a packet’s destination node(s).
To receive Hop-by-Hop options the application must enable the
IPV6_RECVHOPOPTS
socket option:
int on = 1;
setsockopt(fd, IPPROTO_IPV6, IPV6_RECVHOPOPTS, &on, sizeof(on));
To send a Hop-by-Hop options header, the application specifies the header either as ancillary data in a
call to sendmsg() or using setsockopt().
The application can remove any sticky Hop-by-Hop extension header by calling
setsockopt() for
IPV6_HOPOPTS with a zero option length.
To receive Destination options appearing after a Routing header (or in a packet without a Routing
header) the application must enable the
IPV6_RECVDSTOPTS
socket option:
int on = 1;
setsockopt(fd, IPPROTO_IPV6, IPV6_RECVDSTOPTS, &on, sizeof(on));
To receive Destination options appearing before a Routing header the application must enable the
IPV6_RECVRTHDRDSTOPTS socket option:
int on = 1;
setsockopt(fd, IPPROTO_IPV6, IPV6_RECVRTHDRDSTOPTS, &on, sizeof(on));
To send a Destination options header, the application specifies it either as ancillary data in a call to
sendmsg() or using setsockopt().
The application can remove any sticky Destination extension header by calling
setsockopt() for
IPV6_RTHDRDSTOPTS/IPV6_DSTOPTS with a zero option length.
inet6_opt_init()
This function returns the number of bytes needed for the empty extension header without any
options. If extbuf is not NULL, it also initializes the extension header to have the correct length
field. If the extlen value is not a positive multiple of 8, the function fails and returns -1.
inet6_opt_append()
This function returns the updated total length required to add an option with length len and align-
ment align.Ifextbuf is not NULL, then in addition to returning the length, this function also
Section 3524 Hewlett-Packard Company 1 HP-UX 11i Version 2: August 2003