1 1.1 rpaulo /* $FreeBSD: src/sys/netinet6/scope6_var.h,v 1.4 2005/01/07 02:30:35 imp Exp $ */ 2 1.1 rpaulo /* $KAME: scope6_var.h,v 1.4 2000/05/18 15:03:27 jinmei Exp $ */ 3 1.1 rpaulo 4 1.1 rpaulo /*- 5 1.1 rpaulo * Copyright (C) 2000 WIDE Project. 6 1.1 rpaulo * All rights reserved. 7 1.1 rpaulo * 8 1.1 rpaulo * Redistribution and use in source and binary forms, with or without 9 1.1 rpaulo * modification, are permitted provided that the following conditions 10 1.1 rpaulo * are met: 11 1.1 rpaulo * 1. Redistributions of source code must retain the above copyright 12 1.1 rpaulo * notice, this list of conditions and the following disclaimer. 13 1.1 rpaulo * 2. Redistributions in binary form must reproduce the above copyright 14 1.1 rpaulo * notice, this list of conditions and the following disclaimer in the 15 1.1 rpaulo * documentation and/or other materials provided with the distribution. 16 1.1 rpaulo * 3. Neither the name of the project nor the names of its contributors 17 1.1 rpaulo * may be used to endorse or promote products derived from this software 18 1.1 rpaulo * without specific prior written permission. 19 1.1 rpaulo * 20 1.1 rpaulo * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 21 1.1 rpaulo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 1.1 rpaulo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 1.1 rpaulo * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 24 1.1 rpaulo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 1.1 rpaulo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 1.1 rpaulo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 1.1 rpaulo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 1.1 rpaulo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 1.1 rpaulo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 1.1 rpaulo * SUCH DAMAGE. 31 1.1 rpaulo */ 32 1.1 rpaulo 33 1.1 rpaulo #ifndef _NETINET6_SCOPE6_VAR_H_ 34 1.1 rpaulo #define _NETINET6_SCOPE6_VAR_H_ 35 1.1 rpaulo 36 1.1 rpaulo #ifdef _KERNEL 37 1.4 christos 38 1.4 christos /* 39 1.4 christos * IPv6 Core Protocols Implementation 40 1.4 christos * By Qing Li, Tatuya Jinmei, Keiichi Shima 41 1.4 christos * 42 1.4 christos * Some information from Chapter 2.9 (Handling Scope Zones) Figure 2.12, p.56 43 1.4 christos * 44 1.4 christos * User Space 45 1.4 christos * 46 1.4 christos * Normal App Statistics/Mgmt App Routing App 47 1.4 christos * /---------------\ /-------------------\ /------------------\ 48 1.4 christos * | sin6_scope_id | | embedded form | | embedded form | 49 1.4 christos * | only | | (+ sin6_scope_id) | | or sin6_scope_id | 50 1.4 christos * \---------------/ \-------------------/ \------------------/ 51 1.4 christos * ^ ^ ^ | 52 1.4 christos * | | | | 53 1.4 christos * no conversion parse parse embed 54 1.6 andvar * | embedded embedded ID 55 1.4 christos * | ID ID (if necessary) 56 1.4 christos * | | | | 57 1.4 christos * v | | v 58 1.4 christos * /---------------\ /-------------------\ /------------------\ 59 1.4 christos * ------ | AF_INET6 | | kvm | | Routing | 60 1.4 christos * Kernel | socket | | interface | | socket | 61 1.4 christos * \---------------/ \-------------------/ \------------------/ 62 1.4 christos * ^ | ^ ^ 63 1.4 christos * | | | | 64 1.4 christos * clear embed no conversion | 65 1.4 christos * embedded ID | no conversion 66 1.4 christos * ID | ---------------------------------- | 67 1.4 christos * | V | | v 68 1.4 christos * /---------------\ /--------------------\ 69 1.4 christos * | |---- clear sin_scope_id --->| embedded form only | 70 1.4 christos * | |<--- set sin_scope_id ----| | 71 1.4 christos * | | \--------------------/ 72 1.4 christos * | embedded form | ^ 73 1.4 christos * | + | | 74 1.4 christos * | sin_scope_id | no conversion 75 1.4 christos * | | | 76 1.4 christos * | | V 77 1.4 christos * | | /--------------------\ 78 1.4 christos * | |---- clear sin_scope_id --->| embedded form only | 79 1.4 christos * | |<--- set sin_scope_id ----| | 80 1.4 christos * \---------------/ \--------------------/ 81 1.4 christos * -------- ^ | 82 1.4 christos * Physical | clear 83 1.4 christos * Network embed ID, embedded 84 1.4 christos * set ID 85 1.4 christos * sin_scope_id | 86 1.4 christos * | v 87 1.4 christos * /---------------\ 88 1.4 christos * | 128-bit IPv6 | 89 1.4 christos * | address | 90 1.4 christos * | (ID not | 91 1.4 christos * | included) | 92 1.4 christos * \---------------/ 93 1.4 christos */ 94 1.4 christos 95 1.4 christos 96 1.1 rpaulo struct scope6_id { 97 1.1 rpaulo /* 98 1.1 rpaulo * 16 is correspondent to 4bit multicast scope field. 99 1.1 rpaulo * i.e. from interface-local to global with some 100 1.1 rpaulo * reserved/unassigned types. 101 1.1 rpaulo */ 102 1.1 rpaulo uint32_t s6id_list[16]; 103 1.1 rpaulo }; 104 1.1 rpaulo 105 1.1 rpaulo void scope6_init(void); 106 1.1 rpaulo struct scope6_id *scope6_ifattach(struct ifnet *); 107 1.1 rpaulo void scope6_ifdetach(struct scope6_id *); 108 1.1 rpaulo uint32_t scope6_in6_addrscope(struct in6_addr *); 109 1.2 dyoung uint32_t scope6_addr2default(const struct in6_addr *); 110 1.1 rpaulo int sa6_embedscope(struct sockaddr_in6 *, int); 111 1.1 rpaulo int sa6_recoverscope(struct sockaddr_in6 *); 112 1.2 dyoung int in6_setzoneid(struct in6_addr *, uint32_t); 113 1.2 dyoung int in6_setscope(struct in6_addr *, const struct ifnet *, u_int32_t *); 114 1.1 rpaulo int in6_clearscope(struct in6_addr *); 115 1.3 christos const char *in6_getscopename(const struct in6_addr *); 116 1.1 rpaulo #endif /* _KERNEL */ 117 1.1 rpaulo 118 1.1 rpaulo #endif /* _NETINET6_SCOPE6_VAR_H_ */ 119