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 5f4b3ec61Sdh * Common Development and Distribution License (the "License"). 6f4b3ec61Sdh * 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 /* 22f4b3ec61Sdh * 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 _SCTP_ADDR_H 277c478bd9Sstevel@tonic-gate #define _SCTP_ADDR_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #include <sys/list.h> 327c478bd9Sstevel@tonic-gate #include <sys/zone.h> 337c478bd9Sstevel@tonic-gate #include <inet/ip.h> 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifdef __cplusplus 367c478bd9Sstevel@tonic-gate extern "C" { 377c478bd9Sstevel@tonic-gate #endif 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate /* 407c478bd9Sstevel@tonic-gate * SCTP IPIF structure - only relevant fields from ipif_t retained 417c478bd9Sstevel@tonic-gate * 427c478bd9Sstevel@tonic-gate * There is a global array, sctp_g_ipifs, to store all addresses of 437c478bd9Sstevel@tonic-gate * the system. Each element of the global array is a list of 447c478bd9Sstevel@tonic-gate * sctp_ipif_t. 457c478bd9Sstevel@tonic-gate * 467c478bd9Sstevel@tonic-gate * This structure is also shared by all SCTP PCBs. Each SCTP PCB has 477c478bd9Sstevel@tonic-gate * an array of source addresses. Each element of that array is a list 487c478bd9Sstevel@tonic-gate * of sctp_saddr_ipif_t. And each sctp_saddr_ipif_t has a pointer 497c478bd9Sstevel@tonic-gate * to a sctp_ipif_t. The reason for sctp_saddr_ipif_t is that each 507c478bd9Sstevel@tonic-gate * SCTP PCB may do different things to a source address. This info 517c478bd9Sstevel@tonic-gate * is stored locally in sctp_saddr_ipif_t. 527c478bd9Sstevel@tonic-gate * 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate typedef struct sctp_ipif_s { 557c478bd9Sstevel@tonic-gate list_node_t sctp_ipifs; /* Used by the global list */ 567c478bd9Sstevel@tonic-gate struct sctp_ill_s *sctp_ipif_ill; 577c478bd9Sstevel@tonic-gate uint_t sctp_ipif_mtu; 587c478bd9Sstevel@tonic-gate uint_t sctp_ipif_id; 597c478bd9Sstevel@tonic-gate in6_addr_t sctp_ipif_saddr; 607c478bd9Sstevel@tonic-gate int sctp_ipif_state; 617c478bd9Sstevel@tonic-gate uint32_t sctp_ipif_refcnt; 627c478bd9Sstevel@tonic-gate zoneid_t sctp_ipif_zoneid; 637c478bd9Sstevel@tonic-gate krwlock_t sctp_ipif_lock; 647c478bd9Sstevel@tonic-gate boolean_t sctp_ipif_isv6; 65f551bb10Svi uint64_t sctp_ipif_flags; 667c478bd9Sstevel@tonic-gate } sctp_ipif_t; 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* ipif_state */ 697c478bd9Sstevel@tonic-gate #define SCTP_IPIFS_CONDEMNED -1 707c478bd9Sstevel@tonic-gate #define SCTP_IPIFS_INVALID -2 717c478bd9Sstevel@tonic-gate #define SCTP_IPIFS_DOWN 1 727c478bd9Sstevel@tonic-gate #define SCTP_IPIFS_UP 2 737c478bd9Sstevel@tonic-gate 74df19b344Svi /* 75df19b344Svi * Individual SCTP source address structure. 76df19b344Svi * saddr_ipifp is the actual pointer to the ipif/address. 77df19b344Svi * saddr_ipif_dontsrc is used to mark an address as currently unusable. This 78df19b344Svi * would be the case when we have added/deleted an address using sctp_bindx() 79df19b344Svi * and are waiting for the ASCONF ACK from the peer to confirm the addition/ 80df19b344Svi * deletion. Additionally, saddr_ipif_delete_pending is used to specifically 81df19b344Svi * indicate that an address delete operation is in progress. 82df19b344Svi */ 837c478bd9Sstevel@tonic-gate typedef struct sctp_saddrs_ipif_s { 847c478bd9Sstevel@tonic-gate list_node_t saddr_ipif; 857c478bd9Sstevel@tonic-gate sctp_ipif_t *saddr_ipifp; 867c478bd9Sstevel@tonic-gate uint32_t saddr_ipif_dontsrc : 1, 877c478bd9Sstevel@tonic-gate saddr_ipif_delete_pending : 1, 88f551bb10Svi saddr_ipif_unconfirmed : 1, 89f551bb10Svi pad : 29; 907c478bd9Sstevel@tonic-gate } sctp_saddr_ipif_t; 917c478bd9Sstevel@tonic-gate 92f551bb10Svi #define SCTP_DONT_SRC(sctp_saddr) \ 93f551bb10Svi ((sctp_saddr)->saddr_ipif_dontsrc || \ 94f551bb10Svi (sctp_saddr)->saddr_ipif_unconfirmed) 95f551bb10Svi 96f551bb10Svi 97df19b344Svi /* 98df19b344Svi * SCTP ILL structure - only relevant fields from ill_t retained. 99df19b344Svi * This pretty much reflects the ILL<->IPIF relation that IP maintains. 100df19b344Svi * At present the only state an ILL can be in is CONDEMNED or not. 101df19b344Svi * sctp_ill_ipifcnt gives the number of IPIFs for this ILL, 102df19b344Svi * sctp_ill_index is phyint_ifindex in the actual ILL structure (in IP) 103df19b344Svi * and sctp_ill_flags is ill_flags from the ILL structure. 104f4b3ec61Sdh * 105f4b3ec61Sdh * The comment below (and for other netstack_t references) refers 106f4b3ec61Sdh * to the fact that we only do netstack_hold in particular cases, 107f4b3ec61Sdh * such as the references from open streams (ill_t and conn_t's 108f4b3ec61Sdh * pointers). Internally within IP we rely on IP's ability to cleanup e.g. 109f4b3ec61Sdh * ire_t's when an ill goes away. 110df19b344Svi */ 1117c478bd9Sstevel@tonic-gate typedef struct sctp_ill_s { 112f4b3ec61Sdh list_node_t sctp_ills; 113f4b3ec61Sdh int sctp_ill_name_length; 114f4b3ec61Sdh char *sctp_ill_name; 115f4b3ec61Sdh int sctp_ill_state; 116f4b3ec61Sdh uint32_t sctp_ill_ipifcnt; 117f4b3ec61Sdh uint_t sctp_ill_index; 118f4b3ec61Sdh uint64_t sctp_ill_flags; 119f4b3ec61Sdh netstack_t *sctp_ill_netstack; /* Does not have a netstack_hold */ 1207c478bd9Sstevel@tonic-gate } sctp_ill_t; 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate /* ill_state */ 1237c478bd9Sstevel@tonic-gate #define SCTP_ILLS_CONDEMNED -1 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate #define SCTP_ILL_HASH 16 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate typedef struct sctp_ill_hash_s { 1287c478bd9Sstevel@tonic-gate list_t sctp_ill_list; 1297c478bd9Sstevel@tonic-gate int ill_count; 1307c478bd9Sstevel@tonic-gate } sctp_ill_hash_t; 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate #define SCTP_IPIF_REFHOLD(sctp_ipif) { \ 1347c478bd9Sstevel@tonic-gate atomic_add_32(&(sctp_ipif)->sctp_ipif_refcnt, 1); \ 1357c478bd9Sstevel@tonic-gate } 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate #define SCTP_IPIF_REFRELE(sctp_ipif) { \ 138*e35d2278Svi rw_enter(&(sctp_ipif)->sctp_ipif_lock, RW_WRITER); \ 1397c478bd9Sstevel@tonic-gate ASSERT((sctp_ipif)->sctp_ipif_refcnt != 0); \ 140*e35d2278Svi if (--(sctp_ipif)->sctp_ipif_refcnt == 0 && \ 141*e35d2278Svi (sctp_ipif)->sctp_ipif_state == SCTP_IPIFS_CONDEMNED) { \ 142*e35d2278Svi rw_exit(&(sctp_ipif)->sctp_ipif_lock); \ 1437c478bd9Sstevel@tonic-gate sctp_ipif_inactive(sctp_ipif); \ 144*e35d2278Svi } else { \ 145*e35d2278Svi rw_exit(&(sctp_ipif)->sctp_ipif_lock); \ 146*e35d2278Svi } \ 1477c478bd9Sstevel@tonic-gate } 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate /* Address set comparison results. */ 1507c478bd9Sstevel@tonic-gate #define SCTP_ADDR_EQUAL 1 1517c478bd9Sstevel@tonic-gate #define SCTP_ADDR_SUBSET 2 1527c478bd9Sstevel@tonic-gate #define SCTP_ADDR_OVERLAP 3 1537c478bd9Sstevel@tonic-gate #define SCTP_ADDR_DISJOINT 4 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate extern void sctp_update_ill(ill_t *, int); 1567c478bd9Sstevel@tonic-gate extern void sctp_update_ipif(ipif_t *, int); 1577c478bd9Sstevel@tonic-gate 1581d8c4025Svi extern int sctp_valid_addr_list(sctp_t *, const void *, uint32_t, 1591d8c4025Svi uchar_t *, size_t); 1607c478bd9Sstevel@tonic-gate extern int sctp_dup_saddrs(sctp_t *, sctp_t *, int); 1617c478bd9Sstevel@tonic-gate extern int sctp_compare_saddrs(sctp_t *, sctp_t *); 1621d8c4025Svi extern sctp_saddr_ipif_t *sctp_saddr_lookup(sctp_t *, in6_addr_t *, 1631d8c4025Svi uint_t); 1647c478bd9Sstevel@tonic-gate extern in6_addr_t sctp_get_valid_addr(sctp_t *, boolean_t isv6); 165f551bb10Svi extern size_t sctp_saddr_info(sctp_t *, int, uchar_t *, boolean_t); 1667c478bd9Sstevel@tonic-gate extern void sctp_del_saddr_list(sctp_t *, const void *, int, 1677c478bd9Sstevel@tonic-gate boolean_t); 1687c478bd9Sstevel@tonic-gate extern void sctp_del_saddr(sctp_t *, sctp_saddr_ipif_t *); 1697c478bd9Sstevel@tonic-gate extern void sctp_free_saddrs(sctp_t *); 170f4b3ec61Sdh extern void sctp_saddr_init(sctp_stack_t *); 171f4b3ec61Sdh extern void sctp_saddr_fini(sctp_stack_t *); 1727c478bd9Sstevel@tonic-gate extern int sctp_getmyaddrs(void *, void *, int *); 1731d8c4025Svi extern int sctp_saddr_add_addr(sctp_t *, in6_addr_t *, uint_t); 174f551bb10Svi extern void sctp_check_saddr(sctp_t *, int, boolean_t); 1757c478bd9Sstevel@tonic-gate 1767c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1777c478bd9Sstevel@tonic-gate } 1787c478bd9Sstevel@tonic-gate #endif 1797c478bd9Sstevel@tonic-gate 1807c478bd9Sstevel@tonic-gate #endif /* _SCTP_ADDR_H */ 181