The inet6_opt_get_val function extracts data items of various sizes in the data portion of the option. The databuf is a pointer returned by the inet6_opt_next or inet6_opt_find functions. The val argument points where the data will be extracted. The offset argument specifies from where in the data portion of the option the value should be extracted; the first byte of option data is specified by an offset of zero.
It is expected that each field is aligned on its natural boundaries as described in Appendix B of RFC2460.
The function returns the offset for the next field by calculating offset + vallen which can be used when extracting option content with multiple fields. Robust receivers must verify alignment before calling this function.
All the functions return -1 on an error.
RFC3542 gives comprehensive examples in Section 23.
KAME also provides examples in the advapitest directory of its kit.
.Rs "Advanced Sockets API for IPv6"
.Rs "Internet Protocol, Version 6 (IPv6) Specification"