17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*f4b3ec61Sdh155122 * Common Development and Distribution License (the "License"). 6*f4b3ec61Sdh155122 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*f4b3ec61Sdh155122 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _INET_IP6_ASP_H 277c478bd9Sstevel@tonic-gate #define _INET_IP6_ASP_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #include <netinet/in.h> 367c478bd9Sstevel@tonic-gate #include <sys/types.h> 377c478bd9Sstevel@tonic-gate #include <inet/ip6.h> 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate /* 407c478bd9Sstevel@tonic-gate * The maximum size of the label, including NULL bytes following the 417c478bd9Sstevel@tonic-gate * label string. The implementation assumes that this value is 16. 427c478bd9Sstevel@tonic-gate */ 437c478bd9Sstevel@tonic-gate #define IP6_ASP_MAXLABELSIZE 16 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate typedef struct ip6_asp { 467c478bd9Sstevel@tonic-gate in6_addr_t ip6_asp_prefix; 477c478bd9Sstevel@tonic-gate in6_addr_t ip6_asp_mask; 487c478bd9Sstevel@tonic-gate /* 497c478bd9Sstevel@tonic-gate * ip6_asp_label must be on an 8 byte boundary because we cast 507c478bd9Sstevel@tonic-gate * them as (int64_t *) in order to compare them as two 64 bit 517c478bd9Sstevel@tonic-gate * integers rather than sixteen characters. 527c478bd9Sstevel@tonic-gate */ 537c478bd9Sstevel@tonic-gate union { 547c478bd9Sstevel@tonic-gate char iau_label_c[IP6_ASP_MAXLABELSIZE]; 557c478bd9Sstevel@tonic-gate int64_t iau_label_i[IP6_ASP_MAXLABELSIZE / sizeof (int64_t)]; 567c478bd9Sstevel@tonic-gate } ip6_asp_u; 577c478bd9Sstevel@tonic-gate uint32_t ip6_asp_precedence; 587c478bd9Sstevel@tonic-gate } ip6_asp_t; 597c478bd9Sstevel@tonic-gate #define ip6_asp_label ip6_asp_u.iau_label_c 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) && _LONG_LONG_ALIGNMENT_32 == 4 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate /* 647c478bd9Sstevel@tonic-gate * The ip6_asp structure as seen by a 64-bit kernel looking 657c478bd9Sstevel@tonic-gate * at a 32-bit process, where the 32-bit process uses 32-bit 667c478bd9Sstevel@tonic-gate * alignment for 64-bit quantities. Like i386 does :-) 677c478bd9Sstevel@tonic-gate */ 687c478bd9Sstevel@tonic-gate typedef struct ip6_asp32 { 697c478bd9Sstevel@tonic-gate in6_addr_t ip6_asp_prefix; 707c478bd9Sstevel@tonic-gate in6_addr_t ip6_asp_mask; 717c478bd9Sstevel@tonic-gate union { 727c478bd9Sstevel@tonic-gate char iau_label_c[IP6_ASP_MAXLABELSIZE]; 737c478bd9Sstevel@tonic-gate int32_t iau_label_i[IP6_ASP_MAXLABELSIZE / sizeof (int32_t)]; 747c478bd9Sstevel@tonic-gate } ip6_asp_u; 757c478bd9Sstevel@tonic-gate uint32_t ip6_asp_precedence; 767c478bd9Sstevel@tonic-gate } ip6_asp32_t; 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 && _LONG_LONG_ALIGNMENT_32 == 4 */ 797c478bd9Sstevel@tonic-gate 80*f4b3ec61Sdh155122 #define IP6_ASP_TABLE_REFHOLD(ipst) { \ 81*f4b3ec61Sdh155122 ipst->ips_ip6_asp_refcnt++; \ 82*f4b3ec61Sdh155122 ASSERT(ipst->ips_ip6_asp_refcnt != 0); \ 837c478bd9Sstevel@tonic-gate } 847c478bd9Sstevel@tonic-gate 85*f4b3ec61Sdh155122 #define IP6_ASP_TABLE_REFRELE(ipst) { \ 86*f4b3ec61Sdh155122 mutex_enter(&ipst->ips_ip6_asp_lock); \ 87*f4b3ec61Sdh155122 ASSERT(ipst->ips_ip6_asp_refcnt != 0); \ 88*f4b3ec61Sdh155122 if (--ipst->ips_ip6_asp_refcnt == 0) { \ 89*f4b3ec61Sdh155122 mutex_exit(&ipst->ips_ip6_asp_lock); \ 90*f4b3ec61Sdh155122 ip6_asp_check_for_updates(ipst); \ 917c478bd9Sstevel@tonic-gate } else { \ 92*f4b3ec61Sdh155122 mutex_exit(&ipst->ips_ip6_asp_lock); \ 937c478bd9Sstevel@tonic-gate } \ 947c478bd9Sstevel@tonic-gate } 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate /* 977c478bd9Sstevel@tonic-gate * Structure used in the SIOCGDSTINFO request. 987c478bd9Sstevel@tonic-gate * Used to retrieve information about the given destination 997c478bd9Sstevel@tonic-gate * address, to be used by the caller to sort a list of 1007c478bd9Sstevel@tonic-gate * potential destination addresses. 1017c478bd9Sstevel@tonic-gate */ 1027c478bd9Sstevel@tonic-gate struct dstinforeq { 1037c478bd9Sstevel@tonic-gate in6_addr_t dir_daddr; /* destination address */ 1047c478bd9Sstevel@tonic-gate in6_addr_t dir_saddr; /* source address for daddr */ 1057c478bd9Sstevel@tonic-gate in6addr_scope_t dir_dscope; /* destination scope */ 1067c478bd9Sstevel@tonic-gate in6addr_scope_t dir_sscope; /* source scope */ 1077c478bd9Sstevel@tonic-gate t_uscalar_t dir_dmactype; /* dl_mac_type of output inf */ 1087c478bd9Sstevel@tonic-gate uint32_t dir_precedence; /* destination precedence */ 1097c478bd9Sstevel@tonic-gate uint8_t dir_dreachable : 1, /* is destination reachable? */ 1107c478bd9Sstevel@tonic-gate dir_sdeprecated : 1, /* is source deprecated? */ 1117c478bd9Sstevel@tonic-gate dir_labelmatch: 1, /* src and dst labels match? */ 1127c478bd9Sstevel@tonic-gate dir_padbits : 5; 1137c478bd9Sstevel@tonic-gate }; 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate #ifdef _KERNEL 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate typedef void (*aspfunc_t)(ipsq_t *, queue_t *, mblk_t *, void *); 1187c478bd9Sstevel@tonic-gate 119*f4b3ec61Sdh155122 extern void ip6_asp_free(ip_stack_t *); 120*f4b3ec61Sdh155122 extern void ip6_asp_init(ip_stack_t *); 121*f4b3ec61Sdh155122 extern boolean_t ip6_asp_can_lookup(ip_stack_t *); 122*f4b3ec61Sdh155122 extern void ip6_asp_table_refrele(ip_stack_t *); 123*f4b3ec61Sdh155122 extern char *ip6_asp_lookup(const in6_addr_t *, uint32_t *, ip_stack_t *); 124*f4b3ec61Sdh155122 extern void ip6_asp_replace(mblk_t *mp, ip6_asp_t *, size_t, boolean_t, 125*f4b3ec61Sdh155122 ip_stack_t *, model_t); 126*f4b3ec61Sdh155122 extern int ip6_asp_get(ip6_asp_t *, size_t, ip_stack_t *); 1277c478bd9Sstevel@tonic-gate extern boolean_t ip6_asp_labelcmp(const char *, const char *); 1287c478bd9Sstevel@tonic-gate extern void ip6_asp_pending_op(queue_t *, mblk_t *, aspfunc_t); 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1337c478bd9Sstevel@tonic-gate } 1347c478bd9Sstevel@tonic-gate #endif 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate #endif /* _INET_IP6_ASP_H */ 137