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