1163953Srrs/*- 2185694Srrs * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. 3237896Stuexen * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 4237896Stuexen * 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, 10231038Stuexen * 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 14231038Stuexen * 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$"); 35163953Srrs 36237896Stuexen#ifndef _NETINET_SCTP_STRUCTS_H_ 37237896Stuexen#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; 79163953Srrs uint32_t tsn; 80252929Stuexen uint32_t number_entries; 81252929Stuexen uint16_t list_of_streams[]; 82163953Srrs}; 83163953Srrs 84163953SrrsTAILQ_HEAD(sctp_resethead, sctp_stream_reset_list); 85163953Srrs 86163953Srrs/* 87163953Srrs * Users of the iterator need to malloc a iterator with a call to 88167598Srrs * sctp_initiate_iterator(inp_func, assoc_func, inp_func, pcb_flags, pcb_features, 89163953Srrs * asoc_state, void-ptr-arg, uint32-arg, end_func, inp); 90163953Srrs * 91163953Srrs * Use the following two defines if you don't care what pcb flags are on the EP 92163953Srrs * and/or you don't care what state the association is in. 93163953Srrs * 94163953Srrs * Note that if you specify an INP as the last argument then ONLY each 95163953Srrs * association of that single INP will be executed upon. Note that the pcb 96163953Srrs * flags STILL apply so if the inp you specify has different pcb_flags then 97163953Srrs * what you put in pcb_flags nothing will happen. use SCTP_PCB_ANY_FLAGS to 98163953Srrs * assure the inp you specify gets treated. 99163953Srrs */ 100163953Srrs#define SCTP_PCB_ANY_FLAGS 0x00000000 101163953Srrs#define SCTP_PCB_ANY_FEATURES 0x00000000 102163953Srrs#define SCTP_ASOC_ANY_STATE 0x00000000 103163953Srrs 104163953Srrstypedef void (*asoc_func) (struct sctp_inpcb *, struct sctp_tcb *, void *ptr, 105163953Srrs uint32_t val); 106167598Srrstypedef int (*inp_func) (struct sctp_inpcb *, void *ptr, uint32_t val); 107163953Srrstypedef void (*end_func) (void *ptr, uint32_t val); 108163953Srrs 109218211Srrs#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP) 110218211Srrs/* whats on the mcore control struct */ 111218211Srrsstruct sctp_mcore_queue { 112218211Srrs TAILQ_ENTRY(sctp_mcore_queue) next; 113218211Srrs struct vnet *vn; 114218211Srrs struct mbuf *m; 115218211Srrs int off; 116218211Srrs int v6; 117218211Srrs}; 118218211Srrs 119218211SrrsTAILQ_HEAD(sctp_mcore_qhead, sctp_mcore_queue); 120218211Srrs 121218211Srrsstruct sctp_mcore_ctrl { 122218211Srrs SCTP_PROCESS_STRUCT thread_proc; 123218211Srrs struct sctp_mcore_qhead que; 124218211Srrs struct mtx core_mtx; 125218211Srrs struct mtx que_mtx; 126218211Srrs int running; 127218211Srrs int cpuid; 128218211Srrs}; 129218211Srrs 130218211Srrs 131218211Srrs#endif 132218211Srrs 133218211Srrs 134163953Srrsstruct sctp_iterator { 135167598Srrs TAILQ_ENTRY(sctp_iterator) sctp_nxt_itr; 136208160Srrs struct vnet *vn; 137163953Srrs struct sctp_timer tmr; 138163953Srrs struct sctp_inpcb *inp; /* current endpoint */ 139163953Srrs struct sctp_tcb *stcb; /* current* assoc */ 140208160Srrs struct sctp_inpcb *next_inp; /* special hook to skip to */ 141163953Srrs asoc_func function_assoc; /* per assoc function */ 142163953Srrs inp_func function_inp; /* per endpoint function */ 143167598Srrs inp_func function_inp_end; /* end INP function */ 144163953Srrs end_func function_atend;/* iterator completion function */ 145163953Srrs void *pointer; /* pointer for apply func to use */ 146163953Srrs uint32_t val; /* value for apply func to use */ 147163953Srrs uint32_t pcb_flags; /* endpoint flags being checked */ 148163953Srrs uint32_t pcb_features; /* endpoint features being checked */ 149163953Srrs uint32_t asoc_state; /* assoc state being checked */ 150163953Srrs uint32_t iterator_flags; 151163953Srrs uint8_t no_chunk_output; 152167598Srrs uint8_t done_current_ep; 153163953Srrs}; 154163953Srrs 155163953Srrs/* iterator_flags values */ 156163953Srrs#define SCTP_ITERATOR_DO_ALL_INP 0x00000001 157163953Srrs#define SCTP_ITERATOR_DO_SINGLE_INP 0x00000002 158163953Srrs 159208160Srrs 160167598SrrsTAILQ_HEAD(sctpiterators, sctp_iterator); 161163953Srrs 162163953Srrsstruct sctp_copy_all { 163163953Srrs struct sctp_inpcb *inp; /* ep */ 164163953Srrs struct mbuf *m; 165163953Srrs struct sctp_sndrcvinfo sndrcv; 166163953Srrs int sndlen; 167163953Srrs int cnt_sent; 168163953Srrs int cnt_failed; 169163953Srrs}; 170163953Srrs 171167598Srrsstruct sctp_asconf_iterator { 172167598Srrs struct sctpladdr list_of_work; 173167598Srrs int cnt; 174167598Srrs}; 175167598Srrs 176208160Srrsstruct iterator_control { 177208160Srrs struct mtx ipi_iterator_wq_mtx; 178208160Srrs struct mtx it_mtx; 179208160Srrs SCTP_PROCESS_STRUCT thread_proc; 180208160Srrs struct sctpiterators iteratorhead; 181208160Srrs struct sctp_iterator *cur_it; 182208160Srrs uint32_t iterator_running; 183208160Srrs uint32_t iterator_flags; 184208160Srrs}; 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; 191191117Skmacy void *ro_lle; 192226278Stuexen void *ro_ia; 193226278Stuexen int ro_flags; 194169352Srrs union sctp_sockstore _l_addr; /* remote peer addr */ 195169352Srrs struct sctp_ifa *_s_addr; /* our selected src addr */ 196169352Srrs}; 197169352Srrs 198171440Srrsstruct htcp { 199171440Srrs uint16_t alpha; /* Fixed point arith, << 7 */ 200171440Srrs uint8_t beta; /* Fixed point arith, << 7 */ 201171440Srrs uint8_t modeswitch; /* Delay modeswitch until we had at least one 202171440Srrs * congestion event */ 203171440Srrs uint32_t last_cong; /* Time since last congestion event end */ 204171440Srrs uint32_t undo_last_cong; 205171440Srrs uint16_t bytes_acked; 206171440Srrs uint32_t bytecount; 207171440Srrs uint32_t minRTT; 208171440Srrs uint32_t maxRTT; 209171440Srrs 210171440Srrs uint32_t undo_maxRTT; 211171440Srrs uint32_t undo_old_maxB; 212171440Srrs 213171440Srrs /* Bandwidth estimation */ 214171440Srrs uint32_t minB; 215171440Srrs uint32_t maxB; 216171440Srrs uint32_t old_maxB; 217171440Srrs uint32_t Bi; 218171440Srrs uint32_t lasttime; 219171440Srrs}; 220171440Srrs 221219120Srrsstruct rtcc_cc { 222219120Srrs struct timeval tls; /* The time we started the sending */ 223219120Srrs uint64_t lbw; /* Our last estimated bw */ 224219120Srrs uint64_t lbw_rtt; /* RTT at bw estimate */ 225219120Srrs uint64_t bw_bytes; /* The total bytes since this sending began */ 226219120Srrs uint64_t bw_tot_time; /* The total time since sending began */ 227219120Srrs uint64_t new_tot_time; /* temp holding the new value */ 228219397Srrs uint64_t bw_bytes_at_last_rttc; /* What bw_bytes was at last rtt calc */ 229219397Srrs uint32_t cwnd_at_bw_set;/* Cwnd at last bw saved - lbw */ 230219397Srrs uint32_t vol_reduce; /* cnt of voluntary reductions */ 231219397Srrs uint16_t steady_step; /* The number required to be in steady state */ 232219397Srrs uint16_t step_cnt; /* The current number */ 233219397Srrs uint8_t ret_from_eq; /* When all things are equal what do I return 234219397Srrs * 0/1 - 1 no cc advance */ 235219397Srrs uint8_t use_dccc_ecn; /* Flag to enable DCCC ECN */ 236219120Srrs uint8_t tls_needs_set; /* Flag to indicate we need to set tls 0 or 1 237219120Srrs * means set at send 2 not */ 238219397Srrs uint8_t last_step_state;/* Last state if steady state stepdown is on */ 239219397Srrs uint8_t rtt_set_this_sack; /* Flag saying this sack had RTT calc 240219397Srrs * on it */ 241219397Srrs uint8_t last_inst_ind; /* Last saved inst indication */ 242219120Srrs}; 243219120Srrs 244219120Srrs 245163953Srrsstruct sctp_nets { 246163953Srrs TAILQ_ENTRY(sctp_nets) sctp_next; /* next link */ 247163953Srrs 248163953Srrs /* 249163953Srrs * Things on the top half may be able to be split into a common 250163953Srrs * structure shared by all. 251163953Srrs */ 252163953Srrs struct sctp_timer pmtu_timer; 253224641Stuexen struct sctp_timer hb_timer; 254163953Srrs 255163953Srrs /* 256163953Srrs * The following two in combination equate to a route entry for v6 257163953Srrs * or v4. 258163953Srrs */ 259169352Srrs struct sctp_net_route ro; 260169352Srrs 261163953Srrs /* mtu discovered so far */ 262163953Srrs uint32_t mtu; 263163953Srrs uint32_t ssthresh; /* not sure about this one for split */ 264218072Srrs uint32_t last_cwr_tsn; 265218072Srrs uint32_t cwr_window_tsn; 266218072Srrs uint32_t ecn_ce_pkt_cnt; 267218072Srrs uint32_t lost_cnt; 268163953Srrs /* smoothed average things for RTT and RTO itself */ 269163953Srrs int lastsa; 270163953Srrs int lastsv; 271219013Stuexen uint64_t rtt; /* last measured rtt value in us */ 272163953Srrs unsigned int RTO; 273163953Srrs 274163953Srrs /* This is used for SHUTDOWN/SHUTDOWN-ACK/SEND or INIT timers */ 275163953Srrs struct sctp_timer rxt_timer; 276163953Srrs 277163953Srrs /* last time in seconds I sent to it */ 278163953Srrs struct timeval last_sent_time; 279219057Srrs union cc_control_data { 280219057Srrs struct htcp htcp_ca; /* JRS - struct used in HTCP algorithm */ 281219120Srrs struct rtcc_cc rtcc; /* rtcc module cc stuff */ 282219057Srrs } cc_mod; 283163953Srrs int ref_count; 284163953Srrs 285163953Srrs /* Congestion stats per destination */ 286163953Srrs /* 287163953Srrs * flight size variables and such, sorry Vern, I could not avoid 288163953Srrs * this if I wanted performance :> 289163953Srrs */ 290163953Srrs uint32_t flight_size; 291163953Srrs uint32_t cwnd; /* actual cwnd */ 292163953Srrs uint32_t prev_cwnd; /* cwnd before any processing */ 293218186Srrs uint32_t ecn_prev_cwnd; /* ECN prev cwnd at first ecn_echo seen in new 294218186Srrs * window */ 295163953Srrs uint32_t partial_bytes_acked; /* in CA tracks when to incr a MTU */ 296163953Srrs /* tracking variables to avoid the aloc/free in sack processing */ 297163953Srrs unsigned int net_ack; 298163953Srrs unsigned int net_ack2; 299163953Srrs 300163953Srrs /* 301171440Srrs * JRS - 5/8/07 - Variable to track last time a destination was 302171440Srrs * active for CMT PF 303171440Srrs */ 304171440Srrs uint32_t last_active; 305171440Srrs 306171440Srrs /* 307163953Srrs * CMT variables (iyengar@cis.udel.edu) 308163953Srrs */ 309163953Srrs uint32_t this_sack_highest_newack; /* tracks highest TSN newly 310163953Srrs * acked for a given dest in 311163953Srrs * the current SACK. Used in 312163953Srrs * SFR and HTNA algos */ 313163953Srrs uint32_t pseudo_cumack; /* CMT CUC algorithm. Maintains next expected 314163953Srrs * pseudo-cumack for this destination */ 315163953Srrs uint32_t rtx_pseudo_cumack; /* CMT CUC algorithm. Maintains next 316163953Srrs * expected pseudo-cumack for this 317163953Srrs * destination */ 318163953Srrs 319163953Srrs /* CMT fast recovery variables */ 320163953Srrs uint32_t fast_recovery_tsn; 321163953Srrs uint32_t heartbeat_random1; 322163953Srrs uint32_t heartbeat_random2; 323225549Stuexen#ifdef INET6 324224870Stuexen uint32_t flowlabel; 325225549Stuexen#endif 326224870Stuexen uint8_t dscp; 327163953Srrs 328168124Srrs struct timeval start_time; /* time when this net was created */ 329168124Srrs uint32_t marked_retrans;/* number or DATA chunks marked for timer 330168124Srrs * based retransmissions */ 331168124Srrs uint32_t marked_fastretrans; 332224641Stuexen uint32_t heart_beat_delay; /* Heart Beat delay in ms */ 333168124Srrs 334163953Srrs /* if this guy is ok or not ... status */ 335163953Srrs uint16_t dest_state; 336224641Stuexen /* number of timeouts to consider the destination unreachable */ 337163953Srrs uint16_t failure_threshold; 338224641Stuexen /* number of timeouts to consider the destination potentially failed */ 339224641Stuexen uint16_t pf_threshold; 340224641Stuexen /* error stats on the destination */ 341163953Srrs uint16_t error_count; 342179157Srrs /* UDP port number in case of UDP tunneling */ 343179157Srrs uint16_t port; 344163953Srrs 345163953Srrs uint8_t fast_retran_loss_recovery; 346163953Srrs uint8_t will_exit_fast_recovery; 347163953Srrs /* Flags that probably can be combined into dest_state */ 348163953Srrs uint8_t fast_retran_ip; /* fast retransmit in progress */ 349163953Srrs uint8_t hb_responded; 350163953Srrs uint8_t saw_newack; /* CMT's SFR algorithm flag */ 351163953Srrs uint8_t src_addr_selected; /* if we split we move */ 352163953Srrs uint8_t indx_of_eligible_next_to_use; 353163953Srrs uint8_t addr_is_local; /* its a local address (if known) could move 354163953Srrs * in split */ 355163953Srrs 356163953Srrs /* 357163953Srrs * CMT variables (iyengar@cis.udel.edu) 358163953Srrs */ 359163953Srrs uint8_t find_pseudo_cumack; /* CMT CUC algorithm. Flag used to 360163953Srrs * find a new pseudocumack. This flag 361163953Srrs * is set after a new pseudo-cumack 362163953Srrs * has been received and indicates 363163953Srrs * that the sender should find the 364163953Srrs * next pseudo-cumack expected for 365163953Srrs * this destination */ 366163953Srrs uint8_t find_rtx_pseudo_cumack; /* CMT CUCv2 algorithm. Flag used to 367163953Srrs * find a new rtx-pseudocumack. This 368163953Srrs * flag is set after a new 369163953Srrs * rtx-pseudo-cumack has been received 370163953Srrs * and indicates that the sender 371163953Srrs * should find the next 372163953Srrs * rtx-pseudo-cumack expected for this 373163953Srrs * destination */ 374163953Srrs uint8_t new_pseudo_cumack; /* CMT CUC algorithm. Flag used to 375163953Srrs * indicate if a new pseudo-cumack or 376163953Srrs * rtx-pseudo-cumack has been received */ 377168124Srrs uint8_t window_probe; /* Doing a window probe? */ 378170642Srrs uint8_t RTO_measured; /* Have we done the first measure */ 379163953Srrs uint8_t last_hs_used; /* index into the last HS table entry we used */ 380218186Srrs uint8_t lan_type; 381219397Srrs uint8_t rto_needed; 382218335Stuexen uint32_t flowid; 383218400Stuexen#ifdef INVARIANTS 384218392Srrs uint8_t flowidset; 385218400Stuexen#endif 386163953Srrs}; 387163953Srrs 388163953Srrs 389163953Srrsstruct sctp_data_chunkrec { 390163953Srrs uint32_t TSN_seq; /* the TSN of this transmit */ 391163953Srrs uint16_t stream_seq; /* the stream sequence number of this transmit */ 392163953Srrs uint16_t stream_number; /* the stream number of this guy */ 393163953Srrs uint32_t payloadtype; 394163953Srrs uint32_t context; /* from send */ 395218186Srrs uint32_t cwnd_at_send; 396163953Srrs /* 397163953Srrs * part of the Highest sacked algorithm to be able to stroke counts 398163953Srrs * on ones that are FR'd. 399163953Srrs */ 400163953Srrs uint32_t fast_retran_tsn; /* sending_seq at the time of FR */ 401163953Srrs struct timeval timetodrop; /* time we drop it from queue */ 402163953Srrs uint8_t doing_fast_retransmit; 403163953Srrs uint8_t rcv_flags; /* flags pulled from data chunk on inbound for 404165220Srrs * outbound holds sending flags for PR-SCTP. */ 405163953Srrs uint8_t state_flags; 406163953Srrs uint8_t chunk_was_revoked; 407218186Srrs uint8_t fwd_tsn_cnt; 408163953Srrs}; 409163953Srrs 410163953SrrsTAILQ_HEAD(sctpchunk_listhead, sctp_tmit_chunk); 411163953Srrs 412163953Srrs/* The lower byte is used to enumerate PR_SCTP policies */ 413163953Srrs#define CHUNK_FLAGS_PR_SCTP_TTL SCTP_PR_SCTP_TTL 414163953Srrs#define CHUNK_FLAGS_PR_SCTP_BUF SCTP_PR_SCTP_BUF 415163953Srrs#define CHUNK_FLAGS_PR_SCTP_RTX SCTP_PR_SCTP_RTX 416163953Srrs 417231310Stuexen/* The upper byte is used as a bit mask */ 418163953Srrs#define CHUNK_FLAGS_FRAGMENT_OK 0x0100 419163953Srrs 420163953Srrsstruct chk_id { 421163953Srrs uint16_t id; 422163953Srrs uint16_t can_take_data; 423163953Srrs}; 424163953Srrs 425163953Srrs 426163953Srrsstruct sctp_tmit_chunk { 427163953Srrs union { 428163953Srrs struct sctp_data_chunkrec data; 429163953Srrs struct chk_id chunk_id; 430163953Srrs } rec; 431163953Srrs struct sctp_association *asoc; /* bp to asoc this belongs to */ 432163953Srrs struct timeval sent_rcv_time; /* filled in if RTT being calculated */ 433163953Srrs struct mbuf *data; /* pointer to mbuf chain of data */ 434163953Srrs struct mbuf *last_mbuf; /* pointer to last mbuf in chain */ 435163953Srrs struct sctp_nets *whoTo; 436163953Srrs TAILQ_ENTRY(sctp_tmit_chunk) sctp_next; /* next link */ 437163953Srrs int32_t sent; /* the send status */ 438163953Srrs uint16_t snd_count; /* number of times I sent */ 439163953Srrs uint16_t flags; /* flags, such as FRAGMENT_OK */ 440163953Srrs uint16_t send_size; 441163953Srrs uint16_t book_size; 442163953Srrs uint16_t mbcnt; 443185694Srrs uint16_t auth_keyid; 444185694Srrs uint8_t holds_key_ref; /* flag if auth keyid refcount is held */ 445163953Srrs uint8_t pad_inplace; 446163953Srrs uint8_t do_rtt; 447163953Srrs uint8_t book_size_scale; 448163953Srrs uint8_t no_fr_allowed; 449163953Srrs uint8_t copy_by_ref; 450168124Srrs uint8_t window_probe; 451163953Srrs}; 452163953Srrs 453163953Srrs/* 454163953Srrs * The first part of this structure MUST be the entire sinfo structure. Maybe 455163953Srrs * I should have made it a sub structure... we can circle back later and do 456163953Srrs * that if we want. 457163953Srrs */ 458163953Srrsstruct sctp_queued_to_read { /* sinfo structure Pluse more */ 459163953Srrs uint16_t sinfo_stream; /* off the wire */ 460163953Srrs uint16_t sinfo_ssn; /* off the wire */ 461163953Srrs uint16_t sinfo_flags; /* SCTP_UNORDERED from wire use SCTP_EOF for 462163953Srrs * EOR */ 463163953Srrs uint32_t sinfo_ppid; /* off the wire */ 464163953Srrs uint32_t sinfo_context; /* pick this up from assoc def context? */ 465163953Srrs uint32_t sinfo_timetolive; /* not used by kernel */ 466163953Srrs uint32_t sinfo_tsn; /* Use this in reassembly as first TSN */ 467163953Srrs uint32_t sinfo_cumtsn; /* Use this in reassembly as last TSN */ 468163953Srrs sctp_assoc_t sinfo_assoc_id; /* our assoc id */ 469163953Srrs /* Non sinfo stuff */ 470163953Srrs uint32_t length; /* length of data */ 471163953Srrs uint32_t held_length; /* length held in sb */ 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; 480163953Srrs uint16_t port_from; 481165647Srrs uint16_t spec_flags; /* Flags to hold the notification field */ 482163953Srrs uint8_t do_not_ref_stcb; 483163953Srrs uint8_t end_added; 484164085Srrs uint8_t pdapi_aborted; 485168943Srrs uint8_t some_taken; 486163953Srrs}; 487163953Srrs 488163953Srrs/* This data structure will be on the outbound 489163953Srrs * stream queues. Data will be pulled off from 490163953Srrs * the front of the mbuf data and chunk-ified 491163953Srrs * by the output routines. We will custom 492163953Srrs * fit every chunk we pull to the send/sent 493163953Srrs * queue to make up the next full packet 494163953Srrs * if we can. An entry cannot be removed 495163953Srrs * from the stream_out queue until 496163953Srrs * the msg_is_complete flag is set. This 497163953Srrs * means at times data/tail_mbuf MIGHT 498163953Srrs * be NULL.. If that occurs it happens 499163953Srrs * for one of two reasons. Either the user 500163953Srrs * is blocked on a send() call and has not 501163953Srrs * awoken to copy more data down... OR 502163953Srrs * the user is in the explict MSG_EOR mode 503163953Srrs * and wrote some data, but has not completed 504163953Srrs * sending. 505163953Srrs */ 506163953Srrsstruct sctp_stream_queue_pending { 507163953Srrs struct mbuf *data; 508163953Srrs struct mbuf *tail_mbuf; 509163953Srrs struct timeval ts; 510163953Srrs struct sctp_nets *net; 511163953Srrs TAILQ_ENTRY(sctp_stream_queue_pending) next; 512218241Stuexen TAILQ_ENTRY(sctp_stream_queue_pending) ss_next; 513163953Srrs uint32_t length; 514163953Srrs uint32_t timetolive; 515163953Srrs uint32_t ppid; 516163953Srrs uint32_t context; 517163953Srrs uint16_t sinfo_flags; 518163953Srrs uint16_t stream; 519165220Srrs uint16_t act_flags; 520185694Srrs uint16_t auth_keyid; 521185694Srrs uint8_t holds_key_ref; 522163953Srrs uint8_t msg_is_complete; 523163953Srrs uint8_t some_taken; 524168755Srrs uint8_t sender_all_done; 525168859Srrs uint8_t put_last_out; 526189836Srrs uint8_t discard_rest; 527163953Srrs}; 528163953Srrs 529163953Srrs/* 530163953Srrs * this struct contains info that is used to track inbound stream data and 531163953Srrs * help with ordering. 532163953Srrs */ 533163953SrrsTAILQ_HEAD(sctpwheelunrel_listhead, sctp_stream_in); 534163953Srrsstruct sctp_stream_in { 535163953Srrs struct sctp_readhead inqueue; 536163953Srrs uint16_t stream_no; 537163953Srrs uint16_t last_sequence_delivered; /* used for re-order */ 538168943Srrs uint8_t delivery_started; 539163953Srrs}; 540163953Srrs 541217760StuexenTAILQ_HEAD(sctpwheel_listhead, sctp_stream_out); 542217760StuexenTAILQ_HEAD(sctplist_listhead, sctp_stream_queue_pending); 543217760Stuexen 544217760Stuexen/* Round-robin schedulers */ 545217760Stuexenstruct ss_rr { 546217760Stuexen /* next link in wheel */ 547217760Stuexen TAILQ_ENTRY(sctp_stream_out) next_spoke; 548217760Stuexen}; 549217760Stuexen 550217760Stuexen/* Priority scheduler */ 551217760Stuexenstruct ss_prio { 552217760Stuexen /* next link in wheel */ 553217760Stuexen TAILQ_ENTRY(sctp_stream_out) next_spoke; 554217760Stuexen /* priority id */ 555217760Stuexen uint16_t priority; 556217760Stuexen}; 557217760Stuexen 558217760Stuexen/* Fair Bandwidth scheduler */ 559217760Stuexenstruct ss_fb { 560217760Stuexen /* next link in wheel */ 561217760Stuexen TAILQ_ENTRY(sctp_stream_out) next_spoke; 562217760Stuexen /* stores message size */ 563217760Stuexen int32_t rounds; 564217760Stuexen}; 565217760Stuexen 566217760Stuexen/* 567217760Stuexen * This union holds all data necessary for 568217760Stuexen * different stream schedulers. 569217760Stuexen */ 570217760Stuexenunion scheduling_data { 571217760Stuexen struct sctpwheel_listhead out_wheel; 572217760Stuexen struct sctplist_listhead out_list; 573217760Stuexen}; 574217760Stuexen 575217760Stuexen/* 576217760Stuexen * This union holds all parameters per stream 577217760Stuexen * necessary for different stream schedulers. 578217760Stuexen */ 579217760Stuexenunion scheduling_parameters { 580217760Stuexen struct ss_rr rr; 581217760Stuexen struct ss_prio prio; 582217760Stuexen struct ss_fb fb; 583217760Stuexen}; 584217760Stuexen 585163953Srrs/* This struct is used to track the traffic on outbound streams */ 586163953Srrsstruct sctp_stream_out { 587163953Srrs struct sctp_streamhead outqueue; 588217760Stuexen union scheduling_parameters ss_params; 589252942Stuexen uint32_t chunks_on_queues; 590163953Srrs uint16_t stream_no; 591252940Stuexen uint16_t next_sequence_send; /* next one I expect to send out */ 592163953Srrs uint8_t last_msg_incomplete; 593163953Srrs}; 594163953Srrs 595163953Srrs/* used to keep track of the addresses yet to try to add/delete */ 596163953SrrsTAILQ_HEAD(sctp_asconf_addrhead, sctp_asconf_addr); 597163953Srrsstruct sctp_asconf_addr { 598163953Srrs TAILQ_ENTRY(sctp_asconf_addr) next; 599163953Srrs struct sctp_asconf_addr_param ap; 600167598Srrs struct sctp_ifa *ifa; /* save the ifa for add/del ip */ 601163953Srrs uint8_t sent; /* has this been sent yet? */ 602185694Srrs uint8_t special_del; /* not to be used in lookup */ 603163953Srrs}; 604163953Srrs 605163953Srrsstruct sctp_scoping { 606163953Srrs uint8_t ipv4_addr_legal; 607163953Srrs uint8_t ipv6_addr_legal; 608163953Srrs uint8_t loopback_scope; 609163953Srrs uint8_t ipv4_local_scope; 610163953Srrs uint8_t local_scope; 611163953Srrs uint8_t site_scope; 612163953Srrs}; 613163953Srrs 614166675Srrs#define SCTP_TSN_LOG_SIZE 40 615166675Srrs 616166675Srrsstruct sctp_tsn_log { 617171477Srrs void *stcb; 618166675Srrs uint32_t tsn; 619166675Srrs uint16_t strm; 620166675Srrs uint16_t seq; 621168859Srrs uint16_t sz; 622168859Srrs uint16_t flgs; 623171477Srrs uint16_t in_pos; 624171477Srrs uint16_t in_out; 625166675Srrs}; 626166675Srrs 627171440Srrs#define SCTP_FS_SPEC_LOG_SIZE 200 628171440Srrsstruct sctp_fs_spec_log { 629171440Srrs uint32_t sent; 630171440Srrs uint32_t total_flight; 631171440Srrs uint32_t tsn; 632171440Srrs uint16_t book; 633171440Srrs uint8_t incr; 634171440Srrs uint8_t decr; 635171440Srrs}; 636170056Srrs 637170056Srrs/* This struct is here to cut out the compatiabilty 638170056Srrs * pad that bulks up both the inp and stcb. The non 639170056Srrs * pad portion MUST stay in complete sync with 640170056Srrs * sctp_sndrcvinfo... i.e. if sinfo_xxxx is added 641170056Srrs * this must be done here too. 642170056Srrs */ 643170056Srrsstruct sctp_nonpad_sndrcvinfo { 644170056Srrs uint16_t sinfo_stream; 645170056Srrs uint16_t sinfo_ssn; 646170056Srrs uint16_t sinfo_flags; 647170056Srrs uint32_t sinfo_ppid; 648170056Srrs uint32_t sinfo_context; 649170056Srrs uint32_t sinfo_timetolive; 650170056Srrs uint32_t sinfo_tsn; 651170056Srrs uint32_t sinfo_cumtsn; 652170056Srrs sctp_assoc_t sinfo_assoc_id; 653223132Stuexen uint16_t sinfo_keynumber; 654223132Stuexen uint16_t sinfo_keynumber_valid; 655170056Srrs}; 656170056Srrs 657163953Srrs/* 658171440Srrs * JRS - Structure to hold function pointers to the functions responsible 659171440Srrs * for congestion control. 660171440Srrs */ 661171440Srrs 662171440Srrsstruct sctp_cc_functions { 663171440Srrs void (*sctp_set_initial_cc_param) (struct sctp_tcb *stcb, struct sctp_nets *net); 664171440Srrs void (*sctp_cwnd_update_after_sack) (struct sctp_tcb *stcb, 665171440Srrs struct sctp_association *asoc, 666171440Srrs int accum_moved, int reneged_all, int will_exit); 667224641Stuexen void (*sctp_cwnd_update_exit_pf) (struct sctp_tcb *stcb, struct sctp_nets *net); 668171440Srrs void (*sctp_cwnd_update_after_fr) (struct sctp_tcb *stcb, 669171440Srrs struct sctp_association *asoc); 670171440Srrs void (*sctp_cwnd_update_after_timeout) (struct sctp_tcb *stcb, 671171440Srrs struct sctp_nets *net); 672171440Srrs void (*sctp_cwnd_update_after_ecn_echo) (struct sctp_tcb *stcb, 673218129Srrs struct sctp_nets *net, int in_window, int num_pkt_lost); 674171440Srrs void (*sctp_cwnd_update_after_packet_dropped) (struct sctp_tcb *stcb, 675171440Srrs struct sctp_nets *net, struct sctp_pktdrop_chunk *cp, 676171440Srrs uint32_t * bottle_bw, uint32_t * on_queue); 677171440Srrs void (*sctp_cwnd_update_after_output) (struct sctp_tcb *stcb, 678171440Srrs struct sctp_nets *net, int burst_limit); 679219057Srrs void (*sctp_cwnd_update_packet_transmitted) (struct sctp_tcb *stcb, 680219057Srrs struct sctp_nets *net); 681219057Srrs void (*sctp_cwnd_update_tsn_acknowledged) (struct sctp_nets *net, 682219057Srrs struct sctp_tmit_chunk *); 683219057Srrs void (*sctp_cwnd_new_transmission_begins) (struct sctp_tcb *stcb, 684219057Srrs struct sctp_nets *net); 685219057Srrs void (*sctp_cwnd_prepare_net_for_sack) (struct sctp_tcb *stcb, 686219057Srrs struct sctp_nets *net); 687219057Srrs int (*sctp_cwnd_socket_option) (struct sctp_tcb *stcb, int set, struct sctp_cc_option *); 688219397Srrs void (*sctp_rtt_calculated) (struct sctp_tcb *, struct sctp_nets *, struct timeval *); 689171440Srrs}; 690171440Srrs 691217760Stuexen/* 692217760Stuexen * RS - Structure to hold function pointers to the functions responsible 693217760Stuexen * for stream scheduling. 694217760Stuexen */ 695217760Stuexenstruct sctp_ss_functions { 696217760Stuexen void (*sctp_ss_init) (struct sctp_tcb *stcb, struct sctp_association *asoc, 697217760Stuexen int holds_lock); 698217760Stuexen void (*sctp_ss_clear) (struct sctp_tcb *stcb, struct sctp_association *asoc, 699217760Stuexen int clear_values, int holds_lock); 700218241Stuexen void (*sctp_ss_init_stream) (struct sctp_stream_out *strq, struct sctp_stream_out *with_strq); 701217760Stuexen void (*sctp_ss_add_to_stream) (struct sctp_tcb *stcb, struct sctp_association *asoc, 702217760Stuexen struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, int holds_lock); 703217760Stuexen int (*sctp_ss_is_empty) (struct sctp_tcb *stcb, struct sctp_association *asoc); 704217760Stuexen void (*sctp_ss_remove_from_stream) (struct sctp_tcb *stcb, struct sctp_association *asoc, 705217760Stuexen struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, int holds_lock); 706217760Stuexen struct sctp_stream_out *(*sctp_ss_select_stream) (struct sctp_tcb *stcb, 707217760Stuexen struct sctp_nets *net, struct sctp_association *asoc); 708217760Stuexen void (*sctp_ss_scheduled) (struct sctp_tcb *stcb, struct sctp_nets *net, 709217760Stuexen struct sctp_association *asoc, struct sctp_stream_out *strq, int moved_how_much); 710217760Stuexen void (*sctp_ss_packet_done) (struct sctp_tcb *stcb, struct sctp_nets *net, 711217760Stuexen struct sctp_association *asoc); 712217760Stuexen int (*sctp_ss_get_value) (struct sctp_tcb *stcb, struct sctp_association *asoc, 713217760Stuexen struct sctp_stream_out *strq, uint16_t * value); 714217760Stuexen int (*sctp_ss_set_value) (struct sctp_tcb *stcb, struct sctp_association *asoc, 715217760Stuexen struct sctp_stream_out *strq, uint16_t value); 716217760Stuexen}; 717217760Stuexen 718179157Srrs/* used to save ASCONF chunks for retransmission */ 719179157SrrsTAILQ_HEAD(sctp_asconf_head, sctp_asconf); 720179157Srrsstruct sctp_asconf { 721179157Srrs TAILQ_ENTRY(sctp_asconf) next; 722179157Srrs uint32_t serial_number; 723179157Srrs uint16_t snd_count; 724179157Srrs struct mbuf *data; 725179157Srrs uint16_t len; 726179157Srrs}; 727179157Srrs 728171990Srrs/* used to save ASCONF-ACK chunks for retransmission */ 729171990SrrsTAILQ_HEAD(sctp_asconf_ackhead, sctp_asconf_ack); 730171990Srrsstruct sctp_asconf_ack { 731171990Srrs TAILQ_ENTRY(sctp_asconf_ack) next; 732171990Srrs uint32_t serial_number; 733171990Srrs struct sctp_nets *last_sent_to; 734171990Srrs struct mbuf *data; 735171990Srrs uint16_t len; 736171990Srrs}; 737171990Srrs 738171440Srrs/* 739163953Srrs * Here we have information about each individual association that we track. 740163953Srrs * We probably in production would be more dynamic. But for ease of 741163953Srrs * implementation we will have a fixed array that we hunt for in a linear 742163953Srrs * fashion. 743163953Srrs */ 744163953Srrsstruct sctp_association { 745163953Srrs /* association state */ 746163953Srrs int state; 747171572Srrs 748163953Srrs /* queue of pending addrs to add/delete */ 749163953Srrs struct sctp_asconf_addrhead asconf_queue; 750171572Srrs 751163953Srrs struct timeval time_entered; /* time we entered state */ 752163953Srrs struct timeval time_last_rcvd; 753163953Srrs struct timeval time_last_sent; 754163953Srrs struct timeval time_last_sat_advance; 755170056Srrs struct sctp_nonpad_sndrcvinfo def_send; 756163953Srrs 757163953Srrs /* timers and such */ 758163953Srrs struct sctp_timer dack_timer; /* Delayed ack timer */ 759171572Srrs struct sctp_timer asconf_timer; /* asconf */ 760163953Srrs struct sctp_timer strreset_timer; /* stream reset */ 761171572Srrs struct sctp_timer shut_guard_timer; /* shutdown guard */ 762163953Srrs struct sctp_timer autoclose_timer; /* automatic close timer */ 763163953Srrs struct sctp_timer delayed_event_timer; /* timer for delayed events */ 764172091Srrs struct sctp_timer delete_prim_timer; /* deleting primary dst */ 765163953Srrs 766171572Srrs /* list of restricted local addresses */ 767167598Srrs struct sctpladdr sctp_restricted_addrs; 768167598Srrs 769171572Srrs /* last local address pending deletion (waiting for an address add) */ 770171572Srrs struct sctp_ifa *asconf_addr_del_pending; 771172091Srrs /* Deleted primary destination (used to stop timer) */ 772172091Srrs struct sctp_nets *deleted_primary; 773163953Srrs 774171572Srrs struct sctpnetlisthead nets; /* remote address list */ 775171572Srrs 776163953Srrs /* Free chunk list */ 777163953Srrs struct sctpchunk_listhead free_chunks; 778163953Srrs 779163953Srrs /* Control chunk queue */ 780163953Srrs struct sctpchunk_listhead control_send_queue; 781163953Srrs 782179157Srrs /* ASCONF chunk queue */ 783179157Srrs struct sctpchunk_listhead asconf_send_queue; 784179157Srrs 785163953Srrs /* 786163953Srrs * Once a TSN hits the wire it is moved to the sent_queue. We 787163953Srrs * maintain two counts here (don't know if any but retran_cnt is 788163953Srrs * needed). The idea is that the sent_queue_retran_cnt reflects how 789163953Srrs * many chunks have been marked for retranmission by either T3-rxt 790163953Srrs * or FR. 791163953Srrs */ 792163953Srrs struct sctpchunk_listhead sent_queue; 793163953Srrs struct sctpchunk_listhead send_queue; 794163953Srrs 795163953Srrs /* re-assembly queue for fragmented chunks on the inbound path */ 796163953Srrs struct sctpchunk_listhead reasmqueue; 797163953Srrs 798218241Stuexen /* Scheduling queues */ 799217760Stuexen union scheduling_data ss_data; 800163953Srrs 801163953Srrs /* 802163953Srrs * This pointer will be set to NULL most of the time. But when we 803163953Srrs * have a fragmented message, where we could not get out all of the 804163953Srrs * message at the last send then this will point to the stream to go 805163953Srrs * get data from. 806163953Srrs */ 807163953Srrs struct sctp_stream_out *locked_on_sending; 808163953Srrs 809163953Srrs /* If an iterator is looking at me, this is it */ 810163953Srrs struct sctp_iterator *stcb_starting_point_for_iterator; 811163953Srrs 812163953Srrs /* ASCONF save the last ASCONF-ACK so we can resend it if necessary */ 813171990Srrs struct sctp_asconf_ackhead asconf_ack_sent; 814163953Srrs 815163953Srrs /* 816163953Srrs * pointer to last stream reset queued to control queue by us with 817163953Srrs * requests. 818163953Srrs */ 819163953Srrs struct sctp_tmit_chunk *str_reset; 820163953Srrs /* 821163953Srrs * if Source Address Selection happening, this will rotate through 822163953Srrs * the link list. 823163953Srrs */ 824163953Srrs struct sctp_laddr *last_used_address; 825163953Srrs 826163953Srrs /* stream arrays */ 827163953Srrs struct sctp_stream_in *strmin; 828163953Srrs struct sctp_stream_out *strmout; 829163953Srrs uint8_t *mapping_array; 830163953Srrs /* primary destination to use */ 831163953Srrs struct sctp_nets *primary_destination; 832224641Stuexen struct sctp_nets *alternate; /* If primary is down or PF */ 833163953Srrs /* For CMT */ 834190689Srrs struct sctp_nets *last_net_cmt_send_started; 835163953Srrs /* last place I got a data chunk from */ 836163953Srrs struct sctp_nets *last_data_chunk_from; 837163953Srrs /* last place I got a control from */ 838163953Srrs struct sctp_nets *last_control_chunk_from; 839163953Srrs 840163953Srrs /* circular looking for output selection */ 841163953Srrs struct sctp_stream_out *last_out_stream; 842163953Srrs 843163953Srrs /* 844163953Srrs * wait to the point the cum-ack passes req->send_reset_at_tsn for 845163953Srrs * any req on the list. 846163953Srrs */ 847163953Srrs struct sctp_resethead resetHead; 848163953Srrs 849163953Srrs /* queue of chunks waiting to be sent into the local stack */ 850163953Srrs struct sctp_readhead pending_reply_queue; 851163953Srrs 852171440Srrs /* JRS - the congestion control functions are in this struct */ 853171440Srrs struct sctp_cc_functions cc_functions; 854171440Srrs /* 855171440Srrs * JRS - value to store the currently loaded congestion control 856171440Srrs * module 857171440Srrs */ 858171440Srrs uint32_t congestion_control_module; 859217760Stuexen /* RS - the stream scheduling functions are in this struct */ 860217760Stuexen struct sctp_ss_functions ss_functions; 861217760Stuexen /* RS - value to store the currently loaded stream scheduling module */ 862217760Stuexen uint32_t stream_scheduling_module; 863171440Srrs 864167598Srrs uint32_t vrf_id; 865167598Srrs 866163953Srrs uint32_t cookie_preserve_req; 867163953Srrs /* ASCONF next seq I am sending out, inits at init-tsn */ 868163953Srrs uint32_t asconf_seq_out; 869179157Srrs uint32_t asconf_seq_out_acked; 870163953Srrs /* ASCONF last received ASCONF from peer, starts at peer's TSN-1 */ 871163953Srrs uint32_t asconf_seq_in; 872163953Srrs 873163953Srrs /* next seq I am sending in str reset messages */ 874163953Srrs uint32_t str_reset_seq_out; 875163953Srrs /* next seq I am expecting in str reset messages */ 876163953Srrs uint32_t str_reset_seq_in; 877163953Srrs 878163953Srrs /* various verification tag information */ 879163953Srrs uint32_t my_vtag; /* The tag to be used. if assoc is re-initited 880163953Srrs * by remote end, and I have unlocked this 881163953Srrs * will be regenerated to a new random value. */ 882163953Srrs uint32_t peer_vtag; /* The peers last tag */ 883163953Srrs 884163953Srrs uint32_t my_vtag_nonce; 885163953Srrs uint32_t peer_vtag_nonce; 886163953Srrs 887163953Srrs uint32_t assoc_id; 888163953Srrs 889163953Srrs /* This is the SCTP fragmentation threshold */ 890163953Srrs uint32_t smallest_mtu; 891163953Srrs 892163953Srrs /* 893163953Srrs * Special hook for Fast retransmit, allows us to track the highest 894163953Srrs * TSN that is NEW in this SACK if gap ack blocks are present. 895163953Srrs */ 896163953Srrs uint32_t this_sack_highest_gap; 897163953Srrs 898163953Srrs /* 899163953Srrs * The highest consecutive TSN that has been acked by peer on my 900163953Srrs * sends 901163953Srrs */ 902163953Srrs uint32_t last_acked_seq; 903163953Srrs 904163953Srrs /* The next TSN that I will use in sending. */ 905163953Srrs uint32_t sending_seq; 906163953Srrs 907163953Srrs /* Original seq number I used ??questionable to keep?? */ 908163953Srrs uint32_t init_seq_number; 909163953Srrs 910163953Srrs 911163953Srrs /* The Advanced Peer Ack Point, as required by the PR-SCTP */ 912163953Srrs /* (A1 in Section 4.2) */ 913163953Srrs uint32_t advanced_peer_ack_point; 914163953Srrs 915163953Srrs /* 916163953Srrs * The highest consequetive TSN at the bottom of the mapping array 917163953Srrs * (for his sends). 918163953Srrs */ 919163953Srrs uint32_t cumulative_tsn; 920163953Srrs /* 921163953Srrs * Used to track the mapping array and its offset bits. This MAY be 922163953Srrs * lower then cumulative_tsn. 923163953Srrs */ 924163953Srrs uint32_t mapping_array_base_tsn; 925163953Srrs /* 926163953Srrs * used to track highest TSN we have received and is listed in the 927163953Srrs * mapping array. 928163953Srrs */ 929163953Srrs uint32_t highest_tsn_inside_map; 930163953Srrs 931185694Srrs /* EY - new NR variables used for nr_sack based on mapping_array */ 932185694Srrs uint8_t *nr_mapping_array; 933185694Srrs uint32_t highest_tsn_inside_nr_map; 934185694Srrs 935163953Srrs uint32_t fast_recovery_tsn; 936163953Srrs uint32_t sat_t3_recovery_tsn; 937163953Srrs uint32_t tsn_last_delivered; 938163953Srrs /* 939163953Srrs * For the pd-api we should re-write this a bit more efficent. We 940163953Srrs * could have multiple sctp_queued_to_read's that we are building at 941163953Srrs * once. Now we only do this when we get ready to deliver to the 942163953Srrs * socket buffer. Note that we depend on the fact that the struct is 943163953Srrs * "stuck" on the read queue until we finish all the pd-api. 944163953Srrs */ 945163953Srrs struct sctp_queued_to_read *control_pdapi; 946163953Srrs 947163953Srrs uint32_t tsn_of_pdapi_last_delivered; 948163953Srrs uint32_t pdapi_ppid; 949163953Srrs uint32_t context; 950163953Srrs uint32_t last_reset_action[SCTP_MAX_RESET_PARAMS]; 951163953Srrs uint32_t last_sending_seq[SCTP_MAX_RESET_PARAMS]; 952163953Srrs uint32_t last_base_tsnsent[SCTP_MAX_RESET_PARAMS]; 953166675Srrs#ifdef SCTP_ASOCLOG_OF_TSNS 954163953Srrs /* 955166675Srrs * special log - This adds considerable size to the asoc, but 956166675Srrs * provides a log that you can use to detect problems via kgdb. 957166675Srrs */ 958166675Srrs struct sctp_tsn_log in_tsnlog[SCTP_TSN_LOG_SIZE]; 959166675Srrs struct sctp_tsn_log out_tsnlog[SCTP_TSN_LOG_SIZE]; 960171477Srrs uint32_t cumack_log[SCTP_TSN_LOG_SIZE]; 961172703Srrs uint32_t cumack_logsnt[SCTP_TSN_LOG_SIZE]; 962166675Srrs uint16_t tsn_in_at; 963166675Srrs uint16_t tsn_out_at; 964168859Srrs uint16_t tsn_in_wrapped; 965168859Srrs uint16_t tsn_out_wrapped; 966171477Srrs uint16_t cumack_log_at; 967172703Srrs uint16_t cumack_log_atsnt; 968166675Srrs#endif /* SCTP_ASOCLOG_OF_TSNS */ 969171440Srrs#ifdef SCTP_FS_SPEC_LOG 970171440Srrs struct sctp_fs_spec_log fslog[SCTP_FS_SPEC_LOG_SIZE]; 971171440Srrs uint16_t fs_index; 972171440Srrs#endif 973171440Srrs 974166675Srrs /* 975163953Srrs * window state information and smallest MTU that I use to bound 976163953Srrs * segmentation 977163953Srrs */ 978163953Srrs uint32_t peers_rwnd; 979163953Srrs uint32_t my_rwnd; 980163953Srrs uint32_t my_last_reported_rwnd; 981170056Srrs uint32_t sctp_frag_point; 982163953Srrs 983163953Srrs uint32_t total_output_queue_size; 984163953Srrs 985171943Srrs uint32_t sb_cc; /* shadow of sb_cc */ 986174257Srrs uint32_t sb_send_resv; /* amount reserved on a send */ 987171943Srrs uint32_t my_rwnd_control_len; /* shadow of sb_mbcnt used for rwnd 988171943Srrs * control */ 989225549Stuexen#ifdef INET6 990163953Srrs uint32_t default_flowlabel; 991225549Stuexen#endif 992163953Srrs uint32_t pr_sctp_cnt; 993218129Srrs int ctrl_queue_cnt; /* could be removed REM - NO IT CAN'T!! RRS */ 994163953Srrs /* 995163953Srrs * All outbound datagrams queue into this list from the individual 996163953Srrs * stream queue. Here they get assigned a TSN and then await 997163953Srrs * sending. The stream seq comes when it is first put in the 998163953Srrs * individual str queue 999163953Srrs */ 1000163953Srrs unsigned int stream_queue_cnt; 1001163953Srrs unsigned int send_queue_cnt; 1002163953Srrs unsigned int sent_queue_cnt; 1003163953Srrs unsigned int sent_queue_cnt_removeable; 1004163953Srrs /* 1005163953Srrs * Number on sent queue that are marked for retran until this value 1006163953Srrs * is 0 we only send one packet of retran'ed data. 1007163953Srrs */ 1008163953Srrs unsigned int sent_queue_retran_cnt; 1009163953Srrs 1010163953Srrs unsigned int size_on_reasm_queue; 1011163953Srrs unsigned int cnt_on_reasm_queue; 1012210599Srrs unsigned int fwd_tsn_cnt; 1013163953Srrs /* amount of data (bytes) currently in flight (on all destinations) */ 1014163953Srrs unsigned int total_flight; 1015163953Srrs /* Total book size in flight */ 1016163953Srrs unsigned int total_flight_count; /* count of chunks used with 1017163953Srrs * book total */ 1018163953Srrs /* count of destinaton nets and list of destination nets */ 1019163953Srrs unsigned int numnets; 1020163953Srrs 1021163953Srrs /* Total error count on this association */ 1022163953Srrs unsigned int overall_error_count; 1023163953Srrs 1024163953Srrs unsigned int cnt_msg_on_sb; 1025163953Srrs 1026163953Srrs /* All stream count of chunks for delivery */ 1027163953Srrs unsigned int size_on_all_streams; 1028163953Srrs unsigned int cnt_on_all_streams; 1029163953Srrs 1030224641Stuexen /* Heart Beat delay in ms */ 1031224641Stuexen uint32_t heart_beat_delay; 1032163953Srrs 1033163953Srrs /* autoclose */ 1034163953Srrs unsigned int sctp_autoclose_ticks; 1035163953Srrs 1036163953Srrs /* how many preopen streams we have */ 1037163953Srrs unsigned int pre_open_streams; 1038163953Srrs 1039163953Srrs /* How many streams I support coming into me */ 1040163953Srrs unsigned int max_inbound_streams; 1041163953Srrs 1042163953Srrs /* the cookie life I award for any cookie, in seconds */ 1043163953Srrs unsigned int cookie_life; 1044163953Srrs /* time to delay acks for */ 1045163953Srrs unsigned int delayed_ack; 1046167598Srrs unsigned int old_delayed_ack; 1047167598Srrs unsigned int sack_freq; 1048167598Srrs unsigned int data_pkts_seen; 1049163953Srrs 1050163953Srrs unsigned int numduptsns; 1051163953Srrs int dup_tsns[SCTP_MAX_DUP_TSNS]; 1052163953Srrs unsigned int initial_init_rto_max; /* initial RTO for INIT's */ 1053163953Srrs unsigned int initial_rto; /* initial send RTO */ 1054163953Srrs unsigned int minrto; /* per assoc RTO-MIN */ 1055163953Srrs unsigned int maxrto; /* per assoc RTO-MAX */ 1056163953Srrs 1057163953Srrs /* authentication fields */ 1058163953Srrs sctp_auth_chklist_t *local_auth_chunks; 1059163953Srrs sctp_auth_chklist_t *peer_auth_chunks; 1060163953Srrs sctp_hmaclist_t *local_hmacs; /* local HMACs supported */ 1061163953Srrs sctp_hmaclist_t *peer_hmacs; /* peer HMACs supported */ 1062163953Srrs struct sctp_keyhead shared_keys; /* assoc's shared keys */ 1063163953Srrs sctp_authinfo_t authinfo; /* randoms, cached keys */ 1064163953Srrs /* 1065163953Srrs * refcnt to block freeing when a sender or receiver is off coping 1066163953Srrs * user data in. 1067163953Srrs */ 1068163996Srrs uint32_t refcnt; 1069163996Srrs uint32_t chunks_on_out_queue; /* total chunks floating around, 1070163996Srrs * locked by send socket buffer */ 1071171990Srrs uint32_t peers_adaptation; 1072163996Srrs uint16_t peer_hmac_id; /* peer HMAC id to send */ 1073163996Srrs 1074163953Srrs /* 1075163953Srrs * Being that we have no bag to collect stale cookies, and that we 1076163953Srrs * really would not want to anyway.. we will count them in this 1077163953Srrs * counter. We of course feed them to the pigeons right away (I have 1078163953Srrs * always thought of pigeons as flying rats). 1079163953Srrs */ 1080163953Srrs uint16_t stale_cookie_count; 1081163953Srrs 1082163953Srrs /* 1083163953Srrs * For the partial delivery API, if up, invoked this is what last 1084163953Srrs * TSN I delivered 1085163953Srrs */ 1086163953Srrs uint16_t str_of_pdapi; 1087163953Srrs uint16_t ssn_of_pdapi; 1088163953Srrs 1089163953Srrs /* counts of actual built streams. Allocation may be more however */ 1090163953Srrs /* could re-arrange to optimize space here. */ 1091163953Srrs uint16_t streamincnt; 1092163953Srrs uint16_t streamoutcnt; 1093188854Srrs uint16_t strm_realoutsize; 1094234790Stuexen uint16_t strm_pending_add_size; 1095163953Srrs /* my maximum number of retrans of INIT and SEND */ 1096163953Srrs /* copied from SCTP but should be individually setable */ 1097163953Srrs uint16_t max_init_times; 1098163953Srrs uint16_t max_send_times; 1099163953Srrs 1100163953Srrs uint16_t def_net_failure; 1101163953Srrs 1102224641Stuexen uint16_t def_net_pf_threshold; 1103224641Stuexen 1104163953Srrs /* 1105163953Srrs * lock flag: 0 is ok to send, 1+ (duals as a retran count) is 1106163953Srrs * awaiting ACK 1107163953Srrs */ 1108163953Srrs uint16_t mapping_array_size; 1109163953Srrs 1110163953Srrs uint16_t last_strm_seq_delivered; 1111163953Srrs uint16_t last_strm_no_delivered; 1112163953Srrs 1113163953Srrs uint16_t last_revoke_count; 1114163953Srrs int16_t num_send_timers_up; 1115163953Srrs 1116163953Srrs uint16_t stream_locked_on; 1117163953Srrs uint16_t ecn_echo_cnt_onq; 1118163953Srrs 1119163953Srrs uint16_t free_chunk_cnt; 1120163953Srrs uint8_t stream_locked; 1121163953Srrs uint8_t authenticated; /* packet authenticated ok */ 1122163953Srrs /* 1123167598Srrs * This flag indicates that a SACK need to be sent. Initially this 1124167598Srrs * is 1 to send the first sACK immediately. 1125163953Srrs */ 1126167598Srrs uint8_t send_sack; 1127163953Srrs 1128218186Srrs /* max burst of new packets into the network */ 1129217894Stuexen uint32_t max_burst; 1130218186Srrs /* max burst of fast retransmit packets */ 1131218186Srrs uint32_t fr_max_burst; 1132163953Srrs 1133163953Srrs uint8_t sat_network; /* RTT is in range of sat net or greater */ 1134163953Srrs uint8_t sat_network_lockout; /* lockout code */ 1135163953Srrs uint8_t burst_limit_applied; /* Burst limit in effect at last send? */ 1136163953Srrs /* flag goes on when we are doing a partial delivery api */ 1137163953Srrs uint8_t hb_random_values[4]; 1138163953Srrs uint8_t fragmented_delivery_inprogress; 1139163953Srrs uint8_t fragment_flags; 1140163953Srrs uint8_t last_flags_delivered; 1141163953Srrs uint8_t hb_ect_randombit; 1142163953Srrs uint8_t hb_random_idx; 1143224870Stuexen uint8_t default_dscp; 1144171572Srrs uint8_t asconf_del_pending; /* asconf delete last addr pending */ 1145163953Srrs 1146163953Srrs /* 1147163953Srrs * This value, plus all other ack'd but above cum-ack is added 1148163953Srrs * together to cross check against the bit that we have yet to 1149163953Srrs * define (probably in the SACK). When the cum-ack is updated, this 1150163953Srrs * sum is updated as well. 1151163953Srrs */ 1152218129Srrs 1153163953Srrs /* Flag to tell if ECN is allowed */ 1154163953Srrs uint8_t ecn_allowed; 1155163953Srrs 1156234790Stuexen /* Did the peer make the stream config (add out) request */ 1157234790Stuexen uint8_t peer_req_out; 1158234790Stuexen 1159163953Srrs /* flag to indicate if peer can do asconf */ 1160163953Srrs uint8_t peer_supports_asconf; 1161185694Srrs /* EY - flag to indicate if peer can do nr_sack */ 1162185694Srrs uint8_t peer_supports_nr_sack; 1163163953Srrs /* pr-sctp support flag */ 1164163953Srrs uint8_t peer_supports_prsctp; 1165163953Srrs /* peer authentication support flag */ 1166163953Srrs uint8_t peer_supports_auth; 1167163953Srrs /* stream resets are supported by the peer */ 1168163953Srrs uint8_t peer_supports_strreset; 1169234790Stuexen uint8_t local_strreset_support; 1170163953Srrs 1171185694Srrs uint8_t peer_supports_nat; 1172163953Srrs /* 1173163953Srrs * packet drop's are supported by the peer, we don't really care 1174163953Srrs * about this but we bookkeep it anyway. 1175163953Srrs */ 1176163953Srrs uint8_t peer_supports_pktdrop; 1177163953Srrs 1178252961Stuexen struct sctp_scoping scope; 1179163953Srrs /* flags to handle send alternate net tracking */ 1180163953Srrs uint8_t used_alt_onsack; 1181163953Srrs uint8_t used_alt_asconfack; 1182163953Srrs uint8_t fast_retran_loss_recovery; 1183163953Srrs uint8_t sat_t3_loss_recovery; 1184163953Srrs uint8_t dropped_special_cnt; 1185163953Srrs uint8_t seen_a_sack_this_pkt; 1186163953Srrs uint8_t stream_reset_outstanding; 1187163953Srrs uint8_t stream_reset_out_is_outstanding; 1188163953Srrs uint8_t delayed_connection; 1189163953Srrs uint8_t ifp_had_enobuf; 1190163953Srrs uint8_t saw_sack_with_frags; 1191216188Stuexen uint8_t saw_sack_with_nr_frags; 1192185694Srrs uint8_t in_asocid_hash; 1193163953Srrs uint8_t assoc_up_sent; 1194171990Srrs uint8_t adaptation_needed; 1195171990Srrs uint8_t adaptation_sent; 1196163953Srrs /* CMT variables */ 1197163953Srrs uint8_t cmt_dac_pkts_rcvd; 1198163953Srrs uint8_t sctp_cmt_on_off; 1199163953Srrs uint8_t iam_blocking; 1200166023Srrs uint8_t cookie_how[8]; 1201185694Srrs /* EY 05/05/08 - NR_SACK variable */ 1202185694Srrs uint8_t sctp_nr_sack_on_off; 1203171440Srrs /* JRS 5/21/07 - CMT PF variable */ 1204171440Srrs uint8_t sctp_cmt_pf; 1205219057Srrs uint8_t use_precise_time; 1206265958Stuexen uint64_t sctp_features; 1207231070Stuexen uint16_t port; /* remote UDP encapsulation port */ 1208163953Srrs /* 1209163953Srrs * The mapping array is used to track out of order sequences above 1210163953Srrs * last_acked_seq. 0 indicates packet missing 1 indicates packet 1211163953Srrs * rec'd. We slide it up every time we raise last_acked_seq and 0 1212163953Srrs * trailing locactions out. If I get a TSN above the array 1213163953Srrs * mappingArraySz, I discard the datagram and let retransmit happen. 1214163953Srrs */ 1215166675Srrs uint32_t marked_retrans; 1216166675Srrs uint32_t timoinit; 1217166675Srrs uint32_t timodata; 1218166675Srrs uint32_t timosack; 1219166675Srrs uint32_t timoshutdown; 1220166675Srrs uint32_t timoheartbeat; 1221166675Srrs uint32_t timocookie; 1222166675Srrs uint32_t timoshutdownack; 1223166675Srrs struct timeval start_time; 1224166675Srrs struct timeval discontinuity_time; 1225163953Srrs}; 1226163953Srrs 1227163953Srrs#endif 1228