inet6_rth_space() — Return number of bytes for a routing header

Standards

Standards / Extensions C or C++ Dependencies

RFC3542

both z/OS® V1R7

Format

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

socklen_t inet6_rth_space(int type, int segments);

General description

inet6_rth_space() calculates the number of bytes required to hold a routing header for the specified type containing the specified number of segments (addresses).

Returned value

If successful, inet6_rth_space() returns the number of bytes, space required, for the routing header.

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

EINVAL If one of the following is true:

  • type indicates an unsupported header type;
  • segments is not valid for the type.

Usage notes

  1. This function returns the size but does not allocate the space required for the ancillary data. This allows an application to allocate a larger buffer, if other ancillary data objects are desired, because all the ancillary data objects must be specified to sendmsg() as a single msg_control buffer.
  2. For an IPv6 Type 0 routing header, the number of segments must be between 0 and 127, inclusive. When the application uses ancillary data it must pass the returned length to CMSG_SPACE() to determine how much memory is needed for the ancillary data object (including the cmsghdr structure).

Related information