---
name: "inet6_rthdr_space"
section: "3"
platform: "macos"
package: "Libinfo"
version: "600"
release: "macOS 26.5"
platforms: ["freebsd", "macos"]
url: "https://new.carta.tech/inet6_rthdr_space"
---

# inet6\_rthdr\_space(3)

IPv6 Routing Header Options manipulation

## NAME

**inet6\_rthdr\_space**, **inet6\_rthdr\_init**, **inet6\_rthdr\_add**, **inet6\_rthdr\_lasthop**, **inet6\_rthdr\_reverse**, **inet6\_rthdr\_segments**, **inet6\_rthdr\_getaddr**, **inet6\_rthdr\_getflags** – IPv6 Routing Header Options manipulation

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<sys/types.h\>**

**#include \<netinet/in.h\>**

*size\_t*\

**inet6\_rthdr\_space**(*int type*, *int segments*);

*struct cmsghdr \**\

**inet6\_rthdr\_init**(*void \*bp*, *int type*);

*int*\

**inet6\_rthdr\_add**(*struct cmsghdr \*cmsg*, *const struct in6\_addr \*addr*, *unsigned int flags*);

*int*\

**inet6\_rthdr\_lasthop**(*struct cmsghdr \*cmsg*, *unsigned int flags*);

*int*\

**inet6\_rthdr\_reverse**(*const struct cmsghdr \*in*, *struct cmsghdr \*out*);

*int*\

**inet6\_rthdr\_segments**(*const struct cmsghdr \*cmsg*);

*struct in6\_addr \**\

**inet6\_rthdr\_getaddr**(*struct cmsghdr \*cmsg*, *int index*);

*int*\

**inet6\_rthdr\_getflags**(*const struct cmsghdr \*cmsg*, *int index*);

## DESCRIPTION

RFC2292 IPv6 advanced API defines eight functions that the application calls to build and examine a Routing header.  Four functions build a Routing header:

- **inet6\_rthdr\_space**()

  return #bytes required for ancillary data

- **inet6\_rthdr\_init**()

  initialize ancillary data for Routing header

- **inet6\_rthdr\_add**()

  add IPv6 address & flags to Routing header

- **inet6\_rthdr\_lasthop**()

  specify the flags for the final hop

Four functions deal with a returned Routing header:

- **inet6\_rthdr\_reverse**()

  reverse a Routing header

- **inet6\_rthdr\_segments**()

  return #segments in a Routing header

- **inet6\_rthdr\_getaddr**()

  fetch one address from a Routing header

- **inet6\_rthdr\_getflags**()

  fetch one flag from a Routing header

The function prototypes for these functions are all in the ⟨netinet/in.h⟩ header.

The full description of these functions is available in RFC2292.

## DIAGNOSTICS

**inet6\_rthdr\_space**() returns 0 on errors.

**inet6\_rthdr\_add**(), **inet6\_rthdr\_lasthop**() and **inet6\_rthdr\_reverse**() return 0 on success, and returns -1 on error.

**inet6\_rthdr\_init**() and **inet6\_rthdr\_getaddr**() return NULL on error.

**inet6\_rthdr\_segments**() and **inet6\_rthdr\_getflags**() return -1 on error.

## EXAMPLES

RFC2292 gives comprehensive examples in chapter 8.

## SEE ALSO

W. Stevens and M. Thomas, *Advanced Sockets API for IPv6*, RFC2292, February 1998. S. Deering and R. Hinden, *Internet Protocol, Version 6 (IPv6) Specification*, RFC2460, December 1998.

## HISTORY

The implementation first appeared in KAME advanced networking kit.

## STANDARDS

The functions are documented in “Advanced Sockets API for IPv6” (RFC2292).

## BUGS

The text was shamelessly copied from RFC2292.

**inet6\_rthdr\_reverse**() is not implemented yet.
