1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _INET_IP6_ASP_H 27 #define _INET_IP6_ASP_H 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #include <netinet/in.h> 34 #include <sys/types.h> 35 #include <inet/ip6.h> 36 37 /* 38 * The maximum size of the label, including NULL bytes following the 39 * label string. The implementation assumes that this value is 16. 40 */ 41 #define IP6_ASP_MAXLABELSIZE 16 42 43 typedef struct ip6_asp { 44 in6_addr_t ip6_asp_prefix; 45 in6_addr_t ip6_asp_mask; 46 /* 47 * ip6_asp_label must be on an 8 byte boundary because we cast 48 * them as (int64_t *) in order to compare them as two 64 bit 49 * integers rather than sixteen characters. 50 */ 51 union { 52 char iau_label_c[IP6_ASP_MAXLABELSIZE]; 53 int64_t iau_label_i[IP6_ASP_MAXLABELSIZE / sizeof (int64_t)]; 54 } ip6_asp_u; 55 uint32_t ip6_asp_precedence; 56 } ip6_asp_t; 57 #define ip6_asp_label ip6_asp_u.iau_label_c 58 59 #if defined(_SYSCALL32) && _LONG_LONG_ALIGNMENT_32 == 4 60 61 /* 62 * The ip6_asp structure as seen by a 64-bit kernel looking 63 * at a 32-bit process, where the 32-bit process uses 32-bit 64 * alignment for 64-bit quantities. Like i386 does :-) 65 */ 66 typedef struct ip6_asp32 { 67 in6_addr_t ip6_asp_prefix; 68 in6_addr_t ip6_asp_mask; 69 union { 70 char iau_label_c[IP6_ASP_MAXLABELSIZE]; 71 int32_t iau_label_i[IP6_ASP_MAXLABELSIZE / sizeof (int32_t)]; 72 } ip6_asp_u; 73 uint32_t ip6_asp_precedence; 74 } ip6_asp32_t; 75 76 #endif /* _SYSCALL32 && _LONG_LONG_ALIGNMENT_32 == 4 */ 77 78 #define IP6_ASP_TABLE_REFHOLD(ipst) { \ 79 ipst->ips_ip6_asp_refcnt++; \ 80 ASSERT(ipst->ips_ip6_asp_refcnt != 0); \ 81 } 82 83 #define IP6_ASP_TABLE_REFRELE(ipst) { \ 84 mutex_enter(&ipst->ips_ip6_asp_lock); \ 85 ASSERT(ipst->ips_ip6_asp_refcnt != 0); \ 86 if (--ipst->ips_ip6_asp_refcnt == 0) { \ 87 mutex_exit(&ipst->ips_ip6_asp_lock); \ 88 ip6_asp_check_for_updates(ipst); \ 89 } else { \ 90 mutex_exit(&ipst->ips_ip6_asp_lock); \ 91 } \ 92 } 93 94 /* 95 * Structure used in the SIOCGDSTINFO request. 96 * Used to retrieve information about the given destination 97 * address, to be used by the caller to sort a list of 98 * potential destination addresses. 99 */ 100 struct dstinforeq { 101 in6_addr_t dir_daddr; /* destination address */ 102 in6_addr_t dir_saddr; /* source address for daddr */ 103 in6addr_scope_t dir_dscope; /* destination scope */ 104 in6addr_scope_t dir_sscope; /* source scope */ 105 t_uscalar_t dir_dmactype; /* dl_mac_type of output inf */ 106 uint32_t dir_precedence; /* destination precedence */ 107 uint8_t dir_dreachable : 1, /* is destination reachable? */ 108 dir_sdeprecated : 1, /* is source deprecated? */ 109 dir_labelmatch: 1, /* src and dst labels match? */ 110 dir_padbits : 5; 111 }; 112 113 #ifdef _KERNEL 114 115 typedef void (*aspfunc_t)(ipsq_t *, queue_t *, mblk_t *, void *); 116 117 extern void ip6_asp_free(ip_stack_t *); 118 extern void ip6_asp_init(ip_stack_t *); 119 extern boolean_t ip6_asp_can_lookup(ip_stack_t *); 120 extern void ip6_asp_table_refrele(ip_stack_t *); 121 extern char *ip6_asp_lookup(const in6_addr_t *, uint32_t *, ip_stack_t *); 122 extern void ip6_asp_replace(mblk_t *mp, ip6_asp_t *, size_t, boolean_t, 123 ip_stack_t *, model_t); 124 extern int ip6_asp_get(ip6_asp_t *, size_t, ip_stack_t *); 125 extern boolean_t ip6_asp_labelcmp(const char *, const char *); 126 extern void ip6_asp_pending_op(queue_t *, mblk_t *, aspfunc_t); 127 128 #endif /* _KERNEL */ 129 130 #ifdef __cplusplus 131 } 132 #endif 133 134 #endif /* _INET_IP6_ASP_H */ 135