inet6_opt_init.3n (2010 09)
i
inet6_opt_init(3N) inet6_opt_init(3N)
The parameter offset should be the length returned by
inet6_opt_init()
or
inet6_opt_append()
.
inet6_opt_set_val()
This function inserts data items of various sizes (1, 2, 4, or 8 bytes) in the data portion of the option.
After inserting, the function returns the offset for the next field (offset + vallen ) which can be used
when composing option content with multiple fields. The parameter val points to the data to be
inserted and the parameter offset specifies where in the data portion of the option the value should
be inserted. The first byte after the option type and length is accessed by specifying an offset of zero.
The parameter databuf should be a pointer returned by
inet6_opt_append()
.
inet6_opt_next()
This function parses extension header options received by the application and it returns the offset of
the next option.
The parameters extbuf and extlen specify the extension header.
The parameter offset is either zero (for the first option) or the length returned by a previous call to
inet6_opt_next()
or inet6_opt_find()
. offset specifies the position where to continue
scanning the extension buffer. The next option is returned by updating the parameters databufp ,
typep , and lenp . This function returns the updated "previous" length computed by advancing past
the option that was returned. This returned "previous" length can then be passed to subsequent
calls to
inet6_opt_next()
.
This function does not return any Pad1 or PadN options. When there are no more options or if the
option extension header is malformed, the return value is -1.
inet6_opt_find()
This function is similar to the inet6_opt_next()
function but this function lets the caller
specify the option type to be searched for instead of always returning the next option in the exten-
sion header.
If an option of the specified type is located, the function returns the updated "previous" total length.
This "previous" total length is computed by advancing past the option that was returned and past
any options that did not match the type. This returned previous length can then be passed to subse-
quent calls to
inet6_opt_find()
for finding the next occurrence of the same option type.
If an option of the specified type is not located or the option extension header is malformed, the
return value is -1.
inet6_opt_get_val()
This function extracts data items of various sizes (1, 2, 4, or 8 bytes) in the data portion of the
option. The function returns the offset for the next field (offset + vallen ) which can be used when
extracting option content with multiple fields.
The first parameter databuf should be a pointer returned by
inet6_opt_next()
or
inet6_opt_find()
containing the data portion of the option.
offset parameter specifies from where in the data portion of the option the value should be extracted.
The first byte after the option type and length is accessed by specifying an offset of zero.
val points to the destination for the extracted data.
Notes
To use these functions, the application must be compiled with:
-D_HPUX_SOURCE -lipv6
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:
2 Hewlett-Packard Company − 2 − HP-UX 11i Version 3: September 2010