inet6_opt_init()--Initialize Buffer Data for IPv6 Extension Header
Syntax
#include <netinet/in.h> int inet6_opt_init(void *extension_buffer, socklen_t extension_length)
Service Program Name: QSOSRV1IP6
Default Public Authority: *USE
Threadsafe: Yes
The inet6_opt_init() function returns the number of bytes needed for an extension header without any options. If extension_buffer is not NULL, it will also initialize the extension header's length field based on the length provided in extension_length.
Parameters
- extension_buffer
- (Input) Pointer to a buffer that contains the extension header.
- extension_length
- (Input) Length of the extension header pointed to by extension_buffer.
Must be a positive multiple of 8.
This value is the total number of bytes in the buffer pointed to by extension_buffer.
Authorities
No authorization is required.
Return Value
inet6_opt_init() returns an integer. Possible values are:
- -1 (unsuccessful)
- n (successful), where n is the number of bytes needed for an empty extension header (header with no options)
Error Conditions
When inet6_opt_init() fails, errno can be set to one of the following:
[EFAULT] | Bad address.
The system detected an address that was not valid while attempting to access the buffer pointed to by the extension_buffer parameter. |
[EINVAL] | Parameter not valid.
The extension_length field contains a value that is not a positive multiple of 8. |
Usage Notes
- When called with extension_buffer as a NULL pointer, inet6_opt_init() only returns the number of bytes in an extension header with no options.
- When called with a valid pointer for extension_buffer, inet6_opt_init() will initialize the entire extension header. It will set the length field of the options header to the size of the extension header, specified in extension_length, in addition to returning the current number of bytes set in the extension header.
- inet6_opt_init() is normally called twice when building an options header.
The first call is used to begin calculating the size of the extension header as follows:
int currentlen, extlen; void *extbuf; currentlen = inet6_opt_init(NULL, 0);
This is followed by the desired number of inet6_opt_append() calls to increment the calculated length and by a call to inet6_opt_finish() to calculate the final length to be used when actually initializing the extension header as follows:extlen = currentlen; extbuf = malloc(extlen); currentlen = inet6_opt_init(extbuf, extlen);
Related Information
- inet6_opt_append()--Append New Option to IPv6 Extension Header
- inet6_opt_find()--Extract Option of Specified Type from IPv6 Extension Header
- inet6_opt_finish()--Finish Adding Options to IPv6 Extension Header
- inet6_opt_get_val()--Retrieve Data Item from an IPv6 Option
- inet6_opt_next()--Extract the Next Option from the IPv6 Extension Header
- inet6_opt_set_val()--Insert Data Items into IPv6 Option
API introduced: V6R1