HP-UX Reference (11i v2 03/08) - 3 Library Functions A-M (vol 6)
i
inet6_opt_init(3N) inet6_opt_init(3N)
inserts any needed pad option, initializes the option (sets the type and length fields), and returns a
pointer to the location for the option content in databufp . If the option specified by the type does not
fit in the extension header buffer then the function returns -1.
The third parameter prevlen should be the length returned by
inet6_opt_init()
or by a previ-
ous
inet6_opt_append()
.
The parameter type is the 8-bit option type and it must be a value from 2 to 255, inclusive. 0 and 1
are reserved for the Pad1 and PadN options, respectively.
The parameter len is the length of the option data excluding the option type and option length fields.
It must have a value between 0 and 255, inclusive, and it specifies the length of the option data that
follows the option header.
The align parameter must have a value of 1, 2, 4, or 8. The align value can not exceed the value of
len.
Once
inet6_opt_append()
has been called, the application can use databuf directly, or use
inet6_opt_set_val()
to specify (set) the contents of the option.
inet6_opt_finish()
This function returns the updated total length including the final padding of the extension header to
make the header a multiple of 8 bytes.
If extbuf is not NULL, the function also initializes the option by inserting a Pad1 or PadN option of
the proper length. If the necessary pad does not fit in the extension header buffer, the function
returns -1.
The parameter prevlen 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 prevlen is either zero (for the first option) or the length returned by a previous call to
inet6_opt_next()
or inet6_opt_find(). prevlen 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
HP-UX 11i Version 2: August 2003 − 2 − Hewlett-Packard Company Section 3−−525