INET6_GETSCOPEID(3) Library Functions Manual INET6_GETSCOPEID(3)

inet6_getscopeid, inet6_putscopeidIPv6 scope id encoding and decoding functions

#include <netinet/in.h>

void
inet6_getscopeid(struct sockaddr_in6 *sin6, int flags);

void
inet6_putscopeid(struct sockaddr_in6 *sin6, int flags);

These functions implement a KAME-specific extension that encodes and decodes the scope id inside in the 3rd and 4th byte of the address, for link-local, site-local, and multicast-link-local addresses. The scope id helps deciding which interface is used for packets of that type.

Typically those two bytes are 0 for these kinds of addresses. The scope id is stored in network byte order.

The () function retrieves the scope id from the 3rd and the 4th address bytes (from the sin6_addr member of sin6), and sets the sin6_scope_id from them. It then clears the two address bytes.

The () function stores the scope id found in sin6_scope_id into the 3rd and 4th byte of the address (into the sin6_addr member of sin6). It then clears the sin6_scope_id member of sin6.

The flags argument controls for which addresses this action is performed. It can be a combination of:

These functions first appeared in NetBSD 7.0.

October 31, 2013 NetBSD 11.0