inet6_opt_append() — Add an option with length "len" and alignment "align"

Standards

Standards / Extensions C or C++ Dependencies

RFC3542

both z/OS® V1R7

Format

#define _OPEN_SYS_SOCK_IPV6
#include <netinet/in.h>

int inet6_opt_append(void *extbuf, socklen_t extlen, int offset,
                     uint8_t type, socklen_t len, uint8_t align,
                     void **databufp);

General description

inet6_opt_append() returns the updated total length after adding an option with length len and alignment align. If extbuf is not NULL, it inserts any necessary padding and sets the type and length fields. A pointer to the location for the option content in databufp is then returned.

offset should be the length returned by inet6_opt_init() or the previous inet6_opt_append(). type is the 8-bit option type and len is the length of the option data (excluding the option type and option length fields).

Returned value

If successful, inet6_opt_append() returns the updated total length of the extension header.

Upon failure, returns -1 and errno is set to one of the following:

EINVAL If one of the following is true:

  • extbuf is NULL and extlen is non-zero;
  • extbuf is non-NULL and extlen is not a positive multiple of 8;
  • offset is less than the size of the empty extension header;
  • type is not valid (specifies one of the PAD options);
  • len is less than 0 or greater than 255;
  • align is not 1, 2, 4, or 8;
  • align is greater than len;
  • new updated total length would exceed extlen (extbuf is non-NULL);
  • databufp is NULL (extbuf is non-NULL).

Usage notes

  1. The option, type, must have a value from 2 to 255 (0 and 1 are reserved for the Pad1 and PadN options).
  2. The option data length must have a value between 0 and 255, including the values 0 and 255. It is the length of the option data that follows.
  3. The align parameter must have a value of 1, 2, 4, or 8 and can not exceed the value of len.
  4. Once inet6_opt_append() has been called, the application can use databufp directly or use inet6_opt_set_val() to specify the content of the option.

Related information