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
- extbuf and extlen specifies the extension header.
- 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.
- typep points to the option type field.
- lenp stores the length of the option data (excluding the option type and option length fields).
- databufp points to the data field of the of the option.
Related information
- netinet/in.h
- inet6_opt_append() — Add an option with length "len" and alignment "align"
- inet6_opt_find() — Search for an option specified by the caller
- inet6_opt_finish() — Return the updated total length of extension header
- inet6_opt_get_val() — Extract data items in the data portion of the option
- inet6_opt_init() — Return the number of bytes for empty extension header
- inet6_opt_set_val() — Insert data items into the data portion of the option