Manual browser: inet6_putscopeid(3)

Section:
Page:
INET6_GETSCOPEID(3) Library Functions Manual INET6_GETSCOPEID(3)

NAME

inet6_getscopeid, inet6_putscopeidIPv6 scope id encoding and decoding functions

SYNOPSIS

#include <netinet/in.h>

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

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

DESCRIPTION

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 inet6_getscopeid() 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 inet6putscopeid() 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:

  • INET6_IS_ADDR_LINKLOCAL
  • INET6_IS_ADDR_MC_LINKLOCAL
  • INET6_IS_ADDR_SITELOCAL

HISTORY

These functions first appeared in NetBSD 7.0.
October 31, 2013 NetBSD 7.0