1163953Srrs/*- 2185694Srrs * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. 3235828Stuexen * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 4235828Stuexen * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 5163953Srrs * 6163953Srrs * Redistribution and use in source and binary forms, with or without 7163953Srrs * modification, are permitted provided that the following conditions are met: 8163953Srrs * 9163953Srrs * a) Redistributions of source code must retain the above copyright notice, 10228653Stuexen * this list of conditions and the following disclaimer. 11163953Srrs * 12163953Srrs * b) Redistributions in binary form must reproduce the above copyright 13163953Srrs * notice, this list of conditions and the following disclaimer in 14228653Stuexen * the documentation and/or other materials provided with the distribution. 15163953Srrs * 16163953Srrs * c) Neither the name of Cisco Systems, Inc. nor the names of its 17163953Srrs * contributors may be used to endorse or promote products derived 18163953Srrs * from this software without specific prior written permission. 19163953Srrs * 20163953Srrs * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21163953Srrs * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22163953Srrs * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23163953Srrs * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24163953Srrs * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25163953Srrs * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26163953Srrs * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27163953Srrs * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28163953Srrs * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29163953Srrs * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30163953Srrs * THE POSSIBILITY OF SUCH DAMAGE. 31163953Srrs */ 32163953Srrs 33163953Srrs#include <sys/cdefs.h> 34163953Srrs__FBSDID("$FreeBSD: stable/11/sys/netinet/sctp_structs.h 364651 2020-08-24 09:46:36Z tuexen $"); 35163953Srrs 36235828Stuexen#ifndef _NETINET_SCTP_STRUCTS_H_ 37235828Stuexen#define _NETINET_SCTP_STRUCTS_H_ 38163953Srrs 39165647Srrs#include <netinet/sctp_os.h> 40163953Srrs#include <netinet/sctp_header.h> 41163953Srrs#include <netinet/sctp_auth.h> 42163953Srrs 43163953Srrsstruct sctp_timer { 44165647Srrs sctp_os_timer_t timer; 45165647Srrs 46163953Srrs int type; 47163953Srrs /* 48163953Srrs * Depending on the timer type these will be setup and cast with the 49163953Srrs * appropriate entity. 50163953Srrs */ 51163953Srrs void *ep; 52163953Srrs void *tcb; 53163953Srrs void *net; 54197326Stuexen void *vnet; 55163953Srrs 56163953Srrs /* for sanity checking */ 57163953Srrs void *self; 58163953Srrs uint32_t ticks; 59165220Srrs uint32_t stopped_from; 60163953Srrs}; 61163953Srrs 62163953Srrs 63165220Srrsstruct sctp_foo_stuff { 64165220Srrs struct sctp_inpcb *inp; 65165220Srrs uint32_t lineno; 66165220Srrs uint32_t ticks; 67165220Srrs int updown; 68165220Srrs}; 69163953Srrs 70165220Srrs 71163953Srrs/* 72163953Srrs * This is the information we track on each interface that we know about from 73163953Srrs * the distant end. 74163953Srrs */ 75163953SrrsTAILQ_HEAD(sctpnetlisthead, sctp_nets); 76163953Srrs 77163953Srrsstruct sctp_stream_reset_list { 78163953Srrs TAILQ_ENTRY(sctp_stream_reset_list) next_resp; 79285792Srrs uint32_t seq; 80163953Srrs uint32_t tsn; 81240198Stuexen uint32_t number_entries; 82240198Stuexen uint16_t list_of_streams[]; 83163953Srrs}; 84163953Srrs 85163953SrrsTAILQ_HEAD(sctp_resethead, sctp_stream_reset_list); 86163953Srrs 87163953Srrs/* 88163953Srrs * Users of the iterator need to malloc a iterator with a call to 89167598Srrs * sctp_initiate_iterator(inp_func, assoc_func, inp_func, pcb_flags, pcb_features, 90163953Srrs * asoc_state, void-ptr-arg, uint32-arg, end_func, inp); 91163953Srrs * 92163953Srrs * Use the following two defines if you don't care what pcb flags are on the EP 93163953Srrs * and/or you don't care what state the association is in. 94163953Srrs * 95163953Srrs * Note that if you specify an INP as the last argument then ONLY each 96163953Srrs * association of that single INP will be executed upon. Note that the pcb 97163953Srrs * flags STILL apply so if the inp you specify has different pcb_flags then 98163953Srrs * what you put in pcb_flags nothing will happen. use SCTP_PCB_ANY_FLAGS to 99163953Srrs * assure the inp you specify gets treated. 100163953Srrs */ 101163953Srrs#define SCTP_PCB_ANY_FLAGS 0x00000000 102163953Srrs#define SCTP_PCB_ANY_FEATURES 0x00000000 103163953Srrs#define SCTP_ASOC_ANY_STATE 0x00000000 104163953Srrs 105163953Srrstypedef void (*asoc_func) (struct sctp_inpcb *, struct sctp_tcb *, void *ptr, 106347154Stuexen uint32_t val); 107167598Srrstypedef int (*inp_func) (struct sctp_inpcb *, void *ptr, uint32_t val); 108163953Srrstypedef void (*end_func) (void *ptr, uint32_t val); 109163953Srrs 110218211Srrs#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP) 111218211Srrs/* whats on the mcore control struct */ 112218211Srrsstruct sctp_mcore_queue { 113218211Srrs TAILQ_ENTRY(sctp_mcore_queue) next; 114218211Srrs struct vnet *vn; 115218211Srrs struct mbuf *m; 116218211Srrs int off; 117218211Srrs int v6; 118218211Srrs}; 119218211Srrs 120218211SrrsTAILQ_HEAD(sctp_mcore_qhead, sctp_mcore_queue); 121218211Srrs 122218211Srrsstruct sctp_mcore_ctrl { 123218211Srrs SCTP_PROCESS_STRUCT thread_proc; 124218211Srrs struct sctp_mcore_qhead que; 125218211Srrs struct mtx core_mtx; 126218211Srrs struct mtx que_mtx; 127218211Srrs int running; 128218211Srrs int cpuid; 129218211Srrs}; 130218211Srrs 131218211Srrs 132218211Srrs#endif 133218211Srrs 134218211Srrs 135163953Srrsstruct sctp_iterator { 136167598Srrs TAILQ_ENTRY(sctp_iterator) sctp_nxt_itr; 137208160Srrs struct vnet *vn; 138163953Srrs struct sctp_timer tmr; 139163953Srrs struct sctp_inpcb *inp; /* current endpoint */ 140163953Srrs struct sctp_tcb *stcb; /* current* assoc */ 141208160Srrs struct sctp_inpcb *next_inp; /* special hook to skip to */ 142163953Srrs asoc_func function_assoc; /* per assoc function */ 143163953Srrs inp_func function_inp; /* per endpoint function */ 144167598Srrs inp_func function_inp_end; /* end INP function */ 145347154Stuexen end_func function_atend; /* iterator completion function */ 146163953Srrs void *pointer; /* pointer for apply func to use */ 147163953Srrs uint32_t val; /* value for apply func to use */ 148163953Srrs uint32_t pcb_flags; /* endpoint flags being checked */ 149163953Srrs uint32_t pcb_features; /* endpoint features being checked */ 150163953Srrs uint32_t asoc_state; /* assoc state being checked */ 151163953Srrs uint32_t iterator_flags; 152163953Srrs uint8_t no_chunk_output; 153167598Srrs uint8_t done_current_ep; 154163953Srrs}; 155163953Srrs 156163953Srrs/* iterator_flags values */ 157163953Srrs#define SCTP_ITERATOR_DO_ALL_INP 0x00000001 158163953Srrs#define SCTP_ITERATOR_DO_SINGLE_INP 0x00000002 159163953Srrs 160208160Srrs 161167598SrrsTAILQ_HEAD(sctpiterators, sctp_iterator); 162163953Srrs 163163953Srrsstruct sctp_copy_all { 164163953Srrs struct sctp_inpcb *inp; /* ep */ 165163953Srrs struct mbuf *m; 166163953Srrs struct sctp_sndrcvinfo sndrcv; 167347676Stuexen ssize_t sndlen; 168163953Srrs int cnt_sent; 169163953Srrs int cnt_failed; 170163953Srrs}; 171163953Srrs 172167598Srrsstruct sctp_asconf_iterator { 173167598Srrs struct sctpladdr list_of_work; 174167598Srrs int cnt; 175167598Srrs}; 176167598Srrs 177208160Srrsstruct iterator_control { 178208160Srrs struct mtx ipi_iterator_wq_mtx; 179208160Srrs struct mtx it_mtx; 180208160Srrs SCTP_PROCESS_STRUCT thread_proc; 181208160Srrs struct sctpiterators iteratorhead; 182208160Srrs struct sctp_iterator *cur_it; 183208160Srrs uint32_t iterator_running; 184208160Srrs uint32_t iterator_flags; 185208160Srrs}; 186225676Stuexen#define SCTP_ITERATOR_STOP_CUR_IT 0x00000004 187225676Stuexen#define SCTP_ITERATOR_STOP_CUR_INP 0x00000008 188208160Srrs 189169352Srrsstruct sctp_net_route { 190169352Srrs sctp_rtentry_t *ro_rt; 191301246Stuexen struct llentry *ro_lle; 192293176Stuexen char *ro_prepend; 193293176Stuexen uint16_t ro_plen; 194293176Stuexen uint16_t ro_flags; 195293176Stuexen uint16_t ro_mtu; 196293176Stuexen uint16_t spare; 197169352Srrs union sctp_sockstore _l_addr; /* remote peer addr */ 198169352Srrs struct sctp_ifa *_s_addr; /* our selected src addr */ 199169352Srrs}; 200169352Srrs 201171440Srrsstruct htcp { 202171440Srrs uint16_t alpha; /* Fixed point arith, << 7 */ 203171440Srrs uint8_t beta; /* Fixed point arith, << 7 */ 204171440Srrs uint8_t modeswitch; /* Delay modeswitch until we had at least one 205171440Srrs * congestion event */ 206171440Srrs uint32_t last_cong; /* Time since last congestion event end */ 207171440Srrs uint32_t undo_last_cong; 208171440Srrs uint16_t bytes_acked; 209171440Srrs uint32_t bytecount; 210171440Srrs uint32_t minRTT; 211171440Srrs uint32_t maxRTT; 212171440Srrs 213171440Srrs uint32_t undo_maxRTT; 214171440Srrs uint32_t undo_old_maxB; 215171440Srrs 216171440Srrs /* Bandwidth estimation */ 217171440Srrs uint32_t minB; 218171440Srrs uint32_t maxB; 219171440Srrs uint32_t old_maxB; 220171440Srrs uint32_t Bi; 221171440Srrs uint32_t lasttime; 222171440Srrs}; 223171440Srrs 224219120Srrsstruct rtcc_cc { 225219120Srrs struct timeval tls; /* The time we started the sending */ 226219120Srrs uint64_t lbw; /* Our last estimated bw */ 227219120Srrs uint64_t lbw_rtt; /* RTT at bw estimate */ 228219120Srrs uint64_t bw_bytes; /* The total bytes since this sending began */ 229219120Srrs uint64_t bw_tot_time; /* The total time since sending began */ 230219120Srrs uint64_t new_tot_time; /* temp holding the new value */ 231219397Srrs uint64_t bw_bytes_at_last_rttc; /* What bw_bytes was at last rtt calc */ 232347154Stuexen uint32_t cwnd_at_bw_set; /* Cwnd at last bw saved - lbw */ 233219397Srrs uint32_t vol_reduce; /* cnt of voluntary reductions */ 234219397Srrs uint16_t steady_step; /* The number required to be in steady state */ 235219397Srrs uint16_t step_cnt; /* The current number */ 236219397Srrs uint8_t ret_from_eq; /* When all things are equal what do I return 237219397Srrs * 0/1 - 1 no cc advance */ 238219397Srrs uint8_t use_dccc_ecn; /* Flag to enable DCCC ECN */ 239219120Srrs uint8_t tls_needs_set; /* Flag to indicate we need to set tls 0 or 1 240219120Srrs * means set at send 2 not */ 241347154Stuexen uint8_t last_step_state; /* Last state if steady state stepdown 242347154Stuexen * is on */ 243219397Srrs uint8_t rtt_set_this_sack; /* Flag saying this sack had RTT calc 244219397Srrs * on it */ 245219397Srrs uint8_t last_inst_ind; /* Last saved inst indication */ 246219120Srrs}; 247219120Srrs 248219120Srrs 249163953Srrsstruct sctp_nets { 250163953Srrs TAILQ_ENTRY(sctp_nets) sctp_next; /* next link */ 251163953Srrs 252163953Srrs /* 253163953Srrs * Things on the top half may be able to be split into a common 254163953Srrs * structure shared by all. 255163953Srrs */ 256163953Srrs struct sctp_timer pmtu_timer; 257224641Stuexen struct sctp_timer hb_timer; 258163953Srrs 259163953Srrs /* 260163953Srrs * The following two in combination equate to a route entry for v6 261163953Srrs * or v4. 262163953Srrs */ 263169352Srrs struct sctp_net_route ro; 264169352Srrs 265163953Srrs /* mtu discovered so far */ 266163953Srrs uint32_t mtu; 267163953Srrs uint32_t ssthresh; /* not sure about this one for split */ 268218072Srrs uint32_t last_cwr_tsn; 269218072Srrs uint32_t cwr_window_tsn; 270218072Srrs uint32_t ecn_ce_pkt_cnt; 271218072Srrs uint32_t lost_cnt; 272163953Srrs /* smoothed average things for RTT and RTO itself */ 273163953Srrs int lastsa; 274163953Srrs int lastsv; 275219013Stuexen uint64_t rtt; /* last measured rtt value in us */ 276163953Srrs unsigned int RTO; 277163953Srrs 278163953Srrs /* This is used for SHUTDOWN/SHUTDOWN-ACK/SEND or INIT timers */ 279163953Srrs struct sctp_timer rxt_timer; 280163953Srrs 281163953Srrs /* last time in seconds I sent to it */ 282163953Srrs struct timeval last_sent_time; 283219057Srrs union cc_control_data { 284219057Srrs struct htcp htcp_ca; /* JRS - struct used in HTCP algorithm */ 285219120Srrs struct rtcc_cc rtcc; /* rtcc module cc stuff */ 286219057Srrs } cc_mod; 287163953Srrs int ref_count; 288163953Srrs 289163953Srrs /* Congestion stats per destination */ 290163953Srrs /* 291163953Srrs * flight size variables and such, sorry Vern, I could not avoid 292163953Srrs * this if I wanted performance :> 293163953Srrs */ 294163953Srrs uint32_t flight_size; 295163953Srrs uint32_t cwnd; /* actual cwnd */ 296163953Srrs uint32_t prev_cwnd; /* cwnd before any processing */ 297218186Srrs uint32_t ecn_prev_cwnd; /* ECN prev cwnd at first ecn_echo seen in new 298218186Srrs * window */ 299163953Srrs uint32_t partial_bytes_acked; /* in CA tracks when to incr a MTU */ 300163953Srrs /* tracking variables to avoid the aloc/free in sack processing */ 301163953Srrs unsigned int net_ack; 302163953Srrs unsigned int net_ack2; 303163953Srrs 304163953Srrs /* 305171440Srrs * JRS - 5/8/07 - Variable to track last time a destination was 306171440Srrs * active for CMT PF 307171440Srrs */ 308171440Srrs uint32_t last_active; 309171440Srrs 310171440Srrs /* 311163953Srrs * CMT variables (iyengar@cis.udel.edu) 312163953Srrs */ 313163953Srrs uint32_t this_sack_highest_newack; /* tracks highest TSN newly 314163953Srrs * acked for a given dest in 315163953Srrs * the current SACK. Used in 316163953Srrs * SFR and HTNA algos */ 317163953Srrs uint32_t pseudo_cumack; /* CMT CUC algorithm. Maintains next expected 318163953Srrs * pseudo-cumack for this destination */ 319163953Srrs uint32_t rtx_pseudo_cumack; /* CMT CUC algorithm. Maintains next 320163953Srrs * expected pseudo-cumack for this 321163953Srrs * destination */ 322163953Srrs 323163953Srrs /* CMT fast recovery variables */ 324163953Srrs uint32_t fast_recovery_tsn; 325163953Srrs uint32_t heartbeat_random1; 326163953Srrs uint32_t heartbeat_random2; 327225549Stuexen#ifdef INET6 328224870Stuexen uint32_t flowlabel; 329225549Stuexen#endif 330224870Stuexen uint8_t dscp; 331163953Srrs 332168124Srrs struct timeval start_time; /* time when this net was created */ 333347154Stuexen uint32_t marked_retrans; /* number or DATA chunks marked for 334347154Stuexen * timer based retransmissions */ 335168124Srrs uint32_t marked_fastretrans; 336224641Stuexen uint32_t heart_beat_delay; /* Heart Beat delay in ms */ 337168124Srrs 338163953Srrs /* if this guy is ok or not ... status */ 339163953Srrs uint16_t dest_state; 340224641Stuexen /* number of timeouts to consider the destination unreachable */ 341163953Srrs uint16_t failure_threshold; 342224641Stuexen /* number of timeouts to consider the destination potentially failed */ 343224641Stuexen uint16_t pf_threshold; 344224641Stuexen /* error stats on the destination */ 345163953Srrs uint16_t error_count; 346179157Srrs /* UDP port number in case of UDP tunneling */ 347179157Srrs uint16_t port; 348163953Srrs 349163953Srrs uint8_t fast_retran_loss_recovery; 350163953Srrs uint8_t will_exit_fast_recovery; 351163953Srrs /* Flags that probably can be combined into dest_state */ 352163953Srrs uint8_t fast_retran_ip; /* fast retransmit in progress */ 353163953Srrs uint8_t hb_responded; 354163953Srrs uint8_t saw_newack; /* CMT's SFR algorithm flag */ 355163953Srrs uint8_t src_addr_selected; /* if we split we move */ 356163953Srrs uint8_t indx_of_eligible_next_to_use; 357163953Srrs uint8_t addr_is_local; /* its a local address (if known) could move 358163953Srrs * in split */ 359163953Srrs 360163953Srrs /* 361163953Srrs * CMT variables (iyengar@cis.udel.edu) 362163953Srrs */ 363163953Srrs uint8_t find_pseudo_cumack; /* CMT CUC algorithm. Flag used to 364163953Srrs * find a new pseudocumack. This flag 365163953Srrs * is set after a new pseudo-cumack 366163953Srrs * has been received and indicates 367163953Srrs * that the sender should find the 368163953Srrs * next pseudo-cumack expected for 369163953Srrs * this destination */ 370163953Srrs uint8_t find_rtx_pseudo_cumack; /* CMT CUCv2 algorithm. Flag used to 371163953Srrs * find a new rtx-pseudocumack. This 372163953Srrs * flag is set after a new 373163953Srrs * rtx-pseudo-cumack has been received 374163953Srrs * and indicates that the sender 375163953Srrs * should find the next 376163953Srrs * rtx-pseudo-cumack expected for this 377163953Srrs * destination */ 378163953Srrs uint8_t new_pseudo_cumack; /* CMT CUC algorithm. Flag used to 379163953Srrs * indicate if a new pseudo-cumack or 380163953Srrs * rtx-pseudo-cumack has been received */ 381168124Srrs uint8_t window_probe; /* Doing a window probe? */ 382170642Srrs uint8_t RTO_measured; /* Have we done the first measure */ 383163953Srrs uint8_t last_hs_used; /* index into the last HS table entry we used */ 384218186Srrs uint8_t lan_type; 385219397Srrs uint8_t rto_needed; 386218335Stuexen uint32_t flowid; 387275483Stuexen uint8_t flowtype; 388163953Srrs}; 389163953Srrs 390163953Srrs 391163953Srrsstruct sctp_data_chunkrec { 392310219Stuexen uint32_t tsn; /* the TSN of this transmit */ 393310219Stuexen uint32_t mid; /* the message identifier of this transmit */ 394310219Stuexen uint16_t sid; /* the stream number of this guy */ 395310219Stuexen uint32_t ppid; 396163953Srrs uint32_t context; /* from send */ 397218186Srrs uint32_t cwnd_at_send; 398163953Srrs /* 399163953Srrs * part of the Highest sacked algorithm to be able to stroke counts 400163953Srrs * on ones that are FR'd. 401163953Srrs */ 402163953Srrs uint32_t fast_retran_tsn; /* sending_seq at the time of FR */ 403163953Srrs struct timeval timetodrop; /* time we drop it from queue */ 404310219Stuexen uint32_t fsn; /* Fragment Sequence Number */ 405163953Srrs uint8_t doing_fast_retransmit; 406163953Srrs uint8_t rcv_flags; /* flags pulled from data chunk on inbound for 407165220Srrs * outbound holds sending flags for PR-SCTP. */ 408163953Srrs uint8_t state_flags; 409163953Srrs uint8_t chunk_was_revoked; 410218186Srrs uint8_t fwd_tsn_cnt; 411163953Srrs}; 412163953Srrs 413163953SrrsTAILQ_HEAD(sctpchunk_listhead, sctp_tmit_chunk); 414163953Srrs 415163953Srrs/* The lower byte is used to enumerate PR_SCTP policies */ 416163953Srrs#define CHUNK_FLAGS_PR_SCTP_TTL SCTP_PR_SCTP_TTL 417163953Srrs#define CHUNK_FLAGS_PR_SCTP_BUF SCTP_PR_SCTP_BUF 418163953Srrs#define CHUNK_FLAGS_PR_SCTP_RTX SCTP_PR_SCTP_RTX 419163953Srrs 420231074Stuexen/* The upper byte is used as a bit mask */ 421163953Srrs#define CHUNK_FLAGS_FRAGMENT_OK 0x0100 422163953Srrs 423163953Srrsstruct chk_id { 424271643Stuexen uint8_t id; 425271643Stuexen uint8_t can_take_data; 426163953Srrs}; 427163953Srrs 428163953Srrs 429163953Srrsstruct sctp_tmit_chunk { 430163953Srrs union { 431163953Srrs struct sctp_data_chunkrec data; 432163953Srrs struct chk_id chunk_id; 433163953Srrs } rec; 434163953Srrs struct sctp_association *asoc; /* bp to asoc this belongs to */ 435163953Srrs struct timeval sent_rcv_time; /* filled in if RTT being calculated */ 436163953Srrs struct mbuf *data; /* pointer to mbuf chain of data */ 437163953Srrs struct mbuf *last_mbuf; /* pointer to last mbuf in chain */ 438163953Srrs struct sctp_nets *whoTo; 439163953Srrs TAILQ_ENTRY(sctp_tmit_chunk) sctp_next; /* next link */ 440163953Srrs int32_t sent; /* the send status */ 441163953Srrs uint16_t snd_count; /* number of times I sent */ 442163953Srrs uint16_t flags; /* flags, such as FRAGMENT_OK */ 443163953Srrs uint16_t send_size; 444163953Srrs uint16_t book_size; 445163953Srrs uint16_t mbcnt; 446185694Srrs uint16_t auth_keyid; 447185694Srrs uint8_t holds_key_ref; /* flag if auth keyid refcount is held */ 448163953Srrs uint8_t pad_inplace; 449163953Srrs uint8_t do_rtt; 450163953Srrs uint8_t book_size_scale; 451163953Srrs uint8_t no_fr_allowed; 452163953Srrs uint8_t copy_by_ref; 453168124Srrs uint8_t window_probe; 454163953Srrs}; 455163953Srrs 456163953Srrsstruct sctp_queued_to_read { /* sinfo structure Pluse more */ 457163953Srrs uint16_t sinfo_stream; /* off the wire */ 458163953Srrs uint16_t sinfo_flags; /* SCTP_UNORDERED from wire use SCTP_EOF for 459163953Srrs * EOR */ 460163953Srrs uint32_t sinfo_ppid; /* off the wire */ 461163953Srrs uint32_t sinfo_context; /* pick this up from assoc def context? */ 462163953Srrs uint32_t sinfo_timetolive; /* not used by kernel */ 463163953Srrs uint32_t sinfo_tsn; /* Use this in reassembly as first TSN */ 464163953Srrs uint32_t sinfo_cumtsn; /* Use this in reassembly as last TSN */ 465163953Srrs sctp_assoc_t sinfo_assoc_id; /* our assoc id */ 466163953Srrs /* Non sinfo stuff */ 467310219Stuexen uint32_t mid; /* Fragment Index */ 468163953Srrs uint32_t length; /* length of data */ 469163953Srrs uint32_t held_length; /* length held in sb */ 470297662Srrs uint32_t top_fsn; /* Highest FSN in queue */ 471297662Srrs uint32_t fsn_included; /* Highest FSN in *data portion */ 472163953Srrs struct sctp_nets *whoFrom; /* where it came from */ 473163953Srrs struct mbuf *data; /* front of the mbuf chain of data with 474163953Srrs * PKT_HDR */ 475163953Srrs struct mbuf *tail_mbuf; /* used for multi-part data */ 476169352Srrs struct mbuf *aux_data; /* used to hold/cache control if o/s does not 477169352Srrs * take it from us */ 478163953Srrs struct sctp_tcb *stcb; /* assoc, used for window update */ 479163953Srrs TAILQ_ENTRY(sctp_queued_to_read) next; 480297662Srrs TAILQ_ENTRY(sctp_queued_to_read) next_instrm; 481297662Srrs struct sctpchunk_listhead reasm; 482163953Srrs uint16_t port_from; 483165647Srrs uint16_t spec_flags; /* Flags to hold the notification field */ 484163953Srrs uint8_t do_not_ref_stcb; 485163953Srrs uint8_t end_added; 486164085Srrs uint8_t pdapi_aborted; 487297662Srrs uint8_t pdapi_started; 488168943Srrs uint8_t some_taken; 489297662Srrs uint8_t last_frag_seen; 490297662Srrs uint8_t first_frag_seen; 491297662Srrs uint8_t on_read_q; 492297662Srrs uint8_t on_strm_q; 493163953Srrs}; 494163953Srrs 495297662Srrs#define SCTP_ON_ORDERED 1 496297662Srrs#define SCTP_ON_UNORDERED 2 497297662Srrs 498163953Srrs/* This data structure will be on the outbound 499163953Srrs * stream queues. Data will be pulled off from 500163953Srrs * the front of the mbuf data and chunk-ified 501163953Srrs * by the output routines. We will custom 502163953Srrs * fit every chunk we pull to the send/sent 503163953Srrs * queue to make up the next full packet 504163953Srrs * if we can. An entry cannot be removed 505163953Srrs * from the stream_out queue until 506163953Srrs * the msg_is_complete flag is set. This 507163953Srrs * means at times data/tail_mbuf MIGHT 508163953Srrs * be NULL.. If that occurs it happens 509163953Srrs * for one of two reasons. Either the user 510163953Srrs * is blocked on a send() call and has not 511163953Srrs * awoken to copy more data down... OR 512163953Srrs * the user is in the explict MSG_EOR mode 513163953Srrs * and wrote some data, but has not completed 514163953Srrs * sending. 515163953Srrs */ 516163953Srrsstruct sctp_stream_queue_pending { 517163953Srrs struct mbuf *data; 518163953Srrs struct mbuf *tail_mbuf; 519163953Srrs struct timeval ts; 520163953Srrs struct sctp_nets *net; 521163953Srrs TAILQ_ENTRY(sctp_stream_queue_pending) next; 522218241Stuexen TAILQ_ENTRY(sctp_stream_queue_pending) ss_next; 523297662Srrs uint32_t fsn; 524163953Srrs uint32_t length; 525163953Srrs uint32_t timetolive; 526163953Srrs uint32_t ppid; 527163953Srrs uint32_t context; 528163953Srrs uint16_t sinfo_flags; 529310219Stuexen uint16_t sid; 530165220Srrs uint16_t act_flags; 531185694Srrs uint16_t auth_keyid; 532185694Srrs uint8_t holds_key_ref; 533163953Srrs uint8_t msg_is_complete; 534163953Srrs uint8_t some_taken; 535168755Srrs uint8_t sender_all_done; 536168859Srrs uint8_t put_last_out; 537189836Srrs uint8_t discard_rest; 538364651Stuexen uint8_t processing; 539163953Srrs}; 540163953Srrs 541163953Srrs/* 542163953Srrs * this struct contains info that is used to track inbound stream data and 543163953Srrs * help with ordering. 544163953Srrs */ 545163953SrrsTAILQ_HEAD(sctpwheelunrel_listhead, sctp_stream_in); 546163953Srrsstruct sctp_stream_in { 547163953Srrs struct sctp_readhead inqueue; 548297662Srrs struct sctp_readhead uno_inqueue; 549310219Stuexen uint32_t last_mid_delivered; /* used for re-order */ 550310219Stuexen uint16_t sid; 551168943Srrs uint8_t delivery_started; 552297662Srrs uint8_t pd_api_started; 553163953Srrs}; 554163953Srrs 555217760StuexenTAILQ_HEAD(sctpwheel_listhead, sctp_stream_out); 556217760StuexenTAILQ_HEAD(sctplist_listhead, sctp_stream_queue_pending); 557217760Stuexen 558303956Stuexen 559217760Stuexen/* Round-robin schedulers */ 560217760Stuexenstruct ss_rr { 561217760Stuexen /* next link in wheel */ 562217760Stuexen TAILQ_ENTRY(sctp_stream_out) next_spoke; 563217760Stuexen}; 564217760Stuexen 565217760Stuexen/* Priority scheduler */ 566217760Stuexenstruct ss_prio { 567217760Stuexen /* next link in wheel */ 568217760Stuexen TAILQ_ENTRY(sctp_stream_out) next_spoke; 569217760Stuexen /* priority id */ 570217760Stuexen uint16_t priority; 571217760Stuexen}; 572217760Stuexen 573217760Stuexen/* Fair Bandwidth scheduler */ 574217760Stuexenstruct ss_fb { 575217760Stuexen /* next link in wheel */ 576217760Stuexen TAILQ_ENTRY(sctp_stream_out) next_spoke; 577217760Stuexen /* stores message size */ 578217760Stuexen int32_t rounds; 579217760Stuexen}; 580217760Stuexen 581217760Stuexen/* 582217760Stuexen * This union holds all data necessary for 583217760Stuexen * different stream schedulers. 584217760Stuexen */ 585303956Stuexenstruct scheduling_data { 586303956Stuexen struct sctp_stream_out *locked_on_sending; 587303956Stuexen /* circular looking for output selection */ 588303956Stuexen struct sctp_stream_out *last_out_stream; 589303956Stuexen union { 590303956Stuexen struct sctpwheel_listhead wheel; 591303956Stuexen struct sctplist_listhead list; 592303956Stuexen } out; 593217760Stuexen}; 594217760Stuexen 595217760Stuexen/* 596217760Stuexen * This union holds all parameters per stream 597217760Stuexen * necessary for different stream schedulers. 598217760Stuexen */ 599217760Stuexenunion scheduling_parameters { 600217760Stuexen struct ss_rr rr; 601217760Stuexen struct ss_prio prio; 602217760Stuexen struct ss_fb fb; 603217760Stuexen}; 604217760Stuexen 605285792Srrs/* States for outgoing streams */ 606285792Srrs#define SCTP_STREAM_CLOSED 0x00 607285792Srrs#define SCTP_STREAM_OPENING 0x01 608285792Srrs#define SCTP_STREAM_OPEN 0x02 609285792Srrs#define SCTP_STREAM_RESET_PENDING 0x03 610285792Srrs#define SCTP_STREAM_RESET_IN_FLIGHT 0x04 611285792Srrs 612285792Srrs#define SCTP_MAX_STREAMS_AT_ONCE_RESET 200 613285792Srrs 614163953Srrs/* This struct is used to track the traffic on outbound streams */ 615163953Srrsstruct sctp_stream_out { 616163953Srrs struct sctp_streamhead outqueue; 617217760Stuexen union scheduling_parameters ss_params; 618285792Srrs uint32_t chunks_on_queues; /* send queue and sent queue */ 619269945Stuexen#if defined(SCTP_DETAILED_STR_STATS) 620269945Stuexen uint32_t abandoned_unsent[SCTP_PR_SCTP_MAX + 1]; 621269945Stuexen uint32_t abandoned_sent[SCTP_PR_SCTP_MAX + 1]; 622269945Stuexen#else 623269945Stuexen /* Only the aggregation */ 624269945Stuexen uint32_t abandoned_unsent[1]; 625269945Stuexen uint32_t abandoned_sent[1]; 626269945Stuexen#endif 627301666Stuexen /* 628301666Stuexen * For associations using DATA chunks, the lower 16-bit of 629301666Stuexen * next_mid_ordered are used as the next SSN. 630301666Stuexen */ 631301666Stuexen uint32_t next_mid_ordered; 632301666Stuexen uint32_t next_mid_unordered; 633310219Stuexen uint16_t sid; 634163953Srrs uint8_t last_msg_incomplete; 635285792Srrs uint8_t state; 636163953Srrs}; 637163953Srrs 638163953Srrs/* used to keep track of the addresses yet to try to add/delete */ 639163953SrrsTAILQ_HEAD(sctp_asconf_addrhead, sctp_asconf_addr); 640163953Srrsstruct sctp_asconf_addr { 641163953Srrs TAILQ_ENTRY(sctp_asconf_addr) next; 642163953Srrs struct sctp_asconf_addr_param ap; 643167598Srrs struct sctp_ifa *ifa; /* save the ifa for add/del ip */ 644163953Srrs uint8_t sent; /* has this been sent yet? */ 645185694Srrs uint8_t special_del; /* not to be used in lookup */ 646163953Srrs}; 647163953Srrs 648163953Srrsstruct sctp_scoping { 649163953Srrs uint8_t ipv4_addr_legal; 650163953Srrs uint8_t ipv6_addr_legal; 651163953Srrs uint8_t loopback_scope; 652163953Srrs uint8_t ipv4_local_scope; 653163953Srrs uint8_t local_scope; 654163953Srrs uint8_t site_scope; 655163953Srrs}; 656163953Srrs 657166675Srrs#define SCTP_TSN_LOG_SIZE 40 658166675Srrs 659166675Srrsstruct sctp_tsn_log { 660171477Srrs void *stcb; 661166675Srrs uint32_t tsn; 662297662Srrs uint32_t seq; 663166675Srrs uint16_t strm; 664168859Srrs uint16_t sz; 665168859Srrs uint16_t flgs; 666171477Srrs uint16_t in_pos; 667171477Srrs uint16_t in_out; 668297662Srrs uint16_t resv; 669166675Srrs}; 670166675Srrs 671171440Srrs#define SCTP_FS_SPEC_LOG_SIZE 200 672171440Srrsstruct sctp_fs_spec_log { 673171440Srrs uint32_t sent; 674171440Srrs uint32_t total_flight; 675171440Srrs uint32_t tsn; 676171440Srrs uint16_t book; 677171440Srrs uint8_t incr; 678171440Srrs uint8_t decr; 679171440Srrs}; 680170056Srrs 681170056Srrs/* This struct is here to cut out the compatiabilty 682170056Srrs * pad that bulks up both the inp and stcb. The non 683170056Srrs * pad portion MUST stay in complete sync with 684170056Srrs * sctp_sndrcvinfo... i.e. if sinfo_xxxx is added 685170056Srrs * this must be done here too. 686170056Srrs */ 687170056Srrsstruct sctp_nonpad_sndrcvinfo { 688170056Srrs uint16_t sinfo_stream; 689170056Srrs uint16_t sinfo_ssn; 690170056Srrs uint16_t sinfo_flags; 691170056Srrs uint32_t sinfo_ppid; 692170056Srrs uint32_t sinfo_context; 693170056Srrs uint32_t sinfo_timetolive; 694170056Srrs uint32_t sinfo_tsn; 695170056Srrs uint32_t sinfo_cumtsn; 696170056Srrs sctp_assoc_t sinfo_assoc_id; 697223132Stuexen uint16_t sinfo_keynumber; 698223132Stuexen uint16_t sinfo_keynumber_valid; 699170056Srrs}; 700170056Srrs 701163953Srrs/* 702171440Srrs * JRS - Structure to hold function pointers to the functions responsible 703171440Srrs * for congestion control. 704171440Srrs */ 705171440Srrs 706171440Srrsstruct sctp_cc_functions { 707171440Srrs void (*sctp_set_initial_cc_param) (struct sctp_tcb *stcb, struct sctp_nets *net); 708171440Srrs void (*sctp_cwnd_update_after_sack) (struct sctp_tcb *stcb, 709347154Stuexen struct sctp_association *asoc, 710347154Stuexen int accum_moved, int reneged_all, int will_exit); 711224641Stuexen void (*sctp_cwnd_update_exit_pf) (struct sctp_tcb *stcb, struct sctp_nets *net); 712171440Srrs void (*sctp_cwnd_update_after_fr) (struct sctp_tcb *stcb, 713347154Stuexen struct sctp_association *asoc); 714171440Srrs void (*sctp_cwnd_update_after_timeout) (struct sctp_tcb *stcb, 715347154Stuexen struct sctp_nets *net); 716171440Srrs void (*sctp_cwnd_update_after_ecn_echo) (struct sctp_tcb *stcb, 717347154Stuexen struct sctp_nets *net, int in_window, int num_pkt_lost); 718171440Srrs void (*sctp_cwnd_update_after_packet_dropped) (struct sctp_tcb *stcb, 719347154Stuexen struct sctp_nets *net, struct sctp_pktdrop_chunk *cp, 720347154Stuexen uint32_t *bottle_bw, uint32_t *on_queue); 721171440Srrs void (*sctp_cwnd_update_after_output) (struct sctp_tcb *stcb, 722347154Stuexen struct sctp_nets *net, int burst_limit); 723219057Srrs void (*sctp_cwnd_update_packet_transmitted) (struct sctp_tcb *stcb, 724347154Stuexen struct sctp_nets *net); 725219057Srrs void (*sctp_cwnd_update_tsn_acknowledged) (struct sctp_nets *net, 726347154Stuexen struct sctp_tmit_chunk *); 727219057Srrs void (*sctp_cwnd_new_transmission_begins) (struct sctp_tcb *stcb, 728347154Stuexen struct sctp_nets *net); 729219057Srrs void (*sctp_cwnd_prepare_net_for_sack) (struct sctp_tcb *stcb, 730347154Stuexen struct sctp_nets *net); 731219057Srrs int (*sctp_cwnd_socket_option) (struct sctp_tcb *stcb, int set, struct sctp_cc_option *); 732219397Srrs void (*sctp_rtt_calculated) (struct sctp_tcb *, struct sctp_nets *, struct timeval *); 733171440Srrs}; 734171440Srrs 735217760Stuexen/* 736217760Stuexen * RS - Structure to hold function pointers to the functions responsible 737217760Stuexen * for stream scheduling. 738217760Stuexen */ 739217760Stuexenstruct sctp_ss_functions { 740217760Stuexen void (*sctp_ss_init) (struct sctp_tcb *stcb, struct sctp_association *asoc, 741347154Stuexen int holds_lock); 742217760Stuexen void (*sctp_ss_clear) (struct sctp_tcb *stcb, struct sctp_association *asoc, 743347154Stuexen int clear_values, int holds_lock); 744303956Stuexen void (*sctp_ss_init_stream) (struct sctp_tcb *stcb, struct sctp_stream_out *strq, struct sctp_stream_out *with_strq); 745217760Stuexen void (*sctp_ss_add_to_stream) (struct sctp_tcb *stcb, struct sctp_association *asoc, 746347154Stuexen struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, int holds_lock); 747217760Stuexen int (*sctp_ss_is_empty) (struct sctp_tcb *stcb, struct sctp_association *asoc); 748217760Stuexen void (*sctp_ss_remove_from_stream) (struct sctp_tcb *stcb, struct sctp_association *asoc, 749347154Stuexen struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, int holds_lock); 750347154Stuexenstruct sctp_stream_out *(*sctp_ss_select_stream) (struct sctp_tcb *stcb, 751347154Stuexen struct sctp_nets *net, struct sctp_association *asoc); 752217760Stuexen void (*sctp_ss_scheduled) (struct sctp_tcb *stcb, struct sctp_nets *net, 753347154Stuexen struct sctp_association *asoc, struct sctp_stream_out *strq, int moved_how_much); 754217760Stuexen void (*sctp_ss_packet_done) (struct sctp_tcb *stcb, struct sctp_nets *net, 755347154Stuexen struct sctp_association *asoc); 756217760Stuexen int (*sctp_ss_get_value) (struct sctp_tcb *stcb, struct sctp_association *asoc, 757347154Stuexen struct sctp_stream_out *strq, uint16_t *value); 758217760Stuexen int (*sctp_ss_set_value) (struct sctp_tcb *stcb, struct sctp_association *asoc, 759347154Stuexen struct sctp_stream_out *strq, uint16_t value); 760303956Stuexen int (*sctp_ss_is_user_msgs_incomplete) (struct sctp_tcb *stcb, struct sctp_association *asoc); 761217760Stuexen}; 762217760Stuexen 763179157Srrs/* used to save ASCONF chunks for retransmission */ 764179157SrrsTAILQ_HEAD(sctp_asconf_head, sctp_asconf); 765179157Srrsstruct sctp_asconf { 766179157Srrs TAILQ_ENTRY(sctp_asconf) next; 767179157Srrs uint32_t serial_number; 768179157Srrs uint16_t snd_count; 769179157Srrs struct mbuf *data; 770179157Srrs uint16_t len; 771179157Srrs}; 772179157Srrs 773171990Srrs/* used to save ASCONF-ACK chunks for retransmission */ 774171990SrrsTAILQ_HEAD(sctp_asconf_ackhead, sctp_asconf_ack); 775171990Srrsstruct sctp_asconf_ack { 776171990Srrs TAILQ_ENTRY(sctp_asconf_ack) next; 777171990Srrs uint32_t serial_number; 778171990Srrs struct sctp_nets *last_sent_to; 779171990Srrs struct mbuf *data; 780171990Srrs uint16_t len; 781171990Srrs}; 782171990Srrs 783171440Srrs/* 784163953Srrs * Here we have information about each individual association that we track. 785163953Srrs * We probably in production would be more dynamic. But for ease of 786163953Srrs * implementation we will have a fixed array that we hunt for in a linear 787163953Srrs * fashion. 788163953Srrs */ 789163953Srrsstruct sctp_association { 790163953Srrs /* association state */ 791163953Srrs int state; 792171572Srrs 793163953Srrs /* queue of pending addrs to add/delete */ 794163953Srrs struct sctp_asconf_addrhead asconf_queue; 795171572Srrs 796163953Srrs struct timeval time_entered; /* time we entered state */ 797163953Srrs struct timeval time_last_rcvd; 798163953Srrs struct timeval time_last_sent; 799163953Srrs struct timeval time_last_sat_advance; 800170056Srrs struct sctp_nonpad_sndrcvinfo def_send; 801163953Srrs 802163953Srrs /* timers and such */ 803163953Srrs struct sctp_timer dack_timer; /* Delayed ack timer */ 804171572Srrs struct sctp_timer asconf_timer; /* asconf */ 805163953Srrs struct sctp_timer strreset_timer; /* stream reset */ 806171572Srrs struct sctp_timer shut_guard_timer; /* shutdown guard */ 807163953Srrs struct sctp_timer autoclose_timer; /* automatic close timer */ 808172091Srrs struct sctp_timer delete_prim_timer; /* deleting primary dst */ 809163953Srrs 810171572Srrs /* list of restricted local addresses */ 811167598Srrs struct sctpladdr sctp_restricted_addrs; 812167598Srrs 813171572Srrs /* last local address pending deletion (waiting for an address add) */ 814171572Srrs struct sctp_ifa *asconf_addr_del_pending; 815172091Srrs /* Deleted primary destination (used to stop timer) */ 816172091Srrs struct sctp_nets *deleted_primary; 817163953Srrs 818171572Srrs struct sctpnetlisthead nets; /* remote address list */ 819171572Srrs 820163953Srrs /* Free chunk list */ 821163953Srrs struct sctpchunk_listhead free_chunks; 822163953Srrs 823163953Srrs /* Control chunk queue */ 824163953Srrs struct sctpchunk_listhead control_send_queue; 825163953Srrs 826179157Srrs /* ASCONF chunk queue */ 827179157Srrs struct sctpchunk_listhead asconf_send_queue; 828179157Srrs 829163953Srrs /* 830163953Srrs * Once a TSN hits the wire it is moved to the sent_queue. We 831163953Srrs * maintain two counts here (don't know if any but retran_cnt is 832163953Srrs * needed). The idea is that the sent_queue_retran_cnt reflects how 833163953Srrs * many chunks have been marked for retranmission by either T3-rxt 834163953Srrs * or FR. 835163953Srrs */ 836163953Srrs struct sctpchunk_listhead sent_queue; 837163953Srrs struct sctpchunk_listhead send_queue; 838163953Srrs 839218241Stuexen /* Scheduling queues */ 840303956Stuexen struct scheduling_data ss_data; 841163953Srrs 842163953Srrs /* If an iterator is looking at me, this is it */ 843163953Srrs struct sctp_iterator *stcb_starting_point_for_iterator; 844163953Srrs 845163953Srrs /* ASCONF save the last ASCONF-ACK so we can resend it if necessary */ 846171990Srrs struct sctp_asconf_ackhead asconf_ack_sent; 847163953Srrs 848163953Srrs /* 849163953Srrs * pointer to last stream reset queued to control queue by us with 850163953Srrs * requests. 851163953Srrs */ 852163953Srrs struct sctp_tmit_chunk *str_reset; 853163953Srrs /* 854163953Srrs * if Source Address Selection happening, this will rotate through 855163953Srrs * the link list. 856163953Srrs */ 857163953Srrs struct sctp_laddr *last_used_address; 858163953Srrs 859163953Srrs /* stream arrays */ 860163953Srrs struct sctp_stream_in *strmin; 861163953Srrs struct sctp_stream_out *strmout; 862163953Srrs uint8_t *mapping_array; 863163953Srrs /* primary destination to use */ 864163953Srrs struct sctp_nets *primary_destination; 865224641Stuexen struct sctp_nets *alternate; /* If primary is down or PF */ 866163953Srrs /* For CMT */ 867190689Srrs struct sctp_nets *last_net_cmt_send_started; 868163953Srrs /* last place I got a data chunk from */ 869163953Srrs struct sctp_nets *last_data_chunk_from; 870163953Srrs /* last place I got a control from */ 871163953Srrs struct sctp_nets *last_control_chunk_from; 872163953Srrs 873163953Srrs 874163953Srrs /* 875163953Srrs * wait to the point the cum-ack passes req->send_reset_at_tsn for 876163953Srrs * any req on the list. 877163953Srrs */ 878163953Srrs struct sctp_resethead resetHead; 879163953Srrs 880163953Srrs /* queue of chunks waiting to be sent into the local stack */ 881163953Srrs struct sctp_readhead pending_reply_queue; 882163953Srrs 883171440Srrs /* JRS - the congestion control functions are in this struct */ 884171440Srrs struct sctp_cc_functions cc_functions; 885310773Stuexen /* 886310773Stuexen * JRS - value to store the currently loaded congestion control 887310773Stuexen * module 888310773Stuexen */ 889171440Srrs uint32_t congestion_control_module; 890217760Stuexen /* RS - the stream scheduling functions are in this struct */ 891217760Stuexen struct sctp_ss_functions ss_functions; 892217760Stuexen /* RS - value to store the currently loaded stream scheduling module */ 893217760Stuexen uint32_t stream_scheduling_module; 894171440Srrs 895167598Srrs uint32_t vrf_id; 896163953Srrs uint32_t cookie_preserve_req; 897163953Srrs /* ASCONF next seq I am sending out, inits at init-tsn */ 898163953Srrs uint32_t asconf_seq_out; 899179157Srrs uint32_t asconf_seq_out_acked; 900163953Srrs /* ASCONF last received ASCONF from peer, starts at peer's TSN-1 */ 901163953Srrs uint32_t asconf_seq_in; 902163953Srrs 903163953Srrs /* next seq I am sending in str reset messages */ 904163953Srrs uint32_t str_reset_seq_out; 905163953Srrs /* next seq I am expecting in str reset messages */ 906163953Srrs uint32_t str_reset_seq_in; 907163953Srrs 908163953Srrs /* various verification tag information */ 909163953Srrs uint32_t my_vtag; /* The tag to be used. if assoc is re-initited 910163953Srrs * by remote end, and I have unlocked this 911163953Srrs * will be regenerated to a new random value. */ 912163953Srrs uint32_t peer_vtag; /* The peers last tag */ 913163953Srrs 914163953Srrs uint32_t my_vtag_nonce; 915163953Srrs uint32_t peer_vtag_nonce; 916163953Srrs 917163953Srrs uint32_t assoc_id; 918163953Srrs 919163953Srrs /* This is the SCTP fragmentation threshold */ 920163953Srrs uint32_t smallest_mtu; 921163953Srrs 922163953Srrs /* 923163953Srrs * Special hook for Fast retransmit, allows us to track the highest 924163953Srrs * TSN that is NEW in this SACK if gap ack blocks are present. 925163953Srrs */ 926163953Srrs uint32_t this_sack_highest_gap; 927163953Srrs 928163953Srrs /* 929163953Srrs * The highest consecutive TSN that has been acked by peer on my 930163953Srrs * sends 931163953Srrs */ 932163953Srrs uint32_t last_acked_seq; 933163953Srrs 934163953Srrs /* The next TSN that I will use in sending. */ 935163953Srrs uint32_t sending_seq; 936163953Srrs 937163953Srrs /* Original seq number I used ??questionable to keep?? */ 938163953Srrs uint32_t init_seq_number; 939163953Srrs 940163953Srrs 941163953Srrs /* The Advanced Peer Ack Point, as required by the PR-SCTP */ 942163953Srrs /* (A1 in Section 4.2) */ 943163953Srrs uint32_t advanced_peer_ack_point; 944163953Srrs 945163953Srrs /* 946163953Srrs * The highest consequetive TSN at the bottom of the mapping array 947163953Srrs * (for his sends). 948163953Srrs */ 949163953Srrs uint32_t cumulative_tsn; 950163953Srrs /* 951163953Srrs * Used to track the mapping array and its offset bits. This MAY be 952163953Srrs * lower then cumulative_tsn. 953163953Srrs */ 954163953Srrs uint32_t mapping_array_base_tsn; 955163953Srrs /* 956163953Srrs * used to track highest TSN we have received and is listed in the 957163953Srrs * mapping array. 958163953Srrs */ 959163953Srrs uint32_t highest_tsn_inside_map; 960163953Srrs 961185694Srrs /* EY - new NR variables used for nr_sack based on mapping_array */ 962185694Srrs uint8_t *nr_mapping_array; 963185694Srrs uint32_t highest_tsn_inside_nr_map; 964185694Srrs 965163953Srrs uint32_t fast_recovery_tsn; 966163953Srrs uint32_t sat_t3_recovery_tsn; 967163953Srrs uint32_t tsn_last_delivered; 968163953Srrs /* 969298942Spfg * For the pd-api we should re-write this a bit more efficient. We 970163953Srrs * could have multiple sctp_queued_to_read's that we are building at 971163953Srrs * once. Now we only do this when we get ready to deliver to the 972163953Srrs * socket buffer. Note that we depend on the fact that the struct is 973163953Srrs * "stuck" on the read queue until we finish all the pd-api. 974163953Srrs */ 975163953Srrs struct sctp_queued_to_read *control_pdapi; 976163953Srrs 977163953Srrs uint32_t tsn_of_pdapi_last_delivered; 978163953Srrs uint32_t pdapi_ppid; 979163953Srrs uint32_t context; 980163953Srrs uint32_t last_reset_action[SCTP_MAX_RESET_PARAMS]; 981163953Srrs uint32_t last_sending_seq[SCTP_MAX_RESET_PARAMS]; 982163953Srrs uint32_t last_base_tsnsent[SCTP_MAX_RESET_PARAMS]; 983166675Srrs#ifdef SCTP_ASOCLOG_OF_TSNS 984163953Srrs /* 985166675Srrs * special log - This adds considerable size to the asoc, but 986166675Srrs * provides a log that you can use to detect problems via kgdb. 987166675Srrs */ 988166675Srrs struct sctp_tsn_log in_tsnlog[SCTP_TSN_LOG_SIZE]; 989166675Srrs struct sctp_tsn_log out_tsnlog[SCTP_TSN_LOG_SIZE]; 990171477Srrs uint32_t cumack_log[SCTP_TSN_LOG_SIZE]; 991172703Srrs uint32_t cumack_logsnt[SCTP_TSN_LOG_SIZE]; 992166675Srrs uint16_t tsn_in_at; 993166675Srrs uint16_t tsn_out_at; 994168859Srrs uint16_t tsn_in_wrapped; 995168859Srrs uint16_t tsn_out_wrapped; 996171477Srrs uint16_t cumack_log_at; 997172703Srrs uint16_t cumack_log_atsnt; 998166675Srrs#endif /* SCTP_ASOCLOG_OF_TSNS */ 999171440Srrs#ifdef SCTP_FS_SPEC_LOG 1000171440Srrs struct sctp_fs_spec_log fslog[SCTP_FS_SPEC_LOG_SIZE]; 1001171440Srrs uint16_t fs_index; 1002171440Srrs#endif 1003171440Srrs 1004166675Srrs /* 1005163953Srrs * window state information and smallest MTU that I use to bound 1006163953Srrs * segmentation 1007163953Srrs */ 1008163953Srrs uint32_t peers_rwnd; 1009163953Srrs uint32_t my_rwnd; 1010163953Srrs uint32_t my_last_reported_rwnd; 1011170056Srrs uint32_t sctp_frag_point; 1012163953Srrs 1013163953Srrs uint32_t total_output_queue_size; 1014163953Srrs 1015275427Stuexen uint32_t sb_cc; /* shadow of sb_cc */ 1016174257Srrs uint32_t sb_send_resv; /* amount reserved on a send */ 1017171943Srrs uint32_t my_rwnd_control_len; /* shadow of sb_mbcnt used for rwnd 1018171943Srrs * control */ 1019225549Stuexen#ifdef INET6 1020163953Srrs uint32_t default_flowlabel; 1021225549Stuexen#endif 1022163953Srrs uint32_t pr_sctp_cnt; 1023218129Srrs int ctrl_queue_cnt; /* could be removed REM - NO IT CAN'T!! RRS */ 1024163953Srrs /* 1025163953Srrs * All outbound datagrams queue into this list from the individual 1026163953Srrs * stream queue. Here they get assigned a TSN and then await 1027163953Srrs * sending. The stream seq comes when it is first put in the 1028163953Srrs * individual str queue 1029163953Srrs */ 1030163953Srrs unsigned int stream_queue_cnt; 1031163953Srrs unsigned int send_queue_cnt; 1032163953Srrs unsigned int sent_queue_cnt; 1033163953Srrs unsigned int sent_queue_cnt_removeable; 1034163953Srrs /* 1035163953Srrs * Number on sent queue that are marked for retran until this value 1036163953Srrs * is 0 we only send one packet of retran'ed data. 1037163953Srrs */ 1038163953Srrs unsigned int sent_queue_retran_cnt; 1039163953Srrs 1040163953Srrs unsigned int size_on_reasm_queue; 1041163953Srrs unsigned int cnt_on_reasm_queue; 1042210599Srrs unsigned int fwd_tsn_cnt; 1043163953Srrs /* amount of data (bytes) currently in flight (on all destinations) */ 1044163953Srrs unsigned int total_flight; 1045163953Srrs /* Total book size in flight */ 1046163953Srrs unsigned int total_flight_count; /* count of chunks used with 1047163953Srrs * book total */ 1048163953Srrs /* count of destinaton nets and list of destination nets */ 1049163953Srrs unsigned int numnets; 1050163953Srrs 1051163953Srrs /* Total error count on this association */ 1052163953Srrs unsigned int overall_error_count; 1053163953Srrs 1054163953Srrs unsigned int cnt_msg_on_sb; 1055163953Srrs 1056163953Srrs /* All stream count of chunks for delivery */ 1057163953Srrs unsigned int size_on_all_streams; 1058163953Srrs unsigned int cnt_on_all_streams; 1059163953Srrs 1060224641Stuexen /* Heart Beat delay in ms */ 1061224641Stuexen uint32_t heart_beat_delay; 1062163953Srrs 1063163953Srrs /* autoclose */ 1064163953Srrs unsigned int sctp_autoclose_ticks; 1065163953Srrs 1066163953Srrs /* how many preopen streams we have */ 1067163953Srrs unsigned int pre_open_streams; 1068163953Srrs 1069163953Srrs /* How many streams I support coming into me */ 1070163953Srrs unsigned int max_inbound_streams; 1071163953Srrs 1072163953Srrs /* the cookie life I award for any cookie, in seconds */ 1073163953Srrs unsigned int cookie_life; 1074163953Srrs /* time to delay acks for */ 1075163953Srrs unsigned int delayed_ack; 1076167598Srrs unsigned int old_delayed_ack; 1077167598Srrs unsigned int sack_freq; 1078167598Srrs unsigned int data_pkts_seen; 1079163953Srrs 1080163953Srrs unsigned int numduptsns; 1081163953Srrs int dup_tsns[SCTP_MAX_DUP_TSNS]; 1082163953Srrs unsigned int initial_init_rto_max; /* initial RTO for INIT's */ 1083163953Srrs unsigned int initial_rto; /* initial send RTO */ 1084163953Srrs unsigned int minrto; /* per assoc RTO-MIN */ 1085163953Srrs unsigned int maxrto; /* per assoc RTO-MAX */ 1086163953Srrs 1087163953Srrs /* authentication fields */ 1088163953Srrs sctp_auth_chklist_t *local_auth_chunks; 1089163953Srrs sctp_auth_chklist_t *peer_auth_chunks; 1090163953Srrs sctp_hmaclist_t *local_hmacs; /* local HMACs supported */ 1091163953Srrs sctp_hmaclist_t *peer_hmacs; /* peer HMACs supported */ 1092163953Srrs struct sctp_keyhead shared_keys; /* assoc's shared keys */ 1093163953Srrs sctp_authinfo_t authinfo; /* randoms, cached keys */ 1094163953Srrs /* 1095163953Srrs * refcnt to block freeing when a sender or receiver is off coping 1096163953Srrs * user data in. 1097163953Srrs */ 1098163996Srrs uint32_t refcnt; 1099163996Srrs uint32_t chunks_on_out_queue; /* total chunks floating around, 1100163996Srrs * locked by send socket buffer */ 1101171990Srrs uint32_t peers_adaptation; 1102332222Stuexen uint32_t default_mtu; 1103163996Srrs uint16_t peer_hmac_id; /* peer HMAC id to send */ 1104163996Srrs 1105163953Srrs /* 1106163953Srrs * Being that we have no bag to collect stale cookies, and that we 1107163953Srrs * really would not want to anyway.. we will count them in this 1108163953Srrs * counter. We of course feed them to the pigeons right away (I have 1109163953Srrs * always thought of pigeons as flying rats). 1110163953Srrs */ 1111163953Srrs uint16_t stale_cookie_count; 1112163953Srrs 1113163953Srrs /* 1114163953Srrs * For the partial delivery API, if up, invoked this is what last 1115163953Srrs * TSN I delivered 1116163953Srrs */ 1117163953Srrs uint16_t str_of_pdapi; 1118163953Srrs uint16_t ssn_of_pdapi; 1119163953Srrs 1120163953Srrs /* counts of actual built streams. Allocation may be more however */ 1121163953Srrs /* could re-arrange to optimize space here. */ 1122163953Srrs uint16_t streamincnt; 1123163953Srrs uint16_t streamoutcnt; 1124188854Srrs uint16_t strm_realoutsize; 1125233660Srrs uint16_t strm_pending_add_size; 1126163953Srrs /* my maximum number of retrans of INIT and SEND */ 1127163953Srrs /* copied from SCTP but should be individually setable */ 1128163953Srrs uint16_t max_init_times; 1129163953Srrs uint16_t max_send_times; 1130163953Srrs 1131163953Srrs uint16_t def_net_failure; 1132163953Srrs 1133224641Stuexen uint16_t def_net_pf_threshold; 1134224641Stuexen 1135163953Srrs /* 1136163953Srrs * lock flag: 0 is ok to send, 1+ (duals as a retran count) is 1137163953Srrs * awaiting ACK 1138163953Srrs */ 1139163953Srrs uint16_t mapping_array_size; 1140163953Srrs 1141163953Srrs uint16_t last_strm_seq_delivered; 1142163953Srrs uint16_t last_strm_no_delivered; 1143163953Srrs 1144163953Srrs uint16_t last_revoke_count; 1145163953Srrs int16_t num_send_timers_up; 1146163953Srrs 1147163953Srrs uint16_t stream_locked_on; 1148163953Srrs uint16_t ecn_echo_cnt_onq; 1149163953Srrs 1150163953Srrs uint16_t free_chunk_cnt; 1151163953Srrs uint8_t stream_locked; 1152163953Srrs uint8_t authenticated; /* packet authenticated ok */ 1153163953Srrs /* 1154167598Srrs * This flag indicates that a SACK need to be sent. Initially this 1155167598Srrs * is 1 to send the first sACK immediately. 1156163953Srrs */ 1157167598Srrs uint8_t send_sack; 1158163953Srrs 1159218186Srrs /* max burst of new packets into the network */ 1160217894Stuexen uint32_t max_burst; 1161218186Srrs /* max burst of fast retransmit packets */ 1162218186Srrs uint32_t fr_max_burst; 1163163953Srrs 1164163953Srrs uint8_t sat_network; /* RTT is in range of sat net or greater */ 1165163953Srrs uint8_t sat_network_lockout; /* lockout code */ 1166163953Srrs uint8_t burst_limit_applied; /* Burst limit in effect at last send? */ 1167163953Srrs /* flag goes on when we are doing a partial delivery api */ 1168163953Srrs uint8_t hb_random_values[4]; 1169163953Srrs uint8_t fragmented_delivery_inprogress; 1170163953Srrs uint8_t fragment_flags; 1171163953Srrs uint8_t last_flags_delivered; 1172163953Srrs uint8_t hb_ect_randombit; 1173163953Srrs uint8_t hb_random_idx; 1174224870Stuexen uint8_t default_dscp; 1175171572Srrs uint8_t asconf_del_pending; /* asconf delete last addr pending */ 1176285792Srrs uint8_t trigger_reset; 1177163953Srrs /* 1178163953Srrs * This value, plus all other ack'd but above cum-ack is added 1179163953Srrs * together to cross check against the bit that we have yet to 1180163953Srrs * define (probably in the SACK). When the cum-ack is updated, this 1181163953Srrs * sum is updated as well. 1182163953Srrs */ 1183218129Srrs 1184269448Stuexen /* Flags whether an extension is supported or not */ 1185269436Stuexen uint8_t ecn_supported; 1186269448Stuexen uint8_t prsctp_supported; 1187269858Stuexen uint8_t auth_supported; 1188269858Stuexen uint8_t asconf_supported; 1189269527Stuexen uint8_t reconfig_supported; 1190269475Stuexen uint8_t nrsack_supported; 1191269481Stuexen uint8_t pktdrop_supported; 1192297662Srrs uint8_t idata_supported; 1193163953Srrs 1194233660Srrs /* Did the peer make the stream config (add out) request */ 1195233660Srrs uint8_t peer_req_out; 1196233660Srrs 1197233660Srrs uint8_t local_strreset_support; 1198185694Srrs uint8_t peer_supports_nat; 1199163953Srrs 1200246595Stuexen struct sctp_scoping scope; 1201163953Srrs /* flags to handle send alternate net tracking */ 1202163953Srrs uint8_t used_alt_asconfack; 1203163953Srrs uint8_t fast_retran_loss_recovery; 1204163953Srrs uint8_t sat_t3_loss_recovery; 1205163953Srrs uint8_t dropped_special_cnt; 1206163953Srrs uint8_t seen_a_sack_this_pkt; 1207163953Srrs uint8_t stream_reset_outstanding; 1208163953Srrs uint8_t stream_reset_out_is_outstanding; 1209163953Srrs uint8_t delayed_connection; 1210163953Srrs uint8_t ifp_had_enobuf; 1211163953Srrs uint8_t saw_sack_with_frags; 1212216188Stuexen uint8_t saw_sack_with_nr_frags; 1213185694Srrs uint8_t in_asocid_hash; 1214163953Srrs uint8_t assoc_up_sent; 1215171990Srrs uint8_t adaptation_needed; 1216171990Srrs uint8_t adaptation_sent; 1217163953Srrs /* CMT variables */ 1218163953Srrs uint8_t cmt_dac_pkts_rcvd; 1219163953Srrs uint8_t sctp_cmt_on_off; 1220163953Srrs uint8_t iam_blocking; 1221166023Srrs uint8_t cookie_how[8]; 1222171440Srrs /* JRS 5/21/07 - CMT PF variable */ 1223171440Srrs uint8_t sctp_cmt_pf; 1224219057Srrs uint8_t use_precise_time; 1225254670Stuexen uint64_t sctp_features; 1226279859Stuexen uint32_t max_cwnd; 1227227755Stuexen uint16_t port; /* remote UDP encapsulation port */ 1228163953Srrs /* 1229163953Srrs * The mapping array is used to track out of order sequences above 1230163953Srrs * last_acked_seq. 0 indicates packet missing 1 indicates packet 1231163953Srrs * rec'd. We slide it up every time we raise last_acked_seq and 0 1232163953Srrs * trailing locactions out. If I get a TSN above the array 1233163953Srrs * mappingArraySz, I discard the datagram and let retransmit happen. 1234163953Srrs */ 1235166675Srrs uint32_t marked_retrans; 1236166675Srrs uint32_t timoinit; 1237166675Srrs uint32_t timodata; 1238166675Srrs uint32_t timosack; 1239166675Srrs uint32_t timoshutdown; 1240166675Srrs uint32_t timoheartbeat; 1241166675Srrs uint32_t timocookie; 1242166675Srrs uint32_t timoshutdownack; 1243166675Srrs struct timeval start_time; 1244166675Srrs struct timeval discontinuity_time; 1245269945Stuexen uint64_t abandoned_unsent[SCTP_PR_SCTP_MAX + 1]; 1246269945Stuexen uint64_t abandoned_sent[SCTP_PR_SCTP_MAX + 1]; 1247163953Srrs}; 1248163953Srrs 1249163953Srrs#endif 1250