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 /* 2312474SGeorge.Shepherd@Sun.COM * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _INET_SCTP_SCTP_IMPL_H 270Sstevel@tonic-gate #define _INET_SCTP_SCTP_IMPL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #include <sys/inttypes.h> 300Sstevel@tonic-gate #include <sys/taskq.h> 310Sstevel@tonic-gate #include <sys/list.h> 320Sstevel@tonic-gate #include <sys/strsun.h> 331676Sjpk #include <sys/zone.h> 3412869SKacheong.Poon@Sun.COM #include <sys/cpuvar.h> 3512869SKacheong.Poon@Sun.COM #include <sys/clock_impl.h> 3612869SKacheong.Poon@Sun.COM 370Sstevel@tonic-gate #include <netinet/ip6.h> 380Sstevel@tonic-gate #include <inet/optcom.h> 3912016SGirish.Moodalbail@Sun.COM #include <inet/tunables.h> 400Sstevel@tonic-gate #include <netinet/sctp.h> 410Sstevel@tonic-gate #include <inet/sctp_itf.h> 423448Sdh155122 #include "sctp_stack.h" 433448Sdh155122 443448Sdh155122 #ifdef __cplusplus 453448Sdh155122 extern "C" { 463448Sdh155122 #endif 470Sstevel@tonic-gate 480Sstevel@tonic-gate /* Streams device identifying info and version */ 490Sstevel@tonic-gate #define SCTP_DEV_IDINFO "SCTP Streams device 1.0" 500Sstevel@tonic-gate 510Sstevel@tonic-gate #define SSN_GT(a, b) ((int16_t)((a)-(b)) > 0) 520Sstevel@tonic-gate #define SSN_GE(a, b) ((int16_t)((a)-(b)) >= 0) 530Sstevel@tonic-gate 540Sstevel@tonic-gate /* Default buffer size and flow control wake up threshold. */ 550Sstevel@tonic-gate #define SCTP_XMIT_LOWATER 8192 560Sstevel@tonic-gate #define SCTP_XMIT_HIWATER 102400 570Sstevel@tonic-gate #define SCTP_RECV_LOWATER 8192 580Sstevel@tonic-gate #define SCTP_RECV_HIWATER 102400 590Sstevel@tonic-gate 600Sstevel@tonic-gate /* SCTP Timer control structure */ 610Sstevel@tonic-gate typedef struct sctpt_s { 620Sstevel@tonic-gate pfv_t sctpt_pfv; /* The routine we are to call */ 630Sstevel@tonic-gate struct sctp_s *sctpt_sctp; /* The parameter we are to pass in */ 640Sstevel@tonic-gate struct sctp_faddr_s *sctpt_faddr; 650Sstevel@tonic-gate } sctpt_t; 660Sstevel@tonic-gate 670Sstevel@tonic-gate /* 680Sstevel@tonic-gate * Maximum number of duplicate TSNs we can report. This is currently 690Sstevel@tonic-gate * static, and governs the size of the mblk used to hold the duplicate 700Sstevel@tonic-gate * reports. The use of duplcate TSN reports is currently experimental, 710Sstevel@tonic-gate * so for now a static limit should suffice. 720Sstevel@tonic-gate */ 730Sstevel@tonic-gate #define SCTP_DUP_MBLK_SZ 64 740Sstevel@tonic-gate 750Sstevel@tonic-gate #define SCTP_IS_ADDR_UNSPEC(isv4, addr) \ 760Sstevel@tonic-gate ((isv4) ? IN6_IS_ADDR_V4MAPPED_ANY(&(addr)) : \ 770Sstevel@tonic-gate IN6_IS_ADDR_UNSPECIFIED(&(addr))) 780Sstevel@tonic-gate 790Sstevel@tonic-gate /* 8012016SGirish.Moodalbail@Sun.COM * SCTP properties/tunables 810Sstevel@tonic-gate */ 8212016SGirish.Moodalbail@Sun.COM #define sctps_max_init_retr sctps_propinfo_tbl[0].prop_cur_uval 8312016SGirish.Moodalbail@Sun.COM #define sctps_max_init_retr_high sctps_propinfo_tbl[0].prop_max_uval 8412016SGirish.Moodalbail@Sun.COM #define sctps_max_init_retr_low sctps_propinfo_tbl[0].prop_min_uval 8512016SGirish.Moodalbail@Sun.COM #define sctps_pa_max_retr sctps_propinfo_tbl[1].prop_cur_uval 8612016SGirish.Moodalbail@Sun.COM #define sctps_pa_max_retr_high sctps_propinfo_tbl[1].prop_max_uval 8712016SGirish.Moodalbail@Sun.COM #define sctps_pa_max_retr_low sctps_propinfo_tbl[1].prop_min_uval 8812016SGirish.Moodalbail@Sun.COM #define sctps_pp_max_retr sctps_propinfo_tbl[2].prop_cur_uval 8912016SGirish.Moodalbail@Sun.COM #define sctps_pp_max_retr_high sctps_propinfo_tbl[2].prop_max_uval 9012016SGirish.Moodalbail@Sun.COM #define sctps_pp_max_retr_low sctps_propinfo_tbl[2].prop_min_uval 9112016SGirish.Moodalbail@Sun.COM #define sctps_cwnd_max_ sctps_propinfo_tbl[3].prop_cur_uval 9212016SGirish.Moodalbail@Sun.COM #define sctps_smallest_nonpriv_port sctps_propinfo_tbl[4].prop_cur_uval 9312016SGirish.Moodalbail@Sun.COM #define sctps_ipv4_ttl sctps_propinfo_tbl[5].prop_cur_uval 9412016SGirish.Moodalbail@Sun.COM #define sctps_heartbeat_interval sctps_propinfo_tbl[6].prop_cur_uval 9512016SGirish.Moodalbail@Sun.COM #define sctps_heartbeat_interval_high sctps_propinfo_tbl[6].prop_max_uval 9612016SGirish.Moodalbail@Sun.COM #define sctps_heartbeat_interval_low sctps_propinfo_tbl[6].prop_min_uval 9712016SGirish.Moodalbail@Sun.COM #define sctps_initial_mtu sctps_propinfo_tbl[7].prop_cur_uval 9812016SGirish.Moodalbail@Sun.COM #define sctps_mtu_probe_interval sctps_propinfo_tbl[8].prop_cur_uval 9912016SGirish.Moodalbail@Sun.COM #define sctps_new_secret_interval sctps_propinfo_tbl[9].prop_cur_uval 10012016SGirish.Moodalbail@Sun.COM #define sctps_deferred_ack_interval sctps_propinfo_tbl[10].prop_cur_uval 10112016SGirish.Moodalbail@Sun.COM #define sctps_snd_lowat_fraction sctps_propinfo_tbl[11].prop_cur_uval 10212016SGirish.Moodalbail@Sun.COM #define sctps_ignore_path_mtu sctps_propinfo_tbl[12].prop_cur_bval 10312016SGirish.Moodalbail@Sun.COM #define sctps_initial_ssthresh sctps_propinfo_tbl[13].prop_cur_uval 10412016SGirish.Moodalbail@Sun.COM #define sctps_smallest_anon_port sctps_propinfo_tbl[14].prop_cur_uval 10512016SGirish.Moodalbail@Sun.COM #define sctps_largest_anon_port sctps_propinfo_tbl[15].prop_cur_uval 10612016SGirish.Moodalbail@Sun.COM #define sctps_xmit_hiwat sctps_propinfo_tbl[16].prop_cur_uval 10712016SGirish.Moodalbail@Sun.COM #define sctps_xmit_lowat sctps_propinfo_tbl[17].prop_cur_uval 10812016SGirish.Moodalbail@Sun.COM #define sctps_recv_hiwat sctps_propinfo_tbl[18].prop_cur_uval 10912016SGirish.Moodalbail@Sun.COM #define sctps_max_buf sctps_propinfo_tbl[19].prop_cur_uval 11012016SGirish.Moodalbail@Sun.COM #define sctps_rtt_updates sctps_propinfo_tbl[20].prop_cur_uval 11112016SGirish.Moodalbail@Sun.COM #define sctps_ipv6_hoplimit sctps_propinfo_tbl[21].prop_cur_uval 11212016SGirish.Moodalbail@Sun.COM #define sctps_rto_ming sctps_propinfo_tbl[22].prop_cur_uval 11312016SGirish.Moodalbail@Sun.COM #define sctps_rto_ming_high sctps_propinfo_tbl[22].prop_max_uval 11412016SGirish.Moodalbail@Sun.COM #define sctps_rto_ming_low sctps_propinfo_tbl[22].prop_min_uval 11512016SGirish.Moodalbail@Sun.COM #define sctps_rto_maxg sctps_propinfo_tbl[23].prop_cur_uval 11612016SGirish.Moodalbail@Sun.COM #define sctps_rto_maxg_high sctps_propinfo_tbl[23].prop_max_uval 11712016SGirish.Moodalbail@Sun.COM #define sctps_rto_maxg_low sctps_propinfo_tbl[23].prop_min_uval 11812016SGirish.Moodalbail@Sun.COM #define sctps_rto_initialg sctps_propinfo_tbl[24].prop_cur_uval 11912016SGirish.Moodalbail@Sun.COM #define sctps_rto_initialg_high sctps_propinfo_tbl[24].prop_max_uval 12012016SGirish.Moodalbail@Sun.COM #define sctps_rto_initialg_low sctps_propinfo_tbl[24].prop_min_uval 12112016SGirish.Moodalbail@Sun.COM #define sctps_cookie_life sctps_propinfo_tbl[25].prop_cur_uval 12212016SGirish.Moodalbail@Sun.COM #define sctps_cookie_life_high sctps_propinfo_tbl[25].prop_max_uval 12312016SGirish.Moodalbail@Sun.COM #define sctps_cookie_life_low sctps_propinfo_tbl[25].prop_min_uval 12412016SGirish.Moodalbail@Sun.COM #define sctps_max_in_streams sctps_propinfo_tbl[26].prop_cur_uval 12512016SGirish.Moodalbail@Sun.COM #define sctps_max_in_streams_high sctps_propinfo_tbl[26].prop_max_uval 12612016SGirish.Moodalbail@Sun.COM #define sctps_max_in_streams_low sctps_propinfo_tbl[26].prop_min_uval 12712016SGirish.Moodalbail@Sun.COM #define sctps_initial_out_streams sctps_propinfo_tbl[27].prop_cur_uval 12812016SGirish.Moodalbail@Sun.COM #define sctps_initial_out_streams_high sctps_propinfo_tbl[27].prop_max_uval 12912016SGirish.Moodalbail@Sun.COM #define sctps_initial_out_streams_low sctps_propinfo_tbl[27].prop_min_uval 13012016SGirish.Moodalbail@Sun.COM #define sctps_shutack_wait_bound sctps_propinfo_tbl[28].prop_cur_uval 13112016SGirish.Moodalbail@Sun.COM #define sctps_maxburst sctps_propinfo_tbl[29].prop_cur_uval 13212016SGirish.Moodalbail@Sun.COM #define sctps_addip_enabled sctps_propinfo_tbl[30].prop_cur_bval 13312016SGirish.Moodalbail@Sun.COM #define sctps_recv_hiwat_minmss sctps_propinfo_tbl[31].prop_cur_uval 13412016SGirish.Moodalbail@Sun.COM #define sctps_slow_start_initial sctps_propinfo_tbl[32].prop_cur_uval 13512016SGirish.Moodalbail@Sun.COM #define sctps_slow_start_after_idle sctps_propinfo_tbl[33].prop_cur_uval 13612016SGirish.Moodalbail@Sun.COM #define sctps_prsctp_enabled sctps_propinfo_tbl[34].prop_cur_bval 13712016SGirish.Moodalbail@Sun.COM #define sctps_fast_rxt_thresh sctps_propinfo_tbl[35].prop_cur_uval 13812016SGirish.Moodalbail@Sun.COM #define sctps_deferred_acks_max sctps_propinfo_tbl[36].prop_cur_uval 13912016SGirish.Moodalbail@Sun.COM #define sctps_wroff_xtra sctps_propinfo_tbl[37].prop_cur_uval 1400Sstevel@tonic-gate 1411735Skcpoon /* 1421735Skcpoon * Retransmission timer start and stop macro for a given faddr. 1431735Skcpoon */ 1441735Skcpoon #define SCTP_FADDR_TIMER_RESTART(sctp, fp, intvl) \ 1451735Skcpoon { \ 1461735Skcpoon dprint(3, ("faddr_timer_restart: fp=%p %x:%x:%x:%x %d\n", \ 14713009SChandrasekar.Marimuthu@Sun.COM (void *)(fp), SCTP_PRINTADDR((fp)->sf_faddr), (int)(intvl))); \ 14813009SChandrasekar.Marimuthu@Sun.COM sctp_timer((sctp), (fp)->sf_timer_mp, (intvl)); \ 14913009SChandrasekar.Marimuthu@Sun.COM (fp)->sf_timer_running = 1; \ 1501735Skcpoon } 1511735Skcpoon 1521735Skcpoon #define SCTP_FADDR_TIMER_STOP(fp) \ 15313009SChandrasekar.Marimuthu@Sun.COM ASSERT((fp)->sf_timer_mp != NULL); \ 15413009SChandrasekar.Marimuthu@Sun.COM if ((fp)->sf_timer_running) { \ 15513009SChandrasekar.Marimuthu@Sun.COM sctp_timer_stop((fp)->sf_timer_mp); \ 15613009SChandrasekar.Marimuthu@Sun.COM (fp)->sf_timer_running = 0; \ 1571735Skcpoon } 1581735Skcpoon 15910212SGeorge.Shepherd@Sun.COM /* For per endpoint association statistics */ 16010212SGeorge.Shepherd@Sun.COM #define SCTP_MAX_RTO(sctp, fp) { \ 16110212SGeorge.Shepherd@Sun.COM /* \ 16210212SGeorge.Shepherd@Sun.COM * Record the maximum observed RTO, \ 16310212SGeorge.Shepherd@Sun.COM * sctp_maxrto is zeroed elsewhere \ 16410212SGeorge.Shepherd@Sun.COM * at the end of each stats request. \ 16510212SGeorge.Shepherd@Sun.COM */ \ 16610212SGeorge.Shepherd@Sun.COM (sctp)->sctp_maxrto = \ 16713009SChandrasekar.Marimuthu@Sun.COM MAX((sctp)->sctp_maxrto, (fp)->sf_rto); \ 16810212SGeorge.Shepherd@Sun.COM DTRACE_PROBE2(sctp__maxrto, sctp_t *, \ 16910212SGeorge.Shepherd@Sun.COM sctp, struct sctp_faddr_s, fp); \ 17010212SGeorge.Shepherd@Sun.COM } 17110212SGeorge.Shepherd@Sun.COM 17212474SGeorge.Shepherd@Sun.COM #define SCTP_CALC_RXT(sctp, fp, max) \ 17312474SGeorge.Shepherd@Sun.COM { \ 17413009SChandrasekar.Marimuthu@Sun.COM if (((fp)->sf_rto <<= 1) > (max)) \ 17513009SChandrasekar.Marimuthu@Sun.COM (fp)->sf_rto = (max); \ 17612474SGeorge.Shepherd@Sun.COM SCTP_MAX_RTO(sctp, fp); \ 1771735Skcpoon } 1781735Skcpoon 1791735Skcpoon 1800Sstevel@tonic-gate #define SCTP_MAX_COMBINED_HEADER_LENGTH (60 + 12) /* Maxed out ip + sctp */ 1810Sstevel@tonic-gate #define SCTP_MAX_IP_OPTIONS_LENGTH (60 - IP_SIMPLE_HDR_LENGTH) 1820Sstevel@tonic-gate #define SCTP_MAX_HDR_LENGTH 60 1830Sstevel@tonic-gate 1840Sstevel@tonic-gate #define SCTP_SECRET_LEN 16 1850Sstevel@tonic-gate 18611373SGeorge.Shepherd@Sun.COM #define SCTP_REFHOLD(sctp) { \ 18711373SGeorge.Shepherd@Sun.COM mutex_enter(&(sctp)->sctp_reflock); \ 18811373SGeorge.Shepherd@Sun.COM (sctp)->sctp_refcnt++; \ 18911373SGeorge.Shepherd@Sun.COM DTRACE_PROBE1(sctp_refhold, sctp_t, sctp); \ 19011373SGeorge.Shepherd@Sun.COM ASSERT((sctp)->sctp_refcnt != 0); \ 19111373SGeorge.Shepherd@Sun.COM mutex_exit(&(sctp)->sctp_reflock); \ 1920Sstevel@tonic-gate } 1930Sstevel@tonic-gate 19411373SGeorge.Shepherd@Sun.COM #define SCTP_REFRELE(sctp) { \ 19511373SGeorge.Shepherd@Sun.COM mutex_enter(&(sctp)->sctp_reflock); \ 19611373SGeorge.Shepherd@Sun.COM ASSERT((sctp)->sctp_refcnt != 0); \ 19711373SGeorge.Shepherd@Sun.COM if (--(sctp)->sctp_refcnt == 0) { \ 19811373SGeorge.Shepherd@Sun.COM DTRACE_PROBE1(sctp_refrele, sctp_t, sctp); \ 19911373SGeorge.Shepherd@Sun.COM mutex_exit(&(sctp)->sctp_reflock); \ 20011373SGeorge.Shepherd@Sun.COM CONN_DEC_REF((sctp)->sctp_connp); \ 20111373SGeorge.Shepherd@Sun.COM } else { \ 20211373SGeorge.Shepherd@Sun.COM DTRACE_PROBE1(sctp_refrele, sctp_t, sctp); \ 20311373SGeorge.Shepherd@Sun.COM mutex_exit(&(sctp)->sctp_reflock); \ 20411373SGeorge.Shepherd@Sun.COM } \ 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 } \ 26612604SGeorge.Shepherd@Sun.COM DTRACE_PROBE3(sctp__chunk__sent1, sctp_t *, sctp, \ 26712604SGeorge.Shepherd@Sun.COM mblk_t *, mp, mblk_t *, meta); \ 2680Sstevel@tonic-gate (sctp)->sctp_unacked += (chunkdata); \ 2690Sstevel@tonic-gate (sctp)->sctp_unsent -= (chunkdata); \ 2700Sstevel@tonic-gate (sctp)->sctp_frwnd -= (chunkdata); \ 2710Sstevel@tonic-gate } else { \ 2720Sstevel@tonic-gate if (SCTP_CHUNK_ISACKED(mp)) { \ 2730Sstevel@tonic-gate (sctp)->sctp_unacked += (chunkdata); \ 2740Sstevel@tonic-gate } else { \ 27513009SChandrasekar.Marimuthu@Sun.COM ASSERT(SCTP_CHUNK_DEST(mp)->sf_suna >= ((chunkdata) + \ 2760Sstevel@tonic-gate sizeof (*sdc))); \ 27713009SChandrasekar.Marimuthu@Sun.COM SCTP_CHUNK_DEST(mp)->sf_suna -= ((chunkdata) + \ 2780Sstevel@tonic-gate sizeof (*sdc)); \ 2790Sstevel@tonic-gate } \ 28012604SGeorge.Shepherd@Sun.COM DTRACE_PROBE3(sctp__chunk__sent2, sctp_t *, sctp, \ 28112604SGeorge.Shepherd@Sun.COM mblk_t *, mp, mblk_t *, meta); \ 2820Sstevel@tonic-gate (mp)->b_flag &= ~(SCTP_CHUNK_FLAG_REXMIT | \ 2830Sstevel@tonic-gate SCTP_CHUNK_FLAG_ACKED); \ 2840Sstevel@tonic-gate SCTP_CHUNK_SET_SACKCNT(mp, 0); \ 2850Sstevel@tonic-gate BUMP_LOCAL(sctp->sctp_rxtchunks); \ 2860Sstevel@tonic-gate BUMP_LOCAL((sctp)->sctp_T3expire); \ 28713009SChandrasekar.Marimuthu@Sun.COM BUMP_LOCAL((fp)->sf_T3expire); \ 2880Sstevel@tonic-gate } \ 2890Sstevel@tonic-gate SCTP_SET_CHUNK_DEST(mp, fp); \ 29013009SChandrasekar.Marimuthu@Sun.COM (fp)->sf_suna += ((chunkdata) + sizeof (*sdc)); \ 2910Sstevel@tonic-gate } 2920Sstevel@tonic-gate 2930Sstevel@tonic-gate #define SCTP_CHUNK_ISSENT(mp) ((mp)->b_flag & SCTP_CHUNK_FLAG_SENT) 2940Sstevel@tonic-gate #define SCTP_CHUNK_CANSEND(mp) \ 2950Sstevel@tonic-gate (!(SCTP_CHUNK_ABANDONED(mp)) && \ 2960Sstevel@tonic-gate (((mp)->b_flag & (SCTP_CHUNK_FLAG_REXMIT|SCTP_CHUNK_FLAG_SENT)) != \ 2970Sstevel@tonic-gate SCTP_CHUNK_FLAG_SENT)) 2980Sstevel@tonic-gate 2990Sstevel@tonic-gate #define SCTP_CHUNK_DEST(mp) ((sctp_faddr_t *)(mp)->b_queue) 3000Sstevel@tonic-gate #define SCTP_SET_CHUNK_DEST(mp, fp) ((mp)->b_queue = (queue_t *)fp) 3010Sstevel@tonic-gate 30212604SGeorge.Shepherd@Sun.COM #define SCTP_CHUNK_REXMIT(sctp, mp) { \ 30312604SGeorge.Shepherd@Sun.COM DTRACE_PROBE2(sctp__chunk__rexmit, sctp_t *, sctp, mblk_t *, \ 30412604SGeorge.Shepherd@Sun.COM mp); \ 30512604SGeorge.Shepherd@Sun.COM (mp)->b_flag |= SCTP_CHUNK_FLAG_REXMIT; \ 30612604SGeorge.Shepherd@Sun.COM } 3070Sstevel@tonic-gate #define SCTP_CHUNK_CLEAR_REXMIT(mp) ((mp)->b_flag &= ~SCTP_CHUNK_FLAG_REXMIT) 3080Sstevel@tonic-gate #define SCTP_CHUNK_WANT_REXMIT(mp) ((mp)->b_flag & SCTP_CHUNK_FLAG_REXMIT) 3090Sstevel@tonic-gate 3100Sstevel@tonic-gate #define SCTP_CHUNK_ACKED(mp) \ 3110Sstevel@tonic-gate ((mp)->b_flag = (SCTP_CHUNK_FLAG_SENT|SCTP_CHUNK_FLAG_ACKED)) 3120Sstevel@tonic-gate #define SCTP_CHUNK_ISACKED(mp) ((mp)->b_flag & SCTP_CHUNK_FLAG_ACKED) 31312604SGeorge.Shepherd@Sun.COM #define SCTP_CHUNK_CLEAR_ACKED(sctp, mp) { \ 31412604SGeorge.Shepherd@Sun.COM DTRACE_PROBE2(sctp__chunk__clracked, sctp_t *, sctp, mblk_t *, \ 31512604SGeorge.Shepherd@Sun.COM mp); \ 31612604SGeorge.Shepherd@Sun.COM (mp)->b_flag &= ~SCTP_CHUNK_FLAG_ACKED; \ 31712604SGeorge.Shepherd@Sun.COM } 3180Sstevel@tonic-gate 3190Sstevel@tonic-gate #define SCTP_CHUNK_SACKCNT(mp) ((intptr_t)((mp)->b_prev)) 3200Sstevel@tonic-gate #define SCTP_CHUNK_SET_SACKCNT(mp, val) ((mp)->b_prev = \ 3210Sstevel@tonic-gate (mblk_t *)(uintptr_t)(val)) 3220Sstevel@tonic-gate 3230Sstevel@tonic-gate #define SCTP_MSG_SET_CHUNKED(mp) ((mp)->b_flag |= SCTP_MSG_FLAG_CHUNKED) 3240Sstevel@tonic-gate #define SCTP_MSG_CLEAR_CHUNKED(mp)((mp)->b_flag &= ~SCTP_MSG_FLAG_CHUNKED) 3250Sstevel@tonic-gate #define SCTP_IS_MSG_CHUNKED(mp) ((mp)->b_flag & SCTP_MSG_FLAG_CHUNKED) 3260Sstevel@tonic-gate 3270Sstevel@tonic-gate /* For PR-SCTP */ 3280Sstevel@tonic-gate #define SCTP_ABANDON_CHUNK(mp) ((mp)->b_flag |= SCTP_CHUNK_FLAG_ABANDONED) 3290Sstevel@tonic-gate #define SCTP_CHUNK_ABANDONED(mp) \ 3300Sstevel@tonic-gate ((mp)->b_flag & SCTP_CHUNK_FLAG_ABANDONED) 3310Sstevel@tonic-gate 3320Sstevel@tonic-gate #define SCTP_MSG_SET_ABANDONED(mp) \ 3330Sstevel@tonic-gate ((mp)->b_flag |= SCTP_MSG_FLAG_ABANDONED) 3340Sstevel@tonic-gate #define SCTP_MSG_CLEAR_ABANDONED(mp)((mp)->b_flag &= ~SCTP_MSG_FLAG_ABANDONED) 3350Sstevel@tonic-gate #define SCTP_IS_MSG_ABANDONED(mp) ((mp)->b_flag & SCTP_MSG_FLAG_ABANDONED) 3360Sstevel@tonic-gate 3370Sstevel@tonic-gate /* 3380Sstevel@tonic-gate * Check if a message has expired. A message is expired if 3390Sstevel@tonic-gate * 1. It has a non-zero time to live value and has not been sent before 3400Sstevel@tonic-gate * that time expires. 3410Sstevel@tonic-gate * 2. It is sent using PRSCTP and it has not been SACK'ed before 3420Sstevel@tonic-gate * its lifetime expires. 3430Sstevel@tonic-gate */ 3440Sstevel@tonic-gate #define SCTP_MSG_TO_BE_ABANDONED(meta, mhdr, sctp) \ 3450Sstevel@tonic-gate (((!SCTP_CHUNK_ISSENT((meta)->b_cont) && (mhdr)->smh_ttl > 0) || \ 3460Sstevel@tonic-gate ((sctp)->sctp_prsctp_aware && ((mhdr)->smh_flags & MSG_PR_SCTP))) && \ 34711066Srafael.vanoni@sun.com ((ddi_get_lbolt64() - (mhdr)->smh_tob) > (mhdr)->smh_ttl)) 3480Sstevel@tonic-gate 3490Sstevel@tonic-gate /* SCTP association hash function. */ 3503448Sdh155122 #define SCTP_CONN_HASH(sctps, ports) \ 3513448Sdh155122 ((((ports) ^ ((ports) >> 16)) * 31) & \ 3523448Sdh155122 ((sctps)->sctps_conn_hash_size - 1)) 3530Sstevel@tonic-gate 3540Sstevel@tonic-gate /* 35512869SKacheong.Poon@Sun.COM * Linked list struct to store SCTP listener association limit configuration 35612869SKacheong.Poon@Sun.COM * per IP stack. The list is stored at sctps_listener_conf in sctp_stack_t. 35712869SKacheong.Poon@Sun.COM * 35812869SKacheong.Poon@Sun.COM * sl_port: the listener port of this limit configuration 35912869SKacheong.Poon@Sun.COM * sl_ratio: the maximum amount of memory consumed by all concurrent SCTP 36012869SKacheong.Poon@Sun.COM * connections created by a listener does not exceed 1/tl_ratio 36112869SKacheong.Poon@Sun.COM * of the total system memory. Note that this is only an 36212869SKacheong.Poon@Sun.COM * approximation. 36312869SKacheong.Poon@Sun.COM * sl_link: linked list struct 36412869SKacheong.Poon@Sun.COM */ 36512869SKacheong.Poon@Sun.COM typedef struct sctp_listener_s { 36612869SKacheong.Poon@Sun.COM in_port_t sl_port; 36712869SKacheong.Poon@Sun.COM uint32_t sl_ratio; 36812869SKacheong.Poon@Sun.COM list_node_t sl_link; 36912869SKacheong.Poon@Sun.COM } sctp_listener_t; 37012869SKacheong.Poon@Sun.COM 37112869SKacheong.Poon@Sun.COM /* 37212869SKacheong.Poon@Sun.COM * If there is a limit set on the number of association allowed per each 37312869SKacheong.Poon@Sun.COM * listener, the following struct is used to store that counter. It keeps 37412869SKacheong.Poon@Sun.COM * the number of SCTP association created by a listener. Note that this needs 37512869SKacheong.Poon@Sun.COM * to be separated from the listener since the listener can go away before 37612869SKacheong.Poon@Sun.COM * all the associations are gone. 37712869SKacheong.Poon@Sun.COM * 37812869SKacheong.Poon@Sun.COM * When the struct is allocated, slc_cnt is set to 1. When a new association 37912869SKacheong.Poon@Sun.COM * is created by the listener, slc_cnt is incremented by 1. When an 38012869SKacheong.Poon@Sun.COM * association created by the listener goes away, slc_count is decremented by 38112869SKacheong.Poon@Sun.COM * 1. When the listener itself goes away, slc_cnt is decremented by one. 38212869SKacheong.Poon@Sun.COM * The last association (or the listener) which decrements slc_cnt to zero 38312869SKacheong.Poon@Sun.COM * frees the struct. 38412869SKacheong.Poon@Sun.COM * 38512869SKacheong.Poon@Sun.COM * slc_max is the maximum number of concurrent associations created from a 38612869SKacheong.Poon@Sun.COM * listener. It is calculated when the sctp_listen_cnt_t is allocated. 38712869SKacheong.Poon@Sun.COM * 38812869SKacheong.Poon@Sun.COM * slc_report_time stores the time when cmn_err() is called to report that the 38912869SKacheong.Poon@Sun.COM * max has been exceeeded. Report is done at most once every 39012869SKacheong.Poon@Sun.COM * SCTP_SLC_REPORT_INTERVAL mins for a listener. 39112869SKacheong.Poon@Sun.COM * 39212869SKacheong.Poon@Sun.COM * slc_drop stores the number of connection attempt dropped because the 39312869SKacheong.Poon@Sun.COM * limit has reached. 39412869SKacheong.Poon@Sun.COM */ 39512869SKacheong.Poon@Sun.COM typedef struct sctp_listen_cnt_s { 39612869SKacheong.Poon@Sun.COM uint32_t slc_max; 39712869SKacheong.Poon@Sun.COM uint32_t slc_cnt; 39812869SKacheong.Poon@Sun.COM int64_t slc_report_time; 39912869SKacheong.Poon@Sun.COM uint32_t slc_drop; 40012869SKacheong.Poon@Sun.COM } sctp_listen_cnt_t; 40112869SKacheong.Poon@Sun.COM 40212869SKacheong.Poon@Sun.COM #define SCTP_SLC_REPORT_INTERVAL (30 * MINUTES) 40312869SKacheong.Poon@Sun.COM 40412869SKacheong.Poon@Sun.COM #define SCTP_DECR_LISTEN_CNT(sctp) \ 40512869SKacheong.Poon@Sun.COM { \ 40612869SKacheong.Poon@Sun.COM ASSERT((sctp)->sctp_listen_cnt->slc_cnt > 0); \ 40712869SKacheong.Poon@Sun.COM if (atomic_add_32_nv(&(sctp)->sctp_listen_cnt->slc_cnt, -1) == 0) \ 40812869SKacheong.Poon@Sun.COM kmem_free((sctp)->sctp_listen_cnt, sizeof (sctp_listen_cnt_t));\ 40912869SKacheong.Poon@Sun.COM (sctp)->sctp_listen_cnt = NULL; \ 41012869SKacheong.Poon@Sun.COM } 41112869SKacheong.Poon@Sun.COM 41212869SKacheong.Poon@Sun.COM /* Increment and decrement the number of associations in sctp_stack_t. */ 41312869SKacheong.Poon@Sun.COM #define SCTPS_ASSOC_INC(sctps) \ 41412869SKacheong.Poon@Sun.COM atomic_inc_64( \ 41512869SKacheong.Poon@Sun.COM (uint64_t *)&(sctps)->sctps_sc[CPU->cpu_seqid]->sctp_sc_assoc_cnt) 41612869SKacheong.Poon@Sun.COM 41712869SKacheong.Poon@Sun.COM #define SCTPS_ASSOC_DEC(sctps) \ 41812869SKacheong.Poon@Sun.COM atomic_dec_64( \ 41912869SKacheong.Poon@Sun.COM (uint64_t *)&(sctps)->sctps_sc[CPU->cpu_seqid]->sctp_sc_assoc_cnt) 42012869SKacheong.Poon@Sun.COM 42112869SKacheong.Poon@Sun.COM #define SCTP_ASSOC_EST(sctps, sctp) \ 42212869SKacheong.Poon@Sun.COM { \ 42312869SKacheong.Poon@Sun.COM (sctp)->sctp_state = SCTPS_ESTABLISHED; \ 42412869SKacheong.Poon@Sun.COM (sctp)->sctp_assoc_start_time = (uint32_t)LBOLT_FASTPATH64; \ 42512869SKacheong.Poon@Sun.COM SCTPS_ASSOC_INC(sctps); \ 42612869SKacheong.Poon@Sun.COM } 42712869SKacheong.Poon@Sun.COM 42812869SKacheong.Poon@Sun.COM /* 4290Sstevel@tonic-gate * Bind hash array size and hash function. The size must be a power 4300Sstevel@tonic-gate * of 2 and lport must be in host byte order. 4310Sstevel@tonic-gate */ 4320Sstevel@tonic-gate #define SCTP_BIND_FANOUT_SIZE 2048 4330Sstevel@tonic-gate #define SCTP_BIND_HASH(lport) (((lport) * 31) & (SCTP_BIND_FANOUT_SIZE - 1)) 4340Sstevel@tonic-gate 4350Sstevel@tonic-gate /* options that SCTP negotiates during association establishment */ 4360Sstevel@tonic-gate #define SCTP_PRSCTP_OPTION 0x01 4370Sstevel@tonic-gate 4380Sstevel@tonic-gate /* 4390Sstevel@tonic-gate * Listener hash array size and hash function. The size must be a power 4400Sstevel@tonic-gate * of 2 and lport must be in host byte order. 4410Sstevel@tonic-gate */ 4420Sstevel@tonic-gate #define SCTP_LISTEN_FANOUT_SIZE 512 4430Sstevel@tonic-gate #define SCTP_LISTEN_HASH(lport) (((lport) * 31) & (SCTP_LISTEN_FANOUT_SIZE - 1)) 4440Sstevel@tonic-gate 4450Sstevel@tonic-gate typedef struct sctp_tf_s { 4460Sstevel@tonic-gate struct sctp_s *tf_sctp; 4470Sstevel@tonic-gate kmutex_t tf_lock; 4480Sstevel@tonic-gate } sctp_tf_t; 4490Sstevel@tonic-gate 4500Sstevel@tonic-gate /* Round up the value to the nearest mss. */ 4510Sstevel@tonic-gate #define MSS_ROUNDUP(value, mss) ((((value) - 1) / (mss) + 1) * (mss)) 4520Sstevel@tonic-gate 4530Sstevel@tonic-gate extern sin_t sctp_sin_null; /* Zero address for quick clears */ 4540Sstevel@tonic-gate extern sin6_t sctp_sin6_null; /* Zero address for quick clears */ 4550Sstevel@tonic-gate 4560Sstevel@tonic-gate #define SCTP_IS_DETACHED(sctp) ((sctp)->sctp_detached) 4570Sstevel@tonic-gate 4580Sstevel@tonic-gate /* Data structure used to track received TSNs */ 4590Sstevel@tonic-gate typedef struct sctp_set_s { 4600Sstevel@tonic-gate struct sctp_set_s *next; 4610Sstevel@tonic-gate struct sctp_set_s *prev; 4620Sstevel@tonic-gate uint32_t begin; 4630Sstevel@tonic-gate uint32_t end; 4640Sstevel@tonic-gate } sctp_set_t; 4650Sstevel@tonic-gate 4660Sstevel@tonic-gate /* Data structure used to track TSNs for PR-SCTP */ 4670Sstevel@tonic-gate typedef struct sctp_ftsn_set_s { 4680Sstevel@tonic-gate struct sctp_ftsn_set_s *next; 4690Sstevel@tonic-gate ftsn_entry_t ftsn_entries; 4700Sstevel@tonic-gate } sctp_ftsn_set_t; 4710Sstevel@tonic-gate 4720Sstevel@tonic-gate /* Data structure used to track incoming SCTP streams */ 4730Sstevel@tonic-gate typedef struct sctp_instr_s { 4740Sstevel@tonic-gate mblk_t *istr_msgs; 4750Sstevel@tonic-gate int istr_nmsgs; 4760Sstevel@tonic-gate uint16_t nextseq; 4770Sstevel@tonic-gate struct sctp_s *sctp; 4780Sstevel@tonic-gate mblk_t *istr_reass; 4790Sstevel@tonic-gate } sctp_instr_t; 4800Sstevel@tonic-gate 4810Sstevel@tonic-gate /* Reassembly data structure (per-stream) */ 4820Sstevel@tonic-gate typedef struct sctp_reass_s { 48313009SChandrasekar.Marimuthu@Sun.COM uint16_t sr_ssn; 48413009SChandrasekar.Marimuthu@Sun.COM uint16_t sr_needed; 48513009SChandrasekar.Marimuthu@Sun.COM uint16_t sr_got; 48613009SChandrasekar.Marimuthu@Sun.COM uint16_t sr_msglen; /* len of consecutive fragments */ 4873845Svi117747 /* from the begining (B-bit) */ 48813009SChandrasekar.Marimuthu@Sun.COM mblk_t *sr_tail; 48913009SChandrasekar.Marimuthu@Sun.COM boolean_t sr_hasBchunk; /* If the fragment list begins with */ 4903845Svi117747 /* a B-bit set chunk */ 49113009SChandrasekar.Marimuthu@Sun.COM uint32_t sr_nexttsn; /* TSN of the next fragment we */ 4923845Svi117747 /* are expecting */ 49313009SChandrasekar.Marimuthu@Sun.COM boolean_t sr_partial_delivered; 4940Sstevel@tonic-gate } sctp_reass_t; 4950Sstevel@tonic-gate 4960Sstevel@tonic-gate /* debugging */ 4970Sstevel@tonic-gate #undef dprint 4981676Sjpk #ifdef DEBUG 4990Sstevel@tonic-gate extern int sctpdebug; 5000Sstevel@tonic-gate #define dprint(level, args) { if (sctpdebug > (level)) printf args; } 5011676Sjpk #else 5020Sstevel@tonic-gate #define dprint(level, args) {} 5031676Sjpk #endif 5040Sstevel@tonic-gate 5050Sstevel@tonic-gate 5060Sstevel@tonic-gate /* Peer address tracking */ 5070Sstevel@tonic-gate 5080Sstevel@tonic-gate /* 5090Sstevel@tonic-gate * States for peer addresses 5100Sstevel@tonic-gate * 5110Sstevel@tonic-gate * SCTP_FADDRS_UNCONFIRMED: we have not communicated with this peer address 5120Sstevel@tonic-gate * before, mark it as unconfirmed so that we will not send data to it. 5130Sstevel@tonic-gate * All addresses initially are in unconfirmed state and required 5140Sstevel@tonic-gate * validation. SCTP sends a heartbeat to each of them and when it gets 5150Sstevel@tonic-gate * back a heartbeat ACK, the address will be marked as alive. This 5160Sstevel@tonic-gate * validation fixes a security issue with multihoming. If an attacker 5170Sstevel@tonic-gate * establishes an association with us and tells us that it has addresses 5180Sstevel@tonic-gate * belonging to another host A, this will prevent A from communicating 5190Sstevel@tonic-gate * with us. This is fixed by peer address validation. In the above case, 5200Sstevel@tonic-gate * A will respond with an abort. 5210Sstevel@tonic-gate * 5220Sstevel@tonic-gate * SCTP_FADDRS_ALIVE: this peer address is alive and we can communicate with 5230Sstevel@tonic-gate * it with no problem. 5240Sstevel@tonic-gate * 5250Sstevel@tonic-gate * SCTP_FADDRS_DOWN: we have exceeded the retransmission limit to this 5260Sstevel@tonic-gate * peer address. Once an address is marked down, we will only send 5270Sstevel@tonic-gate * a heartbeat to it every hb_interval in case it becomes alive now. 5280Sstevel@tonic-gate * 5290Sstevel@tonic-gate * SCTP_FADDRS_UNREACH: there is no suitable source address to send to 5300Sstevel@tonic-gate * this peer address. For example, the peer address is v6 but we only 5310Sstevel@tonic-gate * have v4 addresses. It is marked unreachable until there is an 5320Sstevel@tonic-gate * address configuration change. At that time, mark these addresses 5330Sstevel@tonic-gate * as unconfirmed and try again to see if those unreachable addresses 5340Sstevel@tonic-gate * are OK as we may have more source addresses. 5350Sstevel@tonic-gate */ 5360Sstevel@tonic-gate typedef enum { 5370Sstevel@tonic-gate SCTP_FADDRS_UNREACH, 5380Sstevel@tonic-gate SCTP_FADDRS_DOWN, 5390Sstevel@tonic-gate SCTP_FADDRS_ALIVE, 5400Sstevel@tonic-gate SCTP_FADDRS_UNCONFIRMED 5410Sstevel@tonic-gate } faddr_state_t; 5420Sstevel@tonic-gate 5430Sstevel@tonic-gate typedef struct sctp_faddr_s { 54413009SChandrasekar.Marimuthu@Sun.COM struct sctp_faddr_s *sf_next; 54513009SChandrasekar.Marimuthu@Sun.COM faddr_state_t sf_state; 5460Sstevel@tonic-gate 54713009SChandrasekar.Marimuthu@Sun.COM in6_addr_t sf_faddr; 54813009SChandrasekar.Marimuthu@Sun.COM in6_addr_t sf_saddr; 5490Sstevel@tonic-gate 55013009SChandrasekar.Marimuthu@Sun.COM int64_t sf_hb_expiry; /* time to retransmit heartbeat */ 55113009SChandrasekar.Marimuthu@Sun.COM uint32_t sf_hb_interval; /* the heartbeat interval */ 5520Sstevel@tonic-gate 55313009SChandrasekar.Marimuthu@Sun.COM int sf_rto; /* RTO in tick */ 55413009SChandrasekar.Marimuthu@Sun.COM int sf_srtt; /* Smoothed RTT in tick */ 55513009SChandrasekar.Marimuthu@Sun.COM int sf_rttvar; /* RTT variance in tick */ 55613009SChandrasekar.Marimuthu@Sun.COM uint32_t sf_rtt_updates; 55713009SChandrasekar.Marimuthu@Sun.COM int sf_strikes; 55813009SChandrasekar.Marimuthu@Sun.COM int sf_max_retr; 55913009SChandrasekar.Marimuthu@Sun.COM uint32_t sf_pmss; 56013009SChandrasekar.Marimuthu@Sun.COM uint32_t sf_cwnd; 56113009SChandrasekar.Marimuthu@Sun.COM uint32_t sf_ssthresh; 56213009SChandrasekar.Marimuthu@Sun.COM uint32_t sf_suna; /* sent - unack'ed */ 56313009SChandrasekar.Marimuthu@Sun.COM uint32_t sf_pba; /* partial bytes acked */ 56413009SChandrasekar.Marimuthu@Sun.COM uint32_t sf_acked; 56513009SChandrasekar.Marimuthu@Sun.COM int64_t sf_lastactive; 56613009SChandrasekar.Marimuthu@Sun.COM mblk_t *sf_timer_mp; /* retransmission timer control */ 5670Sstevel@tonic-gate uint32_t 56813009SChandrasekar.Marimuthu@Sun.COM sf_hb_pending : 1, 56913009SChandrasekar.Marimuthu@Sun.COM sf_timer_running : 1, 57013009SChandrasekar.Marimuthu@Sun.COM sf_df : 1, 57113009SChandrasekar.Marimuthu@Sun.COM sf_pmtu_discovered : 1, 5720Sstevel@tonic-gate 57313009SChandrasekar.Marimuthu@Sun.COM sf_rc_timer_running : 1, 57413009SChandrasekar.Marimuthu@Sun.COM sf_isv4 : 1, 57513009SChandrasekar.Marimuthu@Sun.COM sf_hb_enabled : 1; 5760Sstevel@tonic-gate 57713009SChandrasekar.Marimuthu@Sun.COM mblk_t *sf_rc_timer_mp; /* reliable control chunk timer */ 57813009SChandrasekar.Marimuthu@Sun.COM ip_xmit_attr_t *sf_ixa; /* Transmit attributes */ 57913009SChandrasekar.Marimuthu@Sun.COM uint32_t sf_T3expire; /* # of times T3 timer expired */ 5800Sstevel@tonic-gate 58113009SChandrasekar.Marimuthu@Sun.COM uint64_t sf_hb_secret; /* per addr "secret" in heartbeat */ 58213009SChandrasekar.Marimuthu@Sun.COM uint32_t sf_rxt_unacked; /* # unack'ed retransmitted bytes */ 5830Sstevel@tonic-gate } sctp_faddr_t; 5840Sstevel@tonic-gate 5850Sstevel@tonic-gate /* Flags to indicate supported address type in the PARM_SUP_ADDRS. */ 5860Sstevel@tonic-gate #define PARM_SUPP_V6 0x1 5870Sstevel@tonic-gate #define PARM_SUPP_V4 0x2 5880Sstevel@tonic-gate 5890Sstevel@tonic-gate /* 5900Sstevel@tonic-gate * Set heartbeat interval plus jitter. The jitter is supposed to be random, 5910Sstevel@tonic-gate * up to +/- 50% of the RTO. We use gethrtime() here for performance reason 5920Sstevel@tonic-gate * as the jitter does not really need to be "very" random. 5930Sstevel@tonic-gate */ 5940Sstevel@tonic-gate #define SET_HB_INTVL(fp) \ 59513009SChandrasekar.Marimuthu@Sun.COM ((fp)->sf_hb_interval + (fp)->sf_rto + ((fp)->sf_rto >> 1) - \ 59613009SChandrasekar.Marimuthu@Sun.COM (uint_t)gethrtime() % (fp)->sf_rto) 5970Sstevel@tonic-gate 5980Sstevel@tonic-gate #define SCTP_IPIF_HASH 16 5990Sstevel@tonic-gate 6000Sstevel@tonic-gate typedef struct sctp_ipif_hash_s { 60111373SGeorge.Shepherd@Sun.COM list_t sctp_ipif_list; 60211373SGeorge.Shepherd@Sun.COM int ipif_count; 60311373SGeorge.Shepherd@Sun.COM krwlock_t ipif_hash_lock; 6040Sstevel@tonic-gate } sctp_ipif_hash_t; 6050Sstevel@tonic-gate 6063795Skcpoon 6073795Skcpoon /* 6083795Skcpoon * Initialize cwnd according to RFC 3390. def_max_init_cwnd is 6093795Skcpoon * either sctp_slow_start_initial or sctp_slow_start_after idle 6103795Skcpoon * depending on the caller. 6113795Skcpoon */ 6123795Skcpoon #define SET_CWND(fp, mss, def_max_init_cwnd) \ 6133795Skcpoon { \ 61413009SChandrasekar.Marimuthu@Sun.COM (fp)->sf_cwnd = MIN(def_max_init_cwnd * (mss), \ 6153795Skcpoon MIN(4 * (mss), MAX(2 * (mss), 4380 / (mss) * (mss)))); \ 6163795Skcpoon } 6173795Skcpoon 6183795Skcpoon 6190Sstevel@tonic-gate struct sctp_s; 6200Sstevel@tonic-gate 6210Sstevel@tonic-gate /* 6220Sstevel@tonic-gate * Control structure for each open SCTP stream, 6230Sstevel@tonic-gate * defined only within the kernel or for a kmem user. 6240Sstevel@tonic-gate * NOTE: sctp_reinit_values MUST have a line for each field in this structure! 6250Sstevel@tonic-gate */ 6260Sstevel@tonic-gate #if (defined(_KERNEL) || defined(_KMEMUSER)) 6270Sstevel@tonic-gate 6280Sstevel@tonic-gate typedef struct sctp_s { 6290Sstevel@tonic-gate 6300Sstevel@tonic-gate /* 6310Sstevel@tonic-gate * The following is shared with (and duplicated) in IP, so if you 6320Sstevel@tonic-gate * make changes, make sure you also change things in ip_sctp.c. 6330Sstevel@tonic-gate */ 6340Sstevel@tonic-gate struct sctp_s *sctp_conn_hash_next; 6350Sstevel@tonic-gate struct sctp_s *sctp_conn_hash_prev; 6360Sstevel@tonic-gate 6370Sstevel@tonic-gate struct sctp_s *sctp_listen_hash_next; 6380Sstevel@tonic-gate struct sctp_s *sctp_listen_hash_prev; 6390Sstevel@tonic-gate 6400Sstevel@tonic-gate sctp_tf_t *sctp_listen_tfp; /* Ptr to tf */ 6410Sstevel@tonic-gate sctp_tf_t *sctp_conn_tfp; /* Ptr to tf */ 6420Sstevel@tonic-gate 6430Sstevel@tonic-gate /* Global list of sctp */ 6440Sstevel@tonic-gate list_node_t sctp_list; 6450Sstevel@tonic-gate 6460Sstevel@tonic-gate sctp_faddr_t *sctp_faddrs; 647852Svi117747 int sctp_nfaddrs; 6480Sstevel@tonic-gate sctp_ipif_hash_t sctp_saddrs[SCTP_IPIF_HASH]; 6490Sstevel@tonic-gate int sctp_nsaddrs; 6500Sstevel@tonic-gate 6510Sstevel@tonic-gate kmutex_t sctp_lock; 6520Sstevel@tonic-gate kcondvar_t sctp_cv; 6530Sstevel@tonic-gate boolean_t sctp_running; 6540Sstevel@tonic-gate 6558348SEric.Yu@Sun.COM #define sctp_ulpd sctp_connp->conn_upper_handle 6568348SEric.Yu@Sun.COM #define sctp_upcalls sctp_connp->conn_upcalls 6570Sstevel@tonic-gate 6588348SEric.Yu@Sun.COM #define sctp_ulp_newconn sctp_upcalls->su_newconn 6598348SEric.Yu@Sun.COM #define sctp_ulp_connected sctp_upcalls->su_connected 6608348SEric.Yu@Sun.COM #define sctp_ulp_disconnected sctp_upcalls->su_disconnected 6618348SEric.Yu@Sun.COM #define sctp_ulp_opctl sctp_upcalls->su_opctl 6628348SEric.Yu@Sun.COM #define sctp_ulp_recv sctp_upcalls->su_recv 663*13054SKacheong.Poon@Sun.COM #define sctp_ulp_txq_full sctp_upcalls->su_txq_full 6648348SEric.Yu@Sun.COM #define sctp_ulp_prop sctp_upcalls->su_set_proto_props 6650Sstevel@tonic-gate 6660Sstevel@tonic-gate int32_t sctp_state; 6670Sstevel@tonic-gate 6680Sstevel@tonic-gate conn_t *sctp_connp; /* conn_t stuff */ 6693448Sdh155122 sctp_stack_t *sctp_sctps; 6703448Sdh155122 6710Sstevel@tonic-gate /* Peer address tracking */ 6720Sstevel@tonic-gate sctp_faddr_t *sctp_lastfaddr; /* last faddr in list */ 6730Sstevel@tonic-gate sctp_faddr_t *sctp_primary; /* primary faddr */ 6740Sstevel@tonic-gate sctp_faddr_t *sctp_current; /* current faddr */ 6750Sstevel@tonic-gate sctp_faddr_t *sctp_lastdata; /* last data seen from this */ 6760Sstevel@tonic-gate 6770Sstevel@tonic-gate /* Outbound data tracking */ 6780Sstevel@tonic-gate mblk_t *sctp_xmit_head; 6790Sstevel@tonic-gate mblk_t *sctp_xmit_tail; 6800Sstevel@tonic-gate mblk_t *sctp_xmit_unsent; 6810Sstevel@tonic-gate mblk_t *sctp_xmit_unsent_tail; 6820Sstevel@tonic-gate mblk_t *sctp_xmit_unacked; 6830Sstevel@tonic-gate 6840Sstevel@tonic-gate int32_t sctp_unacked; /* # of unacked bytes */ 6850Sstevel@tonic-gate int32_t sctp_unsent; /* # of unsent bytes in hand */ 6860Sstevel@tonic-gate 6870Sstevel@tonic-gate uint32_t sctp_ltsn; /* Local instance TSN */ 6880Sstevel@tonic-gate uint32_t sctp_lastack_rxd; /* Last rx'd cumtsn */ 6890Sstevel@tonic-gate uint32_t sctp_recovery_tsn; /* Exit from fast recovery */ 6900Sstevel@tonic-gate uint32_t sctp_adv_pap; /* Adv. Peer Ack Point */ 6910Sstevel@tonic-gate 6920Sstevel@tonic-gate uint16_t sctp_num_ostr; 6930Sstevel@tonic-gate uint16_t *sctp_ostrcntrs; 6940Sstevel@tonic-gate 6954691Skcpoon mblk_t *sctp_pad_mp; /* pad unaligned data chunks */ 6964691Skcpoon 6970Sstevel@tonic-gate /* sendmsg() default parameters */ 6980Sstevel@tonic-gate uint16_t sctp_def_stream; /* default stream id */ 6990Sstevel@tonic-gate uint16_t sctp_def_flags; /* default xmit flags */ 7000Sstevel@tonic-gate uint32_t sctp_def_ppid; /* default payload id */ 7010Sstevel@tonic-gate uint32_t sctp_def_context; /* default context */ 7020Sstevel@tonic-gate uint32_t sctp_def_timetolive; /* default msg TTL */ 7030Sstevel@tonic-gate 7040Sstevel@tonic-gate /* Inbound data tracking */ 7050Sstevel@tonic-gate sctp_set_t *sctp_sack_info; /* Sack tracking */ 7060Sstevel@tonic-gate mblk_t *sctp_ack_mp; /* Delayed ACK timer block */ 7070Sstevel@tonic-gate sctp_instr_t *sctp_instr; /* Instream trackers */ 7080Sstevel@tonic-gate mblk_t *sctp_uo_frags; /* Un-ordered msg. fragments */ 7090Sstevel@tonic-gate uint32_t sctp_ftsn; /* Peer's TSN */ 7100Sstevel@tonic-gate uint32_t sctp_lastacked; /* last cumtsn SACKd */ 7110Sstevel@tonic-gate uint16_t sctp_num_istr; /* No. of instreams */ 7120Sstevel@tonic-gate int32_t sctp_istr_nmsgs; /* No. of chunks in instreams */ 7130Sstevel@tonic-gate int32_t sctp_sack_gaps; /* No. of received gaps */ 7140Sstevel@tonic-gate int32_t sctp_sack_toggle; /* SACK every other pkt */ 7150Sstevel@tonic-gate 7160Sstevel@tonic-gate /* RTT calculation */ 7170Sstevel@tonic-gate uint32_t sctp_rtt_tsn; 7180Sstevel@tonic-gate int64_t sctp_out_time; 7190Sstevel@tonic-gate 72010751SGeorge.Shepherd@Sun.COM /* Stats can be reset by snmp users kstat, netstat and snmp agents */ 7210Sstevel@tonic-gate uint64_t sctp_opkts; /* sent pkts */ 7220Sstevel@tonic-gate uint64_t sctp_obchunks; /* sent control chunks */ 7230Sstevel@tonic-gate uint64_t sctp_odchunks; /* sent ordered data chunks */ 7240Sstevel@tonic-gate uint64_t sctp_oudchunks; /* sent unord data chunks */ 7250Sstevel@tonic-gate uint64_t sctp_rxtchunks; /* retransmitted chunks */ 7260Sstevel@tonic-gate uint64_t sctp_ipkts; /* recv pkts */ 7270Sstevel@tonic-gate uint64_t sctp_ibchunks; /* recv control chunks */ 7280Sstevel@tonic-gate uint64_t sctp_idchunks; /* recv ordered data chunks */ 7290Sstevel@tonic-gate uint64_t sctp_iudchunks; /* recv unord data chunks */ 7300Sstevel@tonic-gate uint64_t sctp_fragdmsgs; 7310Sstevel@tonic-gate uint64_t sctp_reassmsgs; 7320Sstevel@tonic-gate uint32_t sctp_T1expire; /* # of times T1timer expired */ 7330Sstevel@tonic-gate uint32_t sctp_T2expire; /* # of times T2timer expired */ 7340Sstevel@tonic-gate uint32_t sctp_T3expire; /* # of times T3timer expired */ 7350Sstevel@tonic-gate uint32_t sctp_assoc_start_time; /* time when assoc was est. */ 7360Sstevel@tonic-gate 7370Sstevel@tonic-gate uint32_t sctp_frwnd; /* Peer RWND */ 7380Sstevel@tonic-gate uint32_t sctp_cwnd_max; 7390Sstevel@tonic-gate 7400Sstevel@tonic-gate /* Inbound flow control */ 7410Sstevel@tonic-gate int32_t sctp_rwnd; /* Current receive window */ 742*13054SKacheong.Poon@Sun.COM int32_t sctp_arwnd; /* Last advertised window */ 7430Sstevel@tonic-gate int32_t sctp_rxqueued; /* No. of bytes in RX q's */ 744*13054SKacheong.Poon@Sun.COM int32_t sctp_ulp_rxqueued; /* Data in ULP */ 7450Sstevel@tonic-gate 7460Sstevel@tonic-gate /* Pre-initialized composite headers */ 74711042SErik.Nordmark@Sun.COM uchar_t *sctp_iphc; /* v4 sctp/ip hdr template buffer */ 74811042SErik.Nordmark@Sun.COM uchar_t *sctp_iphc6; /* v6 sctp/ip hdr template buffer */ 7490Sstevel@tonic-gate 7500Sstevel@tonic-gate int32_t sctp_iphc_len; /* actual allocated v4 buffer size */ 7510Sstevel@tonic-gate int32_t sctp_iphc6_len; /* actual allocated v6 buffer size */ 7520Sstevel@tonic-gate 7530Sstevel@tonic-gate int32_t sctp_hdr_len; /* len of combined SCTP/IP v4 hdr */ 7540Sstevel@tonic-gate int32_t sctp_hdr6_len; /* len of combined SCTP/IP v6 hdr */ 7550Sstevel@tonic-gate 7560Sstevel@tonic-gate ipha_t *sctp_ipha; /* IPv4 header in the buffer */ 7570Sstevel@tonic-gate ip6_t *sctp_ip6h; /* IPv6 header in the buffer */ 7580Sstevel@tonic-gate 7590Sstevel@tonic-gate int32_t sctp_ip_hdr_len; /* Byte len of our current v4 hdr */ 7600Sstevel@tonic-gate int32_t sctp_ip_hdr6_len; /* Byte len of our current v6 hdr */ 7610Sstevel@tonic-gate 7620Sstevel@tonic-gate sctp_hdr_t *sctp_sctph; /* sctp header in combined v4 hdr */ 7630Sstevel@tonic-gate sctp_hdr_t *sctp_sctph6; /* sctp header in combined v6 hdr */ 7640Sstevel@tonic-gate 7650Sstevel@tonic-gate uint32_t sctp_lvtag; /* local SCTP instance verf tag */ 7660Sstevel@tonic-gate uint32_t sctp_fvtag; /* Peer's SCTP verf tag */ 7670Sstevel@tonic-gate 7680Sstevel@tonic-gate /* Path MTU Discovery */ 7690Sstevel@tonic-gate int64_t sctp_last_mtu_probe; 7700Sstevel@tonic-gate clock_t sctp_mtu_probe_intvl; 7710Sstevel@tonic-gate uint32_t sctp_mss; /* Max send size (not TCP MSS!) */ 7720Sstevel@tonic-gate 7730Sstevel@tonic-gate /* structs sctp_bits, sctp_events are for clearing all bits at once */ 7740Sstevel@tonic-gate struct { 7750Sstevel@tonic-gate uint32_t 7760Sstevel@tonic-gate 7770Sstevel@tonic-gate sctp_understands_asconf : 1, /* Peer handles ASCONF chunks */ 7780Sstevel@tonic-gate sctp_cchunk_pend : 1, /* Control chunk in flight. */ 7790Sstevel@tonic-gate sctp_lingering : 1, /* Lingering in close */ 7800Sstevel@tonic-gate sctp_loopback: 1, /* src and dst are the same machine */ 78111042SErik.Nordmark@Sun.COM 7820Sstevel@tonic-gate sctp_force_sack : 1, 7830Sstevel@tonic-gate sctp_ack_timer_running: 1, /* Delayed ACK timer running */ 7840Sstevel@tonic-gate sctp_hwcksum : 1, /* The NIC is capable of hwcksum */ 7850Sstevel@tonic-gate sctp_understands_addip : 1, 7860Sstevel@tonic-gate 7870Sstevel@tonic-gate sctp_bound_to_all : 1, 7880Sstevel@tonic-gate sctp_cansleep : 1, /* itf routines can sleep */ 7890Sstevel@tonic-gate sctp_detached : 1, /* If we're detached from a stream */ 7905586Skcpoon sctp_send_adaptation : 1, /* send adaptation layer ind */ 7910Sstevel@tonic-gate 7925586Skcpoon sctp_recv_adaptation : 1, /* recv adaptation layer ind */ 7930Sstevel@tonic-gate sctp_ndelay : 1, /* turn off Nagle */ 7940Sstevel@tonic-gate sctp_condemned : 1, /* this sctp is about to disappear */ 7950Sstevel@tonic-gate sctp_chk_fast_rexmit : 1, /* check for fast rexmit message */ 796432Svi117747 797432Svi117747 sctp_prsctp_aware : 1, /* is peer PR-SCTP aware? */ 7981676Sjpk sctp_linklocal : 1, /* is linklocal assoc. */ 7991735Skcpoon sctp_rexmitting : 1, /* SCTP is retransmitting */ 8001932Svi117747 sctp_zero_win_probe : 1, /* doing zero win probe */ 8011735Skcpoon 8028348SEric.Yu@Sun.COM sctp_txq_full : 1, /* the tx queue is full */ 8034818Skcpoon sctp_ulp_discon_done : 1, /* ulp_disconnecting done */ 804*13054SKacheong.Poon@Sun.COM sctp_flowctrld : 1, /* upper layer flow controlled */ 805*13054SKacheong.Poon@Sun.COM sctp_dummy : 5; 8060Sstevel@tonic-gate } sctp_bits; 8070Sstevel@tonic-gate struct { 8080Sstevel@tonic-gate uint32_t 8090Sstevel@tonic-gate 8100Sstevel@tonic-gate sctp_recvsndrcvinfo : 1, 8110Sstevel@tonic-gate sctp_recvassocevnt : 1, 8120Sstevel@tonic-gate sctp_recvpathevnt : 1, 8130Sstevel@tonic-gate sctp_recvsendfailevnt : 1, 8140Sstevel@tonic-gate 8150Sstevel@tonic-gate sctp_recvpeererr : 1, 8160Sstevel@tonic-gate sctp_recvshutdownevnt : 1, 8170Sstevel@tonic-gate sctp_recvpdevnt : 1, 8180Sstevel@tonic-gate sctp_recvalevnt : 1; 8190Sstevel@tonic-gate } sctp_events; 8200Sstevel@tonic-gate #define sctp_priv_stream sctp_bits.sctp_priv_stream 8210Sstevel@tonic-gate #define sctp_understands_asconf sctp_bits.sctp_understands_asconf 8220Sstevel@tonic-gate #define sctp_cchunk_pend sctp_bits.sctp_cchunk_pend 8230Sstevel@tonic-gate #define sctp_lingering sctp_bits.sctp_lingering 8240Sstevel@tonic-gate #define sctp_loopback sctp_bits.sctp_loopback 8250Sstevel@tonic-gate #define sctp_force_sack sctp_bits.sctp_force_sack 8260Sstevel@tonic-gate #define sctp_ack_timer_running sctp_bits.sctp_ack_timer_running 8270Sstevel@tonic-gate #define sctp_hwcksum sctp_bits.sctp_hwcksum 8280Sstevel@tonic-gate #define sctp_understands_addip sctp_bits.sctp_understands_addip 8290Sstevel@tonic-gate #define sctp_bound_to_all sctp_bits.sctp_bound_to_all 8300Sstevel@tonic-gate #define sctp_cansleep sctp_bits.sctp_cansleep 8310Sstevel@tonic-gate #define sctp_detached sctp_bits.sctp_detached 8325586Skcpoon #define sctp_send_adaptation sctp_bits.sctp_send_adaptation 8335586Skcpoon #define sctp_recv_adaptation sctp_bits.sctp_recv_adaptation 8340Sstevel@tonic-gate #define sctp_ndelay sctp_bits.sctp_ndelay 8350Sstevel@tonic-gate #define sctp_condemned sctp_bits.sctp_condemned 8360Sstevel@tonic-gate #define sctp_chk_fast_rexmit sctp_bits.sctp_chk_fast_rexmit 8370Sstevel@tonic-gate #define sctp_prsctp_aware sctp_bits.sctp_prsctp_aware 838432Svi117747 #define sctp_linklocal sctp_bits.sctp_linklocal 8391735Skcpoon #define sctp_rexmitting sctp_bits.sctp_rexmitting 8401932Svi117747 #define sctp_zero_win_probe sctp_bits.sctp_zero_win_probe 8418348SEric.Yu@Sun.COM #define sctp_txq_full sctp_bits.sctp_txq_full 8424818Skcpoon #define sctp_ulp_discon_done sctp_bits.sctp_ulp_discon_done 843*13054SKacheong.Poon@Sun.COM #define sctp_flowctrld sctp_bits.sctp_flowctrld 8440Sstevel@tonic-gate 8450Sstevel@tonic-gate #define sctp_recvsndrcvinfo sctp_events.sctp_recvsndrcvinfo 8460Sstevel@tonic-gate #define sctp_recvassocevnt sctp_events.sctp_recvassocevnt 8470Sstevel@tonic-gate #define sctp_recvpathevnt sctp_events.sctp_recvpathevnt 8480Sstevel@tonic-gate #define sctp_recvsendfailevnt sctp_events.sctp_recvsendfailevnt 8490Sstevel@tonic-gate #define sctp_recvpeererr sctp_events.sctp_recvpeererr 8500Sstevel@tonic-gate #define sctp_recvshutdownevnt sctp_events.sctp_recvshutdownevnt 8510Sstevel@tonic-gate #define sctp_recvpdevnt sctp_events.sctp_recvpdevnt 8520Sstevel@tonic-gate #define sctp_recvalevnt sctp_events.sctp_recvalevnt 8530Sstevel@tonic-gate 8540Sstevel@tonic-gate /* Retransmit info */ 8550Sstevel@tonic-gate mblk_t *sctp_cookie_mp; /* cookie chunk, if rxt needed */ 8560Sstevel@tonic-gate int32_t sctp_strikes; /* Total number of assoc strikes */ 8570Sstevel@tonic-gate int32_t sctp_max_init_rxt; 8580Sstevel@tonic-gate int32_t sctp_pa_max_rxt; /* Max per-assoc retransmit cnt */ 8590Sstevel@tonic-gate int32_t sctp_pp_max_rxt; /* Max per-path retransmit cnt */ 8600Sstevel@tonic-gate uint32_t sctp_rto_max; 86112474SGeorge.Shepherd@Sun.COM uint32_t sctp_rto_max_init; 8620Sstevel@tonic-gate uint32_t sctp_rto_min; 8630Sstevel@tonic-gate uint32_t sctp_rto_initial; 8640Sstevel@tonic-gate 8650Sstevel@tonic-gate int64_t sctp_last_secret_update; 8660Sstevel@tonic-gate uint8_t sctp_secret[SCTP_SECRET_LEN]; /* for cookie auth */ 8670Sstevel@tonic-gate uint8_t sctp_old_secret[SCTP_SECRET_LEN]; 8683795Skcpoon uint32_t sctp_cookie_lifetime; /* cookie lifetime in tick */ 8690Sstevel@tonic-gate 8700Sstevel@tonic-gate /* Bind hash tables */ 8710Sstevel@tonic-gate kmutex_t *sctp_bind_lockp; /* Ptr to tf_lock */ 8720Sstevel@tonic-gate struct sctp_s *sctp_bind_hash; 8730Sstevel@tonic-gate struct sctp_s **sctp_ptpbhn; 8740Sstevel@tonic-gate 8750Sstevel@tonic-gate /* Shutdown / cleanup */ 8760Sstevel@tonic-gate sctp_faddr_t *sctp_shutdown_faddr; /* rotate faddr during shutd */ 8770Sstevel@tonic-gate int32_t sctp_client_errno; /* How the client screwed up */ 8780Sstevel@tonic-gate kmutex_t sctp_reflock; /* Protects sctp_refcnt & timer mp */ 8790Sstevel@tonic-gate ushort_t sctp_refcnt; /* No. of pending upstream msg */ 8800Sstevel@tonic-gate mblk_t *sctp_timer_mp; /* List of fired timers. */ 8810Sstevel@tonic-gate 8820Sstevel@tonic-gate mblk_t *sctp_heartbeat_mp; /* Timer block for heartbeats */ 8830Sstevel@tonic-gate uint32_t sctp_hb_interval; /* Default hb_interval */ 8840Sstevel@tonic-gate 8850Sstevel@tonic-gate int32_t sctp_autoclose; /* Auto disconnect in ticks */ 8860Sstevel@tonic-gate int64_t sctp_active; /* Last time data/sack on this conn */ 8875586Skcpoon uint32_t sctp_tx_adaptation_code; /* TX adaptation code */ 8885586Skcpoon uint32_t sctp_rx_adaptation_code; /* RX adaptation code */ 8890Sstevel@tonic-gate 8900Sstevel@tonic-gate /* Reliable control chunks */ 8910Sstevel@tonic-gate mblk_t *sctp_cxmit_list; /* Xmit list for control chunks */ 8920Sstevel@tonic-gate uint32_t sctp_lcsn; /* Our serial number */ 8930Sstevel@tonic-gate uint32_t sctp_fcsn; /* Peer serial number */ 8940Sstevel@tonic-gate 8950Sstevel@tonic-gate /* Per association receive queue */ 8960Sstevel@tonic-gate kmutex_t sctp_recvq_lock; 8970Sstevel@tonic-gate mblk_t *sctp_recvq; 8980Sstevel@tonic-gate mblk_t *sctp_recvq_tail; 8990Sstevel@tonic-gate taskq_t *sctp_recvq_tq; 9000Sstevel@tonic-gate 9010Sstevel@tonic-gate /* IPv6 ancillary data */ 9020Sstevel@tonic-gate uint_t sctp_recvifindex; /* last rcvd IPV6_RCVPKTINFO */ 9030Sstevel@tonic-gate uint_t sctp_recvhops; /* " IPV6_RECVHOPLIMIT */ 90411042SErik.Nordmark@Sun.COM uint_t sctp_recvtclass; /* " IPV6_RECVTCLASS */ 9050Sstevel@tonic-gate ip6_hbh_t *sctp_hopopts; /* " IPV6_RECVHOPOPTS */ 9060Sstevel@tonic-gate ip6_dest_t *sctp_dstopts; /* " IPV6_RECVDSTOPTS */ 90711042SErik.Nordmark@Sun.COM ip6_dest_t *sctp_rthdrdstopts; /* " IPV6_RECVRTHDRDSTOPTS */ 9080Sstevel@tonic-gate ip6_rthdr_t *sctp_rthdr; /* " IPV6_RECVRTHDR */ 9090Sstevel@tonic-gate uint_t sctp_hopoptslen; 9100Sstevel@tonic-gate uint_t sctp_dstoptslen; 91111042SErik.Nordmark@Sun.COM uint_t sctp_rthdrdstoptslen; 9120Sstevel@tonic-gate uint_t sctp_rthdrlen; 9130Sstevel@tonic-gate 9140Sstevel@tonic-gate /* Stats */ 9150Sstevel@tonic-gate uint64_t sctp_msgcount; 9160Sstevel@tonic-gate uint64_t sctp_prsctpdrop; 9171676Sjpk 9181676Sjpk uint_t sctp_v4label_len; /* length of cached v4 label */ 9191676Sjpk uint_t sctp_v6label_len; /* length of cached v6 label */ 9201735Skcpoon uint32_t sctp_rxt_nxttsn; /* Next TSN to be rexmitted */ 9211735Skcpoon uint32_t sctp_rxt_maxtsn; /* Max TSN sent at time out */ 9223845Svi117747 9233845Svi117747 int sctp_pd_point; /* Partial delivery point */ 9244964Skcpoon mblk_t *sctp_err_chunks; /* Error chunks */ 9254964Skcpoon uint32_t sctp_err_len; /* Total error chunks length */ 9268778SErik.Nordmark@Sun.COM 92710212SGeorge.Shepherd@Sun.COM /* additional source data for per endpoint association statistics */ 92810212SGeorge.Shepherd@Sun.COM uint64_t sctp_outseqtsns; /* TSN rx > expected TSN */ 92910212SGeorge.Shepherd@Sun.COM uint64_t sctp_osacks; /* total sacks sent */ 93010212SGeorge.Shepherd@Sun.COM uint64_t sctp_isacks; /* total sacks received */ 93110212SGeorge.Shepherd@Sun.COM uint64_t sctp_idupchunks; /* rx dups, ord or unord */ 93210212SGeorge.Shepherd@Sun.COM uint64_t sctp_gapcnt; /* total gap acks rx */ 93310751SGeorge.Shepherd@Sun.COM /* 93410751SGeorge.Shepherd@Sun.COM * Add the current data from the counters which are reset by snmp 93510751SGeorge.Shepherd@Sun.COM * to these cumulative counters to use in per endpoint statistics. 93610751SGeorge.Shepherd@Sun.COM */ 93710751SGeorge.Shepherd@Sun.COM uint64_t sctp_cum_obchunks; /* sent control chunks */ 93810751SGeorge.Shepherd@Sun.COM uint64_t sctp_cum_odchunks; /* sent ordered data chunks */ 93910751SGeorge.Shepherd@Sun.COM uint64_t sctp_cum_oudchunks; /* sent unord data chunks */ 94010751SGeorge.Shepherd@Sun.COM uint64_t sctp_cum_rxtchunks; /* retransmitted chunks */ 94110751SGeorge.Shepherd@Sun.COM uint64_t sctp_cum_ibchunks; /* recv control chunks */ 94210751SGeorge.Shepherd@Sun.COM uint64_t sctp_cum_idchunks; /* recv ordered data chunks */ 94310751SGeorge.Shepherd@Sun.COM uint64_t sctp_cum_iudchunks; /* recv unord data chunks */ 94410212SGeorge.Shepherd@Sun.COM 94510212SGeorge.Shepherd@Sun.COM /* 94610212SGeorge.Shepherd@Sun.COM * When non-zero, this is the maximum observed RTO since assoc stats 94710212SGeorge.Shepherd@Sun.COM * were last requested. When zero, no RTO update has occurred since 94810212SGeorge.Shepherd@Sun.COM * the previous user request for stats on this endpoint. 94910212SGeorge.Shepherd@Sun.COM */ 95010212SGeorge.Shepherd@Sun.COM int sctp_maxrto; 95110212SGeorge.Shepherd@Sun.COM /* 95210212SGeorge.Shepherd@Sun.COM * The stored value of sctp_maxrto passed to user during the previous 95310212SGeorge.Shepherd@Sun.COM * user request for stats on this endpoint. 95410212SGeorge.Shepherd@Sun.COM */ 95510212SGeorge.Shepherd@Sun.COM int sctp_prev_maxrto; 95612869SKacheong.Poon@Sun.COM 95712869SKacheong.Poon@Sun.COM /* For association counting. */ 95812869SKacheong.Poon@Sun.COM sctp_listen_cnt_t *sctp_listen_cnt; 9590Sstevel@tonic-gate } sctp_t; 9600Sstevel@tonic-gate 9618348SEric.Yu@Sun.COM #define SCTP_TXQ_LEN(sctp) ((sctp)->sctp_unsent + (sctp)->sctp_unacked) 9628348SEric.Yu@Sun.COM #define SCTP_TXQ_UPDATE(sctp) \ 9638348SEric.Yu@Sun.COM if ((sctp)->sctp_txq_full && SCTP_TXQ_LEN(sctp) <= \ 96411042SErik.Nordmark@Sun.COM (sctp)->sctp_connp->conn_sndlowat) { \ 9658348SEric.Yu@Sun.COM (sctp)->sctp_txq_full = 0; \ 966*13054SKacheong.Poon@Sun.COM (sctp)->sctp_ulp_txq_full((sctp)->sctp_ulpd, \ 9678348SEric.Yu@Sun.COM B_FALSE); \ 9688348SEric.Yu@Sun.COM } 9698348SEric.Yu@Sun.COM 9700Sstevel@tonic-gate #endif /* (defined(_KERNEL) || defined(_KMEMUSER)) */ 9710Sstevel@tonic-gate 9720Sstevel@tonic-gate extern void sctp_ack_timer(sctp_t *); 9735586Skcpoon extern size_t sctp_adaptation_code_param(sctp_t *, uchar_t *); 9745586Skcpoon extern void sctp_adaptation_event(sctp_t *); 9754964Skcpoon extern void sctp_add_err(sctp_t *, uint16_t, void *, size_t, 9764964Skcpoon sctp_faddr_t *); 9771735Skcpoon extern int sctp_add_faddr(sctp_t *, in6_addr_t *, int, boolean_t); 9780Sstevel@tonic-gate extern boolean_t sctp_add_ftsn_set(sctp_ftsn_set_t **, sctp_faddr_t *, mblk_t *, 9790Sstevel@tonic-gate uint_t *, uint32_t *); 98011042SErik.Nordmark@Sun.COM extern void sctp_add_recvq(sctp_t *, mblk_t *, boolean_t, 98111042SErik.Nordmark@Sun.COM ip_recv_attr_t *); 9828549SGeorge.Shepherd@Sun.COM extern void sctp_add_unrec_parm(sctp_parm_hdr_t *, mblk_t **, boolean_t); 9833795Skcpoon extern size_t sctp_addr_params(sctp_t *, int, uchar_t *, boolean_t); 984252Svi117747 extern mblk_t *sctp_add_proto_hdr(sctp_t *, sctp_faddr_t *, mblk_t *, int, 985252Svi117747 int *); 9860Sstevel@tonic-gate extern void sctp_addr_req(sctp_t *, mblk_t *); 9870Sstevel@tonic-gate extern sctp_t *sctp_addrlist2sctp(mblk_t *, sctp_hdr_t *, sctp_chunk_hdr_t *, 9883510Svi117747 zoneid_t, sctp_stack_t *); 9890Sstevel@tonic-gate extern void sctp_check_adv_ack_pt(sctp_t *, mblk_t *, mblk_t *); 9900Sstevel@tonic-gate extern void sctp_assoc_event(sctp_t *, uint16_t, uint16_t, 9910Sstevel@tonic-gate sctp_chunk_hdr_t *); 9920Sstevel@tonic-gate 9930Sstevel@tonic-gate extern void sctp_bind_hash_insert(sctp_tf_t *, sctp_t *, int); 9940Sstevel@tonic-gate extern void sctp_bind_hash_remove(sctp_t *); 9951676Sjpk extern int sctp_bindi(sctp_t *, in_port_t, boolean_t, int, in_port_t *); 996852Svi117747 extern int sctp_bind_add(sctp_t *, const void *, uint32_t, boolean_t, 997852Svi117747 in_port_t); 9980Sstevel@tonic-gate extern int sctp_bind_del(sctp_t *, const void *, uint32_t, boolean_t); 99911042SErik.Nordmark@Sun.COM extern int sctp_build_hdrs(sctp_t *, int); 10000Sstevel@tonic-gate 10010Sstevel@tonic-gate extern int sctp_check_abandoned_msg(sctp_t *, mblk_t *); 10020Sstevel@tonic-gate extern void sctp_clean_death(sctp_t *, int); 10030Sstevel@tonic-gate extern void sctp_close_eager(sctp_t *); 10040Sstevel@tonic-gate extern int sctp_compare_faddrsets(sctp_faddr_t *, sctp_faddr_t *); 10050Sstevel@tonic-gate extern void sctp_congest_reset(sctp_t *); 10060Sstevel@tonic-gate extern void sctp_conn_hash_insert(sctp_tf_t *, sctp_t *, int); 10070Sstevel@tonic-gate extern void sctp_conn_hash_remove(sctp_t *); 10084691Skcpoon extern void sctp_conn_init(conn_t *); 100912339Sanil.udupa@sun.com extern sctp_t *sctp_conn_match(in6_addr_t **, uint32_t, in6_addr_t *, 101012339Sanil.udupa@sun.com uint32_t, zoneid_t, iaflags_t, sctp_stack_t *); 101112869SKacheong.Poon@Sun.COM extern void sctp_conn_reclaim(void *); 10120Sstevel@tonic-gate extern sctp_t *sctp_conn_request(sctp_t *, mblk_t *, uint_t, uint_t, 101311042SErik.Nordmark@Sun.COM sctp_init_chunk_t *, ip_recv_attr_t *); 10140Sstevel@tonic-gate extern uint32_t sctp_cumack(sctp_t *, uint32_t, mblk_t **); 10150Sstevel@tonic-gate extern sctp_t *sctp_create_eager(sctp_t *); 10160Sstevel@tonic-gate 10170Sstevel@tonic-gate extern void sctp_dispatch_rput(queue_t *, sctp_t *, sctp_hdr_t *, mblk_t *, 10180Sstevel@tonic-gate uint_t, uint_t, in6_addr_t); 10190Sstevel@tonic-gate extern char *sctp_display(sctp_t *, char *); 10203448Sdh155122 extern void sctp_display_all(sctp_stack_t *); 10210Sstevel@tonic-gate 102211953Sanil.udupa@sun.com extern void sctp_error_event(sctp_t *, sctp_chunk_hdr_t *, boolean_t); 10230Sstevel@tonic-gate 10240Sstevel@tonic-gate extern void sctp_faddr_alive(sctp_t *, sctp_faddr_t *); 10250Sstevel@tonic-gate extern int sctp_faddr_dead(sctp_t *, sctp_faddr_t *, int); 10261676Sjpk extern void sctp_faddr_fini(void); 10271676Sjpk extern void sctp_faddr_init(void); 10280Sstevel@tonic-gate extern void sctp_fast_rexmit(sctp_t *); 10290Sstevel@tonic-gate extern void sctp_fill_sack(sctp_t *, unsigned char *, int); 103012869SKacheong.Poon@Sun.COM extern uint32_t sctp_find_listener_conf(sctp_stack_t *, in_port_t); 10310Sstevel@tonic-gate extern void sctp_free_faddr_timers(sctp_t *); 10320Sstevel@tonic-gate extern void sctp_free_ftsn_set(sctp_ftsn_set_t *); 10330Sstevel@tonic-gate extern void sctp_free_msg(mblk_t *); 10340Sstevel@tonic-gate extern void sctp_free_reass(sctp_instr_t *); 10350Sstevel@tonic-gate extern void sctp_free_set(sctp_set_t *); 10360Sstevel@tonic-gate extern void sctp_ftsn_sets_fini(void); 10370Sstevel@tonic-gate extern void sctp_ftsn_sets_init(void); 10380Sstevel@tonic-gate 1039852Svi117747 extern int sctp_get_addrlist(sctp_t *, const void *, uint32_t *, 1040852Svi117747 uchar_t **, int *, size_t *); 10410Sstevel@tonic-gate extern int sctp_get_addrparams(sctp_t *, sctp_t *, mblk_t *, 10420Sstevel@tonic-gate sctp_chunk_hdr_t *, uint_t *); 104311042SErik.Nordmark@Sun.COM extern void sctp_get_dest(sctp_t *, sctp_faddr_t *); 1044852Svi117747 extern void sctp_get_faddr_list(sctp_t *, uchar_t *, size_t); 10450Sstevel@tonic-gate extern mblk_t *sctp_get_first_sent(sctp_t *); 10460Sstevel@tonic-gate extern mblk_t *sctp_get_msg_to_send(sctp_t *, mblk_t **, mblk_t *, int *, 10470Sstevel@tonic-gate int32_t, uint32_t, sctp_faddr_t *); 1048852Svi117747 extern void sctp_get_saddr_list(sctp_t *, uchar_t *, size_t); 10490Sstevel@tonic-gate 10500Sstevel@tonic-gate extern int sctp_handle_error(sctp_t *, sctp_hdr_t *, sctp_chunk_hdr_t *, 105111042SErik.Nordmark@Sun.COM mblk_t *, ip_recv_attr_t *); 10523448Sdh155122 extern void sctp_hash_destroy(sctp_stack_t *); 10533448Sdh155122 extern void sctp_hash_init(sctp_stack_t *); 10540Sstevel@tonic-gate extern void sctp_heartbeat_timer(sctp_t *); 10550Sstevel@tonic-gate 10560Sstevel@tonic-gate extern void sctp_icmp_error(sctp_t *, mblk_t *); 10573448Sdh155122 extern void sctp_inc_taskq(sctp_stack_t *); 10580Sstevel@tonic-gate extern void sctp_info_req(sctp_t *, mblk_t *); 105911042SErik.Nordmark@Sun.COM extern mblk_t *sctp_init_mp(sctp_t *, sctp_faddr_t *); 10600Sstevel@tonic-gate extern boolean_t sctp_initialize_params(sctp_t *, sctp_init_chunk_t *, 10610Sstevel@tonic-gate sctp_init_chunk_t *); 10620Sstevel@tonic-gate extern uint32_t sctp_init2vtag(sctp_chunk_hdr_t *); 10630Sstevel@tonic-gate extern void sctp_intf_event(sctp_t *, in6_addr_t, int, int); 106411042SErik.Nordmark@Sun.COM extern void sctp_input_data(sctp_t *, mblk_t *, ip_recv_attr_t *); 10650Sstevel@tonic-gate extern void sctp_instream_cleanup(sctp_t *, boolean_t); 106612869SKacheong.Poon@Sun.COM extern boolean_t sctp_is_a_faddr_clean(sctp_t *); 10670Sstevel@tonic-gate 10683448Sdh155122 extern void *sctp_kstat_init(netstackid_t); 10693448Sdh155122 extern void sctp_kstat_fini(netstackid_t, kstat_t *); 107012869SKacheong.Poon@Sun.COM extern void *sctp_kstat2_init(netstackid_t); 10713448Sdh155122 extern void sctp_kstat2_fini(netstackid_t, kstat_t *); 10720Sstevel@tonic-gate 10730Sstevel@tonic-gate extern ssize_t sctp_link_abort(mblk_t *, uint16_t, char *, size_t, int, 10740Sstevel@tonic-gate boolean_t); 10750Sstevel@tonic-gate extern void sctp_listen_hash_insert(sctp_tf_t *, sctp_t *); 10760Sstevel@tonic-gate extern void sctp_listen_hash_remove(sctp_t *); 107712869SKacheong.Poon@Sun.COM extern void sctp_listener_conf_cleanup(sctp_stack_t *); 10780Sstevel@tonic-gate extern sctp_t *sctp_lookup(sctp_t *, in6_addr_t *, sctp_tf_t *, uint32_t *, 10790Sstevel@tonic-gate int); 10800Sstevel@tonic-gate extern sctp_faddr_t *sctp_lookup_faddr(sctp_t *, in6_addr_t *); 10810Sstevel@tonic-gate 10820Sstevel@tonic-gate extern mblk_t *sctp_make_err(sctp_t *, uint16_t, void *, size_t); 10830Sstevel@tonic-gate extern mblk_t *sctp_make_ftsn_chunk(sctp_t *, sctp_faddr_t *, 10840Sstevel@tonic-gate sctp_ftsn_set_t *, uint_t, uint32_t); 10850Sstevel@tonic-gate extern void sctp_make_ftsns(sctp_t *, mblk_t *, mblk_t *, mblk_t **, 10860Sstevel@tonic-gate sctp_faddr_t *, uint32_t *); 10870Sstevel@tonic-gate extern mblk_t *sctp_make_mp(sctp_t *, sctp_faddr_t *, int); 10880Sstevel@tonic-gate extern mblk_t *sctp_make_sack(sctp_t *, sctp_faddr_t *, mblk_t *); 10890Sstevel@tonic-gate extern void sctp_maxpsz_set(sctp_t *); 10900Sstevel@tonic-gate extern void sctp_move_faddr_timers(queue_t *, sctp_t *); 10910Sstevel@tonic-gate 10920Sstevel@tonic-gate extern sctp_parm_hdr_t *sctp_next_parm(sctp_parm_hdr_t *, ssize_t *); 10930Sstevel@tonic-gate 109411042SErik.Nordmark@Sun.COM extern void sctp_ootb_shutdown_ack(mblk_t *, uint_t, ip_recv_attr_t *, 109511042SErik.Nordmark@Sun.COM ip_stack_t *); 10960Sstevel@tonic-gate extern size_t sctp_options_param(const sctp_t *, void *, int); 10970Sstevel@tonic-gate extern size_t sctp_options_param_len(const sctp_t *, int); 10983795Skcpoon extern void sctp_output(sctp_t *, uint_t); 10990Sstevel@tonic-gate 11000Sstevel@tonic-gate extern void sctp_partial_delivery_event(sctp_t *); 11010Sstevel@tonic-gate extern int sctp_process_cookie(sctp_t *, sctp_chunk_hdr_t *, mblk_t *, 110211042SErik.Nordmark@Sun.COM sctp_init_chunk_t **, sctp_hdr_t *, int *, in6_addr_t *, 110311042SErik.Nordmark@Sun.COM ip_recv_attr_t *); 11044964Skcpoon extern void sctp_process_err(sctp_t *); 11050Sstevel@tonic-gate extern void sctp_process_heartbeat(sctp_t *, sctp_chunk_hdr_t *); 11060Sstevel@tonic-gate extern void sctp_process_timer(sctp_t *); 11070Sstevel@tonic-gate 11080Sstevel@tonic-gate extern void sctp_redo_faddr_srcs(sctp_t *); 11090Sstevel@tonic-gate extern void sctp_regift_xmitlist(sctp_t *); 11100Sstevel@tonic-gate extern void sctp_return_heartbeat(sctp_t *, sctp_chunk_hdr_t *, mblk_t *); 11110Sstevel@tonic-gate extern void sctp_rexmit(sctp_t *, sctp_faddr_t *); 11121932Svi117747 extern mblk_t *sctp_rexmit_packet(sctp_t *, mblk_t **, mblk_t **, 11131932Svi117747 sctp_faddr_t *, uint_t *); 11140Sstevel@tonic-gate extern void sctp_rexmit_timer(sctp_t *, sctp_faddr_t *); 11150Sstevel@tonic-gate extern sctp_faddr_t *sctp_rotate_faddr(sctp_t *, sctp_faddr_t *); 11160Sstevel@tonic-gate 11174964Skcpoon extern boolean_t sctp_sack(sctp_t *, mblk_t *); 11180Sstevel@tonic-gate extern int sctp_secure_restart_check(mblk_t *, sctp_chunk_hdr_t *, 111911042SErik.Nordmark@Sun.COM uint32_t, int, sctp_stack_t *, ip_recv_attr_t *); 11200Sstevel@tonic-gate extern void sctp_send_abort(sctp_t *, uint32_t, uint16_t, char *, size_t, 112111042SErik.Nordmark@Sun.COM mblk_t *, int, boolean_t, ip_recv_attr_t *); 112211042SErik.Nordmark@Sun.COM extern void sctp_ootb_send_abort(uint32_t, uint16_t, char *, size_t, 112311042SErik.Nordmark@Sun.COM const mblk_t *, int, boolean_t, ip_recv_attr_t *, 112411042SErik.Nordmark@Sun.COM ip_stack_t *); 11250Sstevel@tonic-gate extern void sctp_send_cookie_ack(sctp_t *); 112611042SErik.Nordmark@Sun.COM extern void sctp_send_cookie_echo(sctp_t *, sctp_chunk_hdr_t *, mblk_t *, 112711042SErik.Nordmark@Sun.COM ip_recv_attr_t *); 11282776Skp158701 extern void sctp_send_initack(sctp_t *, sctp_hdr_t *, sctp_chunk_hdr_t *, 112911042SErik.Nordmark@Sun.COM mblk_t *, ip_recv_attr_t *); 11300Sstevel@tonic-gate extern void sctp_send_shutdown(sctp_t *, int); 11310Sstevel@tonic-gate extern void sctp_send_heartbeat(sctp_t *, sctp_faddr_t *); 11320Sstevel@tonic-gate extern void sctp_sendfail_event(sctp_t *, mblk_t *, int, boolean_t); 11331735Skcpoon extern void sctp_set_faddr_current(sctp_t *, sctp_faddr_t *); 11341735Skcpoon extern int sctp_set_hdraddrs(sctp_t *); 11351932Svi117747 extern void sctp_set_saddr(sctp_t *, sctp_faddr_t *); 11361676Sjpk extern void sctp_sets_init(void); 11371676Sjpk extern void sctp_sets_fini(void); 11380Sstevel@tonic-gate extern void sctp_shutdown_event(sctp_t *); 11390Sstevel@tonic-gate extern void sctp_stop_faddr_timers(sctp_t *); 11401735Skcpoon extern int sctp_shutdown_received(sctp_t *, sctp_chunk_hdr_t *, boolean_t, 11411735Skcpoon boolean_t, sctp_faddr_t *); 11420Sstevel@tonic-gate extern void sctp_shutdown_complete(sctp_t *); 11430Sstevel@tonic-gate extern void sctp_set_if_mtu(sctp_t *); 114411042SErik.Nordmark@Sun.COM extern void sctp_set_iplen(sctp_t *, mblk_t *, ip_xmit_attr_t *); 11450Sstevel@tonic-gate extern void sctp_set_ulp_prop(sctp_t *); 11461735Skcpoon extern void sctp_ss_rexmit(sctp_t *); 114712869SKacheong.Poon@Sun.COM extern void sctp_stack_cpu_add(sctp_stack_t *, processorid_t); 11480Sstevel@tonic-gate extern size_t sctp_supaddr_param_len(sctp_t *); 11490Sstevel@tonic-gate extern size_t sctp_supaddr_param(sctp_t *, uchar_t *); 11500Sstevel@tonic-gate 11510Sstevel@tonic-gate extern void sctp_timer(sctp_t *, mblk_t *, clock_t); 11524691Skcpoon extern mblk_t *sctp_timer_alloc(sctp_t *, pfv_t, int); 11530Sstevel@tonic-gate extern void sctp_timer_call(sctp_t *sctp, mblk_t *); 11540Sstevel@tonic-gate extern void sctp_timer_free(mblk_t *); 11550Sstevel@tonic-gate extern void sctp_timer_stop(mblk_t *); 11560Sstevel@tonic-gate extern void sctp_unlink_faddr(sctp_t *, sctp_faddr_t *); 11570Sstevel@tonic-gate 115811042SErik.Nordmark@Sun.COM extern void sctp_update_dce(sctp_t *sctp); 11593448Sdh155122 extern in_port_t sctp_update_next_port(in_port_t, zone_t *zone, sctp_stack_t *); 11600Sstevel@tonic-gate extern void sctp_update_rtt(sctp_t *, sctp_faddr_t *, clock_t); 11617480SKacheong.Poon@Sun.COM extern void sctp_user_abort(sctp_t *, mblk_t *); 11620Sstevel@tonic-gate 11630Sstevel@tonic-gate extern void sctp_validate_peer(sctp_t *); 11640Sstevel@tonic-gate 11650Sstevel@tonic-gate extern int sctp_xmit_list_clean(sctp_t *, ssize_t); 11660Sstevel@tonic-gate 11670Sstevel@tonic-gate extern void sctp_zap_addrs(sctp_t *); 11680Sstevel@tonic-gate extern void sctp_zap_faddrs(sctp_t *, int); 116912339Sanil.udupa@sun.com extern sctp_chunk_hdr_t *sctp_first_chunk(uchar_t *, ssize_t); 117012721Sanil.udupa@sun.com extern void sctp_send_shutdown_ack(sctp_t *, sctp_faddr_t *, boolean_t); 11710Sstevel@tonic-gate 1172852Svi117747 /* Contract private interface between SCTP and Clustering - PSARC/2005/602 */ 1173852Svi117747 1174852Svi117747 extern void (*cl_sctp_listen)(sa_family_t, uchar_t *, uint_t, in_port_t); 1175852Svi117747 extern void (*cl_sctp_unlisten)(sa_family_t, uchar_t *, uint_t, in_port_t); 1176852Svi117747 extern void (*cl_sctp_connect)(sa_family_t, uchar_t *, uint_t, in_port_t, 1177852Svi117747 uchar_t *, uint_t, in_port_t, boolean_t, cl_sctp_handle_t); 1178852Svi117747 extern void (*cl_sctp_disconnect)(sa_family_t, cl_sctp_handle_t); 1179852Svi117747 extern void (*cl_sctp_assoc_change)(sa_family_t, uchar_t *, size_t, uint_t, 1180852Svi117747 uchar_t *, size_t, uint_t, int, cl_sctp_handle_t); 1181852Svi117747 extern void (*cl_sctp_check_addrs)(sa_family_t, in_port_t, uchar_t **, 1182852Svi117747 size_t, uint_t *, boolean_t); 1183852Svi117747 11840Sstevel@tonic-gate #define RUN_SCTP(sctp) \ 11850Sstevel@tonic-gate { \ 11860Sstevel@tonic-gate mutex_enter(&(sctp)->sctp_lock); \ 11870Sstevel@tonic-gate while ((sctp)->sctp_running) \ 11880Sstevel@tonic-gate cv_wait(&(sctp)->sctp_cv, &(sctp)->sctp_lock); \ 11890Sstevel@tonic-gate (sctp)->sctp_running = B_TRUE; \ 11900Sstevel@tonic-gate mutex_exit(&(sctp)->sctp_lock); \ 11910Sstevel@tonic-gate } 11920Sstevel@tonic-gate 11930Sstevel@tonic-gate /* Wake up recvq taskq */ 11940Sstevel@tonic-gate #define WAKE_SCTP(sctp) \ 11950Sstevel@tonic-gate { \ 11960Sstevel@tonic-gate mutex_enter(&(sctp)->sctp_lock); \ 11970Sstevel@tonic-gate if ((sctp)->sctp_timer_mp != NULL) \ 11980Sstevel@tonic-gate sctp_process_timer(sctp); \ 11990Sstevel@tonic-gate (sctp)->sctp_running = B_FALSE; \ 12000Sstevel@tonic-gate cv_broadcast(&(sctp)->sctp_cv); \ 12010Sstevel@tonic-gate mutex_exit(&(sctp)->sctp_lock); \ 12020Sstevel@tonic-gate } 12030Sstevel@tonic-gate 12040Sstevel@tonic-gate #ifdef __cplusplus 12050Sstevel@tonic-gate } 12060Sstevel@tonic-gate #endif 12070Sstevel@tonic-gate 12080Sstevel@tonic-gate #endif /* _INET_SCTP_SCTP_IMPL_H */ 1209