sctp_addr.h revision 11042:2d6e217af1b4
1326938Sdim/* 2326938Sdim * CDDL HEADER START 3353358Sdim * 4353358Sdim * The contents of this file are subject to the terms of the 5353358Sdim * Common Development and Distribution License (the "License"). 6326938Sdim * You may not use this file except in compliance with the License. 7326938Sdim * 8326938Sdim * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9326938Sdim * or http://www.opensolaris.org/os/licensing. 10341825Sdim * See the License for the specific language governing permissions 11326938Sdim * and limitations under the License. 12326938Sdim * 13326938Sdim * When distributing Covered Code, include this CDDL HEADER in each 14326938Sdim * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15326938Sdim * If applicable, add the following below this CDDL HEADER, with the 16326938Sdim * fields enclosed by brackets "[]" replaced with your own identifying 17326938Sdim * information: Portions Copyright [yyyy] [name of copyright owner] 18326938Sdim * 19326938Sdim * CDDL HEADER END 20326938Sdim */ 21326938Sdim/* 22326938Sdim * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23326938Sdim * Use is subject to license terms. 24326938Sdim */ 25326938Sdim 26353358Sdim#ifndef _SCTP_ADDR_H 27353358Sdim#define _SCTP_ADDR_H 28353358Sdim 29353358Sdim#include <sys/list.h> 30353358Sdim#include <sys/zone.h> 31353358Sdim#include <inet/ip.h> 32353358Sdim 33353358Sdim#ifdef __cplusplus 34353358Sdimextern "C" { 35353358Sdim#endif 36326938Sdim 37326938Sdim/* 38326938Sdim * SCTP IPIF structure - only relevant fields from ipif_t retained 39 * 40 * There is a global array, sctp_g_ipifs, to store all addresses of 41 * the system. Each element of the global array is a list of 42 * sctp_ipif_t. 43 * 44 * This structure is also shared by all SCTP PCBs. Each SCTP PCB has 45 * an array of source addresses. Each element of that array is a list 46 * of sctp_saddr_ipif_t. And each sctp_saddr_ipif_t has a pointer 47 * to a sctp_ipif_t. The reason for sctp_saddr_ipif_t is that each 48 * SCTP PCB may do different things to a source address. This info 49 * is stored locally in sctp_saddr_ipif_t. 50 * 51 */ 52typedef struct sctp_ipif_s { 53 list_node_t sctp_ipifs; /* Used by the global list */ 54 struct sctp_ill_s *sctp_ipif_ill; 55 uint_t sctp_ipif_id; 56 in6_addr_t sctp_ipif_saddr; 57 int sctp_ipif_state; 58 uint32_t sctp_ipif_refcnt; 59 zoneid_t sctp_ipif_zoneid; 60 krwlock_t sctp_ipif_lock; 61 boolean_t sctp_ipif_isv6; 62 uint64_t sctp_ipif_flags; 63} sctp_ipif_t; 64 65/* ipif_state */ 66#define SCTP_IPIFS_CONDEMNED -1 67#define SCTP_IPIFS_INVALID -2 68#define SCTP_IPIFS_DOWN 1 69#define SCTP_IPIFS_UP 2 70 71/* 72 * Individual SCTP source address structure. 73 * saddr_ipifp is the actual pointer to the ipif/address. 74 * saddr_ipif_dontsrc is used to mark an address as currently unusable. This 75 * would be the case when we have added/deleted an address using sctp_bindx() 76 * and are waiting for the ASCONF ACK from the peer to confirm the addition/ 77 * deletion. Additionally, saddr_ipif_delete_pending is used to specifically 78 * indicate that an address delete operation is in progress. 79 */ 80typedef struct sctp_saddrs_ipif_s { 81 list_node_t saddr_ipif; 82 sctp_ipif_t *saddr_ipifp; 83 uint32_t saddr_ipif_dontsrc : 1, 84 saddr_ipif_delete_pending : 1, 85 saddr_ipif_unconfirmed : 1, 86 pad : 29; 87} sctp_saddr_ipif_t; 88 89#define SCTP_DONT_SRC(sctp_saddr) \ 90 ((sctp_saddr)->saddr_ipif_dontsrc || \ 91 (sctp_saddr)->saddr_ipif_unconfirmed) 92 93 94/* 95 * SCTP ILL structure - only relevant fields from ill_t retained. 96 * This pretty much reflects the ILL<->IPIF relation that IP maintains. 97 * At present the only state an ILL can be in is CONDEMNED or not. 98 * sctp_ill_ipifcnt gives the number of IPIFs for this ILL, 99 * sctp_ill_index is phyint_ifindex in the actual ILL structure (in IP) 100 * and sctp_ill_flags is ill_flags from the ILL structure. 101 * 102 * The comment below (and for other netstack_t references) refers 103 * to the fact that we only do netstack_hold in particular cases, 104 * such as the references from open streams (ill_t and conn_t's 105 * pointers). Internally within IP we rely on IP's ability to cleanup e.g. 106 * ire_t's when an ill goes away. 107 */ 108typedef struct sctp_ill_s { 109 list_node_t sctp_ills; 110 int sctp_ill_name_length; 111 char *sctp_ill_name; 112 int sctp_ill_state; 113 uint32_t sctp_ill_ipifcnt; 114 uint_t sctp_ill_index; 115 uint64_t sctp_ill_flags; 116 boolean_t sctp_ill_isv6; 117 netstack_t *sctp_ill_netstack; /* Does not have a netstack_hold */ 118} sctp_ill_t; 119 120/* ill_state */ 121#define SCTP_ILLS_CONDEMNED -1 122 123#define SCTP_ILL_HASH 16 124 125typedef struct sctp_ill_hash_s { 126 list_t sctp_ill_list; 127 int ill_count; 128} sctp_ill_hash_t; 129 130 131#define SCTP_IPIF_REFHOLD(sctp_ipif) { \ 132 atomic_add_32(&(sctp_ipif)->sctp_ipif_refcnt, 1); \ 133} 134 135#define SCTP_IPIF_REFRELE(sctp_ipif) { \ 136 rw_enter(&(sctp_ipif)->sctp_ipif_lock, RW_WRITER); \ 137 ASSERT((sctp_ipif)->sctp_ipif_refcnt != 0); \ 138 if (--(sctp_ipif)->sctp_ipif_refcnt == 0 && \ 139 (sctp_ipif)->sctp_ipif_state == SCTP_IPIFS_CONDEMNED) { \ 140 rw_exit(&(sctp_ipif)->sctp_ipif_lock); \ 141 sctp_ipif_inactive(sctp_ipif); \ 142 } else { \ 143 rw_exit(&(sctp_ipif)->sctp_ipif_lock); \ 144 } \ 145} 146 147/* Address set comparison results. */ 148#define SCTP_ADDR_EQUAL 1 149#define SCTP_ADDR_SUBSET 2 150#define SCTP_ADDR_OVERLAP 3 151#define SCTP_ADDR_DISJOINT 4 152 153extern int sctp_valid_addr_list(sctp_t *, const void *, uint32_t, 154 uchar_t *, size_t); 155extern int sctp_dup_saddrs(sctp_t *, sctp_t *, int); 156extern int sctp_compare_saddrs(sctp_t *, sctp_t *); 157extern sctp_saddr_ipif_t *sctp_saddr_lookup(sctp_t *, in6_addr_t *, 158 uint_t); 159extern in6_addr_t sctp_get_valid_addr(sctp_t *, boolean_t, boolean_t *); 160extern size_t sctp_saddr_info(sctp_t *, int, uchar_t *, boolean_t); 161extern void sctp_del_saddr_list(sctp_t *, const void *, int, 162 boolean_t); 163extern void sctp_del_saddr(sctp_t *, sctp_saddr_ipif_t *); 164extern void sctp_free_saddrs(sctp_t *); 165extern void sctp_saddr_init(sctp_stack_t *); 166extern void sctp_saddr_fini(sctp_stack_t *); 167extern int sctp_getmyaddrs(void *, void *, int *); 168extern int sctp_saddr_add_addr(sctp_t *, in6_addr_t *, uint_t); 169extern void sctp_check_saddr(sctp_t *, int, boolean_t, 170 in6_addr_t *); 171 172#ifdef __cplusplus 173} 174#endif 175 176#endif /* _SCTP_ADDR_H */ 177