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