xref: /minix/lib/libc/net/inet6_getscopeid.3 (revision 84d9c625)
1.\"	$NetBSD: inet6_getscopeid.3,v 1.3 2013/10/31 00:30:14 wiz Exp $
2.\"-
3.\" Copyright (c) 2013 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Christos Zoulas.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.\"
31.Dd October 31, 2013
32.Dt INET6_GETSCOPEID 3
33.Os
34.\"
35.Sh NAME
36.Nm inet6_getscopeid ,
37.Nm inet6_putscopeid
38.Nd IPv6 scope id encoding and decoding functions
39.\"
40.Sh SYNOPSIS
41.In netinet/in.h
42.Ft void
43.Fn inet6_getscopeid "struct sockaddr_in6 *sin6" "int flags"
44.Ft void
45.Fn inet6_putscopeid "struct sockaddr_in6 *sin6" "int flags"
46.\"
47.Sh DESCRIPTION
48These functions implement a KAME-specific extension that encodes and
49decodes the scope id inside in the 3rd and 4th byte of the address,
50for link-local, site-local, and multicast-link-local addresses.
51The scope id helps deciding which interface is used for packets of
52that type.
53.Pp
54Typically those two bytes are
55.Dv 0
56for these kinds of addresses.
57The scope id is stored in network byte order.
58.Pp
59The
60.Fn inet6_getscopeid
61function retrieves the scope id from the 3rd and the 4th address bytes
62(from the
63.Va sin6_addr
64member of
65.Fa sin6 ) ,
66and sets the
67.Ft sin6_scope_id
68from them.
69It then clears the two address bytes.
70.Pp
71The
72.Fn inet6putscopeid
73function stores the scope id found in
74.Ft sin6_scope_id
75into the 3rd and 4th byte of the address
76(into the
77.Va sin6_addr
78member of
79.Fa sin6 ) .
80It then clears the
81.Va sin6_scope_id
82member of
83.Fa sin6 .
84.Pp
85The
86.Fa flags
87argument controls for which addresses this action is performed.
88It
89can be a combination of:
90.Bl -bullet
91.It
92.Dv INET6_IS_ADDR_LINKLOCAL
93.It
94.Dv INET6_IS_ADDR_MC_LINKLOCAL
95.It
96.Dv INET6_IS_ADDR_SITELOCAL
97.El
98.Sh HISTORY
99These functions first appeared in
100.Nx 7.0 .
101