inet6_opt_next() — Parse received option headers returning the next option

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_next(void *extbuf, socklen_t extlen, int offset,
                      uint8_t *typep, socklen_t *lenp, void **databufp);

General description

inet6_opt_next() parses received option extension headers and returns the next option.

Returned value

If successful, inet6_opt_next() 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.

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

EINVAL If one of the following is true:

  • extbuf is NULL;
  • extlen is not a positive multiple of 8;
  • offset is less than 0 or greater than or equal to extlen;
  • typep, lenp, or databufp is NULL;
  • there are no more options;
  • the extension header is malformed.

Usage notes

  1. extbuf and extlen specifies the extension header.
  2. offset should either be zero (for the first option) or the length returned by a previous call to inet6_opt_next() or inet6_opt_find(). It specifies the position to continue scanning the extension buffer. The next option is returned by updating typep, lenp, and databufp.
  3. typep points to the option type field.
  4. lenp stores the length of the option data (excluding the option type and option length fields).
  5. databufp points to the data field of the of the option.

Related information