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:


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

  1. 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.
  2. 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.
  3. 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




API introduced: V6R1

[ Back to top | UNIX-Type APIs | APIs by category ]