#include <netinet/in.h> int inet6_opt_init(void *extension_buffer, socklen_t extension_length)
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.
No authorization is required.
inet6_opt_init() returns an integer. Possible values are:
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. |
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);