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 2005 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 _INET_SCTP_SCTP_IMPL_H 28*7c478bd9Sstevel@tonic-gate #define _INET_SCTP_SCTP_IMPL_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 33*7c478bd9Sstevel@tonic-gate extern "C" { 34*7c478bd9Sstevel@tonic-gate #endif 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #include <sys/inttypes.h> 37*7c478bd9Sstevel@tonic-gate #include <sys/taskq.h> 38*7c478bd9Sstevel@tonic-gate #include <sys/list.h> 39*7c478bd9Sstevel@tonic-gate #include <sys/strsun.h> 40*7c478bd9Sstevel@tonic-gate #include <netinet/ip6.h> 41*7c478bd9Sstevel@tonic-gate #include <inet/optcom.h> 42*7c478bd9Sstevel@tonic-gate #include <netinet/sctp.h> 43*7c478bd9Sstevel@tonic-gate #include <inet/sctp_itf.h> 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate /* Streams device identifying info and version */ 46*7c478bd9Sstevel@tonic-gate #define SCTP_DEV_IDINFO "SCTP Streams device 1.0" 47*7c478bd9Sstevel@tonic-gate 48*7c478bd9Sstevel@tonic-gate #define SSN_GT(a, b) ((int16_t)((a)-(b)) > 0) 49*7c478bd9Sstevel@tonic-gate #define SSN_GE(a, b) ((int16_t)((a)-(b)) >= 0) 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate /* Default buffer size and flow control wake up threshold. */ 52*7c478bd9Sstevel@tonic-gate #define SCTP_XMIT_LOWATER 8192 53*7c478bd9Sstevel@tonic-gate #define SCTP_XMIT_HIWATER 102400 54*7c478bd9Sstevel@tonic-gate #define SCTP_RECV_LOWATER 8192 55*7c478bd9Sstevel@tonic-gate #define SCTP_RECV_HIWATER 102400 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate /* SCTP Timer control structure */ 58*7c478bd9Sstevel@tonic-gate typedef struct sctpt_s { 59*7c478bd9Sstevel@tonic-gate pfv_t sctpt_pfv; /* The routine we are to call */ 60*7c478bd9Sstevel@tonic-gate struct sctp_s *sctpt_sctp; /* The parameter we are to pass in */ 61*7c478bd9Sstevel@tonic-gate struct sctp_faddr_s *sctpt_faddr; 62*7c478bd9Sstevel@tonic-gate } sctpt_t; 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate /* 65*7c478bd9Sstevel@tonic-gate * faddr timer mblks are not allocated until first use. This macro 66*7c478bd9Sstevel@tonic-gate * will allocate the timer mblk if necessary, set the faddr, and then 67*7c478bd9Sstevel@tonic-gate * start the timer. 68*7c478bd9Sstevel@tonic-gate */ 69*7c478bd9Sstevel@tonic-gate #define SCTP_FADDR_TIMER_RESTART(sctp, fp, intvl) \ 70*7c478bd9Sstevel@tonic-gate if ((fp)->timer_mp == NULL) { \ 71*7c478bd9Sstevel@tonic-gate (fp)->timer_mp = sctp_timer_alloc((sctp), sctp_rexmit_timer); \ 72*7c478bd9Sstevel@tonic-gate } \ 73*7c478bd9Sstevel@tonic-gate if ((fp)->timer_mp != NULL) { \ 74*7c478bd9Sstevel@tonic-gate ((sctpt_t *)((fp)->timer_mp->b_rptr))->sctpt_faddr = fp; \ 75*7c478bd9Sstevel@tonic-gate dprint(3, ("faddr_timer_restart: fp=%p %x:%x:%x:%x %d\n", \ 76*7c478bd9Sstevel@tonic-gate (fp), SCTP_PRINTADDR((fp)->faddr), \ 77*7c478bd9Sstevel@tonic-gate (int)(intvl))); \ 78*7c478bd9Sstevel@tonic-gate sctp_timer((sctp), (fp)->timer_mp, (intvl)); \ 79*7c478bd9Sstevel@tonic-gate (fp)->timer_running = 1; \ 80*7c478bd9Sstevel@tonic-gate } 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate #define SCTP_FADDR_TIMER_STOP(fp) \ 83*7c478bd9Sstevel@tonic-gate if ((fp)->timer_running && (fp)->timer_mp != NULL) { \ 84*7c478bd9Sstevel@tonic-gate sctp_timer_stop((fp)->timer_mp); \ 85*7c478bd9Sstevel@tonic-gate (fp)->timer_running = 0; \ 86*7c478bd9Sstevel@tonic-gate } 87*7c478bd9Sstevel@tonic-gate 88*7c478bd9Sstevel@tonic-gate #define SCTP_CALC_RXT(fp, max) \ 89*7c478bd9Sstevel@tonic-gate { \ 90*7c478bd9Sstevel@tonic-gate if (((fp)->rto <<= 1) > (max)) \ 91*7c478bd9Sstevel@tonic-gate (fp)->rto = (max); \ 92*7c478bd9Sstevel@tonic-gate } 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate /* 95*7c478bd9Sstevel@tonic-gate * Maximum number of duplicate TSNs we can report. This is currently 96*7c478bd9Sstevel@tonic-gate * static, and governs the size of the mblk used to hold the duplicate 97*7c478bd9Sstevel@tonic-gate * reports. The use of duplcate TSN reports is currently experimental, 98*7c478bd9Sstevel@tonic-gate * so for now a static limit should suffice. 99*7c478bd9Sstevel@tonic-gate */ 100*7c478bd9Sstevel@tonic-gate #define SCTP_DUP_MBLK_SZ 64 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate #define SCTP_IS_ADDR_UNSPEC(isv4, addr) \ 103*7c478bd9Sstevel@tonic-gate ((isv4) ? IN6_IS_ADDR_V4MAPPED_ANY(&(addr)) : \ 104*7c478bd9Sstevel@tonic-gate IN6_IS_ADDR_UNSPECIFIED(&(addr))) 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate extern int sctp_g_num_epriv_ports; 107*7c478bd9Sstevel@tonic-gate extern uint16_t sctp_g_epriv_ports[]; 108*7c478bd9Sstevel@tonic-gate extern kmutex_t sctp_epriv_port_lock; 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate extern uint_t sctp_next_port_to_try; 111*7c478bd9Sstevel@tonic-gate /* 112*7c478bd9Sstevel@tonic-gate * SCTP parameters 113*7c478bd9Sstevel@tonic-gate */ 114*7c478bd9Sstevel@tonic-gate /* Named Dispatch Parameter Management Structure */ 115*7c478bd9Sstevel@tonic-gate typedef struct sctpparam_s { 116*7c478bd9Sstevel@tonic-gate uint32_t sctp_param_min; 117*7c478bd9Sstevel@tonic-gate uint32_t sctp_param_max; 118*7c478bd9Sstevel@tonic-gate uint32_t sctp_param_val; 119*7c478bd9Sstevel@tonic-gate char *sctp_param_name; 120*7c478bd9Sstevel@tonic-gate } sctpparam_t; 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate extern sctpparam_t sctp_param_arr[]; 123*7c478bd9Sstevel@tonic-gate #define sctp_max_init_retr sctp_param_arr[0].sctp_param_val 124*7c478bd9Sstevel@tonic-gate #define sctp_max_init_retr_high sctp_param_arr[0].sctp_param_max 125*7c478bd9Sstevel@tonic-gate #define sctp_max_init_retr_low sctp_param_arr[0].sctp_param_min 126*7c478bd9Sstevel@tonic-gate #define sctp_pa_max_retr sctp_param_arr[1].sctp_param_val 127*7c478bd9Sstevel@tonic-gate #define sctp_pa_max_retr_high sctp_param_arr[1].sctp_param_max 128*7c478bd9Sstevel@tonic-gate #define sctp_pa_max_retr_low sctp_param_arr[1].sctp_param_min 129*7c478bd9Sstevel@tonic-gate #define sctp_pp_max_retr sctp_param_arr[2].sctp_param_val 130*7c478bd9Sstevel@tonic-gate #define sctp_pp_max_retr_high sctp_param_arr[2].sctp_param_max 131*7c478bd9Sstevel@tonic-gate #define sctp_pp_max_retr_low sctp_param_arr[2].sctp_param_min 132*7c478bd9Sstevel@tonic-gate #define sctp_cwnd_max_ sctp_param_arr[3].sctp_param_val 133*7c478bd9Sstevel@tonic-gate #define sctp_dbg sctp_param_arr[4].sctp_param_val 134*7c478bd9Sstevel@tonic-gate #define sctp_smallest_nonpriv_port sctp_param_arr[5].sctp_param_val 135*7c478bd9Sstevel@tonic-gate #define sctp_ipv4_ttl sctp_param_arr[6].sctp_param_val 136*7c478bd9Sstevel@tonic-gate #define sctp_heartbeat_interval sctp_param_arr[7].sctp_param_val 137*7c478bd9Sstevel@tonic-gate #define sctp_heartbeat_interval_high sctp_param_arr[7].sctp_param_max 138*7c478bd9Sstevel@tonic-gate #define sctp_heartbeat_interval_low sctp_param_arr[7].sctp_param_min 139*7c478bd9Sstevel@tonic-gate #define sctp_initial_mtu sctp_param_arr[8].sctp_param_val 140*7c478bd9Sstevel@tonic-gate #define sctp_mtu_probe_interval sctp_param_arr[9].sctp_param_val 141*7c478bd9Sstevel@tonic-gate #define sctp_new_secret_interval sctp_param_arr[10].sctp_param_val 142*7c478bd9Sstevel@tonic-gate #define sctp_deferred_ack_interval sctp_param_arr[11].sctp_param_val 143*7c478bd9Sstevel@tonic-gate #define sctp_snd_lowat_fraction sctp_param_arr[12].sctp_param_val 144*7c478bd9Sstevel@tonic-gate #define sctp_ignore_path_mtu sctp_param_arr[13].sctp_param_val 145*7c478bd9Sstevel@tonic-gate #define sctp_initial_ssthresh sctp_param_arr[14].sctp_param_val 146*7c478bd9Sstevel@tonic-gate #define sctp_smallest_anon_port sctp_param_arr[15].sctp_param_val 147*7c478bd9Sstevel@tonic-gate #define sctp_largest_anon_port sctp_param_arr[16].sctp_param_val 148*7c478bd9Sstevel@tonic-gate #define sctp_xmit_hiwat sctp_param_arr[17].sctp_param_val 149*7c478bd9Sstevel@tonic-gate #define sctp_xmit_lowat sctp_param_arr[18].sctp_param_val 150*7c478bd9Sstevel@tonic-gate #define sctp_recv_hiwat sctp_param_arr[19].sctp_param_val 151*7c478bd9Sstevel@tonic-gate #define sctp_max_buf sctp_param_arr[20].sctp_param_val 152*7c478bd9Sstevel@tonic-gate #define sctp_rtt_updates sctp_param_arr[21].sctp_param_val 153*7c478bd9Sstevel@tonic-gate #define sctp_ipv6_hoplimit sctp_param_arr[22].sctp_param_val 154*7c478bd9Sstevel@tonic-gate #define sctp_rto_ming sctp_param_arr[23].sctp_param_val 155*7c478bd9Sstevel@tonic-gate #define sctp_rto_ming_high sctp_param_arr[23].sctp_param_max 156*7c478bd9Sstevel@tonic-gate #define sctp_rto_ming_low sctp_param_arr[23].sctp_param_min 157*7c478bd9Sstevel@tonic-gate #define sctp_rto_maxg sctp_param_arr[24].sctp_param_val 158*7c478bd9Sstevel@tonic-gate #define sctp_rto_maxg_high sctp_param_arr[24].sctp_param_max 159*7c478bd9Sstevel@tonic-gate #define sctp_rto_maxg_low sctp_param_arr[24].sctp_param_min 160*7c478bd9Sstevel@tonic-gate #define sctp_rto_initialg sctp_param_arr[25].sctp_param_val 161*7c478bd9Sstevel@tonic-gate #define sctp_rto_initialg_high sctp_param_arr[25].sctp_param_max 162*7c478bd9Sstevel@tonic-gate #define sctp_rto_initialg_low sctp_param_arr[25].sctp_param_min 163*7c478bd9Sstevel@tonic-gate #define sctp_cookie_life sctp_param_arr[26].sctp_param_val 164*7c478bd9Sstevel@tonic-gate #define sctp_cookie_life_high sctp_param_arr[26].sctp_param_max 165*7c478bd9Sstevel@tonic-gate #define sctp_cookie_life_low sctp_param_arr[26].sctp_param_min 166*7c478bd9Sstevel@tonic-gate #define sctp_max_in_streams sctp_param_arr[27].sctp_param_val 167*7c478bd9Sstevel@tonic-gate #define sctp_max_in_streams_high sctp_param_arr[27].sctp_param_max 168*7c478bd9Sstevel@tonic-gate #define sctp_max_in_streams_low sctp_param_arr[27].sctp_param_min 169*7c478bd9Sstevel@tonic-gate #define sctp_initial_out_streams sctp_param_arr[28].sctp_param_val 170*7c478bd9Sstevel@tonic-gate #define sctp_initial_out_streams_high sctp_param_arr[28].sctp_param_max 171*7c478bd9Sstevel@tonic-gate #define sctp_initial_out_streams_low sctp_param_arr[28].sctp_param_min 172*7c478bd9Sstevel@tonic-gate #define sctp_shutack_wait_bound sctp_param_arr[29].sctp_param_val 173*7c478bd9Sstevel@tonic-gate #define sctp_maxburst sctp_param_arr[30].sctp_param_val 174*7c478bd9Sstevel@tonic-gate #define sctp_addip_enabled sctp_param_arr[31].sctp_param_val 175*7c478bd9Sstevel@tonic-gate #define sctp_recv_hiwat_minmss sctp_param_arr[32].sctp_param_val 176*7c478bd9Sstevel@tonic-gate #define sctp_slow_start_initial sctp_param_arr[33].sctp_param_val 177*7c478bd9Sstevel@tonic-gate #define sctp_slow_start_after_idle sctp_param_arr[34].sctp_param_val 178*7c478bd9Sstevel@tonic-gate #define sctp_prsctp_enabled sctp_param_arr[35].sctp_param_val 179*7c478bd9Sstevel@tonic-gate #define sctp_fast_rxt_thresh sctp_param_arr[36].sctp_param_val 180*7c478bd9Sstevel@tonic-gate /* 181*7c478bd9Sstevel@tonic-gate * sctp_wroff_xtra is the extra space in front of SCTP/IP header for link 182*7c478bd9Sstevel@tonic-gate * layer header. It has to be a multiple of 4. 183*7c478bd9Sstevel@tonic-gate */ 184*7c478bd9Sstevel@tonic-gate extern sctpparam_t sctp_wroff_xtra_param; 185*7c478bd9Sstevel@tonic-gate #define sctp_wroff_xtra sctp_wroff_xtra_param.sctp_param_val 186*7c478bd9Sstevel@tonic-gate 187*7c478bd9Sstevel@tonic-gate #define SCTP_MAX_COMBINED_HEADER_LENGTH (60 + 12) /* Maxed out ip + sctp */ 188*7c478bd9Sstevel@tonic-gate #define SCTP_MAX_IP_OPTIONS_LENGTH (60 - IP_SIMPLE_HDR_LENGTH) 189*7c478bd9Sstevel@tonic-gate #define SCTP_MAX_HDR_LENGTH 60 190*7c478bd9Sstevel@tonic-gate 191*7c478bd9Sstevel@tonic-gate #define SCTP_SECRET_LEN 16 192*7c478bd9Sstevel@tonic-gate 193*7c478bd9Sstevel@tonic-gate #define SCTP_REFHOLD(sctp) { \ 194*7c478bd9Sstevel@tonic-gate mutex_enter(&(sctp)->sctp_reflock); \ 195*7c478bd9Sstevel@tonic-gate (sctp)->sctp_refcnt++; \ 196*7c478bd9Sstevel@tonic-gate ASSERT((sctp)->sctp_refcnt != 0); \ 197*7c478bd9Sstevel@tonic-gate mutex_exit(&(sctp)->sctp_reflock); \ 198*7c478bd9Sstevel@tonic-gate } 199*7c478bd9Sstevel@tonic-gate 200*7c478bd9Sstevel@tonic-gate #define SCTP_REFRELE(sctp) { \ 201*7c478bd9Sstevel@tonic-gate mutex_enter(&(sctp)->sctp_reflock); \ 202*7c478bd9Sstevel@tonic-gate ASSERT((sctp)->sctp_refcnt != 0); \ 203*7c478bd9Sstevel@tonic-gate if (--(sctp)->sctp_refcnt == 0) { \ 204*7c478bd9Sstevel@tonic-gate mutex_exit(&(sctp)->sctp_reflock); \ 205*7c478bd9Sstevel@tonic-gate CONN_DEC_REF((sctp)->sctp_connp); \ 206*7c478bd9Sstevel@tonic-gate } else { \ 207*7c478bd9Sstevel@tonic-gate mutex_exit(&(sctp)->sctp_reflock); \ 208*7c478bd9Sstevel@tonic-gate } \ 209*7c478bd9Sstevel@tonic-gate } 210*7c478bd9Sstevel@tonic-gate 211*7c478bd9Sstevel@tonic-gate #define SCTP_PRINTADDR(a) (a).s6_addr32[0], (a).s6_addr32[1],\ 212*7c478bd9Sstevel@tonic-gate (a).s6_addr32[2], (a).s6_addr32[3] 213*7c478bd9Sstevel@tonic-gate 214*7c478bd9Sstevel@tonic-gate #define CONN2SCTP(conn) ((sctp_t *)(&((conn_t *)conn)[1])) 215*7c478bd9Sstevel@tonic-gate 216*7c478bd9Sstevel@tonic-gate /* 217*7c478bd9Sstevel@tonic-gate * Outbound data, flags and macros for per-message, per-chunk info 218*7c478bd9Sstevel@tonic-gate */ 219*7c478bd9Sstevel@tonic-gate typedef struct { 220*7c478bd9Sstevel@tonic-gate int64_t smh_ttl; /* Time to Live */ 221*7c478bd9Sstevel@tonic-gate int64_t smh_tob; /* Time of Birth */ 222*7c478bd9Sstevel@tonic-gate uint32_t smh_context; 223*7c478bd9Sstevel@tonic-gate uint16_t smh_sid; 224*7c478bd9Sstevel@tonic-gate uint16_t smh_ssn; 225*7c478bd9Sstevel@tonic-gate uint32_t smh_ppid; 226*7c478bd9Sstevel@tonic-gate uint16_t smh_flags; 227*7c478bd9Sstevel@tonic-gate uint32_t smh_msglen; 228*7c478bd9Sstevel@tonic-gate } sctp_msg_hdr_t; 229*7c478bd9Sstevel@tonic-gate 230*7c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_FLAG_SENT 0x01 231*7c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_FLAG_REXMIT 0x02 232*7c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_FLAG_ACKED 0x04 233*7c478bd9Sstevel@tonic-gate #define SCTP_MSG_FLAG_CHUNKED 0x08 234*7c478bd9Sstevel@tonic-gate #define SCTP_MSG_FLAG_ABANDONED 0x10 235*7c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_FLAG_ABANDONED 0x20 236*7c478bd9Sstevel@tonic-gate 237*7c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_CLEAR_FLAGS(mp) ((mp)->b_flag = 0) 238*7c478bd9Sstevel@tonic-gate /* 239*7c478bd9Sstevel@tonic-gate * If we are transmitting the chunk for the first time we assign the TSN and 240*7c478bd9Sstevel@tonic-gate * SSN here. The reason we assign the SSN here (as opposed to doing it in 241*7c478bd9Sstevel@tonic-gate * sctp_chunkify()) is that the chunk may expire, if PRSCTP is enabled, before 242*7c478bd9Sstevel@tonic-gate * we get a chance to send it out. If we assign the SSN in sctp_chunkify() 243*7c478bd9Sstevel@tonic-gate * and this happens, then we need to send a Forward TSN to the peer, which 244*7c478bd9Sstevel@tonic-gate * will be expecting this SSN, assuming ordered. If we assign it here we 245*7c478bd9Sstevel@tonic-gate * can just take out the chunk from the transmit list without having to 246*7c478bd9Sstevel@tonic-gate * send a Forward TSN chunk. While assigning the SSN we use (meta)->b_cont 247*7c478bd9Sstevel@tonic-gate * to determine if it needs a new SSN (i.e. the next SSN for the stream), 248*7c478bd9Sstevel@tonic-gate * since (meta)->b_cont signifies the first chunk of a message (if the message 249*7c478bd9Sstevel@tonic-gate * is unordered, then the SSN is 0). 250*7c478bd9Sstevel@tonic-gate * 251*7c478bd9Sstevel@tonic-gate */ 252*7c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_SENT(sctp, mp, sdc, fp, chunkdata, meta) { \ 253*7c478bd9Sstevel@tonic-gate if (!SCTP_CHUNK_ISSENT(mp)) { \ 254*7c478bd9Sstevel@tonic-gate sctp_msg_hdr_t *mhdr = (sctp_msg_hdr_t *)(meta)->b_rptr; \ 255*7c478bd9Sstevel@tonic-gate ASSERT(!SCTP_CHUNK_ABANDONED(mp)); \ 256*7c478bd9Sstevel@tonic-gate (mp)->b_flag = SCTP_CHUNK_FLAG_SENT; \ 257*7c478bd9Sstevel@tonic-gate (sdc)->sdh_tsn = htonl((sctp)->sctp_ltsn++); \ 258*7c478bd9Sstevel@tonic-gate if ((mhdr)->smh_flags & MSG_UNORDERED) { \ 259*7c478bd9Sstevel@tonic-gate (sdc)->sdh_ssn = 0; \ 260*7c478bd9Sstevel@tonic-gate SCTP_DATA_SET_UBIT(sdc); \ 261*7c478bd9Sstevel@tonic-gate BUMP_LOCAL((sctp)->sctp_oudchunks); \ 262*7c478bd9Sstevel@tonic-gate } else { \ 263*7c478bd9Sstevel@tonic-gate BUMP_LOCAL((sctp)->sctp_odchunks); \ 264*7c478bd9Sstevel@tonic-gate if ((mp) == (meta)->b_cont) { \ 265*7c478bd9Sstevel@tonic-gate mhdr->smh_ssn = htons( \ 266*7c478bd9Sstevel@tonic-gate (sctp)->sctp_ostrcntrs[mhdr->smh_sid]++); \ 267*7c478bd9Sstevel@tonic-gate } \ 268*7c478bd9Sstevel@tonic-gate (sdc)->sdh_ssn = mhdr->smh_ssn; \ 269*7c478bd9Sstevel@tonic-gate } \ 270*7c478bd9Sstevel@tonic-gate (sctp)->sctp_unacked += (chunkdata); \ 271*7c478bd9Sstevel@tonic-gate (sctp)->sctp_unsent -= (chunkdata); \ 272*7c478bd9Sstevel@tonic-gate (sctp)->sctp_frwnd -= (chunkdata); \ 273*7c478bd9Sstevel@tonic-gate } else { \ 274*7c478bd9Sstevel@tonic-gate if (SCTP_CHUNK_ISACKED(mp)) { \ 275*7c478bd9Sstevel@tonic-gate (sctp)->sctp_unacked += (chunkdata); \ 276*7c478bd9Sstevel@tonic-gate } else { \ 277*7c478bd9Sstevel@tonic-gate ASSERT(SCTP_CHUNK_DEST(mp)->suna >= ((chunkdata) + \ 278*7c478bd9Sstevel@tonic-gate sizeof (*sdc))); \ 279*7c478bd9Sstevel@tonic-gate SCTP_CHUNK_DEST(mp)->suna -= ((chunkdata) + \ 280*7c478bd9Sstevel@tonic-gate sizeof (*sdc)); \ 281*7c478bd9Sstevel@tonic-gate } \ 282*7c478bd9Sstevel@tonic-gate (mp)->b_flag &= ~(SCTP_CHUNK_FLAG_REXMIT | \ 283*7c478bd9Sstevel@tonic-gate SCTP_CHUNK_FLAG_ACKED); \ 284*7c478bd9Sstevel@tonic-gate SCTP_CHUNK_SET_SACKCNT(mp, 0); \ 285*7c478bd9Sstevel@tonic-gate BUMP_LOCAL(sctp->sctp_rxtchunks); \ 286*7c478bd9Sstevel@tonic-gate BUMP_LOCAL((sctp)->sctp_T3expire); \ 287*7c478bd9Sstevel@tonic-gate BUMP_LOCAL((fp)->T3expire); \ 288*7c478bd9Sstevel@tonic-gate } \ 289*7c478bd9Sstevel@tonic-gate SCTP_SET_CHUNK_DEST(mp, fp); \ 290*7c478bd9Sstevel@tonic-gate (fp)->suna += ((chunkdata) + sizeof (*sdc)); \ 291*7c478bd9Sstevel@tonic-gate } 292*7c478bd9Sstevel@tonic-gate 293*7c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_ISSENT(mp) ((mp)->b_flag & SCTP_CHUNK_FLAG_SENT) 294*7c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_CANSEND(mp) \ 295*7c478bd9Sstevel@tonic-gate (!(SCTP_CHUNK_ABANDONED(mp)) && \ 296*7c478bd9Sstevel@tonic-gate (((mp)->b_flag & (SCTP_CHUNK_FLAG_REXMIT|SCTP_CHUNK_FLAG_SENT)) != \ 297*7c478bd9Sstevel@tonic-gate SCTP_CHUNK_FLAG_SENT)) 298*7c478bd9Sstevel@tonic-gate 299*7c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_DEST(mp) ((sctp_faddr_t *)(mp)->b_queue) 300*7c478bd9Sstevel@tonic-gate #define SCTP_SET_CHUNK_DEST(mp, fp) ((mp)->b_queue = (queue_t *)fp) 301*7c478bd9Sstevel@tonic-gate 302*7c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_REXMIT(mp) ((mp)->b_flag |= SCTP_CHUNK_FLAG_REXMIT) 303*7c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_CLEAR_REXMIT(mp) ((mp)->b_flag &= ~SCTP_CHUNK_FLAG_REXMIT) 304*7c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_WANT_REXMIT(mp) ((mp)->b_flag & SCTP_CHUNK_FLAG_REXMIT) 305*7c478bd9Sstevel@tonic-gate 306*7c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_ACKED(mp) \ 307*7c478bd9Sstevel@tonic-gate ((mp)->b_flag = (SCTP_CHUNK_FLAG_SENT|SCTP_CHUNK_FLAG_ACKED)) 308*7c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_ISACKED(mp) ((mp)->b_flag & SCTP_CHUNK_FLAG_ACKED) 309*7c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_CLEAR_ACKED(mp) ((mp)->b_flag &= ~SCTP_CHUNK_FLAG_ACKED) 310*7c478bd9Sstevel@tonic-gate 311*7c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_SACKCNT(mp) ((intptr_t)((mp)->b_prev)) 312*7c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_SET_SACKCNT(mp, val) ((mp)->b_prev = \ 313*7c478bd9Sstevel@tonic-gate (mblk_t *)(uintptr_t)(val)) 314*7c478bd9Sstevel@tonic-gate 315*7c478bd9Sstevel@tonic-gate #define SCTP_MSG_SET_CHUNKED(mp) ((mp)->b_flag |= SCTP_MSG_FLAG_CHUNKED) 316*7c478bd9Sstevel@tonic-gate #define SCTP_MSG_CLEAR_CHUNKED(mp)((mp)->b_flag &= ~SCTP_MSG_FLAG_CHUNKED) 317*7c478bd9Sstevel@tonic-gate #define SCTP_IS_MSG_CHUNKED(mp) ((mp)->b_flag & SCTP_MSG_FLAG_CHUNKED) 318*7c478bd9Sstevel@tonic-gate 319*7c478bd9Sstevel@tonic-gate /* For PR-SCTP */ 320*7c478bd9Sstevel@tonic-gate #define SCTP_ABANDON_CHUNK(mp) ((mp)->b_flag |= SCTP_CHUNK_FLAG_ABANDONED) 321*7c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_ABANDONED(mp) \ 322*7c478bd9Sstevel@tonic-gate ((mp)->b_flag & SCTP_CHUNK_FLAG_ABANDONED) 323*7c478bd9Sstevel@tonic-gate 324*7c478bd9Sstevel@tonic-gate #define SCTP_MSG_SET_ABANDONED(mp) \ 325*7c478bd9Sstevel@tonic-gate ((mp)->b_flag |= SCTP_MSG_FLAG_ABANDONED) 326*7c478bd9Sstevel@tonic-gate #define SCTP_MSG_CLEAR_ABANDONED(mp)((mp)->b_flag &= ~SCTP_MSG_FLAG_ABANDONED) 327*7c478bd9Sstevel@tonic-gate #define SCTP_IS_MSG_ABANDONED(mp) ((mp)->b_flag & SCTP_MSG_FLAG_ABANDONED) 328*7c478bd9Sstevel@tonic-gate 329*7c478bd9Sstevel@tonic-gate /* 330*7c478bd9Sstevel@tonic-gate * Check if a message has expired. A message is expired if 331*7c478bd9Sstevel@tonic-gate * 1. It has a non-zero time to live value and has not been sent before 332*7c478bd9Sstevel@tonic-gate * that time expires. 333*7c478bd9Sstevel@tonic-gate * 2. It is sent using PRSCTP and it has not been SACK'ed before 334*7c478bd9Sstevel@tonic-gate * its lifetime expires. 335*7c478bd9Sstevel@tonic-gate */ 336*7c478bd9Sstevel@tonic-gate #define SCTP_MSG_TO_BE_ABANDONED(meta, mhdr, sctp) \ 337*7c478bd9Sstevel@tonic-gate (((!SCTP_CHUNK_ISSENT((meta)->b_cont) && (mhdr)->smh_ttl > 0) || \ 338*7c478bd9Sstevel@tonic-gate ((sctp)->sctp_prsctp_aware && ((mhdr)->smh_flags & MSG_PR_SCTP))) && \ 339*7c478bd9Sstevel@tonic-gate ((lbolt64 - (mhdr)->smh_tob) > (mhdr)->smh_ttl)) 340*7c478bd9Sstevel@tonic-gate 341*7c478bd9Sstevel@tonic-gate /* SCTP association hash function. */ 342*7c478bd9Sstevel@tonic-gate #define SCTP_CONN_HASH(ports) \ 343*7c478bd9Sstevel@tonic-gate ((((ports) ^ ((ports) >> 16)) * 31) & (sctp_conn_hash_size - 1)) 344*7c478bd9Sstevel@tonic-gate 345*7c478bd9Sstevel@tonic-gate /* 346*7c478bd9Sstevel@tonic-gate * Bind hash array size and hash function. The size must be a power 347*7c478bd9Sstevel@tonic-gate * of 2 and lport must be in host byte order. 348*7c478bd9Sstevel@tonic-gate */ 349*7c478bd9Sstevel@tonic-gate #define SCTP_BIND_FANOUT_SIZE 2048 350*7c478bd9Sstevel@tonic-gate #define SCTP_BIND_HASH(lport) (((lport) * 31) & (SCTP_BIND_FANOUT_SIZE - 1)) 351*7c478bd9Sstevel@tonic-gate 352*7c478bd9Sstevel@tonic-gate /* options that SCTP negotiates during association establishment */ 353*7c478bd9Sstevel@tonic-gate #define SCTP_PRSCTP_OPTION 0x01 354*7c478bd9Sstevel@tonic-gate 355*7c478bd9Sstevel@tonic-gate /* 356*7c478bd9Sstevel@tonic-gate * Listener hash array size and hash function. The size must be a power 357*7c478bd9Sstevel@tonic-gate * of 2 and lport must be in host byte order. 358*7c478bd9Sstevel@tonic-gate */ 359*7c478bd9Sstevel@tonic-gate #define SCTP_LISTEN_FANOUT_SIZE 512 360*7c478bd9Sstevel@tonic-gate #define SCTP_LISTEN_HASH(lport) (((lport) * 31) & (SCTP_LISTEN_FANOUT_SIZE - 1)) 361*7c478bd9Sstevel@tonic-gate 362*7c478bd9Sstevel@tonic-gate typedef struct sctp_tf_s { 363*7c478bd9Sstevel@tonic-gate struct sctp_s *tf_sctp; 364*7c478bd9Sstevel@tonic-gate kmutex_t tf_lock; 365*7c478bd9Sstevel@tonic-gate } sctp_tf_t; 366*7c478bd9Sstevel@tonic-gate 367*7c478bd9Sstevel@tonic-gate /* SCTP association hash list */ 368*7c478bd9Sstevel@tonic-gate extern sctp_tf_t *sctp_conn_fanout; 369*7c478bd9Sstevel@tonic-gate /* Size of sctp_conn_fanout */ 370*7c478bd9Sstevel@tonic-gate extern uint_t sctp_conn_hash_size; 371*7c478bd9Sstevel@tonic-gate 372*7c478bd9Sstevel@tonic-gate /* SCTP bind hash list - all sctp_t with state >= BOUND. */ 373*7c478bd9Sstevel@tonic-gate extern sctp_tf_t sctp_bind_fanout[]; 374*7c478bd9Sstevel@tonic-gate 375*7c478bd9Sstevel@tonic-gate /* SCTP listener hash list - all sctp_t with state == LISTEN. */ 376*7c478bd9Sstevel@tonic-gate extern sctp_tf_t sctp_listen_fanout[]; 377*7c478bd9Sstevel@tonic-gate 378*7c478bd9Sstevel@tonic-gate /* Round up the value to the nearest mss. */ 379*7c478bd9Sstevel@tonic-gate #define MSS_ROUNDUP(value, mss) ((((value) - 1) / (mss) + 1) * (mss)) 380*7c478bd9Sstevel@tonic-gate 381*7c478bd9Sstevel@tonic-gate extern sin_t sctp_sin_null; /* Zero address for quick clears */ 382*7c478bd9Sstevel@tonic-gate extern sin6_t sctp_sin6_null; /* Zero address for quick clears */ 383*7c478bd9Sstevel@tonic-gate 384*7c478bd9Sstevel@tonic-gate #define SCTP_IS_DETACHED(sctp) ((sctp)->sctp_detached) 385*7c478bd9Sstevel@tonic-gate 386*7c478bd9Sstevel@tonic-gate extern mib2_sctp_t sctp_mib; /* SNMP fixed size info */ 387*7c478bd9Sstevel@tonic-gate 388*7c478bd9Sstevel@tonic-gate /* 389*7c478bd9Sstevel@tonic-gate * Object to represent database of options to search passed to 390*7c478bd9Sstevel@tonic-gate * {sock,tpi}optcom_req() interface routine to take care of option 391*7c478bd9Sstevel@tonic-gate * management and associated methods. 392*7c478bd9Sstevel@tonic-gate * XXX These and other externs should ideally move to a SCTP header 393*7c478bd9Sstevel@tonic-gate */ 394*7c478bd9Sstevel@tonic-gate extern optdb_obj_t sctp_opt_obj; 395*7c478bd9Sstevel@tonic-gate extern uint_t sctp_max_optbuf_len; 396*7c478bd9Sstevel@tonic-gate 397*7c478bd9Sstevel@tonic-gate /* Data structure used to track received TSNs */ 398*7c478bd9Sstevel@tonic-gate typedef struct sctp_set_s { 399*7c478bd9Sstevel@tonic-gate struct sctp_set_s *next; 400*7c478bd9Sstevel@tonic-gate struct sctp_set_s *prev; 401*7c478bd9Sstevel@tonic-gate uint32_t begin; 402*7c478bd9Sstevel@tonic-gate uint32_t end; 403*7c478bd9Sstevel@tonic-gate } sctp_set_t; 404*7c478bd9Sstevel@tonic-gate 405*7c478bd9Sstevel@tonic-gate /* Data structure used to track TSNs for PR-SCTP */ 406*7c478bd9Sstevel@tonic-gate typedef struct sctp_ftsn_set_s { 407*7c478bd9Sstevel@tonic-gate struct sctp_ftsn_set_s *next; 408*7c478bd9Sstevel@tonic-gate ftsn_entry_t ftsn_entries; 409*7c478bd9Sstevel@tonic-gate } sctp_ftsn_set_t; 410*7c478bd9Sstevel@tonic-gate 411*7c478bd9Sstevel@tonic-gate /* Data structure used to track incoming SCTP streams */ 412*7c478bd9Sstevel@tonic-gate typedef struct sctp_instr_s { 413*7c478bd9Sstevel@tonic-gate mblk_t *istr_msgs; 414*7c478bd9Sstevel@tonic-gate int istr_nmsgs; 415*7c478bd9Sstevel@tonic-gate uint16_t nextseq; 416*7c478bd9Sstevel@tonic-gate struct sctp_s *sctp; 417*7c478bd9Sstevel@tonic-gate mblk_t *istr_reass; 418*7c478bd9Sstevel@tonic-gate } sctp_instr_t; 419*7c478bd9Sstevel@tonic-gate 420*7c478bd9Sstevel@tonic-gate /* Reassembly data structure (per-stream) */ 421*7c478bd9Sstevel@tonic-gate typedef struct sctp_reass_s { 422*7c478bd9Sstevel@tonic-gate uint16_t ssn; 423*7c478bd9Sstevel@tonic-gate uint16_t needed; 424*7c478bd9Sstevel@tonic-gate uint16_t got; 425*7c478bd9Sstevel@tonic-gate mblk_t *tail; 426*7c478bd9Sstevel@tonic-gate boolean_t partial_delivered; 427*7c478bd9Sstevel@tonic-gate } sctp_reass_t; 428*7c478bd9Sstevel@tonic-gate 429*7c478bd9Sstevel@tonic-gate /* debugging */ 430*7c478bd9Sstevel@tonic-gate #undef dprint 431*7c478bd9Sstevel@tonic-gate #if defined(DEBUG) && !defined(lint) 432*7c478bd9Sstevel@tonic-gate extern int sctpdebug; 433*7c478bd9Sstevel@tonic-gate 434*7c478bd9Sstevel@tonic-gate #define dprint(level, args) { if (sctpdebug > (level)) printf args; } 435*7c478bd9Sstevel@tonic-gate 436*7c478bd9Sstevel@tonic-gate #else /* define(DEBUG) && !defined(lint) */ 437*7c478bd9Sstevel@tonic-gate 438*7c478bd9Sstevel@tonic-gate #define dprint(level, args) {} 439*7c478bd9Sstevel@tonic-gate 440*7c478bd9Sstevel@tonic-gate #endif /* defined(DEBUG) && !defined(lint) */ 441*7c478bd9Sstevel@tonic-gate 442*7c478bd9Sstevel@tonic-gate 443*7c478bd9Sstevel@tonic-gate /* Peer address tracking */ 444*7c478bd9Sstevel@tonic-gate 445*7c478bd9Sstevel@tonic-gate /* 446*7c478bd9Sstevel@tonic-gate * States for peer addresses 447*7c478bd9Sstevel@tonic-gate * 448*7c478bd9Sstevel@tonic-gate * SCTP_FADDRS_UNCONFIRMED: we have not communicated with this peer address 449*7c478bd9Sstevel@tonic-gate * before, mark it as unconfirmed so that we will not send data to it. 450*7c478bd9Sstevel@tonic-gate * All addresses initially are in unconfirmed state and required 451*7c478bd9Sstevel@tonic-gate * validation. SCTP sends a heartbeat to each of them and when it gets 452*7c478bd9Sstevel@tonic-gate * back a heartbeat ACK, the address will be marked as alive. This 453*7c478bd9Sstevel@tonic-gate * validation fixes a security issue with multihoming. If an attacker 454*7c478bd9Sstevel@tonic-gate * establishes an association with us and tells us that it has addresses 455*7c478bd9Sstevel@tonic-gate * belonging to another host A, this will prevent A from communicating 456*7c478bd9Sstevel@tonic-gate * with us. This is fixed by peer address validation. In the above case, 457*7c478bd9Sstevel@tonic-gate * A will respond with an abort. 458*7c478bd9Sstevel@tonic-gate * 459*7c478bd9Sstevel@tonic-gate * SCTP_FADDRS_ALIVE: this peer address is alive and we can communicate with 460*7c478bd9Sstevel@tonic-gate * it with no problem. 461*7c478bd9Sstevel@tonic-gate * 462*7c478bd9Sstevel@tonic-gate * SCTP_FADDRS_DOWN: we have exceeded the retransmission limit to this 463*7c478bd9Sstevel@tonic-gate * peer address. Once an address is marked down, we will only send 464*7c478bd9Sstevel@tonic-gate * a heartbeat to it every hb_interval in case it becomes alive now. 465*7c478bd9Sstevel@tonic-gate * 466*7c478bd9Sstevel@tonic-gate * SCTP_FADDRS_UNREACH: there is no suitable source address to send to 467*7c478bd9Sstevel@tonic-gate * this peer address. For example, the peer address is v6 but we only 468*7c478bd9Sstevel@tonic-gate * have v4 addresses. It is marked unreachable until there is an 469*7c478bd9Sstevel@tonic-gate * address configuration change. At that time, mark these addresses 470*7c478bd9Sstevel@tonic-gate * as unconfirmed and try again to see if those unreachable addresses 471*7c478bd9Sstevel@tonic-gate * are OK as we may have more source addresses. 472*7c478bd9Sstevel@tonic-gate */ 473*7c478bd9Sstevel@tonic-gate typedef enum { 474*7c478bd9Sstevel@tonic-gate SCTP_FADDRS_UNREACH, 475*7c478bd9Sstevel@tonic-gate SCTP_FADDRS_DOWN, 476*7c478bd9Sstevel@tonic-gate SCTP_FADDRS_ALIVE, 477*7c478bd9Sstevel@tonic-gate SCTP_FADDRS_UNCONFIRMED 478*7c478bd9Sstevel@tonic-gate } faddr_state_t; 479*7c478bd9Sstevel@tonic-gate 480*7c478bd9Sstevel@tonic-gate typedef struct sctp_faddr_s { 481*7c478bd9Sstevel@tonic-gate struct sctp_faddr_s *next; 482*7c478bd9Sstevel@tonic-gate faddr_state_t state; 483*7c478bd9Sstevel@tonic-gate 484*7c478bd9Sstevel@tonic-gate in6_addr_t faddr; 485*7c478bd9Sstevel@tonic-gate in6_addr_t saddr; 486*7c478bd9Sstevel@tonic-gate 487*7c478bd9Sstevel@tonic-gate int64_t hb_expiry; /* time to retransmit heartbeat */ 488*7c478bd9Sstevel@tonic-gate uint32_t hb_interval; /* the heartbeat interval */ 489*7c478bd9Sstevel@tonic-gate 490*7c478bd9Sstevel@tonic-gate int rto; /* RTO in tick */ 491*7c478bd9Sstevel@tonic-gate int srtt; /* Smoothed RTT in tick */ 492*7c478bd9Sstevel@tonic-gate int rttvar; /* RTT variance in tick */ 493*7c478bd9Sstevel@tonic-gate uint32_t rtt_updates; 494*7c478bd9Sstevel@tonic-gate int strikes; 495*7c478bd9Sstevel@tonic-gate int max_retr; 496*7c478bd9Sstevel@tonic-gate uint32_t sfa_pmss; 497*7c478bd9Sstevel@tonic-gate uint32_t cwnd; 498*7c478bd9Sstevel@tonic-gate uint32_t ssthresh; 499*7c478bd9Sstevel@tonic-gate uint32_t suna; /* sent - unack'ed */ 500*7c478bd9Sstevel@tonic-gate uint32_t pba; /* partial bytes acked */ 501*7c478bd9Sstevel@tonic-gate uint32_t acked; 502*7c478bd9Sstevel@tonic-gate int64_t lastactive; 503*7c478bd9Sstevel@tonic-gate mblk_t *timer_mp; /* retransmission timer control */ 504*7c478bd9Sstevel@tonic-gate uint32_t 505*7c478bd9Sstevel@tonic-gate hb_pending : 1, 506*7c478bd9Sstevel@tonic-gate timer_running : 1, 507*7c478bd9Sstevel@tonic-gate df : 1, 508*7c478bd9Sstevel@tonic-gate pmtu_discovered : 1, 509*7c478bd9Sstevel@tonic-gate 510*7c478bd9Sstevel@tonic-gate rc_timer_running : 1, 511*7c478bd9Sstevel@tonic-gate isv4 : 1; 512*7c478bd9Sstevel@tonic-gate 513*7c478bd9Sstevel@tonic-gate mblk_t *rc_timer_mp; /* reliable control chunk timer */ 514*7c478bd9Sstevel@tonic-gate ire_t *ire; /* cached IRE */ 515*7c478bd9Sstevel@tonic-gate uint32_t T3expire; /* # of times T3 timer expired */ 516*7c478bd9Sstevel@tonic-gate 517*7c478bd9Sstevel@tonic-gate uint64_t hb_secret; /* per addr "secret" in heartbeat */ 518*7c478bd9Sstevel@tonic-gate } sctp_faddr_t; 519*7c478bd9Sstevel@tonic-gate 520*7c478bd9Sstevel@tonic-gate /* Flags to indicate supported address type in the PARM_SUP_ADDRS. */ 521*7c478bd9Sstevel@tonic-gate #define PARM_SUPP_V6 0x1 522*7c478bd9Sstevel@tonic-gate #define PARM_SUPP_V4 0x2 523*7c478bd9Sstevel@tonic-gate 524*7c478bd9Sstevel@tonic-gate /* 525*7c478bd9Sstevel@tonic-gate * Set heartbeat interval plus jitter. The jitter is supposed to be random, 526*7c478bd9Sstevel@tonic-gate * up to +/- 50% of the RTO. We use gethrtime() here for performance reason 527*7c478bd9Sstevel@tonic-gate * as the jitter does not really need to be "very" random. 528*7c478bd9Sstevel@tonic-gate */ 529*7c478bd9Sstevel@tonic-gate #define SET_HB_INTVL(fp) \ 530*7c478bd9Sstevel@tonic-gate ((fp)->hb_interval + (fp)->rto + ((fp)->rto >> 1) - \ 531*7c478bd9Sstevel@tonic-gate (uint_t)gethrtime() % (fp)->rto); 532*7c478bd9Sstevel@tonic-gate 533*7c478bd9Sstevel@tonic-gate #define SCTP_IPIF_HASH 16 534*7c478bd9Sstevel@tonic-gate 535*7c478bd9Sstevel@tonic-gate typedef struct sctp_ipif_hash_s { 536*7c478bd9Sstevel@tonic-gate list_t sctp_ipif_list; 537*7c478bd9Sstevel@tonic-gate int ipif_count; 538*7c478bd9Sstevel@tonic-gate } sctp_ipif_hash_t; 539*7c478bd9Sstevel@tonic-gate 540*7c478bd9Sstevel@tonic-gate struct sctp_s; 541*7c478bd9Sstevel@tonic-gate 542*7c478bd9Sstevel@tonic-gate /* 543*7c478bd9Sstevel@tonic-gate * Control structure for each open SCTP stream, 544*7c478bd9Sstevel@tonic-gate * defined only within the kernel or for a kmem user. 545*7c478bd9Sstevel@tonic-gate * NOTE: sctp_reinit_values MUST have a line for each field in this structure! 546*7c478bd9Sstevel@tonic-gate */ 547*7c478bd9Sstevel@tonic-gate #if (defined(_KERNEL) || defined(_KMEMUSER)) 548*7c478bd9Sstevel@tonic-gate 549*7c478bd9Sstevel@tonic-gate typedef struct sctp_s { 550*7c478bd9Sstevel@tonic-gate 551*7c478bd9Sstevel@tonic-gate /* 552*7c478bd9Sstevel@tonic-gate * The following is shared with (and duplicated) in IP, so if you 553*7c478bd9Sstevel@tonic-gate * make changes, make sure you also change things in ip_sctp.c. 554*7c478bd9Sstevel@tonic-gate */ 555*7c478bd9Sstevel@tonic-gate struct sctp_s *sctp_conn_hash_next; 556*7c478bd9Sstevel@tonic-gate struct sctp_s *sctp_conn_hash_prev; 557*7c478bd9Sstevel@tonic-gate 558*7c478bd9Sstevel@tonic-gate struct sctp_s *sctp_listen_hash_next; 559*7c478bd9Sstevel@tonic-gate struct sctp_s *sctp_listen_hash_prev; 560*7c478bd9Sstevel@tonic-gate 561*7c478bd9Sstevel@tonic-gate sctp_tf_t *sctp_listen_tfp; /* Ptr to tf */ 562*7c478bd9Sstevel@tonic-gate sctp_tf_t *sctp_conn_tfp; /* Ptr to tf */ 563*7c478bd9Sstevel@tonic-gate 564*7c478bd9Sstevel@tonic-gate /* Global list of sctp */ 565*7c478bd9Sstevel@tonic-gate list_node_t sctp_list; 566*7c478bd9Sstevel@tonic-gate 567*7c478bd9Sstevel@tonic-gate sctp_faddr_t *sctp_faddrs; 568*7c478bd9Sstevel@tonic-gate sctp_ipif_hash_t sctp_saddrs[SCTP_IPIF_HASH]; 569*7c478bd9Sstevel@tonic-gate int sctp_nsaddrs; 570*7c478bd9Sstevel@tonic-gate 571*7c478bd9Sstevel@tonic-gate /* 572*7c478bd9Sstevel@tonic-gate * These fields contain the same information as sctp_sctph->th_*port. 573*7c478bd9Sstevel@tonic-gate * However, the lookup functions can not use the header fields 574*7c478bd9Sstevel@tonic-gate * since during IP option manipulation the sctp_sctph pointer 575*7c478bd9Sstevel@tonic-gate * changes. 576*7c478bd9Sstevel@tonic-gate */ 577*7c478bd9Sstevel@tonic-gate union { 578*7c478bd9Sstevel@tonic-gate struct { 579*7c478bd9Sstevel@tonic-gate in_port_t sctpu_fport; /* Remote port */ 580*7c478bd9Sstevel@tonic-gate in_port_t sctpu_lport; /* Local port */ 581*7c478bd9Sstevel@tonic-gate } sctpu_ports1; 582*7c478bd9Sstevel@tonic-gate uint32_t sctpu_ports2; /* Rem port, */ 583*7c478bd9Sstevel@tonic-gate /* local port */ 584*7c478bd9Sstevel@tonic-gate /* Used for SCTP_MATCH performance */ 585*7c478bd9Sstevel@tonic-gate } sctp_sctpu; 586*7c478bd9Sstevel@tonic-gate #define sctp_fport sctp_sctpu.sctpu_ports1.sctpu_fport 587*7c478bd9Sstevel@tonic-gate #define sctp_lport sctp_sctpu.sctpu_ports1.sctpu_lport 588*7c478bd9Sstevel@tonic-gate #define sctp_ports sctp_sctpu.sctpu_ports2 589*7c478bd9Sstevel@tonic-gate 590*7c478bd9Sstevel@tonic-gate kmutex_t sctp_lock; 591*7c478bd9Sstevel@tonic-gate kcondvar_t sctp_cv; 592*7c478bd9Sstevel@tonic-gate boolean_t sctp_running; 593*7c478bd9Sstevel@tonic-gate 594*7c478bd9Sstevel@tonic-gate void *sctp_ulpd; /* SCTP upper layer desc. */ 595*7c478bd9Sstevel@tonic-gate 596*7c478bd9Sstevel@tonic-gate struct sctp_upcalls_s sctp_upcalls; /* upcalls for sctp_ulpd */ 597*7c478bd9Sstevel@tonic-gate #define sctp_ulp_newconn sctp_upcalls.su_newconn 598*7c478bd9Sstevel@tonic-gate #define sctp_ulp_connected sctp_upcalls.su_connected 599*7c478bd9Sstevel@tonic-gate #define sctp_ulp_disconnected sctp_upcalls.su_disconnected 600*7c478bd9Sstevel@tonic-gate #define sctp_ulp_disconnecting sctp_upcalls.su_disconnecting 601*7c478bd9Sstevel@tonic-gate #define sctp_ulp_recv sctp_upcalls.su_recv 602*7c478bd9Sstevel@tonic-gate #define sctp_ulp_xmitted sctp_upcalls.su_xmitted 603*7c478bd9Sstevel@tonic-gate #define sctp_ulp_prop sctp_upcalls.su_properties 604*7c478bd9Sstevel@tonic-gate 605*7c478bd9Sstevel@tonic-gate int32_t sctp_state; 606*7c478bd9Sstevel@tonic-gate 607*7c478bd9Sstevel@tonic-gate conn_t *sctp_connp; /* conn_t stuff */ 608*7c478bd9Sstevel@tonic-gate #define sctp_zoneid sctp_connp->conn_zoneid 609*7c478bd9Sstevel@tonic-gate #define sctp_credp sctp_connp->conn_cred 610*7c478bd9Sstevel@tonic-gate 611*7c478bd9Sstevel@tonic-gate /* Peer address tracking */ 612*7c478bd9Sstevel@tonic-gate sctp_faddr_t *sctp_lastfaddr; /* last faddr in list */ 613*7c478bd9Sstevel@tonic-gate sctp_faddr_t *sctp_primary; /* primary faddr */ 614*7c478bd9Sstevel@tonic-gate sctp_faddr_t *sctp_current; /* current faddr */ 615*7c478bd9Sstevel@tonic-gate sctp_faddr_t *sctp_lastdata; /* last data seen from this */ 616*7c478bd9Sstevel@tonic-gate 617*7c478bd9Sstevel@tonic-gate /* Outbound data tracking */ 618*7c478bd9Sstevel@tonic-gate mblk_t *sctp_xmit_head; 619*7c478bd9Sstevel@tonic-gate mblk_t *sctp_xmit_tail; 620*7c478bd9Sstevel@tonic-gate mblk_t *sctp_xmit_unsent; 621*7c478bd9Sstevel@tonic-gate mblk_t *sctp_xmit_unsent_tail; 622*7c478bd9Sstevel@tonic-gate mblk_t *sctp_xmit_unacked; 623*7c478bd9Sstevel@tonic-gate 624*7c478bd9Sstevel@tonic-gate int32_t sctp_unacked; /* # of unacked bytes */ 625*7c478bd9Sstevel@tonic-gate int32_t sctp_unsent; /* # of unsent bytes in hand */ 626*7c478bd9Sstevel@tonic-gate 627*7c478bd9Sstevel@tonic-gate uint32_t sctp_ltsn; /* Local instance TSN */ 628*7c478bd9Sstevel@tonic-gate uint32_t sctp_lastack_rxd; /* Last rx'd cumtsn */ 629*7c478bd9Sstevel@tonic-gate uint32_t sctp_recovery_tsn; /* Exit from fast recovery */ 630*7c478bd9Sstevel@tonic-gate uint32_t sctp_adv_pap; /* Adv. Peer Ack Point */ 631*7c478bd9Sstevel@tonic-gate 632*7c478bd9Sstevel@tonic-gate uint16_t sctp_num_ostr; 633*7c478bd9Sstevel@tonic-gate uint16_t *sctp_ostrcntrs; 634*7c478bd9Sstevel@tonic-gate 635*7c478bd9Sstevel@tonic-gate /* sendmsg() default parameters */ 636*7c478bd9Sstevel@tonic-gate uint16_t sctp_def_stream; /* default stream id */ 637*7c478bd9Sstevel@tonic-gate uint16_t sctp_def_flags; /* default xmit flags */ 638*7c478bd9Sstevel@tonic-gate uint32_t sctp_def_ppid; /* default payload id */ 639*7c478bd9Sstevel@tonic-gate uint32_t sctp_def_context; /* default context */ 640*7c478bd9Sstevel@tonic-gate uint32_t sctp_def_timetolive; /* default msg TTL */ 641*7c478bd9Sstevel@tonic-gate 642*7c478bd9Sstevel@tonic-gate /* Inbound data tracking */ 643*7c478bd9Sstevel@tonic-gate sctp_set_t *sctp_sack_info; /* Sack tracking */ 644*7c478bd9Sstevel@tonic-gate mblk_t *sctp_ack_mp; /* Delayed ACK timer block */ 645*7c478bd9Sstevel@tonic-gate sctp_instr_t *sctp_instr; /* Instream trackers */ 646*7c478bd9Sstevel@tonic-gate mblk_t *sctp_uo_frags; /* Un-ordered msg. fragments */ 647*7c478bd9Sstevel@tonic-gate uint32_t sctp_ftsn; /* Peer's TSN */ 648*7c478bd9Sstevel@tonic-gate uint32_t sctp_lastacked; /* last cumtsn SACKd */ 649*7c478bd9Sstevel@tonic-gate uint16_t sctp_num_istr; /* No. of instreams */ 650*7c478bd9Sstevel@tonic-gate int32_t sctp_istr_nmsgs; /* No. of chunks in instreams */ 651*7c478bd9Sstevel@tonic-gate int32_t sctp_sack_gaps; /* No. of received gaps */ 652*7c478bd9Sstevel@tonic-gate int32_t sctp_sack_toggle; /* SACK every other pkt */ 653*7c478bd9Sstevel@tonic-gate 654*7c478bd9Sstevel@tonic-gate /* RTT calculation */ 655*7c478bd9Sstevel@tonic-gate uint32_t sctp_rtt_tsn; 656*7c478bd9Sstevel@tonic-gate int64_t sctp_out_time; 657*7c478bd9Sstevel@tonic-gate 658*7c478bd9Sstevel@tonic-gate /* Stats */ 659*7c478bd9Sstevel@tonic-gate uint64_t sctp_opkts; /* sent pkts */ 660*7c478bd9Sstevel@tonic-gate uint64_t sctp_obchunks; /* sent control chunks */ 661*7c478bd9Sstevel@tonic-gate uint64_t sctp_odchunks; /* sent ordered data chunks */ 662*7c478bd9Sstevel@tonic-gate uint64_t sctp_oudchunks; /* sent unord data chunks */ 663*7c478bd9Sstevel@tonic-gate uint64_t sctp_rxtchunks; /* retransmitted chunks */ 664*7c478bd9Sstevel@tonic-gate uint64_t sctp_ipkts; /* recv pkts */ 665*7c478bd9Sstevel@tonic-gate uint64_t sctp_ibchunks; /* recv control chunks */ 666*7c478bd9Sstevel@tonic-gate uint64_t sctp_idchunks; /* recv ordered data chunks */ 667*7c478bd9Sstevel@tonic-gate uint64_t sctp_iudchunks; /* recv unord data chunks */ 668*7c478bd9Sstevel@tonic-gate uint64_t sctp_fragdmsgs; 669*7c478bd9Sstevel@tonic-gate uint64_t sctp_reassmsgs; 670*7c478bd9Sstevel@tonic-gate uint32_t sctp_T1expire; /* # of times T1timer expired */ 671*7c478bd9Sstevel@tonic-gate uint32_t sctp_T2expire; /* # of times T2timer expired */ 672*7c478bd9Sstevel@tonic-gate uint32_t sctp_T3expire; /* # of times T3timer expired */ 673*7c478bd9Sstevel@tonic-gate uint32_t sctp_assoc_start_time; /* time when assoc was est. */ 674*7c478bd9Sstevel@tonic-gate 675*7c478bd9Sstevel@tonic-gate /* Outbound flow control */ 676*7c478bd9Sstevel@tonic-gate int32_t sctp_xmit_hiwater; /* Send high water mark */ 677*7c478bd9Sstevel@tonic-gate int32_t sctp_xmit_lowater; /* Send low water mark */ 678*7c478bd9Sstevel@tonic-gate uint32_t sctp_frwnd; /* Peer RWND */ 679*7c478bd9Sstevel@tonic-gate uint32_t sctp_cwnd_max; 680*7c478bd9Sstevel@tonic-gate 681*7c478bd9Sstevel@tonic-gate /* Inbound flow control */ 682*7c478bd9Sstevel@tonic-gate int32_t sctp_rwnd; /* Current receive window */ 683*7c478bd9Sstevel@tonic-gate int32_t sctp_rxqueued; /* No. of bytes in RX q's */ 684*7c478bd9Sstevel@tonic-gate 685*7c478bd9Sstevel@tonic-gate /* Pre-initialized composite headers */ 686*7c478bd9Sstevel@tonic-gate char *sctp_iphc; /* v4 sctp/ip hdr template buffer */ 687*7c478bd9Sstevel@tonic-gate char *sctp_iphc6; /* v6 sctp/ip hdr template buffer */ 688*7c478bd9Sstevel@tonic-gate 689*7c478bd9Sstevel@tonic-gate int32_t sctp_iphc_len; /* actual allocated v4 buffer size */ 690*7c478bd9Sstevel@tonic-gate int32_t sctp_iphc6_len; /* actual allocated v6 buffer size */ 691*7c478bd9Sstevel@tonic-gate 692*7c478bd9Sstevel@tonic-gate int32_t sctp_hdr_len; /* len of combined SCTP/IP v4 hdr */ 693*7c478bd9Sstevel@tonic-gate int32_t sctp_hdr6_len; /* len of combined SCTP/IP v6 hdr */ 694*7c478bd9Sstevel@tonic-gate 695*7c478bd9Sstevel@tonic-gate ipha_t *sctp_ipha; /* IPv4 header in the buffer */ 696*7c478bd9Sstevel@tonic-gate ip6_t *sctp_ip6h; /* IPv6 header in the buffer */ 697*7c478bd9Sstevel@tonic-gate 698*7c478bd9Sstevel@tonic-gate int32_t sctp_ip_hdr_len; /* Byte len of our current v4 hdr */ 699*7c478bd9Sstevel@tonic-gate int32_t sctp_ip_hdr6_len; /* Byte len of our current v6 hdr */ 700*7c478bd9Sstevel@tonic-gate 701*7c478bd9Sstevel@tonic-gate sctp_hdr_t *sctp_sctph; /* sctp header in combined v4 hdr */ 702*7c478bd9Sstevel@tonic-gate sctp_hdr_t *sctp_sctph6; /* sctp header in combined v6 hdr */ 703*7c478bd9Sstevel@tonic-gate 704*7c478bd9Sstevel@tonic-gate uint32_t sctp_lvtag; /* local SCTP instance verf tag */ 705*7c478bd9Sstevel@tonic-gate uint32_t sctp_fvtag; /* Peer's SCTP verf tag */ 706*7c478bd9Sstevel@tonic-gate 707*7c478bd9Sstevel@tonic-gate /* Path MTU Discovery */ 708*7c478bd9Sstevel@tonic-gate int64_t sctp_last_mtu_probe; 709*7c478bd9Sstevel@tonic-gate clock_t sctp_mtu_probe_intvl; 710*7c478bd9Sstevel@tonic-gate uint32_t sctp_mss; /* Max send size (not TCP MSS!) */ 711*7c478bd9Sstevel@tonic-gate 712*7c478bd9Sstevel@tonic-gate /* structs sctp_bits, sctp_events are for clearing all bits at once */ 713*7c478bd9Sstevel@tonic-gate struct { 714*7c478bd9Sstevel@tonic-gate uint32_t 715*7c478bd9Sstevel@tonic-gate 716*7c478bd9Sstevel@tonic-gate sctp_understands_asconf : 1, /* Peer handles ASCONF chunks */ 717*7c478bd9Sstevel@tonic-gate sctp_debug : 1, /* SO_DEBUG "socket" option. */ 718*7c478bd9Sstevel@tonic-gate sctp_dontroute : 1, /* SO_DONTROUTE "socket" option. */ 719*7c478bd9Sstevel@tonic-gate sctp_broadcast : 1, /* SO_BROADCAST "socket" option. */ 720*7c478bd9Sstevel@tonic-gate 721*7c478bd9Sstevel@tonic-gate sctp_useloopback : 1, /* SO_USELOOPBACK "socket" option. */ 722*7c478bd9Sstevel@tonic-gate sctp_cchunk_pend : 1, /* Control chunk in flight. */ 723*7c478bd9Sstevel@tonic-gate sctp_dgram_errind : 1, /* SO_DGRAM_ERRIND option */ 724*7c478bd9Sstevel@tonic-gate sctp_reuseaddr : 1, /* SO_REUSEADDR "socket" option. */ 725*7c478bd9Sstevel@tonic-gate 726*7c478bd9Sstevel@tonic-gate sctp_linger : 1, /* SO_LINGER turned on */ 727*7c478bd9Sstevel@tonic-gate sctp_lingering : 1, /* Lingering in close */ 728*7c478bd9Sstevel@tonic-gate sctp_loopback: 1, /* src and dst are the same machine */ 729*7c478bd9Sstevel@tonic-gate sctp_force_sack : 1, 730*7c478bd9Sstevel@tonic-gate 731*7c478bd9Sstevel@tonic-gate sctp_ack_timer_running: 1, /* Delayed ACK timer running */ 732*7c478bd9Sstevel@tonic-gate sctp_recvdstaddr : 1, /* return T_EXTCONN_IND with dstaddr */ 733*7c478bd9Sstevel@tonic-gate sctp_hwcksum : 1, /* The NIC is capable of hwcksum */ 734*7c478bd9Sstevel@tonic-gate sctp_understands_addip : 1, 735*7c478bd9Sstevel@tonic-gate 736*7c478bd9Sstevel@tonic-gate sctp_bound_to_all : 1, 737*7c478bd9Sstevel@tonic-gate sctp_cansleep : 1, /* itf routines can sleep */ 738*7c478bd9Sstevel@tonic-gate sctp_detached : 1, /* If we're detached from a stream */ 739*7c478bd9Sstevel@tonic-gate sctp_send_adaption : 1, /* send adaption layer ind */ 740*7c478bd9Sstevel@tonic-gate 741*7c478bd9Sstevel@tonic-gate sctp_recv_adaption : 1, /* received adaption layer ind */ 742*7c478bd9Sstevel@tonic-gate sctp_ndelay : 1, /* turn off Nagle */ 743*7c478bd9Sstevel@tonic-gate sctp_condemned : 1, /* this sctp is about to disappear */ 744*7c478bd9Sstevel@tonic-gate sctp_chk_fast_rexmit : 1, /* check for fast rexmit message */ 745*7c478bd9Sstevel@tonic-gate sctp_prsctp_aware : 1; /* is peer PR-SCTP aware? */ 746*7c478bd9Sstevel@tonic-gate } sctp_bits; 747*7c478bd9Sstevel@tonic-gate struct { 748*7c478bd9Sstevel@tonic-gate uint32_t 749*7c478bd9Sstevel@tonic-gate 750*7c478bd9Sstevel@tonic-gate sctp_recvsndrcvinfo : 1, 751*7c478bd9Sstevel@tonic-gate sctp_recvassocevnt : 1, 752*7c478bd9Sstevel@tonic-gate sctp_recvpathevnt : 1, 753*7c478bd9Sstevel@tonic-gate sctp_recvsendfailevnt : 1, 754*7c478bd9Sstevel@tonic-gate 755*7c478bd9Sstevel@tonic-gate sctp_recvpeererr : 1, 756*7c478bd9Sstevel@tonic-gate sctp_recvshutdownevnt : 1, 757*7c478bd9Sstevel@tonic-gate sctp_recvpdevnt : 1, 758*7c478bd9Sstevel@tonic-gate sctp_recvalevnt : 1; 759*7c478bd9Sstevel@tonic-gate } sctp_events; 760*7c478bd9Sstevel@tonic-gate #define sctp_priv_stream sctp_bits.sctp_priv_stream 761*7c478bd9Sstevel@tonic-gate #define sctp_understands_asconf sctp_bits.sctp_understands_asconf 762*7c478bd9Sstevel@tonic-gate #define sctp_debug sctp_bits.sctp_debug 763*7c478bd9Sstevel@tonic-gate #define sctp_dontroute sctp_bits.sctp_dontroute 764*7c478bd9Sstevel@tonic-gate #define sctp_broadcast sctp_bits.sctp_broadcast 765*7c478bd9Sstevel@tonic-gate #define sctp_useloopback sctp_bits.sctp_useloopback 766*7c478bd9Sstevel@tonic-gate #define sctp_cchunk_pend sctp_bits.sctp_cchunk_pend 767*7c478bd9Sstevel@tonic-gate #define sctp_dgram_errind sctp_bits.sctp_dgram_errind 768*7c478bd9Sstevel@tonic-gate #define sctp_reuseaddr sctp_bits.sctp_reuseaddr 769*7c478bd9Sstevel@tonic-gate #define sctp_linger sctp_bits.sctp_linger 770*7c478bd9Sstevel@tonic-gate #define sctp_lingering sctp_bits.sctp_lingering 771*7c478bd9Sstevel@tonic-gate #define sctp_loopback sctp_bits.sctp_loopback 772*7c478bd9Sstevel@tonic-gate #define sctp_force_sack sctp_bits.sctp_force_sack 773*7c478bd9Sstevel@tonic-gate #define sctp_ack_timer_running sctp_bits.sctp_ack_timer_running 774*7c478bd9Sstevel@tonic-gate #define sctp_recvdstaddr sctp_bits.sctp_recvdstaddr 775*7c478bd9Sstevel@tonic-gate #define sctp_hwcksum sctp_bits.sctp_hwcksum 776*7c478bd9Sstevel@tonic-gate #define sctp_understands_addip sctp_bits.sctp_understands_addip 777*7c478bd9Sstevel@tonic-gate #define sctp_bound_to_all sctp_bits.sctp_bound_to_all 778*7c478bd9Sstevel@tonic-gate #define sctp_cansleep sctp_bits.sctp_cansleep 779*7c478bd9Sstevel@tonic-gate #define sctp_detached sctp_bits.sctp_detached 780*7c478bd9Sstevel@tonic-gate #define sctp_send_adaption sctp_bits.sctp_send_adaption 781*7c478bd9Sstevel@tonic-gate #define sctp_recv_adaption sctp_bits.sctp_recv_adaption 782*7c478bd9Sstevel@tonic-gate #define sctp_ndelay sctp_bits.sctp_ndelay 783*7c478bd9Sstevel@tonic-gate #define sctp_condemned sctp_bits.sctp_condemned 784*7c478bd9Sstevel@tonic-gate #define sctp_chk_fast_rexmit sctp_bits.sctp_chk_fast_rexmit 785*7c478bd9Sstevel@tonic-gate #define sctp_prsctp_aware sctp_bits.sctp_prsctp_aware 786*7c478bd9Sstevel@tonic-gate 787*7c478bd9Sstevel@tonic-gate #define sctp_recvsndrcvinfo sctp_events.sctp_recvsndrcvinfo 788*7c478bd9Sstevel@tonic-gate #define sctp_recvassocevnt sctp_events.sctp_recvassocevnt 789*7c478bd9Sstevel@tonic-gate #define sctp_recvpathevnt sctp_events.sctp_recvpathevnt 790*7c478bd9Sstevel@tonic-gate #define sctp_recvsendfailevnt sctp_events.sctp_recvsendfailevnt 791*7c478bd9Sstevel@tonic-gate #define sctp_recvpeererr sctp_events.sctp_recvpeererr 792*7c478bd9Sstevel@tonic-gate #define sctp_recvshutdownevnt sctp_events.sctp_recvshutdownevnt 793*7c478bd9Sstevel@tonic-gate #define sctp_recvpdevnt sctp_events.sctp_recvpdevnt 794*7c478bd9Sstevel@tonic-gate #define sctp_recvalevnt sctp_events.sctp_recvalevnt 795*7c478bd9Sstevel@tonic-gate 796*7c478bd9Sstevel@tonic-gate /* Retransmit info */ 797*7c478bd9Sstevel@tonic-gate mblk_t *sctp_cookie_mp; /* cookie chunk, if rxt needed */ 798*7c478bd9Sstevel@tonic-gate int32_t sctp_strikes; /* Total number of assoc strikes */ 799*7c478bd9Sstevel@tonic-gate int32_t sctp_max_init_rxt; 800*7c478bd9Sstevel@tonic-gate int32_t sctp_pa_max_rxt; /* Max per-assoc retransmit cnt */ 801*7c478bd9Sstevel@tonic-gate int32_t sctp_pp_max_rxt; /* Max per-path retransmit cnt */ 802*7c478bd9Sstevel@tonic-gate uint32_t sctp_rto_max; 803*7c478bd9Sstevel@tonic-gate uint32_t sctp_init_rto_max; 804*7c478bd9Sstevel@tonic-gate uint32_t sctp_rto_min; 805*7c478bd9Sstevel@tonic-gate uint32_t sctp_rto_initial; 806*7c478bd9Sstevel@tonic-gate 807*7c478bd9Sstevel@tonic-gate int64_t sctp_last_secret_update; 808*7c478bd9Sstevel@tonic-gate uint8_t sctp_secret[SCTP_SECRET_LEN]; /* for cookie auth */ 809*7c478bd9Sstevel@tonic-gate uint8_t sctp_old_secret[SCTP_SECRET_LEN]; 810*7c478bd9Sstevel@tonic-gate uint32_t sctp_cookie_lifetime; /* cookie lifetime in ms */ 811*7c478bd9Sstevel@tonic-gate 812*7c478bd9Sstevel@tonic-gate /* 813*7c478bd9Sstevel@tonic-gate * Address family that app wishes returned addrsses to be in. 814*7c478bd9Sstevel@tonic-gate * Currently taken from address family used in T_BIND_REQ, but 815*7c478bd9Sstevel@tonic-gate * should really come from family used in original socket() call. 816*7c478bd9Sstevel@tonic-gate * Value can be AF_INET or AF_INET6. 817*7c478bd9Sstevel@tonic-gate */ 818*7c478bd9Sstevel@tonic-gate uint_t sctp_family; 819*7c478bd9Sstevel@tonic-gate ushort_t sctp_ipversion; 820*7c478bd9Sstevel@tonic-gate 821*7c478bd9Sstevel@tonic-gate /* Bind hash tables */ 822*7c478bd9Sstevel@tonic-gate kmutex_t *sctp_bind_lockp; /* Ptr to tf_lock */ 823*7c478bd9Sstevel@tonic-gate struct sctp_s *sctp_bind_hash; 824*7c478bd9Sstevel@tonic-gate struct sctp_s **sctp_ptpbhn; 825*7c478bd9Sstevel@tonic-gate 826*7c478bd9Sstevel@tonic-gate /* Shutdown / cleanup */ 827*7c478bd9Sstevel@tonic-gate sctp_faddr_t *sctp_shutdown_faddr; /* rotate faddr during shutd */ 828*7c478bd9Sstevel@tonic-gate int32_t sctp_client_errno; /* How the client screwed up */ 829*7c478bd9Sstevel@tonic-gate int sctp_lingertime; /* Close linger time (in seconds) */ 830*7c478bd9Sstevel@tonic-gate kmutex_t sctp_reflock; /* Protects sctp_refcnt & timer mp */ 831*7c478bd9Sstevel@tonic-gate ushort_t sctp_refcnt; /* No. of pending upstream msg */ 832*7c478bd9Sstevel@tonic-gate mblk_t *sctp_timer_mp; /* List of fired timers. */ 833*7c478bd9Sstevel@tonic-gate 834*7c478bd9Sstevel@tonic-gate /* Misc */ 835*7c478bd9Sstevel@tonic-gate uint_t sctp_bound_if; /* IPV6_BOUND_IF */ 836*7c478bd9Sstevel@tonic-gate 837*7c478bd9Sstevel@tonic-gate mblk_t *sctp_heartbeat_mp; /* Timer block for heartbeats */ 838*7c478bd9Sstevel@tonic-gate uint32_t sctp_hb_interval; /* Default hb_interval */ 839*7c478bd9Sstevel@tonic-gate 840*7c478bd9Sstevel@tonic-gate int32_t sctp_autoclose; /* Auto disconnect in ticks */ 841*7c478bd9Sstevel@tonic-gate int64_t sctp_active; /* Last time data/sack on this conn */ 842*7c478bd9Sstevel@tonic-gate uint32_t sctp_tx_adaption_code; /* TX adaptation code */ 843*7c478bd9Sstevel@tonic-gate uint32_t sctp_rx_adaption_code; /* RX adaptation code */ 844*7c478bd9Sstevel@tonic-gate 845*7c478bd9Sstevel@tonic-gate /* Reliable control chunks */ 846*7c478bd9Sstevel@tonic-gate mblk_t *sctp_cxmit_list; /* Xmit list for control chunks */ 847*7c478bd9Sstevel@tonic-gate uint32_t sctp_lcsn; /* Our serial number */ 848*7c478bd9Sstevel@tonic-gate uint32_t sctp_fcsn; /* Peer serial number */ 849*7c478bd9Sstevel@tonic-gate 850*7c478bd9Sstevel@tonic-gate /* Per association receive queue */ 851*7c478bd9Sstevel@tonic-gate kmutex_t sctp_recvq_lock; 852*7c478bd9Sstevel@tonic-gate mblk_t *sctp_recvq; 853*7c478bd9Sstevel@tonic-gate mblk_t *sctp_recvq_tail; 854*7c478bd9Sstevel@tonic-gate taskq_t *sctp_recvq_tq; 855*7c478bd9Sstevel@tonic-gate 856*7c478bd9Sstevel@tonic-gate /* Send queue to IP */ 857*7c478bd9Sstevel@tonic-gate kmutex_t sctp_sendq_lock; 858*7c478bd9Sstevel@tonic-gate mblk_t *sctp_sendq; 859*7c478bd9Sstevel@tonic-gate mblk_t *sctp_sendq_tail; 860*7c478bd9Sstevel@tonic-gate boolean_t sctp_sendq_sending; 861*7c478bd9Sstevel@tonic-gate 862*7c478bd9Sstevel@tonic-gate /* IPv6 ancillary data */ 863*7c478bd9Sstevel@tonic-gate uint_t sctp_ipv6_recvancillary; /* flags */ 864*7c478bd9Sstevel@tonic-gate #define SCTP_IPV6_RECVPKTINFO 0x01 /* IPV6_RECVPKTINFO opt */ 865*7c478bd9Sstevel@tonic-gate #define SCTP_IPV6_RECVHOPLIMIT 0x02 /* IPV6_RECVHOPLIMIT opt */ 866*7c478bd9Sstevel@tonic-gate #define SCTP_IPV6_RECVHOPOPTS 0x04 /* IPV6_RECVHOPOPTS opt */ 867*7c478bd9Sstevel@tonic-gate #define SCTP_IPV6_RECVDSTOPTS 0x08 /* IPV6_RECVDSTOPTS opt */ 868*7c478bd9Sstevel@tonic-gate #define SCTP_IPV6_RECVRTHDR 0x10 /* IPV6_RECVRTHDR opt */ 869*7c478bd9Sstevel@tonic-gate #define SCTP_IPV6_RECVRTDSTOPTS 0x20 /* IPV6_RECVRTHDRDSTOPTS opt */ 870*7c478bd9Sstevel@tonic-gate 871*7c478bd9Sstevel@tonic-gate uint_t sctp_recvifindex; /* last rcvd IPV6_RCVPKTINFO */ 872*7c478bd9Sstevel@tonic-gate uint_t sctp_recvhops; /* " IPV6_RECVHOPLIMIT */ 873*7c478bd9Sstevel@tonic-gate ip6_hbh_t *sctp_hopopts; /* " IPV6_RECVHOPOPTS */ 874*7c478bd9Sstevel@tonic-gate ip6_dest_t *sctp_dstopts; /* " IPV6_RECVDSTOPTS */ 875*7c478bd9Sstevel@tonic-gate ip6_dest_t *sctp_rtdstopts; /* " IPV6_RECVRTHDRDSTOPTS */ 876*7c478bd9Sstevel@tonic-gate ip6_rthdr_t *sctp_rthdr; /* " IPV6_RECVRTHDR */ 877*7c478bd9Sstevel@tonic-gate uint_t sctp_hopoptslen; 878*7c478bd9Sstevel@tonic-gate uint_t sctp_dstoptslen; 879*7c478bd9Sstevel@tonic-gate uint_t sctp_rtdstoptslen; 880*7c478bd9Sstevel@tonic-gate uint_t sctp_rthdrlen; 881*7c478bd9Sstevel@tonic-gate 882*7c478bd9Sstevel@tonic-gate ip6_pkt_t sctp_sticky_ipp; /* Sticky options */ 883*7c478bd9Sstevel@tonic-gate #define sctp_ipp_fields sctp_sticky_ipp.ipp_fields 884*7c478bd9Sstevel@tonic-gate #define sctp_ipp_ifindex sctp_sticky_ipp.ipp_ifindex 885*7c478bd9Sstevel@tonic-gate #define sctp_ipp_addr sctp_sticky_ipp.ipp_addr 886*7c478bd9Sstevel@tonic-gate #define sctp_ipp_hoplimit sctp_sticky_ipp.ipp_hoplimit 887*7c478bd9Sstevel@tonic-gate #define sctp_ipp_hopoptslen sctp_sticky_ipp.ipp_hopoptslen 888*7c478bd9Sstevel@tonic-gate #define sctp_ipp_rtdstoptslen sctp_sticky_ipp.ipp_rtdstoptslen 889*7c478bd9Sstevel@tonic-gate #define sctp_ipp_rthdrlen sctp_sticky_ipp.ipp_rthdrlen 890*7c478bd9Sstevel@tonic-gate #define sctp_ipp_dstoptslen sctp_sticky_ipp.ipp_dstoptslen 891*7c478bd9Sstevel@tonic-gate #define sctp_ipp_hopopts sctp_sticky_ipp.ipp_hopopts 892*7c478bd9Sstevel@tonic-gate #define sctp_ipp_rtdstopts sctp_sticky_ipp.ipp_rtdstopts 893*7c478bd9Sstevel@tonic-gate #define sctp_ipp_rthdr sctp_sticky_ipp.ipp_rthdr 894*7c478bd9Sstevel@tonic-gate #define sctp_ipp_dstopts sctp_sticky_ipp.ipp_dstopts 895*7c478bd9Sstevel@tonic-gate #define sctp_ipp_nexthop sctp_sticky_ipp.ipp_nexthop 896*7c478bd9Sstevel@tonic-gate /* Stats */ 897*7c478bd9Sstevel@tonic-gate uint64_t sctp_msgcount; 898*7c478bd9Sstevel@tonic-gate uint64_t sctp_prsctpdrop; 899*7c478bd9Sstevel@tonic-gate } sctp_t; 900*7c478bd9Sstevel@tonic-gate 901*7c478bd9Sstevel@tonic-gate extern list_t sctp_g_list; /* Head of SCTP instance data chain */ 902*7c478bd9Sstevel@tonic-gate extern kmutex_t sctp_g_lock; 903*7c478bd9Sstevel@tonic-gate 904*7c478bd9Sstevel@tonic-gate #endif /* (defined(_KERNEL) || defined(_KMEMUSER)) */ 905*7c478bd9Sstevel@tonic-gate 906*7c478bd9Sstevel@tonic-gate extern queue_t *sctp_g_q; /* Default queue used during detached closes */ 907*7c478bd9Sstevel@tonic-gate extern sctp_t *gsctp; 908*7c478bd9Sstevel@tonic-gate 909*7c478bd9Sstevel@tonic-gate /* Padding mblk for SCTP chunks. */ 910*7c478bd9Sstevel@tonic-gate extern mblk_t *sctp_pad_mp; 911*7c478bd9Sstevel@tonic-gate 912*7c478bd9Sstevel@tonic-gate extern void sctp_ack_timer(sctp_t *); 913*7c478bd9Sstevel@tonic-gate extern size_t sctp_adaption_code_param(sctp_t *, uchar_t *); 914*7c478bd9Sstevel@tonic-gate extern void sctp_adaption_event(sctp_t *); 915*7c478bd9Sstevel@tonic-gate extern int sctp_add_faddr(sctp_t *, in6_addr_t *, int); 916*7c478bd9Sstevel@tonic-gate extern int sctp_add_faddr_first(sctp_t *, in6_addr_t *, int); 917*7c478bd9Sstevel@tonic-gate extern boolean_t sctp_add_ftsn_set(sctp_ftsn_set_t **, sctp_faddr_t *, mblk_t *, 918*7c478bd9Sstevel@tonic-gate uint_t *, uint32_t *); 919*7c478bd9Sstevel@tonic-gate extern boolean_t sctp_add_recvq(sctp_t *, mblk_t *, boolean_t); 920*7c478bd9Sstevel@tonic-gate extern void sctp_add_sendq(sctp_t *, mblk_t *); 921*7c478bd9Sstevel@tonic-gate extern void sctp_add_unrec_parm(sctp_parm_hdr_t *, mblk_t **); 922*7c478bd9Sstevel@tonic-gate extern size_t sctp_addr_params(sctp_t *, int, uchar_t *); 923*7c478bd9Sstevel@tonic-gate extern size_t sctp_addr_params_len(sctp_t *, int); 924*7c478bd9Sstevel@tonic-gate extern mblk_t *sctp_add_proto_hdr(sctp_t *, sctp_faddr_t *, mblk_t *, int); 925*7c478bd9Sstevel@tonic-gate extern void sctp_addr_req(sctp_t *, mblk_t *); 926*7c478bd9Sstevel@tonic-gate extern sctp_t *sctp_addrlist2sctp(mblk_t *, sctp_hdr_t *, sctp_chunk_hdr_t *, 927*7c478bd9Sstevel@tonic-gate uint_t, zoneid_t); 928*7c478bd9Sstevel@tonic-gate extern void sctp_add_hdr(sctp_t *, uchar_t *, size_t); 929*7c478bd9Sstevel@tonic-gate extern void sctp_check_adv_ack_pt(sctp_t *, mblk_t *, mblk_t *); 930*7c478bd9Sstevel@tonic-gate extern boolean_t sctp_allocbuf(void **, uint_t *, boolean_t, void *, uint_t); 931*7c478bd9Sstevel@tonic-gate extern void sctp_assoc_event(sctp_t *, uint16_t, uint16_t, 932*7c478bd9Sstevel@tonic-gate sctp_chunk_hdr_t *); 933*7c478bd9Sstevel@tonic-gate 934*7c478bd9Sstevel@tonic-gate extern void sctp_bind_hash_insert(sctp_tf_t *, sctp_t *, int); 935*7c478bd9Sstevel@tonic-gate extern void sctp_bind_hash_remove(sctp_t *); 936*7c478bd9Sstevel@tonic-gate extern in_port_t sctp_bindi(sctp_t *, in_port_t, int, int); 937*7c478bd9Sstevel@tonic-gate extern int sctp_bind_add(sctp_t *, const void *, uint32_t, boolean_t); 938*7c478bd9Sstevel@tonic-gate extern int sctp_bind_del(sctp_t *, const void *, uint32_t, boolean_t); 939*7c478bd9Sstevel@tonic-gate extern int sctp_build_hdrs(sctp_t *); 940*7c478bd9Sstevel@tonic-gate 941*7c478bd9Sstevel@tonic-gate extern int sctp_check_abandoned_msg(sctp_t *, mblk_t *); 942*7c478bd9Sstevel@tonic-gate extern void sctp_chunkify(sctp_t *, int, int); 943*7c478bd9Sstevel@tonic-gate extern void sctp_clean_death(sctp_t *, int); 944*7c478bd9Sstevel@tonic-gate extern void sctp_close_eager(sctp_t *); 945*7c478bd9Sstevel@tonic-gate extern boolean_t sctp_cmpbuf(void *, uint_t, boolean_t, void *, uint_t); 946*7c478bd9Sstevel@tonic-gate extern int sctp_compare_faddrsets(sctp_faddr_t *, sctp_faddr_t *); 947*7c478bd9Sstevel@tonic-gate extern void sctp_congest_reset(sctp_t *); 948*7c478bd9Sstevel@tonic-gate extern void sctp_conn_hash_insert(sctp_tf_t *, sctp_t *, int); 949*7c478bd9Sstevel@tonic-gate extern void sctp_conn_hash_remove(sctp_t *); 950*7c478bd9Sstevel@tonic-gate extern sctp_t *sctp_conn_match(in6_addr_t *, in6_addr_t *, uint32_t, uint_t, 951*7c478bd9Sstevel@tonic-gate zoneid_t); 952*7c478bd9Sstevel@tonic-gate extern sctp_t *sctp_conn_request(sctp_t *, mblk_t *, uint_t, uint_t, 953*7c478bd9Sstevel@tonic-gate sctp_init_chunk_t *, mblk_t *); 954*7c478bd9Sstevel@tonic-gate extern int sctp_conprim_opt_process(queue_t *, mblk_t *, int *, int *, 955*7c478bd9Sstevel@tonic-gate int *); 956*7c478bd9Sstevel@tonic-gate extern uint32_t sctp_cumack(sctp_t *, uint32_t, mblk_t **); 957*7c478bd9Sstevel@tonic-gate extern sctp_t *sctp_create_eager(sctp_t *); 958*7c478bd9Sstevel@tonic-gate 959*7c478bd9Sstevel@tonic-gate extern void sctp_dispatch_rput(queue_t *, sctp_t *, sctp_hdr_t *, mblk_t *, 960*7c478bd9Sstevel@tonic-gate uint_t, uint_t, in6_addr_t); 961*7c478bd9Sstevel@tonic-gate extern char *sctp_display(sctp_t *, char *); 962*7c478bd9Sstevel@tonic-gate extern void sctp_display_all(); 963*7c478bd9Sstevel@tonic-gate 964*7c478bd9Sstevel@tonic-gate extern void sctp_error_event(sctp_t *, sctp_chunk_hdr_t *); 965*7c478bd9Sstevel@tonic-gate 966*7c478bd9Sstevel@tonic-gate extern void sctp_faddr_alive(sctp_t *, sctp_faddr_t *); 967*7c478bd9Sstevel@tonic-gate extern int sctp_faddr_dead(sctp_t *, sctp_faddr_t *, int); 968*7c478bd9Sstevel@tonic-gate extern void sctp_faddr_fini(); 969*7c478bd9Sstevel@tonic-gate extern void sctp_faddr_init(); 970*7c478bd9Sstevel@tonic-gate extern void sctp_faddr2hdraddr(sctp_faddr_t *, sctp_t *); 971*7c478bd9Sstevel@tonic-gate extern void sctp_faddr2ire(sctp_t *, sctp_faddr_t *); 972*7c478bd9Sstevel@tonic-gate extern void sctp_fast_rexmit(sctp_t *); 973*7c478bd9Sstevel@tonic-gate extern void sctp_fill_sack(sctp_t *, unsigned char *, int); 974*7c478bd9Sstevel@tonic-gate extern void sctp_free_faddr_timers(sctp_t *); 975*7c478bd9Sstevel@tonic-gate extern void sctp_free_ftsn_set(sctp_ftsn_set_t *); 976*7c478bd9Sstevel@tonic-gate extern void sctp_free_msg(mblk_t *); 977*7c478bd9Sstevel@tonic-gate extern void sctp_free_reass(sctp_instr_t *); 978*7c478bd9Sstevel@tonic-gate extern void sctp_free_set(sctp_set_t *); 979*7c478bd9Sstevel@tonic-gate extern void sctp_ftsn_sets_fini(void); 980*7c478bd9Sstevel@tonic-gate extern void sctp_ftsn_sets_init(void); 981*7c478bd9Sstevel@tonic-gate 982*7c478bd9Sstevel@tonic-gate extern int sctp_get_addrparams(sctp_t *, sctp_t *, mblk_t *, 983*7c478bd9Sstevel@tonic-gate sctp_chunk_hdr_t *, uint_t *); 984*7c478bd9Sstevel@tonic-gate extern mblk_t *sctp_get_first_sent(sctp_t *); 985*7c478bd9Sstevel@tonic-gate extern mblk_t *sctp_get_msg_to_send(sctp_t *, mblk_t **, mblk_t *, int *, 986*7c478bd9Sstevel@tonic-gate int32_t, uint32_t, sctp_faddr_t *); 987*7c478bd9Sstevel@tonic-gate extern in_port_t sctp_get_next_priv_port(); 988*7c478bd9Sstevel@tonic-gate 989*7c478bd9Sstevel@tonic-gate extern int sctp_handle_error(sctp_t *, sctp_hdr_t *, sctp_chunk_hdr_t *, 990*7c478bd9Sstevel@tonic-gate mblk_t *); 991*7c478bd9Sstevel@tonic-gate extern void sctp_hash_destroy(void); 992*7c478bd9Sstevel@tonic-gate extern void sctp_hash_init(void); 993*7c478bd9Sstevel@tonic-gate extern int sctp_header_init_ipv4(sctp_t *, int); 994*7c478bd9Sstevel@tonic-gate extern int sctp_header_init_ipv6(sctp_t *, int); 995*7c478bd9Sstevel@tonic-gate extern void sctp_heartbeat_timer(sctp_t *); 996*7c478bd9Sstevel@tonic-gate 997*7c478bd9Sstevel@tonic-gate extern void sctp_icmp_error(sctp_t *, mblk_t *); 998*7c478bd9Sstevel@tonic-gate extern void sctp_inc_taskq(void); 999*7c478bd9Sstevel@tonic-gate extern void sctp_info_req(sctp_t *, mblk_t *); 1000*7c478bd9Sstevel@tonic-gate extern mblk_t *sctp_init_mp(sctp_t *); 1001*7c478bd9Sstevel@tonic-gate extern boolean_t sctp_initialize_params(sctp_t *, sctp_init_chunk_t *, 1002*7c478bd9Sstevel@tonic-gate sctp_init_chunk_t *); 1003*7c478bd9Sstevel@tonic-gate extern uint32_t sctp_init2vtag(sctp_chunk_hdr_t *); 1004*7c478bd9Sstevel@tonic-gate extern void sctp_intf_event(sctp_t *, in6_addr_t, int, int); 1005*7c478bd9Sstevel@tonic-gate extern void sctp_input_data(sctp_t *, mblk_t *, mblk_t *); 1006*7c478bd9Sstevel@tonic-gate extern void sctp_instream_cleanup(sctp_t *, boolean_t); 1007*7c478bd9Sstevel@tonic-gate extern void sctp_ire2faddr(sctp_t *, sctp_faddr_t *); 1008*7c478bd9Sstevel@tonic-gate extern int sctp_is_a_faddr_clean(sctp_t *); 1009*7c478bd9Sstevel@tonic-gate 1010*7c478bd9Sstevel@tonic-gate extern void sctp_kstat_init(void); 1011*7c478bd9Sstevel@tonic-gate extern void sctp_kstat_fini(void); 1012*7c478bd9Sstevel@tonic-gate 1013*7c478bd9Sstevel@tonic-gate extern ssize_t sctp_link_abort(mblk_t *, uint16_t, char *, size_t, int, 1014*7c478bd9Sstevel@tonic-gate boolean_t); 1015*7c478bd9Sstevel@tonic-gate extern void sctp_listen_hash_insert(sctp_tf_t *, sctp_t *); 1016*7c478bd9Sstevel@tonic-gate extern void sctp_listen_hash_remove(sctp_t *); 1017*7c478bd9Sstevel@tonic-gate extern sctp_t *sctp_lookup(sctp_t *, in6_addr_t *, sctp_tf_t *, uint32_t *, 1018*7c478bd9Sstevel@tonic-gate int); 1019*7c478bd9Sstevel@tonic-gate extern sctp_faddr_t *sctp_lookup_faddr(sctp_t *, in6_addr_t *); 1020*7c478bd9Sstevel@tonic-gate 1021*7c478bd9Sstevel@tonic-gate extern mblk_t *sctp_make_err(sctp_t *, uint16_t, void *, size_t); 1022*7c478bd9Sstevel@tonic-gate extern mblk_t *sctp_make_ftsn_chunk(sctp_t *, sctp_faddr_t *, 1023*7c478bd9Sstevel@tonic-gate sctp_ftsn_set_t *, uint_t, uint32_t); 1024*7c478bd9Sstevel@tonic-gate extern void sctp_make_ftsns(sctp_t *, mblk_t *, mblk_t *, mblk_t **, 1025*7c478bd9Sstevel@tonic-gate sctp_faddr_t *, uint32_t *); 1026*7c478bd9Sstevel@tonic-gate extern mblk_t *sctp_make_mp(sctp_t *, sctp_faddr_t *, int); 1027*7c478bd9Sstevel@tonic-gate extern mblk_t *sctp_make_sack(sctp_t *, sctp_faddr_t *, mblk_t *); 1028*7c478bd9Sstevel@tonic-gate extern void sctp_maxpsz_set(sctp_t *); 1029*7c478bd9Sstevel@tonic-gate extern void sctp_move_faddr_timers(queue_t *, sctp_t *); 1030*7c478bd9Sstevel@tonic-gate 1031*7c478bd9Sstevel@tonic-gate extern void sctp_nd_free(); 1032*7c478bd9Sstevel@tonic-gate extern int sctp_nd_getset(queue_t *, MBLKP); 1033*7c478bd9Sstevel@tonic-gate extern boolean_t sctp_nd_init(); 1034*7c478bd9Sstevel@tonic-gate extern sctp_parm_hdr_t *sctp_next_parm(sctp_parm_hdr_t *, ssize_t *); 1035*7c478bd9Sstevel@tonic-gate 1036*7c478bd9Sstevel@tonic-gate extern void sctp_ootb_shutdown_ack(sctp_t *, mblk_t *, uint_t); 1037*7c478bd9Sstevel@tonic-gate extern size_t sctp_options_param(const sctp_t *, void *, int); 1038*7c478bd9Sstevel@tonic-gate extern size_t sctp_options_param_len(const sctp_t *, int); 1039*7c478bd9Sstevel@tonic-gate extern void sctp_output(sctp_t *sctp); 1040*7c478bd9Sstevel@tonic-gate 1041*7c478bd9Sstevel@tonic-gate extern boolean_t sctp_param_register(sctpparam_t *, int); 1042*7c478bd9Sstevel@tonic-gate extern void sctp_partial_delivery_event(sctp_t *); 1043*7c478bd9Sstevel@tonic-gate extern int sctp_process_cookie(sctp_t *, sctp_chunk_hdr_t *, mblk_t *, 1044*7c478bd9Sstevel@tonic-gate sctp_init_chunk_t **, sctp_hdr_t *, int *, in6_addr_t *); 1045*7c478bd9Sstevel@tonic-gate extern void sctp_process_heartbeat(sctp_t *, sctp_chunk_hdr_t *); 1046*7c478bd9Sstevel@tonic-gate extern void sctp_process_sendq(sctp_t *); 1047*7c478bd9Sstevel@tonic-gate extern void sctp_process_timer(sctp_t *); 1048*7c478bd9Sstevel@tonic-gate 1049*7c478bd9Sstevel@tonic-gate extern void sctp_redo_faddr_srcs(sctp_t *); 1050*7c478bd9Sstevel@tonic-gate extern void sctp_regift_xmitlist(sctp_t *); 1051*7c478bd9Sstevel@tonic-gate extern void sctp_return_heartbeat(sctp_t *, sctp_chunk_hdr_t *, mblk_t *); 1052*7c478bd9Sstevel@tonic-gate extern void sctp_rexmit(sctp_t *, sctp_faddr_t *); 1053*7c478bd9Sstevel@tonic-gate extern void sctp_rexmit_timer(sctp_t *, sctp_faddr_t *); 1054*7c478bd9Sstevel@tonic-gate extern sctp_faddr_t *sctp_rotate_faddr(sctp_t *, sctp_faddr_t *); 1055*7c478bd9Sstevel@tonic-gate 1056*7c478bd9Sstevel@tonic-gate extern void sctp_sack(sctp_t *, mblk_t *); 1057*7c478bd9Sstevel@tonic-gate extern void sctp_savebuf(void **, uint_t *, boolean_t, void *, uint_t); 1058*7c478bd9Sstevel@tonic-gate extern int sctp_secure_restart_check(mblk_t *, sctp_chunk_hdr_t *, 1059*7c478bd9Sstevel@tonic-gate uint32_t, int); 1060*7c478bd9Sstevel@tonic-gate extern void sctp_send_abort(sctp_t *, uint32_t, uint16_t, char *, size_t, 1061*7c478bd9Sstevel@tonic-gate mblk_t *, int, boolean_t); 1062*7c478bd9Sstevel@tonic-gate extern void sctp_send_cookie_ack(sctp_t *); 1063*7c478bd9Sstevel@tonic-gate extern void sctp_send_cookie_echo(sctp_t *, sctp_chunk_hdr_t *, mblk_t *); 1064*7c478bd9Sstevel@tonic-gate extern void sctp_send_err(sctp_t *, mblk_t *, sctp_faddr_t *); 1065*7c478bd9Sstevel@tonic-gate extern void sctp_send_initack(sctp_t *, sctp_chunk_hdr_t *, mblk_t *); 1066*7c478bd9Sstevel@tonic-gate extern void sctp_send_shutdown(sctp_t *, int); 1067*7c478bd9Sstevel@tonic-gate extern void sctp_send_heartbeat(sctp_t *, sctp_faddr_t *); 1068*7c478bd9Sstevel@tonic-gate extern void sctp_sendfail_event(sctp_t *, mblk_t *, int, boolean_t); 1069*7c478bd9Sstevel@tonic-gate extern void sctp_set_hdraddrs(sctp_t *); 1070*7c478bd9Sstevel@tonic-gate extern void sctp_sets_init(); 1071*7c478bd9Sstevel@tonic-gate extern void sctp_sets_fini(); 1072*7c478bd9Sstevel@tonic-gate extern void sctp_shutdown_event(sctp_t *); 1073*7c478bd9Sstevel@tonic-gate extern void sctp_stop_faddr_timers(sctp_t *); 1074*7c478bd9Sstevel@tonic-gate extern int sctp_shutdown_received(sctp_t *, sctp_chunk_hdr_t *, int, int); 1075*7c478bd9Sstevel@tonic-gate extern void sctp_shutdown_complete(sctp_t *); 1076*7c478bd9Sstevel@tonic-gate extern void sctp_set_if_mtu(sctp_t *); 1077*7c478bd9Sstevel@tonic-gate extern void sctp_set_iplen(sctp_t *, mblk_t *); 1078*7c478bd9Sstevel@tonic-gate extern void sctp_set_rto(sctp_t *, clock_t); 1079*7c478bd9Sstevel@tonic-gate extern void sctp_set_ulp_prop(sctp_t *); 1080*7c478bd9Sstevel@tonic-gate extern size_t sctp_supaddr_param_len(sctp_t *); 1081*7c478bd9Sstevel@tonic-gate extern size_t sctp_supaddr_param(sctp_t *, uchar_t *); 1082*7c478bd9Sstevel@tonic-gate 1083*7c478bd9Sstevel@tonic-gate extern void sctp_timer(sctp_t *, mblk_t *, clock_t); 1084*7c478bd9Sstevel@tonic-gate extern mblk_t *sctp_timer_alloc(sctp_t *, pfv_t); 1085*7c478bd9Sstevel@tonic-gate extern void sctp_timer_call(sctp_t *sctp, mblk_t *); 1086*7c478bd9Sstevel@tonic-gate extern void sctp_timer_free(mblk_t *); 1087*7c478bd9Sstevel@tonic-gate extern void sctp_timer_stop(mblk_t *); 1088*7c478bd9Sstevel@tonic-gate extern void sctp_unlink_faddr(sctp_t *, sctp_faddr_t *); 1089*7c478bd9Sstevel@tonic-gate 1090*7c478bd9Sstevel@tonic-gate extern in_port_t sctp_update_next_port(in_port_t); 1091*7c478bd9Sstevel@tonic-gate extern void sctp_update_rtt(sctp_t *, sctp_faddr_t *, clock_t); 1092*7c478bd9Sstevel@tonic-gate extern void sctp_user_abort(sctp_t *, mblk_t *, boolean_t); 1093*7c478bd9Sstevel@tonic-gate 1094*7c478bd9Sstevel@tonic-gate extern void sctp_validate_peer(sctp_t *); 1095*7c478bd9Sstevel@tonic-gate 1096*7c478bd9Sstevel@tonic-gate extern void sctp_wput_ioctl(queue_t *, mblk_t *); 1097*7c478bd9Sstevel@tonic-gate 1098*7c478bd9Sstevel@tonic-gate extern int sctp_xmit_list_clean(sctp_t *, ssize_t); 1099*7c478bd9Sstevel@tonic-gate 1100*7c478bd9Sstevel@tonic-gate extern void sctp_zap_addrs(sctp_t *); 1101*7c478bd9Sstevel@tonic-gate extern void sctp_zap_faddrs(sctp_t *, int); 1102*7c478bd9Sstevel@tonic-gate 1103*7c478bd9Sstevel@tonic-gate /* Send a mp to IP. */ 1104*7c478bd9Sstevel@tonic-gate #define IP_PUT(mp, conn, isv4) \ 1105*7c478bd9Sstevel@tonic-gate { \ 1106*7c478bd9Sstevel@tonic-gate if ((isv4)) \ 1107*7c478bd9Sstevel@tonic-gate ip_output((conn), (mp), WR(sctp_g_q), IP_WPUT); \ 1108*7c478bd9Sstevel@tonic-gate else \ 1109*7c478bd9Sstevel@tonic-gate ip_output_v6((conn), (mp), WR(sctp_g_q), IP_WPUT); \ 1110*7c478bd9Sstevel@tonic-gate } 1111*7c478bd9Sstevel@tonic-gate 1112*7c478bd9Sstevel@tonic-gate #define RUN_SCTP(sctp) \ 1113*7c478bd9Sstevel@tonic-gate { \ 1114*7c478bd9Sstevel@tonic-gate mutex_enter(&(sctp)->sctp_lock); \ 1115*7c478bd9Sstevel@tonic-gate while ((sctp)->sctp_running) \ 1116*7c478bd9Sstevel@tonic-gate cv_wait(&(sctp)->sctp_cv, &(sctp)->sctp_lock); \ 1117*7c478bd9Sstevel@tonic-gate (sctp)->sctp_running = B_TRUE; \ 1118*7c478bd9Sstevel@tonic-gate mutex_exit(&(sctp)->sctp_lock); \ 1119*7c478bd9Sstevel@tonic-gate } 1120*7c478bd9Sstevel@tonic-gate 1121*7c478bd9Sstevel@tonic-gate /* Wake up recvq taskq */ 1122*7c478bd9Sstevel@tonic-gate #define WAKE_SCTP(sctp) \ 1123*7c478bd9Sstevel@tonic-gate { \ 1124*7c478bd9Sstevel@tonic-gate mutex_enter(&(sctp)->sctp_lock); \ 1125*7c478bd9Sstevel@tonic-gate if ((sctp)->sctp_timer_mp != NULL) \ 1126*7c478bd9Sstevel@tonic-gate sctp_process_timer(sctp); \ 1127*7c478bd9Sstevel@tonic-gate (sctp)->sctp_running = B_FALSE; \ 1128*7c478bd9Sstevel@tonic-gate cv_broadcast(&(sctp)->sctp_cv); \ 1129*7c478bd9Sstevel@tonic-gate mutex_exit(&(sctp)->sctp_lock); \ 1130*7c478bd9Sstevel@tonic-gate } 1131*7c478bd9Sstevel@tonic-gate 1132*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1133*7c478bd9Sstevel@tonic-gate } 1134*7c478bd9Sstevel@tonic-gate #endif 1135*7c478bd9Sstevel@tonic-gate 1136*7c478bd9Sstevel@tonic-gate #endif /* _INET_SCTP_SCTP_IMPL_H */ 1137