1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _SCTP_ADDR_H 28*0Sstevel@tonic-gate #define _SCTP_ADDR_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #include <sys/list.h> 33*0Sstevel@tonic-gate #include <sys/zone.h> 34*0Sstevel@tonic-gate #include <inet/ip.h> 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #ifdef __cplusplus 37*0Sstevel@tonic-gate extern "C" { 38*0Sstevel@tonic-gate #endif 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate /* 41*0Sstevel@tonic-gate * SCTP IPIF structure - only relevant fields from ipif_t retained 42*0Sstevel@tonic-gate * 43*0Sstevel@tonic-gate * There is a global array, sctp_g_ipifs, to store all addresses of 44*0Sstevel@tonic-gate * the system. Each element of the global array is a list of 45*0Sstevel@tonic-gate * sctp_ipif_t. 46*0Sstevel@tonic-gate * 47*0Sstevel@tonic-gate * This structure is also shared by all SCTP PCBs. Each SCTP PCB has 48*0Sstevel@tonic-gate * an array of source addresses. Each element of that array is a list 49*0Sstevel@tonic-gate * of sctp_saddr_ipif_t. And each sctp_saddr_ipif_t has a pointer 50*0Sstevel@tonic-gate * to a sctp_ipif_t. The reason for sctp_saddr_ipif_t is that each 51*0Sstevel@tonic-gate * SCTP PCB may do different things to a source address. This info 52*0Sstevel@tonic-gate * is stored locally in sctp_saddr_ipif_t. 53*0Sstevel@tonic-gate * 54*0Sstevel@tonic-gate */ 55*0Sstevel@tonic-gate typedef struct sctp_ipif_s { 56*0Sstevel@tonic-gate list_node_t sctp_ipifs; /* Used by the global list */ 57*0Sstevel@tonic-gate struct sctp_ill_s *sctp_ipif_ill; 58*0Sstevel@tonic-gate uint_t sctp_ipif_mtu; 59*0Sstevel@tonic-gate uint_t sctp_ipif_id; 60*0Sstevel@tonic-gate in6_addr_t sctp_ipif_saddr; 61*0Sstevel@tonic-gate int sctp_ipif_state; 62*0Sstevel@tonic-gate uint32_t sctp_ipif_refcnt; 63*0Sstevel@tonic-gate zoneid_t sctp_ipif_zoneid; 64*0Sstevel@tonic-gate krwlock_t sctp_ipif_lock; 65*0Sstevel@tonic-gate boolean_t sctp_ipif_isv6; 66*0Sstevel@tonic-gate } sctp_ipif_t; 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate /* ipif_state */ 69*0Sstevel@tonic-gate #define SCTP_IPIFS_CONDEMNED -1 70*0Sstevel@tonic-gate #define SCTP_IPIFS_INVALID -2 71*0Sstevel@tonic-gate #define SCTP_IPIFS_DOWN 1 72*0Sstevel@tonic-gate #define SCTP_IPIFS_UP 2 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate /* SCTP source address structure for individual SCTP PCB */ 75*0Sstevel@tonic-gate typedef struct sctp_saddrs_ipif_s { 76*0Sstevel@tonic-gate list_node_t saddr_ipif; 77*0Sstevel@tonic-gate sctp_ipif_t *saddr_ipifp; 78*0Sstevel@tonic-gate uint32_t saddr_ipif_dontsrc : 1, 79*0Sstevel@tonic-gate saddr_ipif_delete_pending : 1, 80*0Sstevel@tonic-gate pad : 30; 81*0Sstevel@tonic-gate } sctp_saddr_ipif_t; 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate /* SCTP ILL structure - only relevant fields from ill_t retained */ 84*0Sstevel@tonic-gate typedef struct sctp_ill_s { 85*0Sstevel@tonic-gate list_node_t sctp_ills; 86*0Sstevel@tonic-gate int sctp_ill_name_length; 87*0Sstevel@tonic-gate char *sctp_ill_name; 88*0Sstevel@tonic-gate int sctp_ill_state; 89*0Sstevel@tonic-gate uint32_t sctp_ill_ipifcnt; 90*0Sstevel@tonic-gate uint_t sctp_ill_index; 91*0Sstevel@tonic-gate uint64_t sctp_ill_flags; 92*0Sstevel@tonic-gate } sctp_ill_t; 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gate /* ill_state */ 95*0Sstevel@tonic-gate #define SCTP_ILLS_CONDEMNED -1 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate #define SCTP_ILL_HASH 16 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gate typedef struct sctp_ill_hash_s { 100*0Sstevel@tonic-gate list_t sctp_ill_list; 101*0Sstevel@tonic-gate int ill_count; 102*0Sstevel@tonic-gate } sctp_ill_hash_t; 103*0Sstevel@tonic-gate 104*0Sstevel@tonic-gate /* Global list of SCTP ILLs */ 105*0Sstevel@tonic-gate extern sctp_ill_hash_t sctp_g_ills[SCTP_ILL_HASH]; 106*0Sstevel@tonic-gate krwlock_t sctp_g_ills_lock; 107*0Sstevel@tonic-gate extern uint32_t sctp_ills_count; 108*0Sstevel@tonic-gate extern uint32_t sctp_ills_min_mtu; 109*0Sstevel@tonic-gate 110*0Sstevel@tonic-gate /* Global list of SCTP ipifs */ 111*0Sstevel@tonic-gate extern sctp_ipif_hash_t sctp_g_ipifs[SCTP_IPIF_HASH]; 112*0Sstevel@tonic-gate extern uint32_t sctp_g_ipifs_count; 113*0Sstevel@tonic-gate krwlock_t sctp_g_ipifs_lock; 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate #define SCTP_IPIF_REFHOLD(sctp_ipif) { \ 117*0Sstevel@tonic-gate atomic_add_32(&(sctp_ipif)->sctp_ipif_refcnt, 1); \ 118*0Sstevel@tonic-gate ASSERT((sctp_ipif)->sctp_ipif_refcnt != 0); \ 119*0Sstevel@tonic-gate } 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gate #define SCTP_IPIF_REFRELE(sctp_ipif) { \ 122*0Sstevel@tonic-gate ASSERT((sctp_ipif)->sctp_ipif_refcnt != 0); \ 123*0Sstevel@tonic-gate if (atomic_add_32_nv(&(sctp_ipif)->sctp_ipif_refcnt, -1) == 0) \ 124*0Sstevel@tonic-gate sctp_ipif_inactive(sctp_ipif); \ 125*0Sstevel@tonic-gate } 126*0Sstevel@tonic-gate 127*0Sstevel@tonic-gate /* Address set comparison results. */ 128*0Sstevel@tonic-gate #define SCTP_ADDR_EQUAL 1 129*0Sstevel@tonic-gate #define SCTP_ADDR_SUBSET 2 130*0Sstevel@tonic-gate #define SCTP_ADDR_OVERLAP 3 131*0Sstevel@tonic-gate #define SCTP_ADDR_DISJOINT 4 132*0Sstevel@tonic-gate 133*0Sstevel@tonic-gate extern void sctp_update_ill(ill_t *, int); 134*0Sstevel@tonic-gate extern void sctp_update_ipif(ipif_t *, int); 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gate extern int sctp_valid_addr_list(sctp_t *, const void *, uint32_t); 137*0Sstevel@tonic-gate extern int sctp_dup_saddrs(sctp_t *, sctp_t *, int); 138*0Sstevel@tonic-gate extern int sctp_compare_saddrs(sctp_t *, sctp_t *); 139*0Sstevel@tonic-gate extern sctp_saddr_ipif_t *sctp_saddr_lookup(sctp_t *, in6_addr_t *); 140*0Sstevel@tonic-gate extern in6_addr_t sctp_get_valid_addr(sctp_t *, boolean_t isv6); 141*0Sstevel@tonic-gate extern size_t sctp_addr_len(sctp_t *, int); 142*0Sstevel@tonic-gate extern size_t sctp_addr_val(sctp_t *, int, uchar_t *); 143*0Sstevel@tonic-gate extern void sctp_del_saddr_list(sctp_t *, const void *, int, 144*0Sstevel@tonic-gate boolean_t); 145*0Sstevel@tonic-gate extern void sctp_del_saddr(sctp_t *, sctp_saddr_ipif_t *); 146*0Sstevel@tonic-gate extern void sctp_free_saddrs(sctp_t *); 147*0Sstevel@tonic-gate extern void sctp_saddr_init(); 148*0Sstevel@tonic-gate extern void sctp_saddr_fini(); 149*0Sstevel@tonic-gate extern sctp_saddr_ipif_t *sctp_ipif_lookup(sctp_t *, uint_t); 150*0Sstevel@tonic-gate extern int sctp_getmyaddrs(void *, void *, int *); 151*0Sstevel@tonic-gate 152*0Sstevel@tonic-gate #ifdef __cplusplus 153*0Sstevel@tonic-gate } 154*0Sstevel@tonic-gate #endif 155*0Sstevel@tonic-gate 156*0Sstevel@tonic-gate #endif /* _SCTP_ADDR_H */ 157