10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51676Sjpk * Common Development and Distribution License (the "License"). 61676Sjpk * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 211735Skcpoon 220Sstevel@tonic-gate /* 231676Sjpk * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _INET_SCTP_SCTP_IMPL_H 280Sstevel@tonic-gate #define _INET_SCTP_SCTP_IMPL_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate #ifdef __cplusplus 330Sstevel@tonic-gate extern "C" { 340Sstevel@tonic-gate #endif 350Sstevel@tonic-gate 360Sstevel@tonic-gate #include <sys/inttypes.h> 370Sstevel@tonic-gate #include <sys/taskq.h> 380Sstevel@tonic-gate #include <sys/list.h> 390Sstevel@tonic-gate #include <sys/strsun.h> 401676Sjpk #include <sys/zone.h> 410Sstevel@tonic-gate #include <netinet/ip6.h> 420Sstevel@tonic-gate #include <inet/optcom.h> 430Sstevel@tonic-gate #include <netinet/sctp.h> 440Sstevel@tonic-gate #include <inet/sctp_itf.h> 450Sstevel@tonic-gate 460Sstevel@tonic-gate /* Streams device identifying info and version */ 470Sstevel@tonic-gate #define SCTP_DEV_IDINFO "SCTP Streams device 1.0" 480Sstevel@tonic-gate 490Sstevel@tonic-gate #define SSN_GT(a, b) ((int16_t)((a)-(b)) > 0) 500Sstevel@tonic-gate #define SSN_GE(a, b) ((int16_t)((a)-(b)) >= 0) 510Sstevel@tonic-gate 520Sstevel@tonic-gate /* Default buffer size and flow control wake up threshold. */ 530Sstevel@tonic-gate #define SCTP_XMIT_LOWATER 8192 540Sstevel@tonic-gate #define SCTP_XMIT_HIWATER 102400 550Sstevel@tonic-gate #define SCTP_RECV_LOWATER 8192 560Sstevel@tonic-gate #define SCTP_RECV_HIWATER 102400 570Sstevel@tonic-gate 580Sstevel@tonic-gate /* SCTP Timer control structure */ 590Sstevel@tonic-gate typedef struct sctpt_s { 600Sstevel@tonic-gate pfv_t sctpt_pfv; /* The routine we are to call */ 610Sstevel@tonic-gate struct sctp_s *sctpt_sctp; /* The parameter we are to pass in */ 620Sstevel@tonic-gate struct sctp_faddr_s *sctpt_faddr; 630Sstevel@tonic-gate } sctpt_t; 640Sstevel@tonic-gate 650Sstevel@tonic-gate /* 660Sstevel@tonic-gate * Maximum number of duplicate TSNs we can report. This is currently 670Sstevel@tonic-gate * static, and governs the size of the mblk used to hold the duplicate 680Sstevel@tonic-gate * reports. The use of duplcate TSN reports is currently experimental, 690Sstevel@tonic-gate * so for now a static limit should suffice. 700Sstevel@tonic-gate */ 710Sstevel@tonic-gate #define SCTP_DUP_MBLK_SZ 64 720Sstevel@tonic-gate 730Sstevel@tonic-gate #define SCTP_IS_ADDR_UNSPEC(isv4, addr) \ 740Sstevel@tonic-gate ((isv4) ? IN6_IS_ADDR_V4MAPPED_ANY(&(addr)) : \ 750Sstevel@tonic-gate IN6_IS_ADDR_UNSPECIFIED(&(addr))) 760Sstevel@tonic-gate 770Sstevel@tonic-gate extern int sctp_g_num_epriv_ports; 780Sstevel@tonic-gate extern uint16_t sctp_g_epriv_ports[]; 790Sstevel@tonic-gate extern kmutex_t sctp_epriv_port_lock; 800Sstevel@tonic-gate 810Sstevel@tonic-gate extern uint_t sctp_next_port_to_try; 820Sstevel@tonic-gate /* 830Sstevel@tonic-gate * SCTP parameters 840Sstevel@tonic-gate */ 850Sstevel@tonic-gate /* Named Dispatch Parameter Management Structure */ 860Sstevel@tonic-gate typedef struct sctpparam_s { 870Sstevel@tonic-gate uint32_t sctp_param_min; 880Sstevel@tonic-gate uint32_t sctp_param_max; 890Sstevel@tonic-gate uint32_t sctp_param_val; 900Sstevel@tonic-gate char *sctp_param_name; 910Sstevel@tonic-gate } sctpparam_t; 920Sstevel@tonic-gate 930Sstevel@tonic-gate extern sctpparam_t sctp_param_arr[]; 940Sstevel@tonic-gate #define sctp_max_init_retr sctp_param_arr[0].sctp_param_val 950Sstevel@tonic-gate #define sctp_max_init_retr_high sctp_param_arr[0].sctp_param_max 960Sstevel@tonic-gate #define sctp_max_init_retr_low sctp_param_arr[0].sctp_param_min 970Sstevel@tonic-gate #define sctp_pa_max_retr sctp_param_arr[1].sctp_param_val 980Sstevel@tonic-gate #define sctp_pa_max_retr_high sctp_param_arr[1].sctp_param_max 990Sstevel@tonic-gate #define sctp_pa_max_retr_low sctp_param_arr[1].sctp_param_min 1000Sstevel@tonic-gate #define sctp_pp_max_retr sctp_param_arr[2].sctp_param_val 1010Sstevel@tonic-gate #define sctp_pp_max_retr_high sctp_param_arr[2].sctp_param_max 1020Sstevel@tonic-gate #define sctp_pp_max_retr_low sctp_param_arr[2].sctp_param_min 1030Sstevel@tonic-gate #define sctp_cwnd_max_ sctp_param_arr[3].sctp_param_val 1040Sstevel@tonic-gate #define sctp_dbg sctp_param_arr[4].sctp_param_val 1050Sstevel@tonic-gate #define sctp_smallest_nonpriv_port sctp_param_arr[5].sctp_param_val 1060Sstevel@tonic-gate #define sctp_ipv4_ttl sctp_param_arr[6].sctp_param_val 1070Sstevel@tonic-gate #define sctp_heartbeat_interval sctp_param_arr[7].sctp_param_val 1080Sstevel@tonic-gate #define sctp_heartbeat_interval_high sctp_param_arr[7].sctp_param_max 1090Sstevel@tonic-gate #define sctp_heartbeat_interval_low sctp_param_arr[7].sctp_param_min 1100Sstevel@tonic-gate #define sctp_initial_mtu sctp_param_arr[8].sctp_param_val 1110Sstevel@tonic-gate #define sctp_mtu_probe_interval sctp_param_arr[9].sctp_param_val 1120Sstevel@tonic-gate #define sctp_new_secret_interval sctp_param_arr[10].sctp_param_val 1130Sstevel@tonic-gate #define sctp_deferred_ack_interval sctp_param_arr[11].sctp_param_val 1140Sstevel@tonic-gate #define sctp_snd_lowat_fraction sctp_param_arr[12].sctp_param_val 1150Sstevel@tonic-gate #define sctp_ignore_path_mtu sctp_param_arr[13].sctp_param_val 1160Sstevel@tonic-gate #define sctp_initial_ssthresh sctp_param_arr[14].sctp_param_val 1170Sstevel@tonic-gate #define sctp_smallest_anon_port sctp_param_arr[15].sctp_param_val 1180Sstevel@tonic-gate #define sctp_largest_anon_port sctp_param_arr[16].sctp_param_val 1190Sstevel@tonic-gate #define sctp_xmit_hiwat sctp_param_arr[17].sctp_param_val 1200Sstevel@tonic-gate #define sctp_xmit_lowat sctp_param_arr[18].sctp_param_val 1210Sstevel@tonic-gate #define sctp_recv_hiwat sctp_param_arr[19].sctp_param_val 1220Sstevel@tonic-gate #define sctp_max_buf sctp_param_arr[20].sctp_param_val 1230Sstevel@tonic-gate #define sctp_rtt_updates sctp_param_arr[21].sctp_param_val 1240Sstevel@tonic-gate #define sctp_ipv6_hoplimit sctp_param_arr[22].sctp_param_val 1250Sstevel@tonic-gate #define sctp_rto_ming sctp_param_arr[23].sctp_param_val 1260Sstevel@tonic-gate #define sctp_rto_ming_high sctp_param_arr[23].sctp_param_max 1270Sstevel@tonic-gate #define sctp_rto_ming_low sctp_param_arr[23].sctp_param_min 1280Sstevel@tonic-gate #define sctp_rto_maxg sctp_param_arr[24].sctp_param_val 1290Sstevel@tonic-gate #define sctp_rto_maxg_high sctp_param_arr[24].sctp_param_max 1300Sstevel@tonic-gate #define sctp_rto_maxg_low sctp_param_arr[24].sctp_param_min 1310Sstevel@tonic-gate #define sctp_rto_initialg sctp_param_arr[25].sctp_param_val 1320Sstevel@tonic-gate #define sctp_rto_initialg_high sctp_param_arr[25].sctp_param_max 1330Sstevel@tonic-gate #define sctp_rto_initialg_low sctp_param_arr[25].sctp_param_min 1340Sstevel@tonic-gate #define sctp_cookie_life sctp_param_arr[26].sctp_param_val 1350Sstevel@tonic-gate #define sctp_cookie_life_high sctp_param_arr[26].sctp_param_max 1360Sstevel@tonic-gate #define sctp_cookie_life_low sctp_param_arr[26].sctp_param_min 1370Sstevel@tonic-gate #define sctp_max_in_streams sctp_param_arr[27].sctp_param_val 1380Sstevel@tonic-gate #define sctp_max_in_streams_high sctp_param_arr[27].sctp_param_max 1390Sstevel@tonic-gate #define sctp_max_in_streams_low sctp_param_arr[27].sctp_param_min 1400Sstevel@tonic-gate #define sctp_initial_out_streams sctp_param_arr[28].sctp_param_val 1410Sstevel@tonic-gate #define sctp_initial_out_streams_high sctp_param_arr[28].sctp_param_max 1420Sstevel@tonic-gate #define sctp_initial_out_streams_low sctp_param_arr[28].sctp_param_min 1430Sstevel@tonic-gate #define sctp_shutack_wait_bound sctp_param_arr[29].sctp_param_val 1440Sstevel@tonic-gate #define sctp_maxburst sctp_param_arr[30].sctp_param_val 1450Sstevel@tonic-gate #define sctp_addip_enabled sctp_param_arr[31].sctp_param_val 1460Sstevel@tonic-gate #define sctp_recv_hiwat_minmss sctp_param_arr[32].sctp_param_val 1470Sstevel@tonic-gate #define sctp_slow_start_initial sctp_param_arr[33].sctp_param_val 1480Sstevel@tonic-gate #define sctp_slow_start_after_idle sctp_param_arr[34].sctp_param_val 1490Sstevel@tonic-gate #define sctp_prsctp_enabled sctp_param_arr[35].sctp_param_val 1500Sstevel@tonic-gate #define sctp_fast_rxt_thresh sctp_param_arr[36].sctp_param_val 1510Sstevel@tonic-gate /* 1520Sstevel@tonic-gate * sctp_wroff_xtra is the extra space in front of SCTP/IP header for link 1530Sstevel@tonic-gate * layer header. It has to be a multiple of 4. 1540Sstevel@tonic-gate */ 1550Sstevel@tonic-gate extern sctpparam_t sctp_wroff_xtra_param; 1560Sstevel@tonic-gate #define sctp_wroff_xtra sctp_wroff_xtra_param.sctp_param_val 1570Sstevel@tonic-gate 1581735Skcpoon /* 1591735Skcpoon * Retransmission timer start and stop macro for a given faddr. 1601735Skcpoon */ 1611735Skcpoon #define SCTP_FADDR_TIMER_RESTART(sctp, fp, intvl) \ 1621735Skcpoon { \ 1631735Skcpoon dprint(3, ("faddr_timer_restart: fp=%p %x:%x:%x:%x %d\n", \ 1641735Skcpoon (void *)(fp), SCTP_PRINTADDR((fp)->faddr), (int)(intvl))); \ 1651735Skcpoon sctp_timer((sctp), (fp)->timer_mp, (intvl)); \ 1661735Skcpoon (fp)->timer_running = 1; \ 1671735Skcpoon } 1681735Skcpoon 1691735Skcpoon #define SCTP_FADDR_TIMER_STOP(fp) \ 1701735Skcpoon ASSERT((fp)->timer_mp != NULL); \ 1711735Skcpoon if ((fp)->timer_running) { \ 1721735Skcpoon sctp_timer_stop((fp)->timer_mp); \ 1731735Skcpoon (fp)->timer_running = 0; \ 1741735Skcpoon } 1751735Skcpoon 1761735Skcpoon #define SCTP_CALC_RXT(fp, max) \ 1771735Skcpoon { \ 1781735Skcpoon if (((fp)->rto <<= 1) > (max)) \ 1791735Skcpoon (fp)->rto = (max); \ 1801735Skcpoon } 1811735Skcpoon 1821735Skcpoon 1830Sstevel@tonic-gate #define SCTP_MAX_COMBINED_HEADER_LENGTH (60 + 12) /* Maxed out ip + sctp */ 1840Sstevel@tonic-gate #define SCTP_MAX_IP_OPTIONS_LENGTH (60 - IP_SIMPLE_HDR_LENGTH) 1850Sstevel@tonic-gate #define SCTP_MAX_HDR_LENGTH 60 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate #define SCTP_SECRET_LEN 16 1880Sstevel@tonic-gate 1890Sstevel@tonic-gate #define SCTP_REFHOLD(sctp) { \ 1900Sstevel@tonic-gate mutex_enter(&(sctp)->sctp_reflock); \ 1910Sstevel@tonic-gate (sctp)->sctp_refcnt++; \ 1920Sstevel@tonic-gate ASSERT((sctp)->sctp_refcnt != 0); \ 1930Sstevel@tonic-gate mutex_exit(&(sctp)->sctp_reflock); \ 1940Sstevel@tonic-gate } 1950Sstevel@tonic-gate 1960Sstevel@tonic-gate #define SCTP_REFRELE(sctp) { \ 1970Sstevel@tonic-gate mutex_enter(&(sctp)->sctp_reflock); \ 1980Sstevel@tonic-gate ASSERT((sctp)->sctp_refcnt != 0); \ 1990Sstevel@tonic-gate if (--(sctp)->sctp_refcnt == 0) { \ 2000Sstevel@tonic-gate mutex_exit(&(sctp)->sctp_reflock); \ 2010Sstevel@tonic-gate CONN_DEC_REF((sctp)->sctp_connp); \ 2020Sstevel@tonic-gate } else { \ 2030Sstevel@tonic-gate mutex_exit(&(sctp)->sctp_reflock); \ 2040Sstevel@tonic-gate } \ 2050Sstevel@tonic-gate } 2060Sstevel@tonic-gate 2070Sstevel@tonic-gate #define SCTP_PRINTADDR(a) (a).s6_addr32[0], (a).s6_addr32[1],\ 2080Sstevel@tonic-gate (a).s6_addr32[2], (a).s6_addr32[3] 2090Sstevel@tonic-gate 2100Sstevel@tonic-gate #define CONN2SCTP(conn) ((sctp_t *)(&((conn_t *)conn)[1])) 2110Sstevel@tonic-gate 2120Sstevel@tonic-gate /* 2130Sstevel@tonic-gate * Outbound data, flags and macros for per-message, per-chunk info 2140Sstevel@tonic-gate */ 2150Sstevel@tonic-gate typedef struct { 2160Sstevel@tonic-gate int64_t smh_ttl; /* Time to Live */ 2170Sstevel@tonic-gate int64_t smh_tob; /* Time of Birth */ 2180Sstevel@tonic-gate uint32_t smh_context; 2190Sstevel@tonic-gate uint16_t smh_sid; 2200Sstevel@tonic-gate uint16_t smh_ssn; 2210Sstevel@tonic-gate uint32_t smh_ppid; 2220Sstevel@tonic-gate uint16_t smh_flags; 2230Sstevel@tonic-gate uint32_t smh_msglen; 2240Sstevel@tonic-gate } sctp_msg_hdr_t; 2250Sstevel@tonic-gate 2260Sstevel@tonic-gate #define SCTP_CHUNK_FLAG_SENT 0x01 2270Sstevel@tonic-gate #define SCTP_CHUNK_FLAG_REXMIT 0x02 2280Sstevel@tonic-gate #define SCTP_CHUNK_FLAG_ACKED 0x04 2290Sstevel@tonic-gate #define SCTP_MSG_FLAG_CHUNKED 0x08 2300Sstevel@tonic-gate #define SCTP_MSG_FLAG_ABANDONED 0x10 2310Sstevel@tonic-gate #define SCTP_CHUNK_FLAG_ABANDONED 0x20 2320Sstevel@tonic-gate 2330Sstevel@tonic-gate #define SCTP_CHUNK_CLEAR_FLAGS(mp) ((mp)->b_flag = 0) 2340Sstevel@tonic-gate /* 2350Sstevel@tonic-gate * If we are transmitting the chunk for the first time we assign the TSN and 2360Sstevel@tonic-gate * SSN here. The reason we assign the SSN here (as opposed to doing it in 2370Sstevel@tonic-gate * sctp_chunkify()) is that the chunk may expire, if PRSCTP is enabled, before 2380Sstevel@tonic-gate * we get a chance to send it out. If we assign the SSN in sctp_chunkify() 2390Sstevel@tonic-gate * and this happens, then we need to send a Forward TSN to the peer, which 2400Sstevel@tonic-gate * will be expecting this SSN, assuming ordered. If we assign it here we 2410Sstevel@tonic-gate * can just take out the chunk from the transmit list without having to 2420Sstevel@tonic-gate * send a Forward TSN chunk. While assigning the SSN we use (meta)->b_cont 2430Sstevel@tonic-gate * to determine if it needs a new SSN (i.e. the next SSN for the stream), 2440Sstevel@tonic-gate * since (meta)->b_cont signifies the first chunk of a message (if the message 2450Sstevel@tonic-gate * is unordered, then the SSN is 0). 2460Sstevel@tonic-gate * 2470Sstevel@tonic-gate */ 2480Sstevel@tonic-gate #define SCTP_CHUNK_SENT(sctp, mp, sdc, fp, chunkdata, meta) { \ 2490Sstevel@tonic-gate if (!SCTP_CHUNK_ISSENT(mp)) { \ 2500Sstevel@tonic-gate sctp_msg_hdr_t *mhdr = (sctp_msg_hdr_t *)(meta)->b_rptr; \ 2510Sstevel@tonic-gate ASSERT(!SCTP_CHUNK_ABANDONED(mp)); \ 2520Sstevel@tonic-gate (mp)->b_flag = SCTP_CHUNK_FLAG_SENT; \ 2530Sstevel@tonic-gate (sdc)->sdh_tsn = htonl((sctp)->sctp_ltsn++); \ 2540Sstevel@tonic-gate if ((mhdr)->smh_flags & MSG_UNORDERED) { \ 2550Sstevel@tonic-gate (sdc)->sdh_ssn = 0; \ 2560Sstevel@tonic-gate SCTP_DATA_SET_UBIT(sdc); \ 2570Sstevel@tonic-gate BUMP_LOCAL((sctp)->sctp_oudchunks); \ 2580Sstevel@tonic-gate } else { \ 2590Sstevel@tonic-gate BUMP_LOCAL((sctp)->sctp_odchunks); \ 2600Sstevel@tonic-gate if ((mp) == (meta)->b_cont) { \ 2610Sstevel@tonic-gate mhdr->smh_ssn = htons( \ 2620Sstevel@tonic-gate (sctp)->sctp_ostrcntrs[mhdr->smh_sid]++); \ 2630Sstevel@tonic-gate } \ 2640Sstevel@tonic-gate (sdc)->sdh_ssn = mhdr->smh_ssn; \ 2650Sstevel@tonic-gate } \ 2660Sstevel@tonic-gate (sctp)->sctp_unacked += (chunkdata); \ 2670Sstevel@tonic-gate (sctp)->sctp_unsent -= (chunkdata); \ 2680Sstevel@tonic-gate (sctp)->sctp_frwnd -= (chunkdata); \ 2690Sstevel@tonic-gate } else { \ 2700Sstevel@tonic-gate if (SCTP_CHUNK_ISACKED(mp)) { \ 2710Sstevel@tonic-gate (sctp)->sctp_unacked += (chunkdata); \ 2720Sstevel@tonic-gate } else { \ 2730Sstevel@tonic-gate ASSERT(SCTP_CHUNK_DEST(mp)->suna >= ((chunkdata) + \ 2740Sstevel@tonic-gate sizeof (*sdc))); \ 2750Sstevel@tonic-gate SCTP_CHUNK_DEST(mp)->suna -= ((chunkdata) + \ 2760Sstevel@tonic-gate sizeof (*sdc)); \ 2770Sstevel@tonic-gate } \ 2780Sstevel@tonic-gate (mp)->b_flag &= ~(SCTP_CHUNK_FLAG_REXMIT | \ 2790Sstevel@tonic-gate SCTP_CHUNK_FLAG_ACKED); \ 2800Sstevel@tonic-gate SCTP_CHUNK_SET_SACKCNT(mp, 0); \ 2810Sstevel@tonic-gate BUMP_LOCAL(sctp->sctp_rxtchunks); \ 2820Sstevel@tonic-gate BUMP_LOCAL((sctp)->sctp_T3expire); \ 2830Sstevel@tonic-gate BUMP_LOCAL((fp)->T3expire); \ 2840Sstevel@tonic-gate } \ 2850Sstevel@tonic-gate SCTP_SET_CHUNK_DEST(mp, fp); \ 2860Sstevel@tonic-gate (fp)->suna += ((chunkdata) + sizeof (*sdc)); \ 2870Sstevel@tonic-gate } 2880Sstevel@tonic-gate 2890Sstevel@tonic-gate #define SCTP_CHUNK_ISSENT(mp) ((mp)->b_flag & SCTP_CHUNK_FLAG_SENT) 2900Sstevel@tonic-gate #define SCTP_CHUNK_CANSEND(mp) \ 2910Sstevel@tonic-gate (!(SCTP_CHUNK_ABANDONED(mp)) && \ 2920Sstevel@tonic-gate (((mp)->b_flag & (SCTP_CHUNK_FLAG_REXMIT|SCTP_CHUNK_FLAG_SENT)) != \ 2930Sstevel@tonic-gate SCTP_CHUNK_FLAG_SENT)) 2940Sstevel@tonic-gate 2950Sstevel@tonic-gate #define SCTP_CHUNK_DEST(mp) ((sctp_faddr_t *)(mp)->b_queue) 2960Sstevel@tonic-gate #define SCTP_SET_CHUNK_DEST(mp, fp) ((mp)->b_queue = (queue_t *)fp) 2970Sstevel@tonic-gate 2980Sstevel@tonic-gate #define SCTP_CHUNK_REXMIT(mp) ((mp)->b_flag |= SCTP_CHUNK_FLAG_REXMIT) 2990Sstevel@tonic-gate #define SCTP_CHUNK_CLEAR_REXMIT(mp) ((mp)->b_flag &= ~SCTP_CHUNK_FLAG_REXMIT) 3000Sstevel@tonic-gate #define SCTP_CHUNK_WANT_REXMIT(mp) ((mp)->b_flag & SCTP_CHUNK_FLAG_REXMIT) 3010Sstevel@tonic-gate 3020Sstevel@tonic-gate #define SCTP_CHUNK_ACKED(mp) \ 3030Sstevel@tonic-gate ((mp)->b_flag = (SCTP_CHUNK_FLAG_SENT|SCTP_CHUNK_FLAG_ACKED)) 3040Sstevel@tonic-gate #define SCTP_CHUNK_ISACKED(mp) ((mp)->b_flag & SCTP_CHUNK_FLAG_ACKED) 3050Sstevel@tonic-gate #define SCTP_CHUNK_CLEAR_ACKED(mp) ((mp)->b_flag &= ~SCTP_CHUNK_FLAG_ACKED) 3060Sstevel@tonic-gate 3070Sstevel@tonic-gate #define SCTP_CHUNK_SACKCNT(mp) ((intptr_t)((mp)->b_prev)) 3080Sstevel@tonic-gate #define SCTP_CHUNK_SET_SACKCNT(mp, val) ((mp)->b_prev = \ 3090Sstevel@tonic-gate (mblk_t *)(uintptr_t)(val)) 3100Sstevel@tonic-gate 3110Sstevel@tonic-gate #define SCTP_MSG_SET_CHUNKED(mp) ((mp)->b_flag |= SCTP_MSG_FLAG_CHUNKED) 3120Sstevel@tonic-gate #define SCTP_MSG_CLEAR_CHUNKED(mp)((mp)->b_flag &= ~SCTP_MSG_FLAG_CHUNKED) 3130Sstevel@tonic-gate #define SCTP_IS_MSG_CHUNKED(mp) ((mp)->b_flag & SCTP_MSG_FLAG_CHUNKED) 3140Sstevel@tonic-gate 3150Sstevel@tonic-gate /* For PR-SCTP */ 3160Sstevel@tonic-gate #define SCTP_ABANDON_CHUNK(mp) ((mp)->b_flag |= SCTP_CHUNK_FLAG_ABANDONED) 3170Sstevel@tonic-gate #define SCTP_CHUNK_ABANDONED(mp) \ 3180Sstevel@tonic-gate ((mp)->b_flag & SCTP_CHUNK_FLAG_ABANDONED) 3190Sstevel@tonic-gate 3200Sstevel@tonic-gate #define SCTP_MSG_SET_ABANDONED(mp) \ 3210Sstevel@tonic-gate ((mp)->b_flag |= SCTP_MSG_FLAG_ABANDONED) 3220Sstevel@tonic-gate #define SCTP_MSG_CLEAR_ABANDONED(mp)((mp)->b_flag &= ~SCTP_MSG_FLAG_ABANDONED) 3230Sstevel@tonic-gate #define SCTP_IS_MSG_ABANDONED(mp) ((mp)->b_flag & SCTP_MSG_FLAG_ABANDONED) 3240Sstevel@tonic-gate 3250Sstevel@tonic-gate /* 3260Sstevel@tonic-gate * Check if a message has expired. A message is expired if 3270Sstevel@tonic-gate * 1. It has a non-zero time to live value and has not been sent before 3280Sstevel@tonic-gate * that time expires. 3290Sstevel@tonic-gate * 2. It is sent using PRSCTP and it has not been SACK'ed before 3300Sstevel@tonic-gate * its lifetime expires. 3310Sstevel@tonic-gate */ 3320Sstevel@tonic-gate #define SCTP_MSG_TO_BE_ABANDONED(meta, mhdr, sctp) \ 3330Sstevel@tonic-gate (((!SCTP_CHUNK_ISSENT((meta)->b_cont) && (mhdr)->smh_ttl > 0) || \ 3340Sstevel@tonic-gate ((sctp)->sctp_prsctp_aware && ((mhdr)->smh_flags & MSG_PR_SCTP))) && \ 3350Sstevel@tonic-gate ((lbolt64 - (mhdr)->smh_tob) > (mhdr)->smh_ttl)) 3360Sstevel@tonic-gate 3370Sstevel@tonic-gate /* SCTP association hash function. */ 3380Sstevel@tonic-gate #define SCTP_CONN_HASH(ports) \ 3390Sstevel@tonic-gate ((((ports) ^ ((ports) >> 16)) * 31) & (sctp_conn_hash_size - 1)) 3400Sstevel@tonic-gate 3410Sstevel@tonic-gate /* 3420Sstevel@tonic-gate * Bind hash array size and hash function. The size must be a power 3430Sstevel@tonic-gate * of 2 and lport must be in host byte order. 3440Sstevel@tonic-gate */ 3450Sstevel@tonic-gate #define SCTP_BIND_FANOUT_SIZE 2048 3460Sstevel@tonic-gate #define SCTP_BIND_HASH(lport) (((lport) * 31) & (SCTP_BIND_FANOUT_SIZE - 1)) 3470Sstevel@tonic-gate 3480Sstevel@tonic-gate /* options that SCTP negotiates during association establishment */ 3490Sstevel@tonic-gate #define SCTP_PRSCTP_OPTION 0x01 3500Sstevel@tonic-gate 3510Sstevel@tonic-gate /* 3520Sstevel@tonic-gate * Listener hash array size and hash function. The size must be a power 3530Sstevel@tonic-gate * of 2 and lport must be in host byte order. 3540Sstevel@tonic-gate */ 3550Sstevel@tonic-gate #define SCTP_LISTEN_FANOUT_SIZE 512 3560Sstevel@tonic-gate #define SCTP_LISTEN_HASH(lport) (((lport) * 31) & (SCTP_LISTEN_FANOUT_SIZE - 1)) 3570Sstevel@tonic-gate 3580Sstevel@tonic-gate typedef struct sctp_tf_s { 3590Sstevel@tonic-gate struct sctp_s *tf_sctp; 3600Sstevel@tonic-gate kmutex_t tf_lock; 3610Sstevel@tonic-gate } sctp_tf_t; 3620Sstevel@tonic-gate 3630Sstevel@tonic-gate /* SCTP association hash list */ 3640Sstevel@tonic-gate extern sctp_tf_t *sctp_conn_fanout; 3650Sstevel@tonic-gate /* Size of sctp_conn_fanout */ 3660Sstevel@tonic-gate extern uint_t sctp_conn_hash_size; 3670Sstevel@tonic-gate 3680Sstevel@tonic-gate /* SCTP bind hash list - all sctp_t with state >= BOUND. */ 3690Sstevel@tonic-gate extern sctp_tf_t sctp_bind_fanout[]; 3700Sstevel@tonic-gate 3710Sstevel@tonic-gate /* SCTP listener hash list - all sctp_t with state == LISTEN. */ 3720Sstevel@tonic-gate extern sctp_tf_t sctp_listen_fanout[]; 3730Sstevel@tonic-gate 3740Sstevel@tonic-gate /* Round up the value to the nearest mss. */ 3750Sstevel@tonic-gate #define MSS_ROUNDUP(value, mss) ((((value) - 1) / (mss) + 1) * (mss)) 3760Sstevel@tonic-gate 3770Sstevel@tonic-gate extern sin_t sctp_sin_null; /* Zero address for quick clears */ 3780Sstevel@tonic-gate extern sin6_t sctp_sin6_null; /* Zero address for quick clears */ 3790Sstevel@tonic-gate 3800Sstevel@tonic-gate #define SCTP_IS_DETACHED(sctp) ((sctp)->sctp_detached) 3810Sstevel@tonic-gate 3820Sstevel@tonic-gate extern mib2_sctp_t sctp_mib; /* SNMP fixed size info */ 3830Sstevel@tonic-gate 3841735Skcpoon /* SCTP kstat */ 3851735Skcpoon typedef struct sctp_kstat_s { 3861735Skcpoon kstat_named_t sctp_add_faddr; 3871735Skcpoon kstat_named_t sctp_add_timer; 3881735Skcpoon kstat_named_t sctp_conn_create; 3891735Skcpoon kstat_named_t sctp_find_next_tq; 3901735Skcpoon kstat_named_t sctp_fr_add_hdr; 3911735Skcpoon kstat_named_t sctp_fr_not_found; 3921735Skcpoon kstat_named_t sctp_output_failed; 3931735Skcpoon kstat_named_t sctp_rexmit_failed; 3941735Skcpoon kstat_named_t sctp_send_init_failed; 3951735Skcpoon kstat_named_t sctp_send_cookie_failed; 3961735Skcpoon kstat_named_t sctp_send_cookie_ack_failed; 3971735Skcpoon kstat_named_t sctp_send_err_failed; 3981735Skcpoon kstat_named_t sctp_send_sack_failed; 3991735Skcpoon kstat_named_t sctp_send_shutdown_failed; 4001735Skcpoon kstat_named_t sctp_send_shutdown_ack_failed; 4011735Skcpoon kstat_named_t sctp_send_shutdown_comp_failed; 4021735Skcpoon kstat_named_t sctp_send_user_abort_failed; 4031735Skcpoon kstat_named_t sctp_send_asconf_failed; 4041735Skcpoon kstat_named_t sctp_send_asconf_ack_failed; 4051735Skcpoon kstat_named_t sctp_send_ftsn_failed; 4061735Skcpoon kstat_named_t sctp_send_hb_failed; 4071735Skcpoon kstat_named_t sctp_return_hb_failed; 4081735Skcpoon kstat_named_t sctp_ss_rexmit_failed; 4091735Skcpoon kstat_named_t sctp_cl_connect; 4101735Skcpoon kstat_named_t sctp_cl_assoc_change; 4111735Skcpoon kstat_named_t sctp_cl_check_addrs; 4121735Skcpoon } sctp_kstat_t; 4131735Skcpoon 4141735Skcpoon extern sctp_kstat_t sctp_statistics; 4151735Skcpoon 4161735Skcpoon #define SCTP_KSTAT(x) (sctp_statistics.x.value.ui64++) 4171735Skcpoon 4180Sstevel@tonic-gate /* 4190Sstevel@tonic-gate * Object to represent database of options to search passed to 4200Sstevel@tonic-gate * {sock,tpi}optcom_req() interface routine to take care of option 4210Sstevel@tonic-gate * management and associated methods. 4220Sstevel@tonic-gate * XXX These and other externs should ideally move to a SCTP header 4230Sstevel@tonic-gate */ 4240Sstevel@tonic-gate extern optdb_obj_t sctp_opt_obj; 4250Sstevel@tonic-gate extern uint_t sctp_max_optbuf_len; 4260Sstevel@tonic-gate 4270Sstevel@tonic-gate /* Data structure used to track received TSNs */ 4280Sstevel@tonic-gate typedef struct sctp_set_s { 4290Sstevel@tonic-gate struct sctp_set_s *next; 4300Sstevel@tonic-gate struct sctp_set_s *prev; 4310Sstevel@tonic-gate uint32_t begin; 4320Sstevel@tonic-gate uint32_t end; 4330Sstevel@tonic-gate } sctp_set_t; 4340Sstevel@tonic-gate 4350Sstevel@tonic-gate /* Data structure used to track TSNs for PR-SCTP */ 4360Sstevel@tonic-gate typedef struct sctp_ftsn_set_s { 4370Sstevel@tonic-gate struct sctp_ftsn_set_s *next; 4380Sstevel@tonic-gate ftsn_entry_t ftsn_entries; 4390Sstevel@tonic-gate } sctp_ftsn_set_t; 4400Sstevel@tonic-gate 4410Sstevel@tonic-gate /* Data structure used to track incoming SCTP streams */ 4420Sstevel@tonic-gate typedef struct sctp_instr_s { 4430Sstevel@tonic-gate mblk_t *istr_msgs; 4440Sstevel@tonic-gate int istr_nmsgs; 4450Sstevel@tonic-gate uint16_t nextseq; 4460Sstevel@tonic-gate struct sctp_s *sctp; 4470Sstevel@tonic-gate mblk_t *istr_reass; 4480Sstevel@tonic-gate } sctp_instr_t; 4490Sstevel@tonic-gate 4500Sstevel@tonic-gate /* Reassembly data structure (per-stream) */ 4510Sstevel@tonic-gate typedef struct sctp_reass_s { 4520Sstevel@tonic-gate uint16_t ssn; 4530Sstevel@tonic-gate uint16_t needed; 4540Sstevel@tonic-gate uint16_t got; 4550Sstevel@tonic-gate mblk_t *tail; 4560Sstevel@tonic-gate boolean_t partial_delivered; 4570Sstevel@tonic-gate } sctp_reass_t; 4580Sstevel@tonic-gate 4590Sstevel@tonic-gate /* debugging */ 4600Sstevel@tonic-gate #undef dprint 4611676Sjpk #ifdef DEBUG 4620Sstevel@tonic-gate extern int sctpdebug; 4630Sstevel@tonic-gate #define dprint(level, args) { if (sctpdebug > (level)) printf args; } 4641676Sjpk #else 4650Sstevel@tonic-gate #define dprint(level, args) {} 4661676Sjpk #endif 4670Sstevel@tonic-gate 4680Sstevel@tonic-gate 4690Sstevel@tonic-gate /* Peer address tracking */ 4700Sstevel@tonic-gate 4710Sstevel@tonic-gate /* 4720Sstevel@tonic-gate * States for peer addresses 4730Sstevel@tonic-gate * 4740Sstevel@tonic-gate * SCTP_FADDRS_UNCONFIRMED: we have not communicated with this peer address 4750Sstevel@tonic-gate * before, mark it as unconfirmed so that we will not send data to it. 4760Sstevel@tonic-gate * All addresses initially are in unconfirmed state and required 4770Sstevel@tonic-gate * validation. SCTP sends a heartbeat to each of them and when it gets 4780Sstevel@tonic-gate * back a heartbeat ACK, the address will be marked as alive. This 4790Sstevel@tonic-gate * validation fixes a security issue with multihoming. If an attacker 4800Sstevel@tonic-gate * establishes an association with us and tells us that it has addresses 4810Sstevel@tonic-gate * belonging to another host A, this will prevent A from communicating 4820Sstevel@tonic-gate * with us. This is fixed by peer address validation. In the above case, 4830Sstevel@tonic-gate * A will respond with an abort. 4840Sstevel@tonic-gate * 4850Sstevel@tonic-gate * SCTP_FADDRS_ALIVE: this peer address is alive and we can communicate with 4860Sstevel@tonic-gate * it with no problem. 4870Sstevel@tonic-gate * 4880Sstevel@tonic-gate * SCTP_FADDRS_DOWN: we have exceeded the retransmission limit to this 4890Sstevel@tonic-gate * peer address. Once an address is marked down, we will only send 4900Sstevel@tonic-gate * a heartbeat to it every hb_interval in case it becomes alive now. 4910Sstevel@tonic-gate * 4920Sstevel@tonic-gate * SCTP_FADDRS_UNREACH: there is no suitable source address to send to 4930Sstevel@tonic-gate * this peer address. For example, the peer address is v6 but we only 4940Sstevel@tonic-gate * have v4 addresses. It is marked unreachable until there is an 4950Sstevel@tonic-gate * address configuration change. At that time, mark these addresses 4960Sstevel@tonic-gate * as unconfirmed and try again to see if those unreachable addresses 4970Sstevel@tonic-gate * are OK as we may have more source addresses. 4980Sstevel@tonic-gate */ 4990Sstevel@tonic-gate typedef enum { 5000Sstevel@tonic-gate SCTP_FADDRS_UNREACH, 5010Sstevel@tonic-gate SCTP_FADDRS_DOWN, 5020Sstevel@tonic-gate SCTP_FADDRS_ALIVE, 5030Sstevel@tonic-gate SCTP_FADDRS_UNCONFIRMED 5040Sstevel@tonic-gate } faddr_state_t; 5050Sstevel@tonic-gate 5060Sstevel@tonic-gate typedef struct sctp_faddr_s { 5070Sstevel@tonic-gate struct sctp_faddr_s *next; 5080Sstevel@tonic-gate faddr_state_t state; 5090Sstevel@tonic-gate 5100Sstevel@tonic-gate in6_addr_t faddr; 5110Sstevel@tonic-gate in6_addr_t saddr; 5120Sstevel@tonic-gate 5130Sstevel@tonic-gate int64_t hb_expiry; /* time to retransmit heartbeat */ 5140Sstevel@tonic-gate uint32_t hb_interval; /* the heartbeat interval */ 5150Sstevel@tonic-gate 5160Sstevel@tonic-gate int rto; /* RTO in tick */ 5170Sstevel@tonic-gate int srtt; /* Smoothed RTT in tick */ 5180Sstevel@tonic-gate int rttvar; /* RTT variance in tick */ 5190Sstevel@tonic-gate uint32_t rtt_updates; 5200Sstevel@tonic-gate int strikes; 5210Sstevel@tonic-gate int max_retr; 5220Sstevel@tonic-gate uint32_t sfa_pmss; 5230Sstevel@tonic-gate uint32_t cwnd; 5240Sstevel@tonic-gate uint32_t ssthresh; 5250Sstevel@tonic-gate uint32_t suna; /* sent - unack'ed */ 5260Sstevel@tonic-gate uint32_t pba; /* partial bytes acked */ 5270Sstevel@tonic-gate uint32_t acked; 5280Sstevel@tonic-gate int64_t lastactive; 5290Sstevel@tonic-gate mblk_t *timer_mp; /* retransmission timer control */ 5300Sstevel@tonic-gate uint32_t 5310Sstevel@tonic-gate hb_pending : 1, 5320Sstevel@tonic-gate timer_running : 1, 5330Sstevel@tonic-gate df : 1, 5340Sstevel@tonic-gate pmtu_discovered : 1, 5350Sstevel@tonic-gate 5360Sstevel@tonic-gate rc_timer_running : 1, 5370Sstevel@tonic-gate isv4 : 1; 5380Sstevel@tonic-gate 5390Sstevel@tonic-gate mblk_t *rc_timer_mp; /* reliable control chunk timer */ 5400Sstevel@tonic-gate ire_t *ire; /* cached IRE */ 5410Sstevel@tonic-gate uint32_t T3expire; /* # of times T3 timer expired */ 5420Sstevel@tonic-gate 5430Sstevel@tonic-gate uint64_t hb_secret; /* per addr "secret" in heartbeat */ 5440Sstevel@tonic-gate } sctp_faddr_t; 5450Sstevel@tonic-gate 5460Sstevel@tonic-gate /* Flags to indicate supported address type in the PARM_SUP_ADDRS. */ 5470Sstevel@tonic-gate #define PARM_SUPP_V6 0x1 5480Sstevel@tonic-gate #define PARM_SUPP_V4 0x2 5490Sstevel@tonic-gate 5500Sstevel@tonic-gate /* 5510Sstevel@tonic-gate * Set heartbeat interval plus jitter. The jitter is supposed to be random, 5520Sstevel@tonic-gate * up to +/- 50% of the RTO. We use gethrtime() here for performance reason 5530Sstevel@tonic-gate * as the jitter does not really need to be "very" random. 5540Sstevel@tonic-gate */ 5550Sstevel@tonic-gate #define SET_HB_INTVL(fp) \ 5560Sstevel@tonic-gate ((fp)->hb_interval + (fp)->rto + ((fp)->rto >> 1) - \ 5570Sstevel@tonic-gate (uint_t)gethrtime() % (fp)->rto); 5580Sstevel@tonic-gate 5590Sstevel@tonic-gate #define SCTP_IPIF_HASH 16 5600Sstevel@tonic-gate 5610Sstevel@tonic-gate typedef struct sctp_ipif_hash_s { 5620Sstevel@tonic-gate list_t sctp_ipif_list; 5630Sstevel@tonic-gate int ipif_count; 5640Sstevel@tonic-gate } sctp_ipif_hash_t; 5650Sstevel@tonic-gate 5660Sstevel@tonic-gate struct sctp_s; 5670Sstevel@tonic-gate 5680Sstevel@tonic-gate /* 5690Sstevel@tonic-gate * Control structure for each open SCTP stream, 5700Sstevel@tonic-gate * defined only within the kernel or for a kmem user. 5710Sstevel@tonic-gate * NOTE: sctp_reinit_values MUST have a line for each field in this structure! 5720Sstevel@tonic-gate */ 5730Sstevel@tonic-gate #if (defined(_KERNEL) || defined(_KMEMUSER)) 5740Sstevel@tonic-gate 5750Sstevel@tonic-gate typedef struct sctp_s { 5760Sstevel@tonic-gate 5770Sstevel@tonic-gate /* 5780Sstevel@tonic-gate * The following is shared with (and duplicated) in IP, so if you 5790Sstevel@tonic-gate * make changes, make sure you also change things in ip_sctp.c. 5800Sstevel@tonic-gate */ 5810Sstevel@tonic-gate struct sctp_s *sctp_conn_hash_next; 5820Sstevel@tonic-gate struct sctp_s *sctp_conn_hash_prev; 5830Sstevel@tonic-gate 5840Sstevel@tonic-gate struct sctp_s *sctp_listen_hash_next; 5850Sstevel@tonic-gate struct sctp_s *sctp_listen_hash_prev; 5860Sstevel@tonic-gate 5870Sstevel@tonic-gate sctp_tf_t *sctp_listen_tfp; /* Ptr to tf */ 5880Sstevel@tonic-gate sctp_tf_t *sctp_conn_tfp; /* Ptr to tf */ 5890Sstevel@tonic-gate 5900Sstevel@tonic-gate /* Global list of sctp */ 5910Sstevel@tonic-gate list_node_t sctp_list; 5920Sstevel@tonic-gate 5930Sstevel@tonic-gate sctp_faddr_t *sctp_faddrs; 594852Svi117747 int sctp_nfaddrs; 5950Sstevel@tonic-gate sctp_ipif_hash_t sctp_saddrs[SCTP_IPIF_HASH]; 5960Sstevel@tonic-gate int sctp_nsaddrs; 5970Sstevel@tonic-gate 5980Sstevel@tonic-gate /* 5990Sstevel@tonic-gate * These fields contain the same information as sctp_sctph->th_*port. 6000Sstevel@tonic-gate * However, the lookup functions can not use the header fields 6010Sstevel@tonic-gate * since during IP option manipulation the sctp_sctph pointer 6020Sstevel@tonic-gate * changes. 6030Sstevel@tonic-gate */ 6040Sstevel@tonic-gate union { 6050Sstevel@tonic-gate struct { 6060Sstevel@tonic-gate in_port_t sctpu_fport; /* Remote port */ 6070Sstevel@tonic-gate in_port_t sctpu_lport; /* Local port */ 6080Sstevel@tonic-gate } sctpu_ports1; 6090Sstevel@tonic-gate uint32_t sctpu_ports2; /* Rem port, */ 6100Sstevel@tonic-gate /* local port */ 6110Sstevel@tonic-gate /* Used for SCTP_MATCH performance */ 6120Sstevel@tonic-gate } sctp_sctpu; 6130Sstevel@tonic-gate #define sctp_fport sctp_sctpu.sctpu_ports1.sctpu_fport 6140Sstevel@tonic-gate #define sctp_lport sctp_sctpu.sctpu_ports1.sctpu_lport 6150Sstevel@tonic-gate #define sctp_ports sctp_sctpu.sctpu_ports2 6160Sstevel@tonic-gate 6170Sstevel@tonic-gate kmutex_t sctp_lock; 6180Sstevel@tonic-gate kcondvar_t sctp_cv; 6190Sstevel@tonic-gate boolean_t sctp_running; 6200Sstevel@tonic-gate 6210Sstevel@tonic-gate void *sctp_ulpd; /* SCTP upper layer desc. */ 6220Sstevel@tonic-gate 6230Sstevel@tonic-gate struct sctp_upcalls_s sctp_upcalls; /* upcalls for sctp_ulpd */ 6240Sstevel@tonic-gate #define sctp_ulp_newconn sctp_upcalls.su_newconn 6250Sstevel@tonic-gate #define sctp_ulp_connected sctp_upcalls.su_connected 6260Sstevel@tonic-gate #define sctp_ulp_disconnected sctp_upcalls.su_disconnected 6270Sstevel@tonic-gate #define sctp_ulp_disconnecting sctp_upcalls.su_disconnecting 6280Sstevel@tonic-gate #define sctp_ulp_recv sctp_upcalls.su_recv 6290Sstevel@tonic-gate #define sctp_ulp_xmitted sctp_upcalls.su_xmitted 6300Sstevel@tonic-gate #define sctp_ulp_prop sctp_upcalls.su_properties 6310Sstevel@tonic-gate 6320Sstevel@tonic-gate int32_t sctp_state; 6330Sstevel@tonic-gate 6340Sstevel@tonic-gate conn_t *sctp_connp; /* conn_t stuff */ 6350Sstevel@tonic-gate #define sctp_zoneid sctp_connp->conn_zoneid 6362263Ssommerfe #define sctp_allzones sctp_connp->conn_allzones 6372263Ssommerfe #define sctp_mac_exempt sctp_connp->conn_mac_exempt 6380Sstevel@tonic-gate #define sctp_credp sctp_connp->conn_cred 6392263Ssommerfe #define sctp_reuseaddr sctp_connp->conn_reuseaddr 6400Sstevel@tonic-gate 6410Sstevel@tonic-gate /* Peer address tracking */ 6420Sstevel@tonic-gate sctp_faddr_t *sctp_lastfaddr; /* last faddr in list */ 6430Sstevel@tonic-gate sctp_faddr_t *sctp_primary; /* primary faddr */ 6440Sstevel@tonic-gate sctp_faddr_t *sctp_current; /* current faddr */ 6450Sstevel@tonic-gate sctp_faddr_t *sctp_lastdata; /* last data seen from this */ 6460Sstevel@tonic-gate 6470Sstevel@tonic-gate /* Outbound data tracking */ 6480Sstevel@tonic-gate mblk_t *sctp_xmit_head; 6490Sstevel@tonic-gate mblk_t *sctp_xmit_tail; 6500Sstevel@tonic-gate mblk_t *sctp_xmit_unsent; 6510Sstevel@tonic-gate mblk_t *sctp_xmit_unsent_tail; 6520Sstevel@tonic-gate mblk_t *sctp_xmit_unacked; 6530Sstevel@tonic-gate 6540Sstevel@tonic-gate int32_t sctp_unacked; /* # of unacked bytes */ 6550Sstevel@tonic-gate int32_t sctp_unsent; /* # of unsent bytes in hand */ 6560Sstevel@tonic-gate 6570Sstevel@tonic-gate uint32_t sctp_ltsn; /* Local instance TSN */ 6580Sstevel@tonic-gate uint32_t sctp_lastack_rxd; /* Last rx'd cumtsn */ 6590Sstevel@tonic-gate uint32_t sctp_recovery_tsn; /* Exit from fast recovery */ 6600Sstevel@tonic-gate uint32_t sctp_adv_pap; /* Adv. Peer Ack Point */ 6610Sstevel@tonic-gate 6620Sstevel@tonic-gate uint16_t sctp_num_ostr; 6630Sstevel@tonic-gate uint16_t *sctp_ostrcntrs; 6640Sstevel@tonic-gate 6650Sstevel@tonic-gate /* sendmsg() default parameters */ 6660Sstevel@tonic-gate uint16_t sctp_def_stream; /* default stream id */ 6670Sstevel@tonic-gate uint16_t sctp_def_flags; /* default xmit flags */ 6680Sstevel@tonic-gate uint32_t sctp_def_ppid; /* default payload id */ 6690Sstevel@tonic-gate uint32_t sctp_def_context; /* default context */ 6700Sstevel@tonic-gate uint32_t sctp_def_timetolive; /* default msg TTL */ 6710Sstevel@tonic-gate 6720Sstevel@tonic-gate /* Inbound data tracking */ 6730Sstevel@tonic-gate sctp_set_t *sctp_sack_info; /* Sack tracking */ 6740Sstevel@tonic-gate mblk_t *sctp_ack_mp; /* Delayed ACK timer block */ 6750Sstevel@tonic-gate sctp_instr_t *sctp_instr; /* Instream trackers */ 6760Sstevel@tonic-gate mblk_t *sctp_uo_frags; /* Un-ordered msg. fragments */ 6770Sstevel@tonic-gate uint32_t sctp_ftsn; /* Peer's TSN */ 6780Sstevel@tonic-gate uint32_t sctp_lastacked; /* last cumtsn SACKd */ 6790Sstevel@tonic-gate uint16_t sctp_num_istr; /* No. of instreams */ 6800Sstevel@tonic-gate int32_t sctp_istr_nmsgs; /* No. of chunks in instreams */ 6810Sstevel@tonic-gate int32_t sctp_sack_gaps; /* No. of received gaps */ 6820Sstevel@tonic-gate int32_t sctp_sack_toggle; /* SACK every other pkt */ 6830Sstevel@tonic-gate 6840Sstevel@tonic-gate /* RTT calculation */ 6850Sstevel@tonic-gate uint32_t sctp_rtt_tsn; 6860Sstevel@tonic-gate int64_t sctp_out_time; 6870Sstevel@tonic-gate 6880Sstevel@tonic-gate /* Stats */ 6890Sstevel@tonic-gate uint64_t sctp_opkts; /* sent pkts */ 6900Sstevel@tonic-gate uint64_t sctp_obchunks; /* sent control chunks */ 6910Sstevel@tonic-gate uint64_t sctp_odchunks; /* sent ordered data chunks */ 6920Sstevel@tonic-gate uint64_t sctp_oudchunks; /* sent unord data chunks */ 6930Sstevel@tonic-gate uint64_t sctp_rxtchunks; /* retransmitted chunks */ 6940Sstevel@tonic-gate uint64_t sctp_ipkts; /* recv pkts */ 6950Sstevel@tonic-gate uint64_t sctp_ibchunks; /* recv control chunks */ 6960Sstevel@tonic-gate uint64_t sctp_idchunks; /* recv ordered data chunks */ 6970Sstevel@tonic-gate uint64_t sctp_iudchunks; /* recv unord data chunks */ 6980Sstevel@tonic-gate uint64_t sctp_fragdmsgs; 6990Sstevel@tonic-gate uint64_t sctp_reassmsgs; 7000Sstevel@tonic-gate uint32_t sctp_T1expire; /* # of times T1timer expired */ 7010Sstevel@tonic-gate uint32_t sctp_T2expire; /* # of times T2timer expired */ 7020Sstevel@tonic-gate uint32_t sctp_T3expire; /* # of times T3timer expired */ 7030Sstevel@tonic-gate uint32_t sctp_assoc_start_time; /* time when assoc was est. */ 7040Sstevel@tonic-gate 7050Sstevel@tonic-gate /* Outbound flow control */ 7060Sstevel@tonic-gate int32_t sctp_xmit_hiwater; /* Send high water mark */ 7070Sstevel@tonic-gate int32_t sctp_xmit_lowater; /* Send low water mark */ 7080Sstevel@tonic-gate uint32_t sctp_frwnd; /* Peer RWND */ 7090Sstevel@tonic-gate uint32_t sctp_cwnd_max; 7100Sstevel@tonic-gate 7110Sstevel@tonic-gate /* Inbound flow control */ 7120Sstevel@tonic-gate int32_t sctp_rwnd; /* Current receive window */ 713852Svi117747 int32_t sctp_irwnd; /* Initial receive window */ 7140Sstevel@tonic-gate int32_t sctp_rxqueued; /* No. of bytes in RX q's */ 7150Sstevel@tonic-gate 7160Sstevel@tonic-gate /* Pre-initialized composite headers */ 7170Sstevel@tonic-gate char *sctp_iphc; /* v4 sctp/ip hdr template buffer */ 7180Sstevel@tonic-gate char *sctp_iphc6; /* v6 sctp/ip hdr template buffer */ 7190Sstevel@tonic-gate 7200Sstevel@tonic-gate int32_t sctp_iphc_len; /* actual allocated v4 buffer size */ 7210Sstevel@tonic-gate int32_t sctp_iphc6_len; /* actual allocated v6 buffer size */ 7220Sstevel@tonic-gate 7230Sstevel@tonic-gate int32_t sctp_hdr_len; /* len of combined SCTP/IP v4 hdr */ 7240Sstevel@tonic-gate int32_t sctp_hdr6_len; /* len of combined SCTP/IP v6 hdr */ 7250Sstevel@tonic-gate 7260Sstevel@tonic-gate ipha_t *sctp_ipha; /* IPv4 header in the buffer */ 7270Sstevel@tonic-gate ip6_t *sctp_ip6h; /* IPv6 header in the buffer */ 7280Sstevel@tonic-gate 7290Sstevel@tonic-gate int32_t sctp_ip_hdr_len; /* Byte len of our current v4 hdr */ 7300Sstevel@tonic-gate int32_t sctp_ip_hdr6_len; /* Byte len of our current v6 hdr */ 7310Sstevel@tonic-gate 7320Sstevel@tonic-gate sctp_hdr_t *sctp_sctph; /* sctp header in combined v4 hdr */ 7330Sstevel@tonic-gate sctp_hdr_t *sctp_sctph6; /* sctp header in combined v6 hdr */ 7340Sstevel@tonic-gate 7350Sstevel@tonic-gate uint32_t sctp_lvtag; /* local SCTP instance verf tag */ 7360Sstevel@tonic-gate uint32_t sctp_fvtag; /* Peer's SCTP verf tag */ 7370Sstevel@tonic-gate 7380Sstevel@tonic-gate /* Path MTU Discovery */ 7390Sstevel@tonic-gate int64_t sctp_last_mtu_probe; 7400Sstevel@tonic-gate clock_t sctp_mtu_probe_intvl; 7410Sstevel@tonic-gate uint32_t sctp_mss; /* Max send size (not TCP MSS!) */ 7420Sstevel@tonic-gate 7430Sstevel@tonic-gate /* structs sctp_bits, sctp_events are for clearing all bits at once */ 7440Sstevel@tonic-gate struct { 7450Sstevel@tonic-gate uint32_t 7460Sstevel@tonic-gate 7470Sstevel@tonic-gate sctp_understands_asconf : 1, /* Peer handles ASCONF chunks */ 7480Sstevel@tonic-gate sctp_debug : 1, /* SO_DEBUG "socket" option. */ 7490Sstevel@tonic-gate sctp_cchunk_pend : 1, /* Control chunk in flight. */ 7500Sstevel@tonic-gate sctp_dgram_errind : 1, /* SO_DGRAM_ERRIND option */ 7510Sstevel@tonic-gate 7520Sstevel@tonic-gate sctp_linger : 1, /* SO_LINGER turned on */ 7530Sstevel@tonic-gate sctp_lingering : 1, /* Lingering in close */ 7540Sstevel@tonic-gate sctp_loopback: 1, /* src and dst are the same machine */ 7550Sstevel@tonic-gate sctp_force_sack : 1, 7560Sstevel@tonic-gate 7570Sstevel@tonic-gate sctp_ack_timer_running: 1, /* Delayed ACK timer running */ 7580Sstevel@tonic-gate sctp_recvdstaddr : 1, /* return T_EXTCONN_IND with dstaddr */ 7590Sstevel@tonic-gate sctp_hwcksum : 1, /* The NIC is capable of hwcksum */ 7600Sstevel@tonic-gate sctp_understands_addip : 1, 7610Sstevel@tonic-gate 7620Sstevel@tonic-gate sctp_bound_to_all : 1, 7630Sstevel@tonic-gate sctp_cansleep : 1, /* itf routines can sleep */ 7640Sstevel@tonic-gate sctp_detached : 1, /* If we're detached from a stream */ 7650Sstevel@tonic-gate sctp_send_adaption : 1, /* send adaption layer ind */ 7660Sstevel@tonic-gate 7670Sstevel@tonic-gate sctp_recv_adaption : 1, /* received adaption layer ind */ 7680Sstevel@tonic-gate sctp_ndelay : 1, /* turn off Nagle */ 7690Sstevel@tonic-gate sctp_condemned : 1, /* this sctp is about to disappear */ 7700Sstevel@tonic-gate sctp_chk_fast_rexmit : 1, /* check for fast rexmit message */ 771432Svi117747 772432Svi117747 sctp_prsctp_aware : 1, /* is peer PR-SCTP aware? */ 7731676Sjpk sctp_linklocal : 1, /* is linklocal assoc. */ 7741735Skcpoon sctp_rexmitting : 1, /* SCTP is retransmitting */ 7751932Svi117747 sctp_zero_win_probe : 1, /* doing zero win probe */ 7761735Skcpoon 7772263Ssommerfe sctp_dummy : 8; 7780Sstevel@tonic-gate } sctp_bits; 7790Sstevel@tonic-gate struct { 7800Sstevel@tonic-gate uint32_t 7810Sstevel@tonic-gate 7820Sstevel@tonic-gate sctp_recvsndrcvinfo : 1, 7830Sstevel@tonic-gate sctp_recvassocevnt : 1, 7840Sstevel@tonic-gate sctp_recvpathevnt : 1, 7850Sstevel@tonic-gate sctp_recvsendfailevnt : 1, 7860Sstevel@tonic-gate 7870Sstevel@tonic-gate sctp_recvpeererr : 1, 7880Sstevel@tonic-gate sctp_recvshutdownevnt : 1, 7890Sstevel@tonic-gate sctp_recvpdevnt : 1, 7900Sstevel@tonic-gate sctp_recvalevnt : 1; 7910Sstevel@tonic-gate } sctp_events; 7920Sstevel@tonic-gate #define sctp_priv_stream sctp_bits.sctp_priv_stream 7930Sstevel@tonic-gate #define sctp_understands_asconf sctp_bits.sctp_understands_asconf 7940Sstevel@tonic-gate #define sctp_debug sctp_bits.sctp_debug 7950Sstevel@tonic-gate #define sctp_cchunk_pend sctp_bits.sctp_cchunk_pend 7960Sstevel@tonic-gate #define sctp_dgram_errind sctp_bits.sctp_dgram_errind 7970Sstevel@tonic-gate #define sctp_linger sctp_bits.sctp_linger 7980Sstevel@tonic-gate #define sctp_lingering sctp_bits.sctp_lingering 7990Sstevel@tonic-gate #define sctp_loopback sctp_bits.sctp_loopback 8000Sstevel@tonic-gate #define sctp_force_sack sctp_bits.sctp_force_sack 8010Sstevel@tonic-gate #define sctp_ack_timer_running sctp_bits.sctp_ack_timer_running 8020Sstevel@tonic-gate #define sctp_recvdstaddr sctp_bits.sctp_recvdstaddr 8030Sstevel@tonic-gate #define sctp_hwcksum sctp_bits.sctp_hwcksum 8040Sstevel@tonic-gate #define sctp_understands_addip sctp_bits.sctp_understands_addip 8050Sstevel@tonic-gate #define sctp_bound_to_all sctp_bits.sctp_bound_to_all 8060Sstevel@tonic-gate #define sctp_cansleep sctp_bits.sctp_cansleep 8070Sstevel@tonic-gate #define sctp_detached sctp_bits.sctp_detached 8080Sstevel@tonic-gate #define sctp_send_adaption sctp_bits.sctp_send_adaption 8090Sstevel@tonic-gate #define sctp_recv_adaption sctp_bits.sctp_recv_adaption 8100Sstevel@tonic-gate #define sctp_ndelay sctp_bits.sctp_ndelay 8110Sstevel@tonic-gate #define sctp_condemned sctp_bits.sctp_condemned 8120Sstevel@tonic-gate #define sctp_chk_fast_rexmit sctp_bits.sctp_chk_fast_rexmit 8130Sstevel@tonic-gate #define sctp_prsctp_aware sctp_bits.sctp_prsctp_aware 814432Svi117747 #define sctp_linklocal sctp_bits.sctp_linklocal 8151735Skcpoon #define sctp_rexmitting sctp_bits.sctp_rexmitting 8161932Svi117747 #define sctp_zero_win_probe sctp_bits.sctp_zero_win_probe 8170Sstevel@tonic-gate 8180Sstevel@tonic-gate #define sctp_recvsndrcvinfo sctp_events.sctp_recvsndrcvinfo 8190Sstevel@tonic-gate #define sctp_recvassocevnt sctp_events.sctp_recvassocevnt 8200Sstevel@tonic-gate #define sctp_recvpathevnt sctp_events.sctp_recvpathevnt 8210Sstevel@tonic-gate #define sctp_recvsendfailevnt sctp_events.sctp_recvsendfailevnt 8220Sstevel@tonic-gate #define sctp_recvpeererr sctp_events.sctp_recvpeererr 8230Sstevel@tonic-gate #define sctp_recvshutdownevnt sctp_events.sctp_recvshutdownevnt 8240Sstevel@tonic-gate #define sctp_recvpdevnt sctp_events.sctp_recvpdevnt 8250Sstevel@tonic-gate #define sctp_recvalevnt sctp_events.sctp_recvalevnt 8260Sstevel@tonic-gate 8270Sstevel@tonic-gate /* Retransmit info */ 8280Sstevel@tonic-gate mblk_t *sctp_cookie_mp; /* cookie chunk, if rxt needed */ 8290Sstevel@tonic-gate int32_t sctp_strikes; /* Total number of assoc strikes */ 8300Sstevel@tonic-gate int32_t sctp_max_init_rxt; 8310Sstevel@tonic-gate int32_t sctp_pa_max_rxt; /* Max per-assoc retransmit cnt */ 8320Sstevel@tonic-gate int32_t sctp_pp_max_rxt; /* Max per-path retransmit cnt */ 8330Sstevel@tonic-gate uint32_t sctp_rto_max; 8340Sstevel@tonic-gate uint32_t sctp_init_rto_max; 8350Sstevel@tonic-gate uint32_t sctp_rto_min; 8360Sstevel@tonic-gate uint32_t sctp_rto_initial; 8370Sstevel@tonic-gate 8380Sstevel@tonic-gate int64_t sctp_last_secret_update; 8390Sstevel@tonic-gate uint8_t sctp_secret[SCTP_SECRET_LEN]; /* for cookie auth */ 8400Sstevel@tonic-gate uint8_t sctp_old_secret[SCTP_SECRET_LEN]; 8410Sstevel@tonic-gate uint32_t sctp_cookie_lifetime; /* cookie lifetime in ms */ 8420Sstevel@tonic-gate 8430Sstevel@tonic-gate /* 8440Sstevel@tonic-gate * Address family that app wishes returned addrsses to be in. 8450Sstevel@tonic-gate * Currently taken from address family used in T_BIND_REQ, but 8460Sstevel@tonic-gate * should really come from family used in original socket() call. 8470Sstevel@tonic-gate * Value can be AF_INET or AF_INET6. 8480Sstevel@tonic-gate */ 8490Sstevel@tonic-gate uint_t sctp_family; 8500Sstevel@tonic-gate ushort_t sctp_ipversion; 8510Sstevel@tonic-gate 8520Sstevel@tonic-gate /* Bind hash tables */ 8530Sstevel@tonic-gate kmutex_t *sctp_bind_lockp; /* Ptr to tf_lock */ 8540Sstevel@tonic-gate struct sctp_s *sctp_bind_hash; 8550Sstevel@tonic-gate struct sctp_s **sctp_ptpbhn; 8560Sstevel@tonic-gate 8570Sstevel@tonic-gate /* Shutdown / cleanup */ 8580Sstevel@tonic-gate sctp_faddr_t *sctp_shutdown_faddr; /* rotate faddr during shutd */ 8590Sstevel@tonic-gate int32_t sctp_client_errno; /* How the client screwed up */ 8600Sstevel@tonic-gate int sctp_lingertime; /* Close linger time (in seconds) */ 8610Sstevel@tonic-gate kmutex_t sctp_reflock; /* Protects sctp_refcnt & timer mp */ 8620Sstevel@tonic-gate ushort_t sctp_refcnt; /* No. of pending upstream msg */ 8630Sstevel@tonic-gate mblk_t *sctp_timer_mp; /* List of fired timers. */ 8640Sstevel@tonic-gate 8650Sstevel@tonic-gate /* Misc */ 8660Sstevel@tonic-gate uint_t sctp_bound_if; /* IPV6_BOUND_IF */ 8670Sstevel@tonic-gate 8680Sstevel@tonic-gate mblk_t *sctp_heartbeat_mp; /* Timer block for heartbeats */ 8690Sstevel@tonic-gate uint32_t sctp_hb_interval; /* Default hb_interval */ 8700Sstevel@tonic-gate 8710Sstevel@tonic-gate int32_t sctp_autoclose; /* Auto disconnect in ticks */ 8720Sstevel@tonic-gate int64_t sctp_active; /* Last time data/sack on this conn */ 8730Sstevel@tonic-gate uint32_t sctp_tx_adaption_code; /* TX adaptation code */ 8740Sstevel@tonic-gate uint32_t sctp_rx_adaption_code; /* RX adaptation code */ 8750Sstevel@tonic-gate 8760Sstevel@tonic-gate /* Reliable control chunks */ 8770Sstevel@tonic-gate mblk_t *sctp_cxmit_list; /* Xmit list for control chunks */ 8780Sstevel@tonic-gate uint32_t sctp_lcsn; /* Our serial number */ 8790Sstevel@tonic-gate uint32_t sctp_fcsn; /* Peer serial number */ 8800Sstevel@tonic-gate 8810Sstevel@tonic-gate /* Per association receive queue */ 8820Sstevel@tonic-gate kmutex_t sctp_recvq_lock; 8830Sstevel@tonic-gate mblk_t *sctp_recvq; 8840Sstevel@tonic-gate mblk_t *sctp_recvq_tail; 8850Sstevel@tonic-gate taskq_t *sctp_recvq_tq; 8860Sstevel@tonic-gate 8870Sstevel@tonic-gate /* Send queue to IP */ 8880Sstevel@tonic-gate kmutex_t sctp_sendq_lock; 8890Sstevel@tonic-gate mblk_t *sctp_sendq; 8900Sstevel@tonic-gate mblk_t *sctp_sendq_tail; 8910Sstevel@tonic-gate boolean_t sctp_sendq_sending; 8920Sstevel@tonic-gate 8930Sstevel@tonic-gate /* IPv6 ancillary data */ 8940Sstevel@tonic-gate uint_t sctp_ipv6_recvancillary; /* flags */ 8950Sstevel@tonic-gate #define SCTP_IPV6_RECVPKTINFO 0x01 /* IPV6_RECVPKTINFO opt */ 8960Sstevel@tonic-gate #define SCTP_IPV6_RECVHOPLIMIT 0x02 /* IPV6_RECVHOPLIMIT opt */ 8970Sstevel@tonic-gate #define SCTP_IPV6_RECVHOPOPTS 0x04 /* IPV6_RECVHOPOPTS opt */ 8980Sstevel@tonic-gate #define SCTP_IPV6_RECVDSTOPTS 0x08 /* IPV6_RECVDSTOPTS opt */ 8990Sstevel@tonic-gate #define SCTP_IPV6_RECVRTHDR 0x10 /* IPV6_RECVRTHDR opt */ 9000Sstevel@tonic-gate #define SCTP_IPV6_RECVRTDSTOPTS 0x20 /* IPV6_RECVRTHDRDSTOPTS opt */ 9010Sstevel@tonic-gate 9020Sstevel@tonic-gate uint_t sctp_recvifindex; /* last rcvd IPV6_RCVPKTINFO */ 9030Sstevel@tonic-gate uint_t sctp_recvhops; /* " IPV6_RECVHOPLIMIT */ 9040Sstevel@tonic-gate ip6_hbh_t *sctp_hopopts; /* " IPV6_RECVHOPOPTS */ 9050Sstevel@tonic-gate ip6_dest_t *sctp_dstopts; /* " IPV6_RECVDSTOPTS */ 9060Sstevel@tonic-gate ip6_dest_t *sctp_rtdstopts; /* " IPV6_RECVRTHDRDSTOPTS */ 9070Sstevel@tonic-gate ip6_rthdr_t *sctp_rthdr; /* " IPV6_RECVRTHDR */ 9080Sstevel@tonic-gate uint_t sctp_hopoptslen; 9090Sstevel@tonic-gate uint_t sctp_dstoptslen; 9100Sstevel@tonic-gate uint_t sctp_rtdstoptslen; 9110Sstevel@tonic-gate uint_t sctp_rthdrlen; 9120Sstevel@tonic-gate 9130Sstevel@tonic-gate ip6_pkt_t sctp_sticky_ipp; /* Sticky options */ 9140Sstevel@tonic-gate #define sctp_ipp_fields sctp_sticky_ipp.ipp_fields 9150Sstevel@tonic-gate #define sctp_ipp_ifindex sctp_sticky_ipp.ipp_ifindex 9160Sstevel@tonic-gate #define sctp_ipp_addr sctp_sticky_ipp.ipp_addr 9170Sstevel@tonic-gate #define sctp_ipp_hoplimit sctp_sticky_ipp.ipp_hoplimit 9180Sstevel@tonic-gate #define sctp_ipp_hopoptslen sctp_sticky_ipp.ipp_hopoptslen 9190Sstevel@tonic-gate #define sctp_ipp_rtdstoptslen sctp_sticky_ipp.ipp_rtdstoptslen 9200Sstevel@tonic-gate #define sctp_ipp_rthdrlen sctp_sticky_ipp.ipp_rthdrlen 9210Sstevel@tonic-gate #define sctp_ipp_dstoptslen sctp_sticky_ipp.ipp_dstoptslen 9220Sstevel@tonic-gate #define sctp_ipp_hopopts sctp_sticky_ipp.ipp_hopopts 9230Sstevel@tonic-gate #define sctp_ipp_rtdstopts sctp_sticky_ipp.ipp_rtdstopts 9240Sstevel@tonic-gate #define sctp_ipp_rthdr sctp_sticky_ipp.ipp_rthdr 9250Sstevel@tonic-gate #define sctp_ipp_dstopts sctp_sticky_ipp.ipp_dstopts 9262283Skp158701 #define sctp_ipp_pathmtu sctp_sticky_ipp.ipp_pathmtu 9270Sstevel@tonic-gate #define sctp_ipp_nexthop sctp_sticky_ipp.ipp_nexthop 9280Sstevel@tonic-gate /* Stats */ 9290Sstevel@tonic-gate uint64_t sctp_msgcount; 9300Sstevel@tonic-gate uint64_t sctp_prsctpdrop; 9311676Sjpk 9321676Sjpk uint_t sctp_v4label_len; /* length of cached v4 label */ 9331676Sjpk uint_t sctp_v6label_len; /* length of cached v6 label */ 9341735Skcpoon uint32_t sctp_rxt_nxttsn; /* Next TSN to be rexmitted */ 9351735Skcpoon uint32_t sctp_rxt_maxtsn; /* Max TSN sent at time out */ 9360Sstevel@tonic-gate } sctp_t; 9370Sstevel@tonic-gate 9380Sstevel@tonic-gate extern list_t sctp_g_list; /* Head of SCTP instance data chain */ 9390Sstevel@tonic-gate extern kmutex_t sctp_g_lock; 9400Sstevel@tonic-gate 9410Sstevel@tonic-gate #endif /* (defined(_KERNEL) || defined(_KMEMUSER)) */ 9420Sstevel@tonic-gate 9430Sstevel@tonic-gate extern queue_t *sctp_g_q; /* Default queue used during detached closes */ 9440Sstevel@tonic-gate extern sctp_t *gsctp; 9450Sstevel@tonic-gate 9460Sstevel@tonic-gate /* Padding mblk for SCTP chunks. */ 9470Sstevel@tonic-gate extern mblk_t *sctp_pad_mp; 9480Sstevel@tonic-gate 9490Sstevel@tonic-gate extern void sctp_ack_timer(sctp_t *); 9500Sstevel@tonic-gate extern size_t sctp_adaption_code_param(sctp_t *, uchar_t *); 9510Sstevel@tonic-gate extern void sctp_adaption_event(sctp_t *); 9521735Skcpoon extern int sctp_add_faddr(sctp_t *, in6_addr_t *, int, boolean_t); 9530Sstevel@tonic-gate extern boolean_t sctp_add_ftsn_set(sctp_ftsn_set_t **, sctp_faddr_t *, mblk_t *, 9540Sstevel@tonic-gate uint_t *, uint32_t *); 9550Sstevel@tonic-gate extern boolean_t sctp_add_recvq(sctp_t *, mblk_t *, boolean_t); 9560Sstevel@tonic-gate extern void sctp_add_sendq(sctp_t *, mblk_t *); 9570Sstevel@tonic-gate extern void sctp_add_unrec_parm(sctp_parm_hdr_t *, mblk_t **); 9580Sstevel@tonic-gate extern size_t sctp_addr_params(sctp_t *, int, uchar_t *); 959432Svi117747 extern size_t sctp_addr_params_len(sctp_t *, int, boolean_t); 960252Svi117747 extern mblk_t *sctp_add_proto_hdr(sctp_t *, sctp_faddr_t *, mblk_t *, int, 961252Svi117747 int *); 9620Sstevel@tonic-gate extern void sctp_addr_req(sctp_t *, mblk_t *); 9630Sstevel@tonic-gate extern sctp_t *sctp_addrlist2sctp(mblk_t *, sctp_hdr_t *, sctp_chunk_hdr_t *, 9640Sstevel@tonic-gate uint_t, zoneid_t); 9650Sstevel@tonic-gate extern void sctp_add_hdr(sctp_t *, uchar_t *, size_t); 9660Sstevel@tonic-gate extern void sctp_check_adv_ack_pt(sctp_t *, mblk_t *, mblk_t *); 9670Sstevel@tonic-gate extern void sctp_assoc_event(sctp_t *, uint16_t, uint16_t, 9680Sstevel@tonic-gate sctp_chunk_hdr_t *); 9690Sstevel@tonic-gate 9700Sstevel@tonic-gate extern void sctp_bind_hash_insert(sctp_tf_t *, sctp_t *, int); 9710Sstevel@tonic-gate extern void sctp_bind_hash_remove(sctp_t *); 9721676Sjpk extern int sctp_bindi(sctp_t *, in_port_t, boolean_t, int, in_port_t *); 973852Svi117747 extern int sctp_bind_add(sctp_t *, const void *, uint32_t, boolean_t, 974852Svi117747 in_port_t); 9750Sstevel@tonic-gate extern int sctp_bind_del(sctp_t *, const void *, uint32_t, boolean_t); 9760Sstevel@tonic-gate extern int sctp_build_hdrs(sctp_t *); 9770Sstevel@tonic-gate 9780Sstevel@tonic-gate extern int sctp_check_abandoned_msg(sctp_t *, mblk_t *); 9790Sstevel@tonic-gate extern void sctp_chunkify(sctp_t *, int, int); 9800Sstevel@tonic-gate extern void sctp_clean_death(sctp_t *, int); 9810Sstevel@tonic-gate extern void sctp_close_eager(sctp_t *); 9820Sstevel@tonic-gate extern int sctp_compare_faddrsets(sctp_faddr_t *, sctp_faddr_t *); 9830Sstevel@tonic-gate extern void sctp_congest_reset(sctp_t *); 9840Sstevel@tonic-gate extern void sctp_conn_hash_insert(sctp_tf_t *, sctp_t *, int); 9850Sstevel@tonic-gate extern void sctp_conn_hash_remove(sctp_t *); 9860Sstevel@tonic-gate extern sctp_t *sctp_conn_match(in6_addr_t *, in6_addr_t *, uint32_t, uint_t, 9870Sstevel@tonic-gate zoneid_t); 9880Sstevel@tonic-gate extern sctp_t *sctp_conn_request(sctp_t *, mblk_t *, uint_t, uint_t, 9890Sstevel@tonic-gate sctp_init_chunk_t *, mblk_t *); 9900Sstevel@tonic-gate extern int sctp_conprim_opt_process(queue_t *, mblk_t *, int *, int *, 9910Sstevel@tonic-gate int *); 9920Sstevel@tonic-gate extern uint32_t sctp_cumack(sctp_t *, uint32_t, mblk_t **); 9930Sstevel@tonic-gate extern sctp_t *sctp_create_eager(sctp_t *); 9940Sstevel@tonic-gate 9950Sstevel@tonic-gate extern void sctp_dispatch_rput(queue_t *, sctp_t *, sctp_hdr_t *, mblk_t *, 9960Sstevel@tonic-gate uint_t, uint_t, in6_addr_t); 9970Sstevel@tonic-gate extern char *sctp_display(sctp_t *, char *); 9981676Sjpk extern void sctp_display_all(void); 9990Sstevel@tonic-gate 10000Sstevel@tonic-gate extern void sctp_error_event(sctp_t *, sctp_chunk_hdr_t *); 10010Sstevel@tonic-gate 10020Sstevel@tonic-gate extern void sctp_faddr_alive(sctp_t *, sctp_faddr_t *); 10030Sstevel@tonic-gate extern int sctp_faddr_dead(sctp_t *, sctp_faddr_t *, int); 10041676Sjpk extern void sctp_faddr_fini(void); 10051676Sjpk extern void sctp_faddr_init(void); 10060Sstevel@tonic-gate extern void sctp_fast_rexmit(sctp_t *); 10070Sstevel@tonic-gate extern void sctp_fill_sack(sctp_t *, unsigned char *, int); 10080Sstevel@tonic-gate extern void sctp_free_faddr_timers(sctp_t *); 10090Sstevel@tonic-gate extern void sctp_free_ftsn_set(sctp_ftsn_set_t *); 10100Sstevel@tonic-gate extern void sctp_free_msg(mblk_t *); 10110Sstevel@tonic-gate extern void sctp_free_reass(sctp_instr_t *); 10120Sstevel@tonic-gate extern void sctp_free_set(sctp_set_t *); 10130Sstevel@tonic-gate extern void sctp_ftsn_sets_fini(void); 10140Sstevel@tonic-gate extern void sctp_ftsn_sets_init(void); 10150Sstevel@tonic-gate 1016852Svi117747 extern int sctp_get_addrlist(sctp_t *, const void *, uint32_t *, 1017852Svi117747 uchar_t **, int *, size_t *); 10180Sstevel@tonic-gate extern int sctp_get_addrparams(sctp_t *, sctp_t *, mblk_t *, 10190Sstevel@tonic-gate sctp_chunk_hdr_t *, uint_t *); 10201735Skcpoon extern void sctp_get_ire(sctp_t *, sctp_faddr_t *); 1021852Svi117747 extern void sctp_get_faddr_list(sctp_t *, uchar_t *, size_t); 10220Sstevel@tonic-gate extern mblk_t *sctp_get_first_sent(sctp_t *); 10230Sstevel@tonic-gate extern mblk_t *sctp_get_msg_to_send(sctp_t *, mblk_t **, mblk_t *, int *, 10240Sstevel@tonic-gate int32_t, uint32_t, sctp_faddr_t *); 1025852Svi117747 extern void sctp_get_saddr_list(sctp_t *, uchar_t *, size_t); 10260Sstevel@tonic-gate 10270Sstevel@tonic-gate extern int sctp_handle_error(sctp_t *, sctp_hdr_t *, sctp_chunk_hdr_t *, 10280Sstevel@tonic-gate mblk_t *); 10290Sstevel@tonic-gate extern void sctp_hash_destroy(void); 10300Sstevel@tonic-gate extern void sctp_hash_init(void); 10310Sstevel@tonic-gate extern int sctp_header_init_ipv4(sctp_t *, int); 10320Sstevel@tonic-gate extern int sctp_header_init_ipv6(sctp_t *, int); 10330Sstevel@tonic-gate extern void sctp_heartbeat_timer(sctp_t *); 10340Sstevel@tonic-gate 10350Sstevel@tonic-gate extern void sctp_icmp_error(sctp_t *, mblk_t *); 10360Sstevel@tonic-gate extern void sctp_inc_taskq(void); 10370Sstevel@tonic-gate extern void sctp_info_req(sctp_t *, mblk_t *); 10380Sstevel@tonic-gate extern mblk_t *sctp_init_mp(sctp_t *); 10390Sstevel@tonic-gate extern boolean_t sctp_initialize_params(sctp_t *, sctp_init_chunk_t *, 10400Sstevel@tonic-gate sctp_init_chunk_t *); 10410Sstevel@tonic-gate extern uint32_t sctp_init2vtag(sctp_chunk_hdr_t *); 10420Sstevel@tonic-gate extern void sctp_intf_event(sctp_t *, in6_addr_t, int, int); 10430Sstevel@tonic-gate extern void sctp_input_data(sctp_t *, mblk_t *, mblk_t *); 10440Sstevel@tonic-gate extern void sctp_instream_cleanup(sctp_t *, boolean_t); 10450Sstevel@tonic-gate extern int sctp_is_a_faddr_clean(sctp_t *); 10460Sstevel@tonic-gate 10470Sstevel@tonic-gate extern void sctp_kstat_init(void); 10480Sstevel@tonic-gate extern void sctp_kstat_fini(void); 10490Sstevel@tonic-gate 10500Sstevel@tonic-gate extern ssize_t sctp_link_abort(mblk_t *, uint16_t, char *, size_t, int, 10510Sstevel@tonic-gate boolean_t); 10520Sstevel@tonic-gate extern void sctp_listen_hash_insert(sctp_tf_t *, sctp_t *); 10530Sstevel@tonic-gate extern void sctp_listen_hash_remove(sctp_t *); 10540Sstevel@tonic-gate extern sctp_t *sctp_lookup(sctp_t *, in6_addr_t *, sctp_tf_t *, uint32_t *, 10550Sstevel@tonic-gate int); 10560Sstevel@tonic-gate extern sctp_faddr_t *sctp_lookup_faddr(sctp_t *, in6_addr_t *); 10570Sstevel@tonic-gate 10580Sstevel@tonic-gate extern mblk_t *sctp_make_err(sctp_t *, uint16_t, void *, size_t); 10590Sstevel@tonic-gate extern mblk_t *sctp_make_ftsn_chunk(sctp_t *, sctp_faddr_t *, 10600Sstevel@tonic-gate sctp_ftsn_set_t *, uint_t, uint32_t); 10610Sstevel@tonic-gate extern void sctp_make_ftsns(sctp_t *, mblk_t *, mblk_t *, mblk_t **, 10620Sstevel@tonic-gate sctp_faddr_t *, uint32_t *); 10630Sstevel@tonic-gate extern mblk_t *sctp_make_mp(sctp_t *, sctp_faddr_t *, int); 10640Sstevel@tonic-gate extern mblk_t *sctp_make_sack(sctp_t *, sctp_faddr_t *, mblk_t *); 10650Sstevel@tonic-gate extern void sctp_maxpsz_set(sctp_t *); 10660Sstevel@tonic-gate extern void sctp_move_faddr_timers(queue_t *, sctp_t *); 10670Sstevel@tonic-gate 10681676Sjpk extern void sctp_nd_free(void); 10690Sstevel@tonic-gate extern int sctp_nd_getset(queue_t *, MBLKP); 10701676Sjpk extern boolean_t sctp_nd_init(void); 10710Sstevel@tonic-gate extern sctp_parm_hdr_t *sctp_next_parm(sctp_parm_hdr_t *, ssize_t *); 10720Sstevel@tonic-gate 10730Sstevel@tonic-gate extern void sctp_ootb_shutdown_ack(sctp_t *, mblk_t *, uint_t); 10740Sstevel@tonic-gate extern size_t sctp_options_param(const sctp_t *, void *, int); 10750Sstevel@tonic-gate extern size_t sctp_options_param_len(const sctp_t *, int); 10760Sstevel@tonic-gate extern void sctp_output(sctp_t *sctp); 10770Sstevel@tonic-gate 10780Sstevel@tonic-gate extern boolean_t sctp_param_register(sctpparam_t *, int); 10790Sstevel@tonic-gate extern void sctp_partial_delivery_event(sctp_t *); 10800Sstevel@tonic-gate extern int sctp_process_cookie(sctp_t *, sctp_chunk_hdr_t *, mblk_t *, 10810Sstevel@tonic-gate sctp_init_chunk_t **, sctp_hdr_t *, int *, in6_addr_t *); 10820Sstevel@tonic-gate extern void sctp_process_heartbeat(sctp_t *, sctp_chunk_hdr_t *); 10830Sstevel@tonic-gate extern void sctp_process_sendq(sctp_t *); 10840Sstevel@tonic-gate extern void sctp_process_timer(sctp_t *); 10850Sstevel@tonic-gate 10860Sstevel@tonic-gate extern void sctp_redo_faddr_srcs(sctp_t *); 10870Sstevel@tonic-gate extern void sctp_regift_xmitlist(sctp_t *); 10880Sstevel@tonic-gate extern void sctp_return_heartbeat(sctp_t *, sctp_chunk_hdr_t *, mblk_t *); 10890Sstevel@tonic-gate extern void sctp_rexmit(sctp_t *, sctp_faddr_t *); 10901932Svi117747 extern mblk_t *sctp_rexmit_packet(sctp_t *, mblk_t **, mblk_t **, 10911932Svi117747 sctp_faddr_t *, uint_t *); 10920Sstevel@tonic-gate extern void sctp_rexmit_timer(sctp_t *, sctp_faddr_t *); 10930Sstevel@tonic-gate extern sctp_faddr_t *sctp_rotate_faddr(sctp_t *, sctp_faddr_t *); 10940Sstevel@tonic-gate 10950Sstevel@tonic-gate extern void sctp_sack(sctp_t *, mblk_t *); 10960Sstevel@tonic-gate extern int sctp_secure_restart_check(mblk_t *, sctp_chunk_hdr_t *, 10970Sstevel@tonic-gate uint32_t, int); 10980Sstevel@tonic-gate extern void sctp_send_abort(sctp_t *, uint32_t, uint16_t, char *, size_t, 10990Sstevel@tonic-gate mblk_t *, int, boolean_t); 11000Sstevel@tonic-gate extern void sctp_send_cookie_ack(sctp_t *); 11010Sstevel@tonic-gate extern void sctp_send_cookie_echo(sctp_t *, sctp_chunk_hdr_t *, mblk_t *); 11020Sstevel@tonic-gate extern void sctp_send_err(sctp_t *, mblk_t *, sctp_faddr_t *); 1103*2776Skp158701 extern void sctp_send_initack(sctp_t *, sctp_hdr_t *, sctp_chunk_hdr_t *, 1104*2776Skp158701 mblk_t *); 11050Sstevel@tonic-gate extern void sctp_send_shutdown(sctp_t *, int); 11060Sstevel@tonic-gate extern void sctp_send_heartbeat(sctp_t *, sctp_faddr_t *); 11070Sstevel@tonic-gate extern void sctp_sendfail_event(sctp_t *, mblk_t *, int, boolean_t); 11081735Skcpoon extern void sctp_set_faddr_current(sctp_t *, sctp_faddr_t *); 11091735Skcpoon extern int sctp_set_hdraddrs(sctp_t *); 11101932Svi117747 extern void sctp_set_saddr(sctp_t *, sctp_faddr_t *); 11111676Sjpk extern void sctp_sets_init(void); 11121676Sjpk extern void sctp_sets_fini(void); 11130Sstevel@tonic-gate extern void sctp_shutdown_event(sctp_t *); 11140Sstevel@tonic-gate extern void sctp_stop_faddr_timers(sctp_t *); 11151735Skcpoon extern int sctp_shutdown_received(sctp_t *, sctp_chunk_hdr_t *, boolean_t, 11161735Skcpoon boolean_t, sctp_faddr_t *); 11170Sstevel@tonic-gate extern void sctp_shutdown_complete(sctp_t *); 11180Sstevel@tonic-gate extern void sctp_set_if_mtu(sctp_t *); 11190Sstevel@tonic-gate extern void sctp_set_iplen(sctp_t *, mblk_t *); 11200Sstevel@tonic-gate extern void sctp_set_ulp_prop(sctp_t *); 11211735Skcpoon extern void sctp_ss_rexmit(sctp_t *); 11220Sstevel@tonic-gate extern size_t sctp_supaddr_param_len(sctp_t *); 11230Sstevel@tonic-gate extern size_t sctp_supaddr_param(sctp_t *, uchar_t *); 11240Sstevel@tonic-gate 11250Sstevel@tonic-gate extern void sctp_timer(sctp_t *, mblk_t *, clock_t); 11260Sstevel@tonic-gate extern mblk_t *sctp_timer_alloc(sctp_t *, pfv_t); 11270Sstevel@tonic-gate extern void sctp_timer_call(sctp_t *sctp, mblk_t *); 11280Sstevel@tonic-gate extern void sctp_timer_free(mblk_t *); 11290Sstevel@tonic-gate extern void sctp_timer_stop(mblk_t *); 11300Sstevel@tonic-gate extern void sctp_unlink_faddr(sctp_t *, sctp_faddr_t *); 11310Sstevel@tonic-gate 11321735Skcpoon extern void sctp_update_ire(sctp_t *sctp); 11331676Sjpk extern in_port_t sctp_update_next_port(in_port_t, zone_t *zone); 11340Sstevel@tonic-gate extern void sctp_update_rtt(sctp_t *, sctp_faddr_t *, clock_t); 11350Sstevel@tonic-gate extern void sctp_user_abort(sctp_t *, mblk_t *, boolean_t); 11360Sstevel@tonic-gate 11370Sstevel@tonic-gate extern void sctp_validate_peer(sctp_t *); 11380Sstevel@tonic-gate 11390Sstevel@tonic-gate extern void sctp_wput_ioctl(queue_t *, mblk_t *); 11400Sstevel@tonic-gate 11410Sstevel@tonic-gate extern int sctp_xmit_list_clean(sctp_t *, ssize_t); 11420Sstevel@tonic-gate 11430Sstevel@tonic-gate extern void sctp_zap_addrs(sctp_t *); 11440Sstevel@tonic-gate extern void sctp_zap_faddrs(sctp_t *, int); 11450Sstevel@tonic-gate 1146852Svi117747 /* Contract private interface between SCTP and Clustering - PSARC/2005/602 */ 1147852Svi117747 1148852Svi117747 extern void (*cl_sctp_listen)(sa_family_t, uchar_t *, uint_t, in_port_t); 1149852Svi117747 extern void (*cl_sctp_unlisten)(sa_family_t, uchar_t *, uint_t, in_port_t); 1150852Svi117747 extern void (*cl_sctp_connect)(sa_family_t, uchar_t *, uint_t, in_port_t, 1151852Svi117747 uchar_t *, uint_t, in_port_t, boolean_t, cl_sctp_handle_t); 1152852Svi117747 extern void (*cl_sctp_disconnect)(sa_family_t, cl_sctp_handle_t); 1153852Svi117747 extern void (*cl_sctp_assoc_change)(sa_family_t, uchar_t *, size_t, uint_t, 1154852Svi117747 uchar_t *, size_t, uint_t, int, cl_sctp_handle_t); 1155852Svi117747 extern void (*cl_sctp_check_addrs)(sa_family_t, in_port_t, uchar_t **, 1156852Svi117747 size_t, uint_t *, boolean_t); 1157852Svi117747 11580Sstevel@tonic-gate /* Send a mp to IP. */ 11590Sstevel@tonic-gate #define IP_PUT(mp, conn, isv4) \ 11600Sstevel@tonic-gate { \ 11610Sstevel@tonic-gate if ((isv4)) \ 11620Sstevel@tonic-gate ip_output((conn), (mp), WR(sctp_g_q), IP_WPUT); \ 11630Sstevel@tonic-gate else \ 11640Sstevel@tonic-gate ip_output_v6((conn), (mp), WR(sctp_g_q), IP_WPUT); \ 11650Sstevel@tonic-gate } 11660Sstevel@tonic-gate 11670Sstevel@tonic-gate #define RUN_SCTP(sctp) \ 11680Sstevel@tonic-gate { \ 11690Sstevel@tonic-gate mutex_enter(&(sctp)->sctp_lock); \ 11700Sstevel@tonic-gate while ((sctp)->sctp_running) \ 11710Sstevel@tonic-gate cv_wait(&(sctp)->sctp_cv, &(sctp)->sctp_lock); \ 11720Sstevel@tonic-gate (sctp)->sctp_running = B_TRUE; \ 11730Sstevel@tonic-gate mutex_exit(&(sctp)->sctp_lock); \ 11740Sstevel@tonic-gate } 11750Sstevel@tonic-gate 11760Sstevel@tonic-gate /* Wake up recvq taskq */ 11770Sstevel@tonic-gate #define WAKE_SCTP(sctp) \ 11780Sstevel@tonic-gate { \ 11790Sstevel@tonic-gate mutex_enter(&(sctp)->sctp_lock); \ 11800Sstevel@tonic-gate if ((sctp)->sctp_timer_mp != NULL) \ 11810Sstevel@tonic-gate sctp_process_timer(sctp); \ 11820Sstevel@tonic-gate (sctp)->sctp_running = B_FALSE; \ 11830Sstevel@tonic-gate cv_broadcast(&(sctp)->sctp_cv); \ 11840Sstevel@tonic-gate mutex_exit(&(sctp)->sctp_lock); \ 11850Sstevel@tonic-gate } 11860Sstevel@tonic-gate 11870Sstevel@tonic-gate #ifdef __cplusplus 11880Sstevel@tonic-gate } 11890Sstevel@tonic-gate #endif 11900Sstevel@tonic-gate 11910Sstevel@tonic-gate #endif /* _INET_SCTP_SCTP_IMPL_H */ 1192