xref: /freebsd/sys/netinet6/scope6_var.h (revision 2ff63af9b88c7413b7d71715b5532625752a248e)
1caf43b02SWarner Losh /*-
251369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
351369649SPedro F. Giffuni  *
4686cdd19SJun-ichiro itojun Hagino  * Copyright (C) 2000 WIDE Project.
5686cdd19SJun-ichiro itojun Hagino  * All rights reserved.
6686cdd19SJun-ichiro itojun Hagino  *
7686cdd19SJun-ichiro itojun Hagino  * Redistribution and use in source and binary forms, with or without
8686cdd19SJun-ichiro itojun Hagino  * modification, are permitted provided that the following conditions
9686cdd19SJun-ichiro itojun Hagino  * are met:
10686cdd19SJun-ichiro itojun Hagino  * 1. Redistributions of source code must retain the above copyright
11686cdd19SJun-ichiro itojun Hagino  *    notice, this list of conditions and the following disclaimer.
12686cdd19SJun-ichiro itojun Hagino  * 2. Redistributions in binary form must reproduce the above copyright
13686cdd19SJun-ichiro itojun Hagino  *    notice, this list of conditions and the following disclaimer in the
14686cdd19SJun-ichiro itojun Hagino  *    documentation and/or other materials provided with the distribution.
15686cdd19SJun-ichiro itojun Hagino  * 3. Neither the name of the project nor the names of its contributors
16686cdd19SJun-ichiro itojun Hagino  *    may be used to endorse or promote products derived from this software
17686cdd19SJun-ichiro itojun Hagino  *    without specific prior written permission.
18686cdd19SJun-ichiro itojun Hagino  *
19686cdd19SJun-ichiro itojun Hagino  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20686cdd19SJun-ichiro itojun Hagino  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21686cdd19SJun-ichiro itojun Hagino  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22686cdd19SJun-ichiro itojun Hagino  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23686cdd19SJun-ichiro itojun Hagino  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24686cdd19SJun-ichiro itojun Hagino  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25686cdd19SJun-ichiro itojun Hagino  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26686cdd19SJun-ichiro itojun Hagino  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27686cdd19SJun-ichiro itojun Hagino  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28686cdd19SJun-ichiro itojun Hagino  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29686cdd19SJun-ichiro itojun Hagino  * SUCH DAMAGE.
30b48287a3SDavid E. O'Brien  *
31b48287a3SDavid E. O'Brien  *	$KAME: scope6_var.h,v 1.4 2000/05/18 15:03:27 jinmei Exp $
32686cdd19SJun-ichiro itojun Hagino  */
33686cdd19SJun-ichiro itojun Hagino 
34686cdd19SJun-ichiro itojun Hagino #ifndef _NETINET6_SCOPE6_VAR_H_
35686cdd19SJun-ichiro itojun Hagino #define _NETINET6_SCOPE6_VAR_H_
36686cdd19SJun-ichiro itojun Hagino 
37686cdd19SJun-ichiro itojun Hagino #ifdef _KERNEL
380bebb544SHiroki Sato #include <net/vnet.h>
390bebb544SHiroki Sato 
4041874e85SAndrey V. Elsukov #define	IPV6_ADDR_SCOPES_COUNT	16
4131b1bfe1SHajimu UMEMOTO struct scope6_id {
4231b1bfe1SHajimu UMEMOTO 	/*
4331b1bfe1SHajimu UMEMOTO 	 * 16 is correspondent to 4bit multicast scope field.
4431b1bfe1SHajimu UMEMOTO 	 * i.e. from node-local to global with some reserved/unassigned types.
4531b1bfe1SHajimu UMEMOTO 	 */
4641874e85SAndrey V. Elsukov 	uint32_t s6id_list[IPV6_ADDR_SCOPES_COUNT];
4731b1bfe1SHajimu UMEMOTO };
4831b1bfe1SHajimu UMEMOTO 
496f56329aSXin LI void	scope6_init(void);
506f56329aSXin LI struct scope6_id *scope6_ifattach(struct ifnet *);
516f56329aSXin LI void	scope6_ifdetach(struct scope6_id *);
525fc26322SMark Johnston int	scope6_ioctl(u_long cmd, caddr_t data, struct ifnet *);
536f56329aSXin LI void	scope6_setdefault(struct ifnet *);
546f56329aSXin LI int	scope6_get_default(struct scope6_id *);
556f56329aSXin LI u_int32_t scope6_addr2default(struct in6_addr *);
566f56329aSXin LI int	sa6_embedscope(struct sockaddr_in6 *, int);
576f56329aSXin LI int	sa6_recoverscope(struct sockaddr_in6 *);
5841874e85SAndrey V. Elsukov int	sa6_checkzone(struct sockaddr_in6 *);
59002c2439SAndrey V. Elsukov int	sa6_checkzone_ifp(struct ifnet *, struct sockaddr_in6 *);
606f56329aSXin LI int	in6_setscope(struct in6_addr *, struct ifnet *, u_int32_t *);
616f56329aSXin LI int	in6_clearscope(struct in6_addr *);
6273ae9758SAndrey V. Elsukov uint16_t in6_getscope(const struct in6_addr *);
6341874e85SAndrey V. Elsukov uint32_t in6_getscopezone(const struct ifnet *, int);
6465ff3638SAlexander V. Chernikov void	in6_splitscope(const struct in6_addr *, struct in6_addr *, uint32_t *);
6541874e85SAndrey V. Elsukov struct ifnet* in6_getlinkifnet(uint32_t);
66*53a4886dSAlexander V. Chernikov uint32_t in6_get_unicast_scopeid(const struct in6_addr *, const struct ifnet *);
67*53a4886dSAlexander V. Chernikov void	in6_set_unicast_scopeid(struct in6_addr *, uint32_t);
68686cdd19SJun-ichiro itojun Hagino #endif /* _KERNEL */
69686cdd19SJun-ichiro itojun Hagino 
70686cdd19SJun-ichiro itojun Hagino #endif /* _NETINET6_SCOPE6_VAR_H_ */
71