17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 545916cd2Sjpk * Common Development and Distribution License (the "License"). 645916cd2Sjpk * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 2177c67f2fSkcpoon 227c478bd9Sstevel@tonic-gate /* 2345916cd2Sjpk * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _INET_SCTP_SCTP_IMPL_H 287c478bd9Sstevel@tonic-gate #define _INET_SCTP_SCTP_IMPL_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 337c478bd9Sstevel@tonic-gate extern "C" { 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #include <sys/inttypes.h> 377c478bd9Sstevel@tonic-gate #include <sys/taskq.h> 387c478bd9Sstevel@tonic-gate #include <sys/list.h> 397c478bd9Sstevel@tonic-gate #include <sys/strsun.h> 4045916cd2Sjpk #include <sys/zone.h> 417c478bd9Sstevel@tonic-gate #include <netinet/ip6.h> 427c478bd9Sstevel@tonic-gate #include <inet/optcom.h> 437c478bd9Sstevel@tonic-gate #include <netinet/sctp.h> 447c478bd9Sstevel@tonic-gate #include <inet/sctp_itf.h> 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /* Streams device identifying info and version */ 477c478bd9Sstevel@tonic-gate #define SCTP_DEV_IDINFO "SCTP Streams device 1.0" 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #define SSN_GT(a, b) ((int16_t)((a)-(b)) > 0) 507c478bd9Sstevel@tonic-gate #define SSN_GE(a, b) ((int16_t)((a)-(b)) >= 0) 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate /* Default buffer size and flow control wake up threshold. */ 537c478bd9Sstevel@tonic-gate #define SCTP_XMIT_LOWATER 8192 547c478bd9Sstevel@tonic-gate #define SCTP_XMIT_HIWATER 102400 557c478bd9Sstevel@tonic-gate #define SCTP_RECV_LOWATER 8192 567c478bd9Sstevel@tonic-gate #define SCTP_RECV_HIWATER 102400 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* SCTP Timer control structure */ 597c478bd9Sstevel@tonic-gate typedef struct sctpt_s { 607c478bd9Sstevel@tonic-gate pfv_t sctpt_pfv; /* The routine we are to call */ 617c478bd9Sstevel@tonic-gate struct sctp_s *sctpt_sctp; /* The parameter we are to pass in */ 627c478bd9Sstevel@tonic-gate struct sctp_faddr_s *sctpt_faddr; 637c478bd9Sstevel@tonic-gate } sctpt_t; 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate /* 667c478bd9Sstevel@tonic-gate * Maximum number of duplicate TSNs we can report. This is currently 677c478bd9Sstevel@tonic-gate * static, and governs the size of the mblk used to hold the duplicate 687c478bd9Sstevel@tonic-gate * reports. The use of duplcate TSN reports is currently experimental, 697c478bd9Sstevel@tonic-gate * so for now a static limit should suffice. 707c478bd9Sstevel@tonic-gate */ 717c478bd9Sstevel@tonic-gate #define SCTP_DUP_MBLK_SZ 64 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate #define SCTP_IS_ADDR_UNSPEC(isv4, addr) \ 747c478bd9Sstevel@tonic-gate ((isv4) ? IN6_IS_ADDR_V4MAPPED_ANY(&(addr)) : \ 757c478bd9Sstevel@tonic-gate IN6_IS_ADDR_UNSPECIFIED(&(addr))) 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate extern int sctp_g_num_epriv_ports; 787c478bd9Sstevel@tonic-gate extern uint16_t sctp_g_epriv_ports[]; 797c478bd9Sstevel@tonic-gate extern kmutex_t sctp_epriv_port_lock; 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate extern uint_t sctp_next_port_to_try; 827c478bd9Sstevel@tonic-gate /* 837c478bd9Sstevel@tonic-gate * SCTP parameters 847c478bd9Sstevel@tonic-gate */ 857c478bd9Sstevel@tonic-gate /* Named Dispatch Parameter Management Structure */ 867c478bd9Sstevel@tonic-gate typedef struct sctpparam_s { 877c478bd9Sstevel@tonic-gate uint32_t sctp_param_min; 887c478bd9Sstevel@tonic-gate uint32_t sctp_param_max; 897c478bd9Sstevel@tonic-gate uint32_t sctp_param_val; 907c478bd9Sstevel@tonic-gate char *sctp_param_name; 917c478bd9Sstevel@tonic-gate } sctpparam_t; 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate extern sctpparam_t sctp_param_arr[]; 947c478bd9Sstevel@tonic-gate #define sctp_max_init_retr sctp_param_arr[0].sctp_param_val 957c478bd9Sstevel@tonic-gate #define sctp_max_init_retr_high sctp_param_arr[0].sctp_param_max 967c478bd9Sstevel@tonic-gate #define sctp_max_init_retr_low sctp_param_arr[0].sctp_param_min 977c478bd9Sstevel@tonic-gate #define sctp_pa_max_retr sctp_param_arr[1].sctp_param_val 987c478bd9Sstevel@tonic-gate #define sctp_pa_max_retr_high sctp_param_arr[1].sctp_param_max 997c478bd9Sstevel@tonic-gate #define sctp_pa_max_retr_low sctp_param_arr[1].sctp_param_min 1007c478bd9Sstevel@tonic-gate #define sctp_pp_max_retr sctp_param_arr[2].sctp_param_val 1017c478bd9Sstevel@tonic-gate #define sctp_pp_max_retr_high sctp_param_arr[2].sctp_param_max 1027c478bd9Sstevel@tonic-gate #define sctp_pp_max_retr_low sctp_param_arr[2].sctp_param_min 1037c478bd9Sstevel@tonic-gate #define sctp_cwnd_max_ sctp_param_arr[3].sctp_param_val 1047c478bd9Sstevel@tonic-gate #define sctp_dbg sctp_param_arr[4].sctp_param_val 1057c478bd9Sstevel@tonic-gate #define sctp_smallest_nonpriv_port sctp_param_arr[5].sctp_param_val 1067c478bd9Sstevel@tonic-gate #define sctp_ipv4_ttl sctp_param_arr[6].sctp_param_val 1077c478bd9Sstevel@tonic-gate #define sctp_heartbeat_interval sctp_param_arr[7].sctp_param_val 1087c478bd9Sstevel@tonic-gate #define sctp_heartbeat_interval_high sctp_param_arr[7].sctp_param_max 1097c478bd9Sstevel@tonic-gate #define sctp_heartbeat_interval_low sctp_param_arr[7].sctp_param_min 1107c478bd9Sstevel@tonic-gate #define sctp_initial_mtu sctp_param_arr[8].sctp_param_val 1117c478bd9Sstevel@tonic-gate #define sctp_mtu_probe_interval sctp_param_arr[9].sctp_param_val 1127c478bd9Sstevel@tonic-gate #define sctp_new_secret_interval sctp_param_arr[10].sctp_param_val 1137c478bd9Sstevel@tonic-gate #define sctp_deferred_ack_interval sctp_param_arr[11].sctp_param_val 1147c478bd9Sstevel@tonic-gate #define sctp_snd_lowat_fraction sctp_param_arr[12].sctp_param_val 1157c478bd9Sstevel@tonic-gate #define sctp_ignore_path_mtu sctp_param_arr[13].sctp_param_val 1167c478bd9Sstevel@tonic-gate #define sctp_initial_ssthresh sctp_param_arr[14].sctp_param_val 1177c478bd9Sstevel@tonic-gate #define sctp_smallest_anon_port sctp_param_arr[15].sctp_param_val 1187c478bd9Sstevel@tonic-gate #define sctp_largest_anon_port sctp_param_arr[16].sctp_param_val 1197c478bd9Sstevel@tonic-gate #define sctp_xmit_hiwat sctp_param_arr[17].sctp_param_val 1207c478bd9Sstevel@tonic-gate #define sctp_xmit_lowat sctp_param_arr[18].sctp_param_val 1217c478bd9Sstevel@tonic-gate #define sctp_recv_hiwat sctp_param_arr[19].sctp_param_val 1227c478bd9Sstevel@tonic-gate #define sctp_max_buf sctp_param_arr[20].sctp_param_val 1237c478bd9Sstevel@tonic-gate #define sctp_rtt_updates sctp_param_arr[21].sctp_param_val 1247c478bd9Sstevel@tonic-gate #define sctp_ipv6_hoplimit sctp_param_arr[22].sctp_param_val 1257c478bd9Sstevel@tonic-gate #define sctp_rto_ming sctp_param_arr[23].sctp_param_val 1267c478bd9Sstevel@tonic-gate #define sctp_rto_ming_high sctp_param_arr[23].sctp_param_max 1277c478bd9Sstevel@tonic-gate #define sctp_rto_ming_low sctp_param_arr[23].sctp_param_min 1287c478bd9Sstevel@tonic-gate #define sctp_rto_maxg sctp_param_arr[24].sctp_param_val 1297c478bd9Sstevel@tonic-gate #define sctp_rto_maxg_high sctp_param_arr[24].sctp_param_max 1307c478bd9Sstevel@tonic-gate #define sctp_rto_maxg_low sctp_param_arr[24].sctp_param_min 1317c478bd9Sstevel@tonic-gate #define sctp_rto_initialg sctp_param_arr[25].sctp_param_val 1327c478bd9Sstevel@tonic-gate #define sctp_rto_initialg_high sctp_param_arr[25].sctp_param_max 1337c478bd9Sstevel@tonic-gate #define sctp_rto_initialg_low sctp_param_arr[25].sctp_param_min 1347c478bd9Sstevel@tonic-gate #define sctp_cookie_life sctp_param_arr[26].sctp_param_val 1357c478bd9Sstevel@tonic-gate #define sctp_cookie_life_high sctp_param_arr[26].sctp_param_max 1367c478bd9Sstevel@tonic-gate #define sctp_cookie_life_low sctp_param_arr[26].sctp_param_min 1377c478bd9Sstevel@tonic-gate #define sctp_max_in_streams sctp_param_arr[27].sctp_param_val 1387c478bd9Sstevel@tonic-gate #define sctp_max_in_streams_high sctp_param_arr[27].sctp_param_max 1397c478bd9Sstevel@tonic-gate #define sctp_max_in_streams_low sctp_param_arr[27].sctp_param_min 1407c478bd9Sstevel@tonic-gate #define sctp_initial_out_streams sctp_param_arr[28].sctp_param_val 1417c478bd9Sstevel@tonic-gate #define sctp_initial_out_streams_high sctp_param_arr[28].sctp_param_max 1427c478bd9Sstevel@tonic-gate #define sctp_initial_out_streams_low sctp_param_arr[28].sctp_param_min 1437c478bd9Sstevel@tonic-gate #define sctp_shutack_wait_bound sctp_param_arr[29].sctp_param_val 1447c478bd9Sstevel@tonic-gate #define sctp_maxburst sctp_param_arr[30].sctp_param_val 1457c478bd9Sstevel@tonic-gate #define sctp_addip_enabled sctp_param_arr[31].sctp_param_val 1467c478bd9Sstevel@tonic-gate #define sctp_recv_hiwat_minmss sctp_param_arr[32].sctp_param_val 1477c478bd9Sstevel@tonic-gate #define sctp_slow_start_initial sctp_param_arr[33].sctp_param_val 1487c478bd9Sstevel@tonic-gate #define sctp_slow_start_after_idle sctp_param_arr[34].sctp_param_val 1497c478bd9Sstevel@tonic-gate #define sctp_prsctp_enabled sctp_param_arr[35].sctp_param_val 1507c478bd9Sstevel@tonic-gate #define sctp_fast_rxt_thresh sctp_param_arr[36].sctp_param_val 1517c478bd9Sstevel@tonic-gate /* 1527c478bd9Sstevel@tonic-gate * sctp_wroff_xtra is the extra space in front of SCTP/IP header for link 1537c478bd9Sstevel@tonic-gate * layer header. It has to be a multiple of 4. 1547c478bd9Sstevel@tonic-gate */ 1557c478bd9Sstevel@tonic-gate extern sctpparam_t sctp_wroff_xtra_param; 1567c478bd9Sstevel@tonic-gate #define sctp_wroff_xtra sctp_wroff_xtra_param.sctp_param_val 1577c478bd9Sstevel@tonic-gate 15877c67f2fSkcpoon /* 15977c67f2fSkcpoon * Retransmission timer start and stop macro for a given faddr. 16077c67f2fSkcpoon */ 16177c67f2fSkcpoon #define SCTP_FADDR_TIMER_RESTART(sctp, fp, intvl) \ 16277c67f2fSkcpoon { \ 16377c67f2fSkcpoon dprint(3, ("faddr_timer_restart: fp=%p %x:%x:%x:%x %d\n", \ 16477c67f2fSkcpoon (void *)(fp), SCTP_PRINTADDR((fp)->faddr), (int)(intvl))); \ 16577c67f2fSkcpoon sctp_timer((sctp), (fp)->timer_mp, (intvl)); \ 16677c67f2fSkcpoon (fp)->timer_running = 1; \ 16777c67f2fSkcpoon } 16877c67f2fSkcpoon 16977c67f2fSkcpoon #define SCTP_FADDR_TIMER_STOP(fp) \ 17077c67f2fSkcpoon ASSERT((fp)->timer_mp != NULL); \ 17177c67f2fSkcpoon if ((fp)->timer_running) { \ 17277c67f2fSkcpoon sctp_timer_stop((fp)->timer_mp); \ 17377c67f2fSkcpoon (fp)->timer_running = 0; \ 17477c67f2fSkcpoon } 17577c67f2fSkcpoon 17677c67f2fSkcpoon #define SCTP_CALC_RXT(fp, max) \ 17777c67f2fSkcpoon { \ 17877c67f2fSkcpoon if (((fp)->rto <<= 1) > (max)) \ 17977c67f2fSkcpoon (fp)->rto = (max); \ 18077c67f2fSkcpoon } 18177c67f2fSkcpoon 18277c67f2fSkcpoon 1837c478bd9Sstevel@tonic-gate #define SCTP_MAX_COMBINED_HEADER_LENGTH (60 + 12) /* Maxed out ip + sctp */ 1847c478bd9Sstevel@tonic-gate #define SCTP_MAX_IP_OPTIONS_LENGTH (60 - IP_SIMPLE_HDR_LENGTH) 1857c478bd9Sstevel@tonic-gate #define SCTP_MAX_HDR_LENGTH 60 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate #define SCTP_SECRET_LEN 16 1887c478bd9Sstevel@tonic-gate 1897c478bd9Sstevel@tonic-gate #define SCTP_REFHOLD(sctp) { \ 1907c478bd9Sstevel@tonic-gate mutex_enter(&(sctp)->sctp_reflock); \ 1917c478bd9Sstevel@tonic-gate (sctp)->sctp_refcnt++; \ 1927c478bd9Sstevel@tonic-gate ASSERT((sctp)->sctp_refcnt != 0); \ 1937c478bd9Sstevel@tonic-gate mutex_exit(&(sctp)->sctp_reflock); \ 1947c478bd9Sstevel@tonic-gate } 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate #define SCTP_REFRELE(sctp) { \ 1977c478bd9Sstevel@tonic-gate mutex_enter(&(sctp)->sctp_reflock); \ 1987c478bd9Sstevel@tonic-gate ASSERT((sctp)->sctp_refcnt != 0); \ 1997c478bd9Sstevel@tonic-gate if (--(sctp)->sctp_refcnt == 0) { \ 2007c478bd9Sstevel@tonic-gate mutex_exit(&(sctp)->sctp_reflock); \ 2017c478bd9Sstevel@tonic-gate CONN_DEC_REF((sctp)->sctp_connp); \ 2027c478bd9Sstevel@tonic-gate } else { \ 2037c478bd9Sstevel@tonic-gate mutex_exit(&(sctp)->sctp_reflock); \ 2047c478bd9Sstevel@tonic-gate } \ 2057c478bd9Sstevel@tonic-gate } 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate #define SCTP_PRINTADDR(a) (a).s6_addr32[0], (a).s6_addr32[1],\ 2087c478bd9Sstevel@tonic-gate (a).s6_addr32[2], (a).s6_addr32[3] 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate #define CONN2SCTP(conn) ((sctp_t *)(&((conn_t *)conn)[1])) 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate /* 2137c478bd9Sstevel@tonic-gate * Outbound data, flags and macros for per-message, per-chunk info 2147c478bd9Sstevel@tonic-gate */ 2157c478bd9Sstevel@tonic-gate typedef struct { 2167c478bd9Sstevel@tonic-gate int64_t smh_ttl; /* Time to Live */ 2177c478bd9Sstevel@tonic-gate int64_t smh_tob; /* Time of Birth */ 2187c478bd9Sstevel@tonic-gate uint32_t smh_context; 2197c478bd9Sstevel@tonic-gate uint16_t smh_sid; 2207c478bd9Sstevel@tonic-gate uint16_t smh_ssn; 2217c478bd9Sstevel@tonic-gate uint32_t smh_ppid; 2227c478bd9Sstevel@tonic-gate uint16_t smh_flags; 2237c478bd9Sstevel@tonic-gate uint32_t smh_msglen; 2247c478bd9Sstevel@tonic-gate } sctp_msg_hdr_t; 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_FLAG_SENT 0x01 2277c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_FLAG_REXMIT 0x02 2287c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_FLAG_ACKED 0x04 2297c478bd9Sstevel@tonic-gate #define SCTP_MSG_FLAG_CHUNKED 0x08 2307c478bd9Sstevel@tonic-gate #define SCTP_MSG_FLAG_ABANDONED 0x10 2317c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_FLAG_ABANDONED 0x20 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_CLEAR_FLAGS(mp) ((mp)->b_flag = 0) 2347c478bd9Sstevel@tonic-gate /* 2357c478bd9Sstevel@tonic-gate * If we are transmitting the chunk for the first time we assign the TSN and 2367c478bd9Sstevel@tonic-gate * SSN here. The reason we assign the SSN here (as opposed to doing it in 2377c478bd9Sstevel@tonic-gate * sctp_chunkify()) is that the chunk may expire, if PRSCTP is enabled, before 2387c478bd9Sstevel@tonic-gate * we get a chance to send it out. If we assign the SSN in sctp_chunkify() 2397c478bd9Sstevel@tonic-gate * and this happens, then we need to send a Forward TSN to the peer, which 2407c478bd9Sstevel@tonic-gate * will be expecting this SSN, assuming ordered. If we assign it here we 2417c478bd9Sstevel@tonic-gate * can just take out the chunk from the transmit list without having to 2427c478bd9Sstevel@tonic-gate * send a Forward TSN chunk. While assigning the SSN we use (meta)->b_cont 2437c478bd9Sstevel@tonic-gate * to determine if it needs a new SSN (i.e. the next SSN for the stream), 2447c478bd9Sstevel@tonic-gate * since (meta)->b_cont signifies the first chunk of a message (if the message 2457c478bd9Sstevel@tonic-gate * is unordered, then the SSN is 0). 2467c478bd9Sstevel@tonic-gate * 2477c478bd9Sstevel@tonic-gate */ 2487c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_SENT(sctp, mp, sdc, fp, chunkdata, meta) { \ 2497c478bd9Sstevel@tonic-gate if (!SCTP_CHUNK_ISSENT(mp)) { \ 2507c478bd9Sstevel@tonic-gate sctp_msg_hdr_t *mhdr = (sctp_msg_hdr_t *)(meta)->b_rptr; \ 2517c478bd9Sstevel@tonic-gate ASSERT(!SCTP_CHUNK_ABANDONED(mp)); \ 2527c478bd9Sstevel@tonic-gate (mp)->b_flag = SCTP_CHUNK_FLAG_SENT; \ 2537c478bd9Sstevel@tonic-gate (sdc)->sdh_tsn = htonl((sctp)->sctp_ltsn++); \ 2547c478bd9Sstevel@tonic-gate if ((mhdr)->smh_flags & MSG_UNORDERED) { \ 2557c478bd9Sstevel@tonic-gate (sdc)->sdh_ssn = 0; \ 2567c478bd9Sstevel@tonic-gate SCTP_DATA_SET_UBIT(sdc); \ 2577c478bd9Sstevel@tonic-gate BUMP_LOCAL((sctp)->sctp_oudchunks); \ 2587c478bd9Sstevel@tonic-gate } else { \ 2597c478bd9Sstevel@tonic-gate BUMP_LOCAL((sctp)->sctp_odchunks); \ 2607c478bd9Sstevel@tonic-gate if ((mp) == (meta)->b_cont) { \ 2617c478bd9Sstevel@tonic-gate mhdr->smh_ssn = htons( \ 2627c478bd9Sstevel@tonic-gate (sctp)->sctp_ostrcntrs[mhdr->smh_sid]++); \ 2637c478bd9Sstevel@tonic-gate } \ 2647c478bd9Sstevel@tonic-gate (sdc)->sdh_ssn = mhdr->smh_ssn; \ 2657c478bd9Sstevel@tonic-gate } \ 2667c478bd9Sstevel@tonic-gate (sctp)->sctp_unacked += (chunkdata); \ 2677c478bd9Sstevel@tonic-gate (sctp)->sctp_unsent -= (chunkdata); \ 2687c478bd9Sstevel@tonic-gate (sctp)->sctp_frwnd -= (chunkdata); \ 2697c478bd9Sstevel@tonic-gate } else { \ 2707c478bd9Sstevel@tonic-gate if (SCTP_CHUNK_ISACKED(mp)) { \ 2717c478bd9Sstevel@tonic-gate (sctp)->sctp_unacked += (chunkdata); \ 2727c478bd9Sstevel@tonic-gate } else { \ 2737c478bd9Sstevel@tonic-gate ASSERT(SCTP_CHUNK_DEST(mp)->suna >= ((chunkdata) + \ 2747c478bd9Sstevel@tonic-gate sizeof (*sdc))); \ 2757c478bd9Sstevel@tonic-gate SCTP_CHUNK_DEST(mp)->suna -= ((chunkdata) + \ 2767c478bd9Sstevel@tonic-gate sizeof (*sdc)); \ 2777c478bd9Sstevel@tonic-gate } \ 2787c478bd9Sstevel@tonic-gate (mp)->b_flag &= ~(SCTP_CHUNK_FLAG_REXMIT | \ 2797c478bd9Sstevel@tonic-gate SCTP_CHUNK_FLAG_ACKED); \ 2807c478bd9Sstevel@tonic-gate SCTP_CHUNK_SET_SACKCNT(mp, 0); \ 2817c478bd9Sstevel@tonic-gate BUMP_LOCAL(sctp->sctp_rxtchunks); \ 2827c478bd9Sstevel@tonic-gate BUMP_LOCAL((sctp)->sctp_T3expire); \ 2837c478bd9Sstevel@tonic-gate BUMP_LOCAL((fp)->T3expire); \ 2847c478bd9Sstevel@tonic-gate } \ 2857c478bd9Sstevel@tonic-gate SCTP_SET_CHUNK_DEST(mp, fp); \ 2867c478bd9Sstevel@tonic-gate (fp)->suna += ((chunkdata) + sizeof (*sdc)); \ 2877c478bd9Sstevel@tonic-gate } 2887c478bd9Sstevel@tonic-gate 2897c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_ISSENT(mp) ((mp)->b_flag & SCTP_CHUNK_FLAG_SENT) 2907c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_CANSEND(mp) \ 2917c478bd9Sstevel@tonic-gate (!(SCTP_CHUNK_ABANDONED(mp)) && \ 2927c478bd9Sstevel@tonic-gate (((mp)->b_flag & (SCTP_CHUNK_FLAG_REXMIT|SCTP_CHUNK_FLAG_SENT)) != \ 2937c478bd9Sstevel@tonic-gate SCTP_CHUNK_FLAG_SENT)) 2947c478bd9Sstevel@tonic-gate 2957c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_DEST(mp) ((sctp_faddr_t *)(mp)->b_queue) 2967c478bd9Sstevel@tonic-gate #define SCTP_SET_CHUNK_DEST(mp, fp) ((mp)->b_queue = (queue_t *)fp) 2977c478bd9Sstevel@tonic-gate 2987c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_REXMIT(mp) ((mp)->b_flag |= SCTP_CHUNK_FLAG_REXMIT) 2997c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_CLEAR_REXMIT(mp) ((mp)->b_flag &= ~SCTP_CHUNK_FLAG_REXMIT) 3007c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_WANT_REXMIT(mp) ((mp)->b_flag & SCTP_CHUNK_FLAG_REXMIT) 3017c478bd9Sstevel@tonic-gate 3027c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_ACKED(mp) \ 3037c478bd9Sstevel@tonic-gate ((mp)->b_flag = (SCTP_CHUNK_FLAG_SENT|SCTP_CHUNK_FLAG_ACKED)) 3047c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_ISACKED(mp) ((mp)->b_flag & SCTP_CHUNK_FLAG_ACKED) 3057c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_CLEAR_ACKED(mp) ((mp)->b_flag &= ~SCTP_CHUNK_FLAG_ACKED) 3067c478bd9Sstevel@tonic-gate 3077c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_SACKCNT(mp) ((intptr_t)((mp)->b_prev)) 3087c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_SET_SACKCNT(mp, val) ((mp)->b_prev = \ 3097c478bd9Sstevel@tonic-gate (mblk_t *)(uintptr_t)(val)) 3107c478bd9Sstevel@tonic-gate 3117c478bd9Sstevel@tonic-gate #define SCTP_MSG_SET_CHUNKED(mp) ((mp)->b_flag |= SCTP_MSG_FLAG_CHUNKED) 3127c478bd9Sstevel@tonic-gate #define SCTP_MSG_CLEAR_CHUNKED(mp)((mp)->b_flag &= ~SCTP_MSG_FLAG_CHUNKED) 3137c478bd9Sstevel@tonic-gate #define SCTP_IS_MSG_CHUNKED(mp) ((mp)->b_flag & SCTP_MSG_FLAG_CHUNKED) 3147c478bd9Sstevel@tonic-gate 3157c478bd9Sstevel@tonic-gate /* For PR-SCTP */ 3167c478bd9Sstevel@tonic-gate #define SCTP_ABANDON_CHUNK(mp) ((mp)->b_flag |= SCTP_CHUNK_FLAG_ABANDONED) 3177c478bd9Sstevel@tonic-gate #define SCTP_CHUNK_ABANDONED(mp) \ 3187c478bd9Sstevel@tonic-gate ((mp)->b_flag & SCTP_CHUNK_FLAG_ABANDONED) 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate #define SCTP_MSG_SET_ABANDONED(mp) \ 3217c478bd9Sstevel@tonic-gate ((mp)->b_flag |= SCTP_MSG_FLAG_ABANDONED) 3227c478bd9Sstevel@tonic-gate #define SCTP_MSG_CLEAR_ABANDONED(mp)((mp)->b_flag &= ~SCTP_MSG_FLAG_ABANDONED) 3237c478bd9Sstevel@tonic-gate #define SCTP_IS_MSG_ABANDONED(mp) ((mp)->b_flag & SCTP_MSG_FLAG_ABANDONED) 3247c478bd9Sstevel@tonic-gate 3257c478bd9Sstevel@tonic-gate /* 3267c478bd9Sstevel@tonic-gate * Check if a message has expired. A message is expired if 3277c478bd9Sstevel@tonic-gate * 1. It has a non-zero time to live value and has not been sent before 3287c478bd9Sstevel@tonic-gate * that time expires. 3297c478bd9Sstevel@tonic-gate * 2. It is sent using PRSCTP and it has not been SACK'ed before 3307c478bd9Sstevel@tonic-gate * its lifetime expires. 3317c478bd9Sstevel@tonic-gate */ 3327c478bd9Sstevel@tonic-gate #define SCTP_MSG_TO_BE_ABANDONED(meta, mhdr, sctp) \ 3337c478bd9Sstevel@tonic-gate (((!SCTP_CHUNK_ISSENT((meta)->b_cont) && (mhdr)->smh_ttl > 0) || \ 3347c478bd9Sstevel@tonic-gate ((sctp)->sctp_prsctp_aware && ((mhdr)->smh_flags & MSG_PR_SCTP))) && \ 3357c478bd9Sstevel@tonic-gate ((lbolt64 - (mhdr)->smh_tob) > (mhdr)->smh_ttl)) 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate /* SCTP association hash function. */ 3387c478bd9Sstevel@tonic-gate #define SCTP_CONN_HASH(ports) \ 3397c478bd9Sstevel@tonic-gate ((((ports) ^ ((ports) >> 16)) * 31) & (sctp_conn_hash_size - 1)) 3407c478bd9Sstevel@tonic-gate 3417c478bd9Sstevel@tonic-gate /* 3427c478bd9Sstevel@tonic-gate * Bind hash array size and hash function. The size must be a power 3437c478bd9Sstevel@tonic-gate * of 2 and lport must be in host byte order. 3447c478bd9Sstevel@tonic-gate */ 3457c478bd9Sstevel@tonic-gate #define SCTP_BIND_FANOUT_SIZE 2048 3467c478bd9Sstevel@tonic-gate #define SCTP_BIND_HASH(lport) (((lport) * 31) & (SCTP_BIND_FANOUT_SIZE - 1)) 3477c478bd9Sstevel@tonic-gate 3487c478bd9Sstevel@tonic-gate /* options that SCTP negotiates during association establishment */ 3497c478bd9Sstevel@tonic-gate #define SCTP_PRSCTP_OPTION 0x01 3507c478bd9Sstevel@tonic-gate 3517c478bd9Sstevel@tonic-gate /* 3527c478bd9Sstevel@tonic-gate * Listener hash array size and hash function. The size must be a power 3537c478bd9Sstevel@tonic-gate * of 2 and lport must be in host byte order. 3547c478bd9Sstevel@tonic-gate */ 3557c478bd9Sstevel@tonic-gate #define SCTP_LISTEN_FANOUT_SIZE 512 3567c478bd9Sstevel@tonic-gate #define SCTP_LISTEN_HASH(lport) (((lport) * 31) & (SCTP_LISTEN_FANOUT_SIZE - 1)) 3577c478bd9Sstevel@tonic-gate 3587c478bd9Sstevel@tonic-gate typedef struct sctp_tf_s { 3597c478bd9Sstevel@tonic-gate struct sctp_s *tf_sctp; 3607c478bd9Sstevel@tonic-gate kmutex_t tf_lock; 3617c478bd9Sstevel@tonic-gate } sctp_tf_t; 3627c478bd9Sstevel@tonic-gate 3637c478bd9Sstevel@tonic-gate /* SCTP association hash list */ 3647c478bd9Sstevel@tonic-gate extern sctp_tf_t *sctp_conn_fanout; 3657c478bd9Sstevel@tonic-gate /* Size of sctp_conn_fanout */ 3667c478bd9Sstevel@tonic-gate extern uint_t sctp_conn_hash_size; 3677c478bd9Sstevel@tonic-gate 3687c478bd9Sstevel@tonic-gate /* SCTP bind hash list - all sctp_t with state >= BOUND. */ 3697c478bd9Sstevel@tonic-gate extern sctp_tf_t sctp_bind_fanout[]; 3707c478bd9Sstevel@tonic-gate 3717c478bd9Sstevel@tonic-gate /* SCTP listener hash list - all sctp_t with state == LISTEN. */ 3727c478bd9Sstevel@tonic-gate extern sctp_tf_t sctp_listen_fanout[]; 3737c478bd9Sstevel@tonic-gate 3747c478bd9Sstevel@tonic-gate /* Round up the value to the nearest mss. */ 3757c478bd9Sstevel@tonic-gate #define MSS_ROUNDUP(value, mss) ((((value) - 1) / (mss) + 1) * (mss)) 3767c478bd9Sstevel@tonic-gate 3777c478bd9Sstevel@tonic-gate extern sin_t sctp_sin_null; /* Zero address for quick clears */ 3787c478bd9Sstevel@tonic-gate extern sin6_t sctp_sin6_null; /* Zero address for quick clears */ 3797c478bd9Sstevel@tonic-gate 3807c478bd9Sstevel@tonic-gate #define SCTP_IS_DETACHED(sctp) ((sctp)->sctp_detached) 3817c478bd9Sstevel@tonic-gate 3827c478bd9Sstevel@tonic-gate extern mib2_sctp_t sctp_mib; /* SNMP fixed size info */ 3837c478bd9Sstevel@tonic-gate 38477c67f2fSkcpoon /* SCTP kstat */ 38577c67f2fSkcpoon typedef struct sctp_kstat_s { 38677c67f2fSkcpoon kstat_named_t sctp_add_faddr; 38777c67f2fSkcpoon kstat_named_t sctp_add_timer; 38877c67f2fSkcpoon kstat_named_t sctp_conn_create; 38977c67f2fSkcpoon kstat_named_t sctp_find_next_tq; 39077c67f2fSkcpoon kstat_named_t sctp_fr_add_hdr; 39177c67f2fSkcpoon kstat_named_t sctp_fr_not_found; 39277c67f2fSkcpoon kstat_named_t sctp_output_failed; 39377c67f2fSkcpoon kstat_named_t sctp_rexmit_failed; 39477c67f2fSkcpoon kstat_named_t sctp_send_init_failed; 39577c67f2fSkcpoon kstat_named_t sctp_send_cookie_failed; 39677c67f2fSkcpoon kstat_named_t sctp_send_cookie_ack_failed; 39777c67f2fSkcpoon kstat_named_t sctp_send_err_failed; 39877c67f2fSkcpoon kstat_named_t sctp_send_sack_failed; 39977c67f2fSkcpoon kstat_named_t sctp_send_shutdown_failed; 40077c67f2fSkcpoon kstat_named_t sctp_send_shutdown_ack_failed; 40177c67f2fSkcpoon kstat_named_t sctp_send_shutdown_comp_failed; 40277c67f2fSkcpoon kstat_named_t sctp_send_user_abort_failed; 40377c67f2fSkcpoon kstat_named_t sctp_send_asconf_failed; 40477c67f2fSkcpoon kstat_named_t sctp_send_asconf_ack_failed; 40577c67f2fSkcpoon kstat_named_t sctp_send_ftsn_failed; 40677c67f2fSkcpoon kstat_named_t sctp_send_hb_failed; 40777c67f2fSkcpoon kstat_named_t sctp_return_hb_failed; 40877c67f2fSkcpoon kstat_named_t sctp_ss_rexmit_failed; 40977c67f2fSkcpoon kstat_named_t sctp_cl_connect; 41077c67f2fSkcpoon kstat_named_t sctp_cl_assoc_change; 41177c67f2fSkcpoon kstat_named_t sctp_cl_check_addrs; 41277c67f2fSkcpoon } sctp_kstat_t; 41377c67f2fSkcpoon 41477c67f2fSkcpoon extern sctp_kstat_t sctp_statistics; 41577c67f2fSkcpoon 41677c67f2fSkcpoon #define SCTP_KSTAT(x) (sctp_statistics.x.value.ui64++) 41777c67f2fSkcpoon 4187c478bd9Sstevel@tonic-gate /* 4197c478bd9Sstevel@tonic-gate * Object to represent database of options to search passed to 4207c478bd9Sstevel@tonic-gate * {sock,tpi}optcom_req() interface routine to take care of option 4217c478bd9Sstevel@tonic-gate * management and associated methods. 4227c478bd9Sstevel@tonic-gate * XXX These and other externs should ideally move to a SCTP header 4237c478bd9Sstevel@tonic-gate */ 4247c478bd9Sstevel@tonic-gate extern optdb_obj_t sctp_opt_obj; 4257c478bd9Sstevel@tonic-gate extern uint_t sctp_max_optbuf_len; 4267c478bd9Sstevel@tonic-gate 4277c478bd9Sstevel@tonic-gate /* Data structure used to track received TSNs */ 4287c478bd9Sstevel@tonic-gate typedef struct sctp_set_s { 4297c478bd9Sstevel@tonic-gate struct sctp_set_s *next; 4307c478bd9Sstevel@tonic-gate struct sctp_set_s *prev; 4317c478bd9Sstevel@tonic-gate uint32_t begin; 4327c478bd9Sstevel@tonic-gate uint32_t end; 4337c478bd9Sstevel@tonic-gate } sctp_set_t; 4347c478bd9Sstevel@tonic-gate 4357c478bd9Sstevel@tonic-gate /* Data structure used to track TSNs for PR-SCTP */ 4367c478bd9Sstevel@tonic-gate typedef struct sctp_ftsn_set_s { 4377c478bd9Sstevel@tonic-gate struct sctp_ftsn_set_s *next; 4387c478bd9Sstevel@tonic-gate ftsn_entry_t ftsn_entries; 4397c478bd9Sstevel@tonic-gate } sctp_ftsn_set_t; 4407c478bd9Sstevel@tonic-gate 4417c478bd9Sstevel@tonic-gate /* Data structure used to track incoming SCTP streams */ 4427c478bd9Sstevel@tonic-gate typedef struct sctp_instr_s { 4437c478bd9Sstevel@tonic-gate mblk_t *istr_msgs; 4447c478bd9Sstevel@tonic-gate int istr_nmsgs; 4457c478bd9Sstevel@tonic-gate uint16_t nextseq; 4467c478bd9Sstevel@tonic-gate struct sctp_s *sctp; 4477c478bd9Sstevel@tonic-gate mblk_t *istr_reass; 4487c478bd9Sstevel@tonic-gate } sctp_instr_t; 4497c478bd9Sstevel@tonic-gate 4507c478bd9Sstevel@tonic-gate /* Reassembly data structure (per-stream) */ 4517c478bd9Sstevel@tonic-gate typedef struct sctp_reass_s { 4527c478bd9Sstevel@tonic-gate uint16_t ssn; 4537c478bd9Sstevel@tonic-gate uint16_t needed; 4547c478bd9Sstevel@tonic-gate uint16_t got; 4557c478bd9Sstevel@tonic-gate mblk_t *tail; 4567c478bd9Sstevel@tonic-gate boolean_t partial_delivered; 4577c478bd9Sstevel@tonic-gate } sctp_reass_t; 4587c478bd9Sstevel@tonic-gate 4597c478bd9Sstevel@tonic-gate /* debugging */ 4607c478bd9Sstevel@tonic-gate #undef dprint 46145916cd2Sjpk #ifdef DEBUG 4627c478bd9Sstevel@tonic-gate extern int sctpdebug; 4637c478bd9Sstevel@tonic-gate #define dprint(level, args) { if (sctpdebug > (level)) printf args; } 46445916cd2Sjpk #else 4657c478bd9Sstevel@tonic-gate #define dprint(level, args) {} 46645916cd2Sjpk #endif 4677c478bd9Sstevel@tonic-gate 4687c478bd9Sstevel@tonic-gate 4697c478bd9Sstevel@tonic-gate /* Peer address tracking */ 4707c478bd9Sstevel@tonic-gate 4717c478bd9Sstevel@tonic-gate /* 4727c478bd9Sstevel@tonic-gate * States for peer addresses 4737c478bd9Sstevel@tonic-gate * 4747c478bd9Sstevel@tonic-gate * SCTP_FADDRS_UNCONFIRMED: we have not communicated with this peer address 4757c478bd9Sstevel@tonic-gate * before, mark it as unconfirmed so that we will not send data to it. 4767c478bd9Sstevel@tonic-gate * All addresses initially are in unconfirmed state and required 4777c478bd9Sstevel@tonic-gate * validation. SCTP sends a heartbeat to each of them and when it gets 4787c478bd9Sstevel@tonic-gate * back a heartbeat ACK, the address will be marked as alive. This 4797c478bd9Sstevel@tonic-gate * validation fixes a security issue with multihoming. If an attacker 4807c478bd9Sstevel@tonic-gate * establishes an association with us and tells us that it has addresses 4817c478bd9Sstevel@tonic-gate * belonging to another host A, this will prevent A from communicating 4827c478bd9Sstevel@tonic-gate * with us. This is fixed by peer address validation. In the above case, 4837c478bd9Sstevel@tonic-gate * A will respond with an abort. 4847c478bd9Sstevel@tonic-gate * 4857c478bd9Sstevel@tonic-gate * SCTP_FADDRS_ALIVE: this peer address is alive and we can communicate with 4867c478bd9Sstevel@tonic-gate * it with no problem. 4877c478bd9Sstevel@tonic-gate * 4887c478bd9Sstevel@tonic-gate * SCTP_FADDRS_DOWN: we have exceeded the retransmission limit to this 4897c478bd9Sstevel@tonic-gate * peer address. Once an address is marked down, we will only send 4907c478bd9Sstevel@tonic-gate * a heartbeat to it every hb_interval in case it becomes alive now. 4917c478bd9Sstevel@tonic-gate * 4927c478bd9Sstevel@tonic-gate * SCTP_FADDRS_UNREACH: there is no suitable source address to send to 4937c478bd9Sstevel@tonic-gate * this peer address. For example, the peer address is v6 but we only 4947c478bd9Sstevel@tonic-gate * have v4 addresses. It is marked unreachable until there is an 4957c478bd9Sstevel@tonic-gate * address configuration change. At that time, mark these addresses 4967c478bd9Sstevel@tonic-gate * as unconfirmed and try again to see if those unreachable addresses 4977c478bd9Sstevel@tonic-gate * are OK as we may have more source addresses. 4987c478bd9Sstevel@tonic-gate */ 4997c478bd9Sstevel@tonic-gate typedef enum { 5007c478bd9Sstevel@tonic-gate SCTP_FADDRS_UNREACH, 5017c478bd9Sstevel@tonic-gate SCTP_FADDRS_DOWN, 5027c478bd9Sstevel@tonic-gate SCTP_FADDRS_ALIVE, 5037c478bd9Sstevel@tonic-gate SCTP_FADDRS_UNCONFIRMED 5047c478bd9Sstevel@tonic-gate } faddr_state_t; 5057c478bd9Sstevel@tonic-gate 5067c478bd9Sstevel@tonic-gate typedef struct sctp_faddr_s { 5077c478bd9Sstevel@tonic-gate struct sctp_faddr_s *next; 5087c478bd9Sstevel@tonic-gate faddr_state_t state; 5097c478bd9Sstevel@tonic-gate 5107c478bd9Sstevel@tonic-gate in6_addr_t faddr; 5117c478bd9Sstevel@tonic-gate in6_addr_t saddr; 5127c478bd9Sstevel@tonic-gate 5137c478bd9Sstevel@tonic-gate int64_t hb_expiry; /* time to retransmit heartbeat */ 5147c478bd9Sstevel@tonic-gate uint32_t hb_interval; /* the heartbeat interval */ 5157c478bd9Sstevel@tonic-gate 5167c478bd9Sstevel@tonic-gate int rto; /* RTO in tick */ 5177c478bd9Sstevel@tonic-gate int srtt; /* Smoothed RTT in tick */ 5187c478bd9Sstevel@tonic-gate int rttvar; /* RTT variance in tick */ 5197c478bd9Sstevel@tonic-gate uint32_t rtt_updates; 5207c478bd9Sstevel@tonic-gate int strikes; 5217c478bd9Sstevel@tonic-gate int max_retr; 5227c478bd9Sstevel@tonic-gate uint32_t sfa_pmss; 5237c478bd9Sstevel@tonic-gate uint32_t cwnd; 5247c478bd9Sstevel@tonic-gate uint32_t ssthresh; 5257c478bd9Sstevel@tonic-gate uint32_t suna; /* sent - unack'ed */ 5267c478bd9Sstevel@tonic-gate uint32_t pba; /* partial bytes acked */ 5277c478bd9Sstevel@tonic-gate uint32_t acked; 5287c478bd9Sstevel@tonic-gate int64_t lastactive; 5297c478bd9Sstevel@tonic-gate mblk_t *timer_mp; /* retransmission timer control */ 5307c478bd9Sstevel@tonic-gate uint32_t 5317c478bd9Sstevel@tonic-gate hb_pending : 1, 5327c478bd9Sstevel@tonic-gate timer_running : 1, 5337c478bd9Sstevel@tonic-gate df : 1, 5347c478bd9Sstevel@tonic-gate pmtu_discovered : 1, 5357c478bd9Sstevel@tonic-gate 5367c478bd9Sstevel@tonic-gate rc_timer_running : 1, 5377c478bd9Sstevel@tonic-gate isv4 : 1; 5387c478bd9Sstevel@tonic-gate 5397c478bd9Sstevel@tonic-gate mblk_t *rc_timer_mp; /* reliable control chunk timer */ 5407c478bd9Sstevel@tonic-gate ire_t *ire; /* cached IRE */ 5417c478bd9Sstevel@tonic-gate uint32_t T3expire; /* # of times T3 timer expired */ 5427c478bd9Sstevel@tonic-gate 5437c478bd9Sstevel@tonic-gate uint64_t hb_secret; /* per addr "secret" in heartbeat */ 5447c478bd9Sstevel@tonic-gate } sctp_faddr_t; 5457c478bd9Sstevel@tonic-gate 5467c478bd9Sstevel@tonic-gate /* Flags to indicate supported address type in the PARM_SUP_ADDRS. */ 5477c478bd9Sstevel@tonic-gate #define PARM_SUPP_V6 0x1 5487c478bd9Sstevel@tonic-gate #define PARM_SUPP_V4 0x2 5497c478bd9Sstevel@tonic-gate 5507c478bd9Sstevel@tonic-gate /* 5517c478bd9Sstevel@tonic-gate * Set heartbeat interval plus jitter. The jitter is supposed to be random, 5527c478bd9Sstevel@tonic-gate * up to +/- 50% of the RTO. We use gethrtime() here for performance reason 5537c478bd9Sstevel@tonic-gate * as the jitter does not really need to be "very" random. 5547c478bd9Sstevel@tonic-gate */ 5557c478bd9Sstevel@tonic-gate #define SET_HB_INTVL(fp) \ 5567c478bd9Sstevel@tonic-gate ((fp)->hb_interval + (fp)->rto + ((fp)->rto >> 1) - \ 5577c478bd9Sstevel@tonic-gate (uint_t)gethrtime() % (fp)->rto); 5587c478bd9Sstevel@tonic-gate 5597c478bd9Sstevel@tonic-gate #define SCTP_IPIF_HASH 16 5607c478bd9Sstevel@tonic-gate 5617c478bd9Sstevel@tonic-gate typedef struct sctp_ipif_hash_s { 5627c478bd9Sstevel@tonic-gate list_t sctp_ipif_list; 5637c478bd9Sstevel@tonic-gate int ipif_count; 5647c478bd9Sstevel@tonic-gate } sctp_ipif_hash_t; 5657c478bd9Sstevel@tonic-gate 5667c478bd9Sstevel@tonic-gate struct sctp_s; 5677c478bd9Sstevel@tonic-gate 5687c478bd9Sstevel@tonic-gate /* 5697c478bd9Sstevel@tonic-gate * Control structure for each open SCTP stream, 5707c478bd9Sstevel@tonic-gate * defined only within the kernel or for a kmem user. 5717c478bd9Sstevel@tonic-gate * NOTE: sctp_reinit_values MUST have a line for each field in this structure! 5727c478bd9Sstevel@tonic-gate */ 5737c478bd9Sstevel@tonic-gate #if (defined(_KERNEL) || defined(_KMEMUSER)) 5747c478bd9Sstevel@tonic-gate 5757c478bd9Sstevel@tonic-gate typedef struct sctp_s { 5767c478bd9Sstevel@tonic-gate 5777c478bd9Sstevel@tonic-gate /* 5787c478bd9Sstevel@tonic-gate * The following is shared with (and duplicated) in IP, so if you 5797c478bd9Sstevel@tonic-gate * make changes, make sure you also change things in ip_sctp.c. 5807c478bd9Sstevel@tonic-gate */ 5817c478bd9Sstevel@tonic-gate struct sctp_s *sctp_conn_hash_next; 5827c478bd9Sstevel@tonic-gate struct sctp_s *sctp_conn_hash_prev; 5837c478bd9Sstevel@tonic-gate 5847c478bd9Sstevel@tonic-gate struct sctp_s *sctp_listen_hash_next; 5857c478bd9Sstevel@tonic-gate struct sctp_s *sctp_listen_hash_prev; 5867c478bd9Sstevel@tonic-gate 5877c478bd9Sstevel@tonic-gate sctp_tf_t *sctp_listen_tfp; /* Ptr to tf */ 5887c478bd9Sstevel@tonic-gate sctp_tf_t *sctp_conn_tfp; /* Ptr to tf */ 5897c478bd9Sstevel@tonic-gate 5907c478bd9Sstevel@tonic-gate /* Global list of sctp */ 5917c478bd9Sstevel@tonic-gate list_node_t sctp_list; 5927c478bd9Sstevel@tonic-gate 5937c478bd9Sstevel@tonic-gate sctp_faddr_t *sctp_faddrs; 5941d8c4025Svi int sctp_nfaddrs; 5957c478bd9Sstevel@tonic-gate sctp_ipif_hash_t sctp_saddrs[SCTP_IPIF_HASH]; 5967c478bd9Sstevel@tonic-gate int sctp_nsaddrs; 5977c478bd9Sstevel@tonic-gate 5987c478bd9Sstevel@tonic-gate /* 5997c478bd9Sstevel@tonic-gate * These fields contain the same information as sctp_sctph->th_*port. 6007c478bd9Sstevel@tonic-gate * However, the lookup functions can not use the header fields 6017c478bd9Sstevel@tonic-gate * since during IP option manipulation the sctp_sctph pointer 6027c478bd9Sstevel@tonic-gate * changes. 6037c478bd9Sstevel@tonic-gate */ 6047c478bd9Sstevel@tonic-gate union { 6057c478bd9Sstevel@tonic-gate struct { 6067c478bd9Sstevel@tonic-gate in_port_t sctpu_fport; /* Remote port */ 6077c478bd9Sstevel@tonic-gate in_port_t sctpu_lport; /* Local port */ 6087c478bd9Sstevel@tonic-gate } sctpu_ports1; 6097c478bd9Sstevel@tonic-gate uint32_t sctpu_ports2; /* Rem port, */ 6107c478bd9Sstevel@tonic-gate /* local port */ 6117c478bd9Sstevel@tonic-gate /* Used for SCTP_MATCH performance */ 6127c478bd9Sstevel@tonic-gate } sctp_sctpu; 6137c478bd9Sstevel@tonic-gate #define sctp_fport sctp_sctpu.sctpu_ports1.sctpu_fport 6147c478bd9Sstevel@tonic-gate #define sctp_lport sctp_sctpu.sctpu_ports1.sctpu_lport 6157c478bd9Sstevel@tonic-gate #define sctp_ports sctp_sctpu.sctpu_ports2 6167c478bd9Sstevel@tonic-gate 6177c478bd9Sstevel@tonic-gate kmutex_t sctp_lock; 6187c478bd9Sstevel@tonic-gate kcondvar_t sctp_cv; 6197c478bd9Sstevel@tonic-gate boolean_t sctp_running; 6207c478bd9Sstevel@tonic-gate 6217c478bd9Sstevel@tonic-gate void *sctp_ulpd; /* SCTP upper layer desc. */ 6227c478bd9Sstevel@tonic-gate 6237c478bd9Sstevel@tonic-gate struct sctp_upcalls_s sctp_upcalls; /* upcalls for sctp_ulpd */ 6247c478bd9Sstevel@tonic-gate #define sctp_ulp_newconn sctp_upcalls.su_newconn 6257c478bd9Sstevel@tonic-gate #define sctp_ulp_connected sctp_upcalls.su_connected 6267c478bd9Sstevel@tonic-gate #define sctp_ulp_disconnected sctp_upcalls.su_disconnected 6277c478bd9Sstevel@tonic-gate #define sctp_ulp_disconnecting sctp_upcalls.su_disconnecting 6287c478bd9Sstevel@tonic-gate #define sctp_ulp_recv sctp_upcalls.su_recv 6297c478bd9Sstevel@tonic-gate #define sctp_ulp_xmitted sctp_upcalls.su_xmitted 6307c478bd9Sstevel@tonic-gate #define sctp_ulp_prop sctp_upcalls.su_properties 6317c478bd9Sstevel@tonic-gate 6327c478bd9Sstevel@tonic-gate int32_t sctp_state; 6337c478bd9Sstevel@tonic-gate 6347c478bd9Sstevel@tonic-gate conn_t *sctp_connp; /* conn_t stuff */ 6357c478bd9Sstevel@tonic-gate #define sctp_zoneid sctp_connp->conn_zoneid 6365d0bc3edSsommerfe #define sctp_allzones sctp_connp->conn_allzones 6375d0bc3edSsommerfe #define sctp_mac_exempt sctp_connp->conn_mac_exempt 6387c478bd9Sstevel@tonic-gate #define sctp_credp sctp_connp->conn_cred 6395d0bc3edSsommerfe #define sctp_reuseaddr sctp_connp->conn_reuseaddr 6407c478bd9Sstevel@tonic-gate 6417c478bd9Sstevel@tonic-gate /* Peer address tracking */ 6427c478bd9Sstevel@tonic-gate sctp_faddr_t *sctp_lastfaddr; /* last faddr in list */ 6437c478bd9Sstevel@tonic-gate sctp_faddr_t *sctp_primary; /* primary faddr */ 6447c478bd9Sstevel@tonic-gate sctp_faddr_t *sctp_current; /* current faddr */ 6457c478bd9Sstevel@tonic-gate sctp_faddr_t *sctp_lastdata; /* last data seen from this */ 6467c478bd9Sstevel@tonic-gate 6477c478bd9Sstevel@tonic-gate /* Outbound data tracking */ 6487c478bd9Sstevel@tonic-gate mblk_t *sctp_xmit_head; 6497c478bd9Sstevel@tonic-gate mblk_t *sctp_xmit_tail; 6507c478bd9Sstevel@tonic-gate mblk_t *sctp_xmit_unsent; 6517c478bd9Sstevel@tonic-gate mblk_t *sctp_xmit_unsent_tail; 6527c478bd9Sstevel@tonic-gate mblk_t *sctp_xmit_unacked; 6537c478bd9Sstevel@tonic-gate 6547c478bd9Sstevel@tonic-gate int32_t sctp_unacked; /* # of unacked bytes */ 6557c478bd9Sstevel@tonic-gate int32_t sctp_unsent; /* # of unsent bytes in hand */ 6567c478bd9Sstevel@tonic-gate 6577c478bd9Sstevel@tonic-gate uint32_t sctp_ltsn; /* Local instance TSN */ 6587c478bd9Sstevel@tonic-gate uint32_t sctp_lastack_rxd; /* Last rx'd cumtsn */ 6597c478bd9Sstevel@tonic-gate uint32_t sctp_recovery_tsn; /* Exit from fast recovery */ 6607c478bd9Sstevel@tonic-gate uint32_t sctp_adv_pap; /* Adv. Peer Ack Point */ 6617c478bd9Sstevel@tonic-gate 6627c478bd9Sstevel@tonic-gate uint16_t sctp_num_ostr; 6637c478bd9Sstevel@tonic-gate uint16_t *sctp_ostrcntrs; 6647c478bd9Sstevel@tonic-gate 6657c478bd9Sstevel@tonic-gate /* sendmsg() default parameters */ 6667c478bd9Sstevel@tonic-gate uint16_t sctp_def_stream; /* default stream id */ 6677c478bd9Sstevel@tonic-gate uint16_t sctp_def_flags; /* default xmit flags */ 6687c478bd9Sstevel@tonic-gate uint32_t sctp_def_ppid; /* default payload id */ 6697c478bd9Sstevel@tonic-gate uint32_t sctp_def_context; /* default context */ 6707c478bd9Sstevel@tonic-gate uint32_t sctp_def_timetolive; /* default msg TTL */ 6717c478bd9Sstevel@tonic-gate 6727c478bd9Sstevel@tonic-gate /* Inbound data tracking */ 6737c478bd9Sstevel@tonic-gate sctp_set_t *sctp_sack_info; /* Sack tracking */ 6747c478bd9Sstevel@tonic-gate mblk_t *sctp_ack_mp; /* Delayed ACK timer block */ 6757c478bd9Sstevel@tonic-gate sctp_instr_t *sctp_instr; /* Instream trackers */ 6767c478bd9Sstevel@tonic-gate mblk_t *sctp_uo_frags; /* Un-ordered msg. fragments */ 6777c478bd9Sstevel@tonic-gate uint32_t sctp_ftsn; /* Peer's TSN */ 6787c478bd9Sstevel@tonic-gate uint32_t sctp_lastacked; /* last cumtsn SACKd */ 6797c478bd9Sstevel@tonic-gate uint16_t sctp_num_istr; /* No. of instreams */ 6807c478bd9Sstevel@tonic-gate int32_t sctp_istr_nmsgs; /* No. of chunks in instreams */ 6817c478bd9Sstevel@tonic-gate int32_t sctp_sack_gaps; /* No. of received gaps */ 6827c478bd9Sstevel@tonic-gate int32_t sctp_sack_toggle; /* SACK every other pkt */ 6837c478bd9Sstevel@tonic-gate 6847c478bd9Sstevel@tonic-gate /* RTT calculation */ 6857c478bd9Sstevel@tonic-gate uint32_t sctp_rtt_tsn; 6867c478bd9Sstevel@tonic-gate int64_t sctp_out_time; 6877c478bd9Sstevel@tonic-gate 6887c478bd9Sstevel@tonic-gate /* Stats */ 6897c478bd9Sstevel@tonic-gate uint64_t sctp_opkts; /* sent pkts */ 6907c478bd9Sstevel@tonic-gate uint64_t sctp_obchunks; /* sent control chunks */ 6917c478bd9Sstevel@tonic-gate uint64_t sctp_odchunks; /* sent ordered data chunks */ 6927c478bd9Sstevel@tonic-gate uint64_t sctp_oudchunks; /* sent unord data chunks */ 6937c478bd9Sstevel@tonic-gate uint64_t sctp_rxtchunks; /* retransmitted chunks */ 6947c478bd9Sstevel@tonic-gate uint64_t sctp_ipkts; /* recv pkts */ 6957c478bd9Sstevel@tonic-gate uint64_t sctp_ibchunks; /* recv control chunks */ 6967c478bd9Sstevel@tonic-gate uint64_t sctp_idchunks; /* recv ordered data chunks */ 6977c478bd9Sstevel@tonic-gate uint64_t sctp_iudchunks; /* recv unord data chunks */ 6987c478bd9Sstevel@tonic-gate uint64_t sctp_fragdmsgs; 6997c478bd9Sstevel@tonic-gate uint64_t sctp_reassmsgs; 7007c478bd9Sstevel@tonic-gate uint32_t sctp_T1expire; /* # of times T1timer expired */ 7017c478bd9Sstevel@tonic-gate uint32_t sctp_T2expire; /* # of times T2timer expired */ 7027c478bd9Sstevel@tonic-gate uint32_t sctp_T3expire; /* # of times T3timer expired */ 7037c478bd9Sstevel@tonic-gate uint32_t sctp_assoc_start_time; /* time when assoc was est. */ 7047c478bd9Sstevel@tonic-gate 7057c478bd9Sstevel@tonic-gate /* Outbound flow control */ 7067c478bd9Sstevel@tonic-gate int32_t sctp_xmit_hiwater; /* Send high water mark */ 7077c478bd9Sstevel@tonic-gate int32_t sctp_xmit_lowater; /* Send low water mark */ 7087c478bd9Sstevel@tonic-gate uint32_t sctp_frwnd; /* Peer RWND */ 7097c478bd9Sstevel@tonic-gate uint32_t sctp_cwnd_max; 7107c478bd9Sstevel@tonic-gate 7117c478bd9Sstevel@tonic-gate /* Inbound flow control */ 7127c478bd9Sstevel@tonic-gate int32_t sctp_rwnd; /* Current receive window */ 7131d8c4025Svi int32_t sctp_irwnd; /* Initial receive window */ 7147c478bd9Sstevel@tonic-gate int32_t sctp_rxqueued; /* No. of bytes in RX q's */ 7157c478bd9Sstevel@tonic-gate 7167c478bd9Sstevel@tonic-gate /* Pre-initialized composite headers */ 7177c478bd9Sstevel@tonic-gate char *sctp_iphc; /* v4 sctp/ip hdr template buffer */ 7187c478bd9Sstevel@tonic-gate char *sctp_iphc6; /* v6 sctp/ip hdr template buffer */ 7197c478bd9Sstevel@tonic-gate 7207c478bd9Sstevel@tonic-gate int32_t sctp_iphc_len; /* actual allocated v4 buffer size */ 7217c478bd9Sstevel@tonic-gate int32_t sctp_iphc6_len; /* actual allocated v6 buffer size */ 7227c478bd9Sstevel@tonic-gate 7237c478bd9Sstevel@tonic-gate int32_t sctp_hdr_len; /* len of combined SCTP/IP v4 hdr */ 7247c478bd9Sstevel@tonic-gate int32_t sctp_hdr6_len; /* len of combined SCTP/IP v6 hdr */ 7257c478bd9Sstevel@tonic-gate 7267c478bd9Sstevel@tonic-gate ipha_t *sctp_ipha; /* IPv4 header in the buffer */ 7277c478bd9Sstevel@tonic-gate ip6_t *sctp_ip6h; /* IPv6 header in the buffer */ 7287c478bd9Sstevel@tonic-gate 7297c478bd9Sstevel@tonic-gate int32_t sctp_ip_hdr_len; /* Byte len of our current v4 hdr */ 7307c478bd9Sstevel@tonic-gate int32_t sctp_ip_hdr6_len; /* Byte len of our current v6 hdr */ 7317c478bd9Sstevel@tonic-gate 7327c478bd9Sstevel@tonic-gate sctp_hdr_t *sctp_sctph; /* sctp header in combined v4 hdr */ 7337c478bd9Sstevel@tonic-gate sctp_hdr_t *sctp_sctph6; /* sctp header in combined v6 hdr */ 7347c478bd9Sstevel@tonic-gate 7357c478bd9Sstevel@tonic-gate uint32_t sctp_lvtag; /* local SCTP instance verf tag */ 7367c478bd9Sstevel@tonic-gate uint32_t sctp_fvtag; /* Peer's SCTP verf tag */ 7377c478bd9Sstevel@tonic-gate 7387c478bd9Sstevel@tonic-gate /* Path MTU Discovery */ 7397c478bd9Sstevel@tonic-gate int64_t sctp_last_mtu_probe; 7407c478bd9Sstevel@tonic-gate clock_t sctp_mtu_probe_intvl; 7417c478bd9Sstevel@tonic-gate uint32_t sctp_mss; /* Max send size (not TCP MSS!) */ 7427c478bd9Sstevel@tonic-gate 7437c478bd9Sstevel@tonic-gate /* structs sctp_bits, sctp_events are for clearing all bits at once */ 7447c478bd9Sstevel@tonic-gate struct { 7457c478bd9Sstevel@tonic-gate uint32_t 7467c478bd9Sstevel@tonic-gate 7477c478bd9Sstevel@tonic-gate sctp_understands_asconf : 1, /* Peer handles ASCONF chunks */ 7487c478bd9Sstevel@tonic-gate sctp_debug : 1, /* SO_DEBUG "socket" option. */ 7497c478bd9Sstevel@tonic-gate sctp_cchunk_pend : 1, /* Control chunk in flight. */ 7507c478bd9Sstevel@tonic-gate sctp_dgram_errind : 1, /* SO_DGRAM_ERRIND option */ 7517c478bd9Sstevel@tonic-gate 7527c478bd9Sstevel@tonic-gate sctp_linger : 1, /* SO_LINGER turned on */ 7537c478bd9Sstevel@tonic-gate sctp_lingering : 1, /* Lingering in close */ 7547c478bd9Sstevel@tonic-gate sctp_loopback: 1, /* src and dst are the same machine */ 7557c478bd9Sstevel@tonic-gate sctp_force_sack : 1, 7567c478bd9Sstevel@tonic-gate 7577c478bd9Sstevel@tonic-gate sctp_ack_timer_running: 1, /* Delayed ACK timer running */ 7587c478bd9Sstevel@tonic-gate sctp_recvdstaddr : 1, /* return T_EXTCONN_IND with dstaddr */ 7597c478bd9Sstevel@tonic-gate sctp_hwcksum : 1, /* The NIC is capable of hwcksum */ 7607c478bd9Sstevel@tonic-gate sctp_understands_addip : 1, 7617c478bd9Sstevel@tonic-gate 7627c478bd9Sstevel@tonic-gate sctp_bound_to_all : 1, 7637c478bd9Sstevel@tonic-gate sctp_cansleep : 1, /* itf routines can sleep */ 7647c478bd9Sstevel@tonic-gate sctp_detached : 1, /* If we're detached from a stream */ 7657c478bd9Sstevel@tonic-gate sctp_send_adaption : 1, /* send adaption layer ind */ 7667c478bd9Sstevel@tonic-gate 7677c478bd9Sstevel@tonic-gate sctp_recv_adaption : 1, /* received adaption layer ind */ 7687c478bd9Sstevel@tonic-gate sctp_ndelay : 1, /* turn off Nagle */ 7697c478bd9Sstevel@tonic-gate sctp_condemned : 1, /* this sctp is about to disappear */ 7707c478bd9Sstevel@tonic-gate sctp_chk_fast_rexmit : 1, /* check for fast rexmit message */ 771f551bb10Svi 772f551bb10Svi sctp_prsctp_aware : 1, /* is peer PR-SCTP aware? */ 77345916cd2Sjpk sctp_linklocal : 1, /* is linklocal assoc. */ 77477c67f2fSkcpoon sctp_rexmitting : 1, /* SCTP is retransmitting */ 775769b977dSvi sctp_zero_win_probe : 1, /* doing zero win probe */ 77677c67f2fSkcpoon 7775d0bc3edSsommerfe sctp_dummy : 8; 7787c478bd9Sstevel@tonic-gate } sctp_bits; 7797c478bd9Sstevel@tonic-gate struct { 7807c478bd9Sstevel@tonic-gate uint32_t 7817c478bd9Sstevel@tonic-gate 7827c478bd9Sstevel@tonic-gate sctp_recvsndrcvinfo : 1, 7837c478bd9Sstevel@tonic-gate sctp_recvassocevnt : 1, 7847c478bd9Sstevel@tonic-gate sctp_recvpathevnt : 1, 7857c478bd9Sstevel@tonic-gate sctp_recvsendfailevnt : 1, 7867c478bd9Sstevel@tonic-gate 7877c478bd9Sstevel@tonic-gate sctp_recvpeererr : 1, 7887c478bd9Sstevel@tonic-gate sctp_recvshutdownevnt : 1, 7897c478bd9Sstevel@tonic-gate sctp_recvpdevnt : 1, 7907c478bd9Sstevel@tonic-gate sctp_recvalevnt : 1; 7917c478bd9Sstevel@tonic-gate } sctp_events; 7927c478bd9Sstevel@tonic-gate #define sctp_priv_stream sctp_bits.sctp_priv_stream 7937c478bd9Sstevel@tonic-gate #define sctp_understands_asconf sctp_bits.sctp_understands_asconf 7947c478bd9Sstevel@tonic-gate #define sctp_debug sctp_bits.sctp_debug 7957c478bd9Sstevel@tonic-gate #define sctp_cchunk_pend sctp_bits.sctp_cchunk_pend 7967c478bd9Sstevel@tonic-gate #define sctp_dgram_errind sctp_bits.sctp_dgram_errind 7977c478bd9Sstevel@tonic-gate #define sctp_linger sctp_bits.sctp_linger 7987c478bd9Sstevel@tonic-gate #define sctp_lingering sctp_bits.sctp_lingering 7997c478bd9Sstevel@tonic-gate #define sctp_loopback sctp_bits.sctp_loopback 8007c478bd9Sstevel@tonic-gate #define sctp_force_sack sctp_bits.sctp_force_sack 8017c478bd9Sstevel@tonic-gate #define sctp_ack_timer_running sctp_bits.sctp_ack_timer_running 8027c478bd9Sstevel@tonic-gate #define sctp_recvdstaddr sctp_bits.sctp_recvdstaddr 8037c478bd9Sstevel@tonic-gate #define sctp_hwcksum sctp_bits.sctp_hwcksum 8047c478bd9Sstevel@tonic-gate #define sctp_understands_addip sctp_bits.sctp_understands_addip 8057c478bd9Sstevel@tonic-gate #define sctp_bound_to_all sctp_bits.sctp_bound_to_all 8067c478bd9Sstevel@tonic-gate #define sctp_cansleep sctp_bits.sctp_cansleep 8077c478bd9Sstevel@tonic-gate #define sctp_detached sctp_bits.sctp_detached 8087c478bd9Sstevel@tonic-gate #define sctp_send_adaption sctp_bits.sctp_send_adaption 8097c478bd9Sstevel@tonic-gate #define sctp_recv_adaption sctp_bits.sctp_recv_adaption 8107c478bd9Sstevel@tonic-gate #define sctp_ndelay sctp_bits.sctp_ndelay 8117c478bd9Sstevel@tonic-gate #define sctp_condemned sctp_bits.sctp_condemned 8127c478bd9Sstevel@tonic-gate #define sctp_chk_fast_rexmit sctp_bits.sctp_chk_fast_rexmit 8137c478bd9Sstevel@tonic-gate #define sctp_prsctp_aware sctp_bits.sctp_prsctp_aware 814f551bb10Svi #define sctp_linklocal sctp_bits.sctp_linklocal 81577c67f2fSkcpoon #define sctp_rexmitting sctp_bits.sctp_rexmitting 816769b977dSvi #define sctp_zero_win_probe sctp_bits.sctp_zero_win_probe 8177c478bd9Sstevel@tonic-gate 8187c478bd9Sstevel@tonic-gate #define sctp_recvsndrcvinfo sctp_events.sctp_recvsndrcvinfo 8197c478bd9Sstevel@tonic-gate #define sctp_recvassocevnt sctp_events.sctp_recvassocevnt 8207c478bd9Sstevel@tonic-gate #define sctp_recvpathevnt sctp_events.sctp_recvpathevnt 8217c478bd9Sstevel@tonic-gate #define sctp_recvsendfailevnt sctp_events.sctp_recvsendfailevnt 8227c478bd9Sstevel@tonic-gate #define sctp_recvpeererr sctp_events.sctp_recvpeererr 8237c478bd9Sstevel@tonic-gate #define sctp_recvshutdownevnt sctp_events.sctp_recvshutdownevnt 8247c478bd9Sstevel@tonic-gate #define sctp_recvpdevnt sctp_events.sctp_recvpdevnt 8257c478bd9Sstevel@tonic-gate #define sctp_recvalevnt sctp_events.sctp_recvalevnt 8267c478bd9Sstevel@tonic-gate 8277c478bd9Sstevel@tonic-gate /* Retransmit info */ 8287c478bd9Sstevel@tonic-gate mblk_t *sctp_cookie_mp; /* cookie chunk, if rxt needed */ 8297c478bd9Sstevel@tonic-gate int32_t sctp_strikes; /* Total number of assoc strikes */ 8307c478bd9Sstevel@tonic-gate int32_t sctp_max_init_rxt; 8317c478bd9Sstevel@tonic-gate int32_t sctp_pa_max_rxt; /* Max per-assoc retransmit cnt */ 8327c478bd9Sstevel@tonic-gate int32_t sctp_pp_max_rxt; /* Max per-path retransmit cnt */ 8337c478bd9Sstevel@tonic-gate uint32_t sctp_rto_max; 8347c478bd9Sstevel@tonic-gate uint32_t sctp_init_rto_max; 8357c478bd9Sstevel@tonic-gate uint32_t sctp_rto_min; 8367c478bd9Sstevel@tonic-gate uint32_t sctp_rto_initial; 8377c478bd9Sstevel@tonic-gate 8387c478bd9Sstevel@tonic-gate int64_t sctp_last_secret_update; 8397c478bd9Sstevel@tonic-gate uint8_t sctp_secret[SCTP_SECRET_LEN]; /* for cookie auth */ 8407c478bd9Sstevel@tonic-gate uint8_t sctp_old_secret[SCTP_SECRET_LEN]; 8417c478bd9Sstevel@tonic-gate uint32_t sctp_cookie_lifetime; /* cookie lifetime in ms */ 8427c478bd9Sstevel@tonic-gate 8437c478bd9Sstevel@tonic-gate /* 8447c478bd9Sstevel@tonic-gate * Address family that app wishes returned addrsses to be in. 8457c478bd9Sstevel@tonic-gate * Currently taken from address family used in T_BIND_REQ, but 8467c478bd9Sstevel@tonic-gate * should really come from family used in original socket() call. 8477c478bd9Sstevel@tonic-gate * Value can be AF_INET or AF_INET6. 8487c478bd9Sstevel@tonic-gate */ 8497c478bd9Sstevel@tonic-gate uint_t sctp_family; 8507c478bd9Sstevel@tonic-gate ushort_t sctp_ipversion; 8517c478bd9Sstevel@tonic-gate 8527c478bd9Sstevel@tonic-gate /* Bind hash tables */ 8537c478bd9Sstevel@tonic-gate kmutex_t *sctp_bind_lockp; /* Ptr to tf_lock */ 8547c478bd9Sstevel@tonic-gate struct sctp_s *sctp_bind_hash; 8557c478bd9Sstevel@tonic-gate struct sctp_s **sctp_ptpbhn; 8567c478bd9Sstevel@tonic-gate 8577c478bd9Sstevel@tonic-gate /* Shutdown / cleanup */ 8587c478bd9Sstevel@tonic-gate sctp_faddr_t *sctp_shutdown_faddr; /* rotate faddr during shutd */ 8597c478bd9Sstevel@tonic-gate int32_t sctp_client_errno; /* How the client screwed up */ 8607c478bd9Sstevel@tonic-gate int sctp_lingertime; /* Close linger time (in seconds) */ 8617c478bd9Sstevel@tonic-gate kmutex_t sctp_reflock; /* Protects sctp_refcnt & timer mp */ 8627c478bd9Sstevel@tonic-gate ushort_t sctp_refcnt; /* No. of pending upstream msg */ 8637c478bd9Sstevel@tonic-gate mblk_t *sctp_timer_mp; /* List of fired timers. */ 8647c478bd9Sstevel@tonic-gate 8657c478bd9Sstevel@tonic-gate /* Misc */ 8667c478bd9Sstevel@tonic-gate uint_t sctp_bound_if; /* IPV6_BOUND_IF */ 8677c478bd9Sstevel@tonic-gate 8687c478bd9Sstevel@tonic-gate mblk_t *sctp_heartbeat_mp; /* Timer block for heartbeats */ 8697c478bd9Sstevel@tonic-gate uint32_t sctp_hb_interval; /* Default hb_interval */ 8707c478bd9Sstevel@tonic-gate 8717c478bd9Sstevel@tonic-gate int32_t sctp_autoclose; /* Auto disconnect in ticks */ 8727c478bd9Sstevel@tonic-gate int64_t sctp_active; /* Last time data/sack on this conn */ 8737c478bd9Sstevel@tonic-gate uint32_t sctp_tx_adaption_code; /* TX adaptation code */ 8747c478bd9Sstevel@tonic-gate uint32_t sctp_rx_adaption_code; /* RX adaptation code */ 8757c478bd9Sstevel@tonic-gate 8767c478bd9Sstevel@tonic-gate /* Reliable control chunks */ 8777c478bd9Sstevel@tonic-gate mblk_t *sctp_cxmit_list; /* Xmit list for control chunks */ 8787c478bd9Sstevel@tonic-gate uint32_t sctp_lcsn; /* Our serial number */ 8797c478bd9Sstevel@tonic-gate uint32_t sctp_fcsn; /* Peer serial number */ 8807c478bd9Sstevel@tonic-gate 8817c478bd9Sstevel@tonic-gate /* Per association receive queue */ 8827c478bd9Sstevel@tonic-gate kmutex_t sctp_recvq_lock; 8837c478bd9Sstevel@tonic-gate mblk_t *sctp_recvq; 8847c478bd9Sstevel@tonic-gate mblk_t *sctp_recvq_tail; 8857c478bd9Sstevel@tonic-gate taskq_t *sctp_recvq_tq; 8867c478bd9Sstevel@tonic-gate 8877c478bd9Sstevel@tonic-gate /* Send queue to IP */ 8887c478bd9Sstevel@tonic-gate kmutex_t sctp_sendq_lock; 8897c478bd9Sstevel@tonic-gate mblk_t *sctp_sendq; 8907c478bd9Sstevel@tonic-gate mblk_t *sctp_sendq_tail; 8917c478bd9Sstevel@tonic-gate boolean_t sctp_sendq_sending; 8927c478bd9Sstevel@tonic-gate 8937c478bd9Sstevel@tonic-gate /* IPv6 ancillary data */ 8947c478bd9Sstevel@tonic-gate uint_t sctp_ipv6_recvancillary; /* flags */ 8957c478bd9Sstevel@tonic-gate #define SCTP_IPV6_RECVPKTINFO 0x01 /* IPV6_RECVPKTINFO opt */ 8967c478bd9Sstevel@tonic-gate #define SCTP_IPV6_RECVHOPLIMIT 0x02 /* IPV6_RECVHOPLIMIT opt */ 8977c478bd9Sstevel@tonic-gate #define SCTP_IPV6_RECVHOPOPTS 0x04 /* IPV6_RECVHOPOPTS opt */ 8987c478bd9Sstevel@tonic-gate #define SCTP_IPV6_RECVDSTOPTS 0x08 /* IPV6_RECVDSTOPTS opt */ 8997c478bd9Sstevel@tonic-gate #define SCTP_IPV6_RECVRTHDR 0x10 /* IPV6_RECVRTHDR opt */ 9007c478bd9Sstevel@tonic-gate #define SCTP_IPV6_RECVRTDSTOPTS 0x20 /* IPV6_RECVRTHDRDSTOPTS opt */ 9017c478bd9Sstevel@tonic-gate 9027c478bd9Sstevel@tonic-gate uint_t sctp_recvifindex; /* last rcvd IPV6_RCVPKTINFO */ 9037c478bd9Sstevel@tonic-gate uint_t sctp_recvhops; /* " IPV6_RECVHOPLIMIT */ 9047c478bd9Sstevel@tonic-gate ip6_hbh_t *sctp_hopopts; /* " IPV6_RECVHOPOPTS */ 9057c478bd9Sstevel@tonic-gate ip6_dest_t *sctp_dstopts; /* " IPV6_RECVDSTOPTS */ 9067c478bd9Sstevel@tonic-gate ip6_dest_t *sctp_rtdstopts; /* " IPV6_RECVRTHDRDSTOPTS */ 9077c478bd9Sstevel@tonic-gate ip6_rthdr_t *sctp_rthdr; /* " IPV6_RECVRTHDR */ 9087c478bd9Sstevel@tonic-gate uint_t sctp_hopoptslen; 9097c478bd9Sstevel@tonic-gate uint_t sctp_dstoptslen; 9107c478bd9Sstevel@tonic-gate uint_t sctp_rtdstoptslen; 9117c478bd9Sstevel@tonic-gate uint_t sctp_rthdrlen; 9127c478bd9Sstevel@tonic-gate 9137c478bd9Sstevel@tonic-gate ip6_pkt_t sctp_sticky_ipp; /* Sticky options */ 9147c478bd9Sstevel@tonic-gate #define sctp_ipp_fields sctp_sticky_ipp.ipp_fields 9157c478bd9Sstevel@tonic-gate #define sctp_ipp_ifindex sctp_sticky_ipp.ipp_ifindex 9167c478bd9Sstevel@tonic-gate #define sctp_ipp_addr sctp_sticky_ipp.ipp_addr 9177c478bd9Sstevel@tonic-gate #define sctp_ipp_hoplimit sctp_sticky_ipp.ipp_hoplimit 9187c478bd9Sstevel@tonic-gate #define sctp_ipp_hopoptslen sctp_sticky_ipp.ipp_hopoptslen 9197c478bd9Sstevel@tonic-gate #define sctp_ipp_rtdstoptslen sctp_sticky_ipp.ipp_rtdstoptslen 9207c478bd9Sstevel@tonic-gate #define sctp_ipp_rthdrlen sctp_sticky_ipp.ipp_rthdrlen 9217c478bd9Sstevel@tonic-gate #define sctp_ipp_dstoptslen sctp_sticky_ipp.ipp_dstoptslen 9227c478bd9Sstevel@tonic-gate #define sctp_ipp_hopopts sctp_sticky_ipp.ipp_hopopts 9237c478bd9Sstevel@tonic-gate #define sctp_ipp_rtdstopts sctp_sticky_ipp.ipp_rtdstopts 9247c478bd9Sstevel@tonic-gate #define sctp_ipp_rthdr sctp_sticky_ipp.ipp_rthdr 9257c478bd9Sstevel@tonic-gate #define sctp_ipp_dstopts sctp_sticky_ipp.ipp_dstopts 926*7f99e6fcSkp #define sctp_ipp_pathmtu sctp_sticky_ipp.ipp_pathmtu 9277c478bd9Sstevel@tonic-gate #define sctp_ipp_nexthop sctp_sticky_ipp.ipp_nexthop 9287c478bd9Sstevel@tonic-gate /* Stats */ 9297c478bd9Sstevel@tonic-gate uint64_t sctp_msgcount; 9307c478bd9Sstevel@tonic-gate uint64_t sctp_prsctpdrop; 93145916cd2Sjpk 93245916cd2Sjpk uint_t sctp_v4label_len; /* length of cached v4 label */ 93345916cd2Sjpk uint_t sctp_v6label_len; /* length of cached v6 label */ 93477c67f2fSkcpoon uint32_t sctp_rxt_nxttsn; /* Next TSN to be rexmitted */ 93577c67f2fSkcpoon uint32_t sctp_rxt_maxtsn; /* Max TSN sent at time out */ 9367c478bd9Sstevel@tonic-gate } sctp_t; 9377c478bd9Sstevel@tonic-gate 9387c478bd9Sstevel@tonic-gate extern list_t sctp_g_list; /* Head of SCTP instance data chain */ 9397c478bd9Sstevel@tonic-gate extern kmutex_t sctp_g_lock; 9407c478bd9Sstevel@tonic-gate 9417c478bd9Sstevel@tonic-gate #endif /* (defined(_KERNEL) || defined(_KMEMUSER)) */ 9427c478bd9Sstevel@tonic-gate 9437c478bd9Sstevel@tonic-gate extern queue_t *sctp_g_q; /* Default queue used during detached closes */ 9447c478bd9Sstevel@tonic-gate extern sctp_t *gsctp; 9457c478bd9Sstevel@tonic-gate 9467c478bd9Sstevel@tonic-gate /* Padding mblk for SCTP chunks. */ 9477c478bd9Sstevel@tonic-gate extern mblk_t *sctp_pad_mp; 9487c478bd9Sstevel@tonic-gate 9497c478bd9Sstevel@tonic-gate extern void sctp_ack_timer(sctp_t *); 9507c478bd9Sstevel@tonic-gate extern size_t sctp_adaption_code_param(sctp_t *, uchar_t *); 9517c478bd9Sstevel@tonic-gate extern void sctp_adaption_event(sctp_t *); 95277c67f2fSkcpoon extern int sctp_add_faddr(sctp_t *, in6_addr_t *, int, boolean_t); 9537c478bd9Sstevel@tonic-gate extern boolean_t sctp_add_ftsn_set(sctp_ftsn_set_t **, sctp_faddr_t *, mblk_t *, 9547c478bd9Sstevel@tonic-gate uint_t *, uint32_t *); 9557c478bd9Sstevel@tonic-gate extern boolean_t sctp_add_recvq(sctp_t *, mblk_t *, boolean_t); 9567c478bd9Sstevel@tonic-gate extern void sctp_add_sendq(sctp_t *, mblk_t *); 9577c478bd9Sstevel@tonic-gate extern void sctp_add_unrec_parm(sctp_parm_hdr_t *, mblk_t **); 9587c478bd9Sstevel@tonic-gate extern size_t sctp_addr_params(sctp_t *, int, uchar_t *); 959f551bb10Svi extern size_t sctp_addr_params_len(sctp_t *, int, boolean_t); 960df19b344Svi extern mblk_t *sctp_add_proto_hdr(sctp_t *, sctp_faddr_t *, mblk_t *, int, 961df19b344Svi int *); 9627c478bd9Sstevel@tonic-gate extern void sctp_addr_req(sctp_t *, mblk_t *); 9637c478bd9Sstevel@tonic-gate extern sctp_t *sctp_addrlist2sctp(mblk_t *, sctp_hdr_t *, sctp_chunk_hdr_t *, 9647c478bd9Sstevel@tonic-gate uint_t, zoneid_t); 9657c478bd9Sstevel@tonic-gate extern void sctp_add_hdr(sctp_t *, uchar_t *, size_t); 9667c478bd9Sstevel@tonic-gate extern void sctp_check_adv_ack_pt(sctp_t *, mblk_t *, mblk_t *); 9677c478bd9Sstevel@tonic-gate extern void sctp_assoc_event(sctp_t *, uint16_t, uint16_t, 9687c478bd9Sstevel@tonic-gate sctp_chunk_hdr_t *); 9697c478bd9Sstevel@tonic-gate 9707c478bd9Sstevel@tonic-gate extern void sctp_bind_hash_insert(sctp_tf_t *, sctp_t *, int); 9717c478bd9Sstevel@tonic-gate extern void sctp_bind_hash_remove(sctp_t *); 97245916cd2Sjpk extern int sctp_bindi(sctp_t *, in_port_t, boolean_t, int, in_port_t *); 9731d8c4025Svi extern int sctp_bind_add(sctp_t *, const void *, uint32_t, boolean_t, 9741d8c4025Svi in_port_t); 9757c478bd9Sstevel@tonic-gate extern int sctp_bind_del(sctp_t *, const void *, uint32_t, boolean_t); 9767c478bd9Sstevel@tonic-gate extern int sctp_build_hdrs(sctp_t *); 9777c478bd9Sstevel@tonic-gate 9787c478bd9Sstevel@tonic-gate extern int sctp_check_abandoned_msg(sctp_t *, mblk_t *); 9797c478bd9Sstevel@tonic-gate extern void sctp_chunkify(sctp_t *, int, int); 9807c478bd9Sstevel@tonic-gate extern void sctp_clean_death(sctp_t *, int); 9817c478bd9Sstevel@tonic-gate extern void sctp_close_eager(sctp_t *); 9827c478bd9Sstevel@tonic-gate extern int sctp_compare_faddrsets(sctp_faddr_t *, sctp_faddr_t *); 9837c478bd9Sstevel@tonic-gate extern void sctp_congest_reset(sctp_t *); 9847c478bd9Sstevel@tonic-gate extern void sctp_conn_hash_insert(sctp_tf_t *, sctp_t *, int); 9857c478bd9Sstevel@tonic-gate extern void sctp_conn_hash_remove(sctp_t *); 9867c478bd9Sstevel@tonic-gate extern sctp_t *sctp_conn_match(in6_addr_t *, in6_addr_t *, uint32_t, uint_t, 9877c478bd9Sstevel@tonic-gate zoneid_t); 9887c478bd9Sstevel@tonic-gate extern sctp_t *sctp_conn_request(sctp_t *, mblk_t *, uint_t, uint_t, 9897c478bd9Sstevel@tonic-gate sctp_init_chunk_t *, mblk_t *); 9907c478bd9Sstevel@tonic-gate extern int sctp_conprim_opt_process(queue_t *, mblk_t *, int *, int *, 9917c478bd9Sstevel@tonic-gate int *); 9927c478bd9Sstevel@tonic-gate extern uint32_t sctp_cumack(sctp_t *, uint32_t, mblk_t **); 9937c478bd9Sstevel@tonic-gate extern sctp_t *sctp_create_eager(sctp_t *); 9947c478bd9Sstevel@tonic-gate 9957c478bd9Sstevel@tonic-gate extern void sctp_dispatch_rput(queue_t *, sctp_t *, sctp_hdr_t *, mblk_t *, 9967c478bd9Sstevel@tonic-gate uint_t, uint_t, in6_addr_t); 9977c478bd9Sstevel@tonic-gate extern char *sctp_display(sctp_t *, char *); 99845916cd2Sjpk extern void sctp_display_all(void); 9997c478bd9Sstevel@tonic-gate 10007c478bd9Sstevel@tonic-gate extern void sctp_error_event(sctp_t *, sctp_chunk_hdr_t *); 10017c478bd9Sstevel@tonic-gate 10027c478bd9Sstevel@tonic-gate extern void sctp_faddr_alive(sctp_t *, sctp_faddr_t *); 10037c478bd9Sstevel@tonic-gate extern int sctp_faddr_dead(sctp_t *, sctp_faddr_t *, int); 100445916cd2Sjpk extern void sctp_faddr_fini(void); 100545916cd2Sjpk extern void sctp_faddr_init(void); 10067c478bd9Sstevel@tonic-gate extern void sctp_fast_rexmit(sctp_t *); 10077c478bd9Sstevel@tonic-gate extern void sctp_fill_sack(sctp_t *, unsigned char *, int); 10087c478bd9Sstevel@tonic-gate extern void sctp_free_faddr_timers(sctp_t *); 10097c478bd9Sstevel@tonic-gate extern void sctp_free_ftsn_set(sctp_ftsn_set_t *); 10107c478bd9Sstevel@tonic-gate extern void sctp_free_msg(mblk_t *); 10117c478bd9Sstevel@tonic-gate extern void sctp_free_reass(sctp_instr_t *); 10127c478bd9Sstevel@tonic-gate extern void sctp_free_set(sctp_set_t *); 10137c478bd9Sstevel@tonic-gate extern void sctp_ftsn_sets_fini(void); 10147c478bd9Sstevel@tonic-gate extern void sctp_ftsn_sets_init(void); 10157c478bd9Sstevel@tonic-gate 10161d8c4025Svi extern int sctp_get_addrlist(sctp_t *, const void *, uint32_t *, 10171d8c4025Svi uchar_t **, int *, size_t *); 10187c478bd9Sstevel@tonic-gate extern int sctp_get_addrparams(sctp_t *, sctp_t *, mblk_t *, 10197c478bd9Sstevel@tonic-gate sctp_chunk_hdr_t *, uint_t *); 102077c67f2fSkcpoon extern void sctp_get_ire(sctp_t *, sctp_faddr_t *); 10211d8c4025Svi extern void sctp_get_faddr_list(sctp_t *, uchar_t *, size_t); 10227c478bd9Sstevel@tonic-gate extern mblk_t *sctp_get_first_sent(sctp_t *); 10237c478bd9Sstevel@tonic-gate extern mblk_t *sctp_get_msg_to_send(sctp_t *, mblk_t **, mblk_t *, int *, 10247c478bd9Sstevel@tonic-gate int32_t, uint32_t, sctp_faddr_t *); 10251d8c4025Svi extern void sctp_get_saddr_list(sctp_t *, uchar_t *, size_t); 10267c478bd9Sstevel@tonic-gate 10277c478bd9Sstevel@tonic-gate extern int sctp_handle_error(sctp_t *, sctp_hdr_t *, sctp_chunk_hdr_t *, 10287c478bd9Sstevel@tonic-gate mblk_t *); 10297c478bd9Sstevel@tonic-gate extern void sctp_hash_destroy(void); 10307c478bd9Sstevel@tonic-gate extern void sctp_hash_init(void); 10317c478bd9Sstevel@tonic-gate extern int sctp_header_init_ipv4(sctp_t *, int); 10327c478bd9Sstevel@tonic-gate extern int sctp_header_init_ipv6(sctp_t *, int); 10337c478bd9Sstevel@tonic-gate extern void sctp_heartbeat_timer(sctp_t *); 10347c478bd9Sstevel@tonic-gate 10357c478bd9Sstevel@tonic-gate extern void sctp_icmp_error(sctp_t *, mblk_t *); 10367c478bd9Sstevel@tonic-gate extern void sctp_inc_taskq(void); 10377c478bd9Sstevel@tonic-gate extern void sctp_info_req(sctp_t *, mblk_t *); 10387c478bd9Sstevel@tonic-gate extern mblk_t *sctp_init_mp(sctp_t *); 10397c478bd9Sstevel@tonic-gate extern boolean_t sctp_initialize_params(sctp_t *, sctp_init_chunk_t *, 10407c478bd9Sstevel@tonic-gate sctp_init_chunk_t *); 10417c478bd9Sstevel@tonic-gate extern uint32_t sctp_init2vtag(sctp_chunk_hdr_t *); 10427c478bd9Sstevel@tonic-gate extern void sctp_intf_event(sctp_t *, in6_addr_t, int, int); 10437c478bd9Sstevel@tonic-gate extern void sctp_input_data(sctp_t *, mblk_t *, mblk_t *); 10447c478bd9Sstevel@tonic-gate extern void sctp_instream_cleanup(sctp_t *, boolean_t); 10457c478bd9Sstevel@tonic-gate extern int sctp_is_a_faddr_clean(sctp_t *); 10467c478bd9Sstevel@tonic-gate 10477c478bd9Sstevel@tonic-gate extern void sctp_kstat_init(void); 10487c478bd9Sstevel@tonic-gate extern void sctp_kstat_fini(void); 10497c478bd9Sstevel@tonic-gate 10507c478bd9Sstevel@tonic-gate extern ssize_t sctp_link_abort(mblk_t *, uint16_t, char *, size_t, int, 10517c478bd9Sstevel@tonic-gate boolean_t); 10527c478bd9Sstevel@tonic-gate extern void sctp_listen_hash_insert(sctp_tf_t *, sctp_t *); 10537c478bd9Sstevel@tonic-gate extern void sctp_listen_hash_remove(sctp_t *); 10547c478bd9Sstevel@tonic-gate extern sctp_t *sctp_lookup(sctp_t *, in6_addr_t *, sctp_tf_t *, uint32_t *, 10557c478bd9Sstevel@tonic-gate int); 10567c478bd9Sstevel@tonic-gate extern sctp_faddr_t *sctp_lookup_faddr(sctp_t *, in6_addr_t *); 10577c478bd9Sstevel@tonic-gate 10587c478bd9Sstevel@tonic-gate extern mblk_t *sctp_make_err(sctp_t *, uint16_t, void *, size_t); 10597c478bd9Sstevel@tonic-gate extern mblk_t *sctp_make_ftsn_chunk(sctp_t *, sctp_faddr_t *, 10607c478bd9Sstevel@tonic-gate sctp_ftsn_set_t *, uint_t, uint32_t); 10617c478bd9Sstevel@tonic-gate extern void sctp_make_ftsns(sctp_t *, mblk_t *, mblk_t *, mblk_t **, 10627c478bd9Sstevel@tonic-gate sctp_faddr_t *, uint32_t *); 10637c478bd9Sstevel@tonic-gate extern mblk_t *sctp_make_mp(sctp_t *, sctp_faddr_t *, int); 10647c478bd9Sstevel@tonic-gate extern mblk_t *sctp_make_sack(sctp_t *, sctp_faddr_t *, mblk_t *); 10657c478bd9Sstevel@tonic-gate extern void sctp_maxpsz_set(sctp_t *); 10667c478bd9Sstevel@tonic-gate extern void sctp_move_faddr_timers(queue_t *, sctp_t *); 10677c478bd9Sstevel@tonic-gate 106845916cd2Sjpk extern void sctp_nd_free(void); 10697c478bd9Sstevel@tonic-gate extern int sctp_nd_getset(queue_t *, MBLKP); 107045916cd2Sjpk extern boolean_t sctp_nd_init(void); 10717c478bd9Sstevel@tonic-gate extern sctp_parm_hdr_t *sctp_next_parm(sctp_parm_hdr_t *, ssize_t *); 10727c478bd9Sstevel@tonic-gate 10737c478bd9Sstevel@tonic-gate extern void sctp_ootb_shutdown_ack(sctp_t *, mblk_t *, uint_t); 10747c478bd9Sstevel@tonic-gate extern size_t sctp_options_param(const sctp_t *, void *, int); 10757c478bd9Sstevel@tonic-gate extern size_t sctp_options_param_len(const sctp_t *, int); 10767c478bd9Sstevel@tonic-gate extern void sctp_output(sctp_t *sctp); 10777c478bd9Sstevel@tonic-gate 10787c478bd9Sstevel@tonic-gate extern boolean_t sctp_param_register(sctpparam_t *, int); 10797c478bd9Sstevel@tonic-gate extern void sctp_partial_delivery_event(sctp_t *); 10807c478bd9Sstevel@tonic-gate extern int sctp_process_cookie(sctp_t *, sctp_chunk_hdr_t *, mblk_t *, 10817c478bd9Sstevel@tonic-gate sctp_init_chunk_t **, sctp_hdr_t *, int *, in6_addr_t *); 10827c478bd9Sstevel@tonic-gate extern void sctp_process_heartbeat(sctp_t *, sctp_chunk_hdr_t *); 10837c478bd9Sstevel@tonic-gate extern void sctp_process_sendq(sctp_t *); 10847c478bd9Sstevel@tonic-gate extern void sctp_process_timer(sctp_t *); 10857c478bd9Sstevel@tonic-gate 10867c478bd9Sstevel@tonic-gate extern void sctp_redo_faddr_srcs(sctp_t *); 10877c478bd9Sstevel@tonic-gate extern void sctp_regift_xmitlist(sctp_t *); 10887c478bd9Sstevel@tonic-gate extern void sctp_return_heartbeat(sctp_t *, sctp_chunk_hdr_t *, mblk_t *); 10897c478bd9Sstevel@tonic-gate extern void sctp_rexmit(sctp_t *, sctp_faddr_t *); 1090769b977dSvi extern mblk_t *sctp_rexmit_packet(sctp_t *, mblk_t **, mblk_t **, 1091769b977dSvi sctp_faddr_t *, uint_t *); 10927c478bd9Sstevel@tonic-gate extern void sctp_rexmit_timer(sctp_t *, sctp_faddr_t *); 10937c478bd9Sstevel@tonic-gate extern sctp_faddr_t *sctp_rotate_faddr(sctp_t *, sctp_faddr_t *); 10947c478bd9Sstevel@tonic-gate 10957c478bd9Sstevel@tonic-gate extern void sctp_sack(sctp_t *, mblk_t *); 10967c478bd9Sstevel@tonic-gate extern int sctp_secure_restart_check(mblk_t *, sctp_chunk_hdr_t *, 10977c478bd9Sstevel@tonic-gate uint32_t, int); 10987c478bd9Sstevel@tonic-gate extern void sctp_send_abort(sctp_t *, uint32_t, uint16_t, char *, size_t, 10997c478bd9Sstevel@tonic-gate mblk_t *, int, boolean_t); 11007c478bd9Sstevel@tonic-gate extern void sctp_send_cookie_ack(sctp_t *); 11017c478bd9Sstevel@tonic-gate extern void sctp_send_cookie_echo(sctp_t *, sctp_chunk_hdr_t *, mblk_t *); 11027c478bd9Sstevel@tonic-gate extern void sctp_send_err(sctp_t *, mblk_t *, sctp_faddr_t *); 11037c478bd9Sstevel@tonic-gate extern void sctp_send_initack(sctp_t *, sctp_chunk_hdr_t *, mblk_t *); 11047c478bd9Sstevel@tonic-gate extern void sctp_send_shutdown(sctp_t *, int); 11057c478bd9Sstevel@tonic-gate extern void sctp_send_heartbeat(sctp_t *, sctp_faddr_t *); 11067c478bd9Sstevel@tonic-gate extern void sctp_sendfail_event(sctp_t *, mblk_t *, int, boolean_t); 110777c67f2fSkcpoon extern void sctp_set_faddr_current(sctp_t *, sctp_faddr_t *); 110877c67f2fSkcpoon extern int sctp_set_hdraddrs(sctp_t *); 1109769b977dSvi extern void sctp_set_saddr(sctp_t *, sctp_faddr_t *); 111045916cd2Sjpk extern void sctp_sets_init(void); 111145916cd2Sjpk extern void sctp_sets_fini(void); 11127c478bd9Sstevel@tonic-gate extern void sctp_shutdown_event(sctp_t *); 11137c478bd9Sstevel@tonic-gate extern void sctp_stop_faddr_timers(sctp_t *); 111477c67f2fSkcpoon extern int sctp_shutdown_received(sctp_t *, sctp_chunk_hdr_t *, boolean_t, 111577c67f2fSkcpoon boolean_t, sctp_faddr_t *); 11167c478bd9Sstevel@tonic-gate extern void sctp_shutdown_complete(sctp_t *); 11177c478bd9Sstevel@tonic-gate extern void sctp_set_if_mtu(sctp_t *); 11187c478bd9Sstevel@tonic-gate extern void sctp_set_iplen(sctp_t *, mblk_t *); 11197c478bd9Sstevel@tonic-gate extern void sctp_set_ulp_prop(sctp_t *); 112077c67f2fSkcpoon extern void sctp_ss_rexmit(sctp_t *); 11217c478bd9Sstevel@tonic-gate extern size_t sctp_supaddr_param_len(sctp_t *); 11227c478bd9Sstevel@tonic-gate extern size_t sctp_supaddr_param(sctp_t *, uchar_t *); 11237c478bd9Sstevel@tonic-gate 11247c478bd9Sstevel@tonic-gate extern void sctp_timer(sctp_t *, mblk_t *, clock_t); 11257c478bd9Sstevel@tonic-gate extern mblk_t *sctp_timer_alloc(sctp_t *, pfv_t); 11267c478bd9Sstevel@tonic-gate extern void sctp_timer_call(sctp_t *sctp, mblk_t *); 11277c478bd9Sstevel@tonic-gate extern void sctp_timer_free(mblk_t *); 11287c478bd9Sstevel@tonic-gate extern void sctp_timer_stop(mblk_t *); 11297c478bd9Sstevel@tonic-gate extern void sctp_unlink_faddr(sctp_t *, sctp_faddr_t *); 11307c478bd9Sstevel@tonic-gate 113177c67f2fSkcpoon extern void sctp_update_ire(sctp_t *sctp); 113245916cd2Sjpk extern in_port_t sctp_update_next_port(in_port_t, zone_t *zone); 11337c478bd9Sstevel@tonic-gate extern void sctp_update_rtt(sctp_t *, sctp_faddr_t *, clock_t); 11347c478bd9Sstevel@tonic-gate extern void sctp_user_abort(sctp_t *, mblk_t *, boolean_t); 11357c478bd9Sstevel@tonic-gate 11367c478bd9Sstevel@tonic-gate extern void sctp_validate_peer(sctp_t *); 11377c478bd9Sstevel@tonic-gate 11387c478bd9Sstevel@tonic-gate extern void sctp_wput_ioctl(queue_t *, mblk_t *); 11397c478bd9Sstevel@tonic-gate 11407c478bd9Sstevel@tonic-gate extern int sctp_xmit_list_clean(sctp_t *, ssize_t); 11417c478bd9Sstevel@tonic-gate 11427c478bd9Sstevel@tonic-gate extern void sctp_zap_addrs(sctp_t *); 11437c478bd9Sstevel@tonic-gate extern void sctp_zap_faddrs(sctp_t *, int); 11447c478bd9Sstevel@tonic-gate 11451d8c4025Svi /* Contract private interface between SCTP and Clustering - PSARC/2005/602 */ 11461d8c4025Svi 11471d8c4025Svi extern void (*cl_sctp_listen)(sa_family_t, uchar_t *, uint_t, in_port_t); 11481d8c4025Svi extern void (*cl_sctp_unlisten)(sa_family_t, uchar_t *, uint_t, in_port_t); 11491d8c4025Svi extern void (*cl_sctp_connect)(sa_family_t, uchar_t *, uint_t, in_port_t, 11501d8c4025Svi uchar_t *, uint_t, in_port_t, boolean_t, cl_sctp_handle_t); 11511d8c4025Svi extern void (*cl_sctp_disconnect)(sa_family_t, cl_sctp_handle_t); 11521d8c4025Svi extern void (*cl_sctp_assoc_change)(sa_family_t, uchar_t *, size_t, uint_t, 11531d8c4025Svi uchar_t *, size_t, uint_t, int, cl_sctp_handle_t); 11541d8c4025Svi extern void (*cl_sctp_check_addrs)(sa_family_t, in_port_t, uchar_t **, 11551d8c4025Svi size_t, uint_t *, boolean_t); 11561d8c4025Svi 11577c478bd9Sstevel@tonic-gate /* Send a mp to IP. */ 11587c478bd9Sstevel@tonic-gate #define IP_PUT(mp, conn, isv4) \ 11597c478bd9Sstevel@tonic-gate { \ 11607c478bd9Sstevel@tonic-gate if ((isv4)) \ 11617c478bd9Sstevel@tonic-gate ip_output((conn), (mp), WR(sctp_g_q), IP_WPUT); \ 11627c478bd9Sstevel@tonic-gate else \ 11637c478bd9Sstevel@tonic-gate ip_output_v6((conn), (mp), WR(sctp_g_q), IP_WPUT); \ 11647c478bd9Sstevel@tonic-gate } 11657c478bd9Sstevel@tonic-gate 11667c478bd9Sstevel@tonic-gate #define RUN_SCTP(sctp) \ 11677c478bd9Sstevel@tonic-gate { \ 11687c478bd9Sstevel@tonic-gate mutex_enter(&(sctp)->sctp_lock); \ 11697c478bd9Sstevel@tonic-gate while ((sctp)->sctp_running) \ 11707c478bd9Sstevel@tonic-gate cv_wait(&(sctp)->sctp_cv, &(sctp)->sctp_lock); \ 11717c478bd9Sstevel@tonic-gate (sctp)->sctp_running = B_TRUE; \ 11727c478bd9Sstevel@tonic-gate mutex_exit(&(sctp)->sctp_lock); \ 11737c478bd9Sstevel@tonic-gate } 11747c478bd9Sstevel@tonic-gate 11757c478bd9Sstevel@tonic-gate /* Wake up recvq taskq */ 11767c478bd9Sstevel@tonic-gate #define WAKE_SCTP(sctp) \ 11777c478bd9Sstevel@tonic-gate { \ 11787c478bd9Sstevel@tonic-gate mutex_enter(&(sctp)->sctp_lock); \ 11797c478bd9Sstevel@tonic-gate if ((sctp)->sctp_timer_mp != NULL) \ 11807c478bd9Sstevel@tonic-gate sctp_process_timer(sctp); \ 11817c478bd9Sstevel@tonic-gate (sctp)->sctp_running = B_FALSE; \ 11827c478bd9Sstevel@tonic-gate cv_broadcast(&(sctp)->sctp_cv); \ 11837c478bd9Sstevel@tonic-gate mutex_exit(&(sctp)->sctp_lock); \ 11847c478bd9Sstevel@tonic-gate } 11857c478bd9Sstevel@tonic-gate 11867c478bd9Sstevel@tonic-gate #ifdef __cplusplus 11877c478bd9Sstevel@tonic-gate } 11887c478bd9Sstevel@tonic-gate #endif 11897c478bd9Sstevel@tonic-gate 11907c478bd9Sstevel@tonic-gate #endif /* _INET_SCTP_SCTP_IMPL_H */ 1191