James Kuszmaul | 4cb043c | 2021-01-17 11:25:51 -0800 | [diff] [blame^] | 1 | /*- |
| 2 | * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. |
| 3 | * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. |
| 4 | * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions are met: |
| 8 | * |
| 9 | * a) Redistributions of source code must retain the above copyright notice, |
| 10 | * this list of conditions and the following disclaimer. |
| 11 | * |
| 12 | * b) Redistributions in binary form must reproduce the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer in |
| 14 | * the documentation and/or other materials provided with the distribution. |
| 15 | * |
| 16 | * c) Neither the name of Cisco Systems, Inc. nor the names of its |
| 17 | * contributors may be used to endorse or promote products derived |
| 18 | * from this software without specific prior written permission. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 30 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | */ |
| 32 | |
| 33 | #ifdef __FreeBSD__ |
| 34 | #include <sys/cdefs.h> |
| 35 | __FBSDID("$FreeBSD: head/sys/netinet/sctp_structs.h 310590 2016-12-26 11:06:41Z tuexen $"); |
| 36 | #endif |
| 37 | |
| 38 | #ifndef _NETINET_SCTP_STRUCTS_H_ |
| 39 | #define _NETINET_SCTP_STRUCTS_H_ |
| 40 | |
| 41 | #include <netinet/sctp_os.h> |
| 42 | #include <netinet/sctp_header.h> |
| 43 | #include <netinet/sctp_auth.h> |
| 44 | |
| 45 | struct sctp_timer { |
| 46 | sctp_os_timer_t timer; |
| 47 | |
| 48 | int type; |
| 49 | /* |
| 50 | * Depending on the timer type these will be setup and cast with the |
| 51 | * appropriate entity. |
| 52 | */ |
| 53 | void *ep; |
| 54 | void *tcb; |
| 55 | void *net; |
| 56 | #if defined(__FreeBSD__) && __FreeBSD_version >= 800000 |
| 57 | void *vnet; |
| 58 | #endif |
| 59 | |
| 60 | /* for sanity checking */ |
| 61 | void *self; |
| 62 | uint32_t ticks; |
| 63 | uint32_t stopped_from; |
| 64 | }; |
| 65 | |
| 66 | |
| 67 | struct sctp_foo_stuff { |
| 68 | struct sctp_inpcb *inp; |
| 69 | uint32_t lineno; |
| 70 | uint32_t ticks; |
| 71 | int updown; |
| 72 | }; |
| 73 | |
| 74 | |
| 75 | /* |
| 76 | * This is the information we track on each interface that we know about from |
| 77 | * the distant end. |
| 78 | */ |
| 79 | TAILQ_HEAD(sctpnetlisthead, sctp_nets); |
| 80 | |
| 81 | struct sctp_stream_reset_list { |
| 82 | TAILQ_ENTRY(sctp_stream_reset_list) next_resp; |
| 83 | uint32_t seq; |
| 84 | uint32_t tsn; |
| 85 | uint32_t number_entries; |
| 86 | uint16_t list_of_streams[]; |
| 87 | }; |
| 88 | |
| 89 | TAILQ_HEAD(sctp_resethead, sctp_stream_reset_list); |
| 90 | |
| 91 | /* |
| 92 | * Users of the iterator need to malloc a iterator with a call to |
| 93 | * sctp_initiate_iterator(inp_func, assoc_func, inp_func, pcb_flags, pcb_features, |
| 94 | * asoc_state, void-ptr-arg, uint32-arg, end_func, inp); |
| 95 | * |
| 96 | * Use the following two defines if you don't care what pcb flags are on the EP |
| 97 | * and/or you don't care what state the association is in. |
| 98 | * |
| 99 | * Note that if you specify an INP as the last argument then ONLY each |
| 100 | * association of that single INP will be executed upon. Note that the pcb |
| 101 | * flags STILL apply so if the inp you specify has different pcb_flags then |
| 102 | * what you put in pcb_flags nothing will happen. use SCTP_PCB_ANY_FLAGS to |
| 103 | * assure the inp you specify gets treated. |
| 104 | */ |
| 105 | #define SCTP_PCB_ANY_FLAGS 0x00000000 |
| 106 | #define SCTP_PCB_ANY_FEATURES 0x00000000 |
| 107 | #define SCTP_ASOC_ANY_STATE 0x00000000 |
| 108 | |
| 109 | typedef void (*asoc_func) (struct sctp_inpcb *, struct sctp_tcb *, void *ptr, |
| 110 | uint32_t val); |
| 111 | typedef int (*inp_func) (struct sctp_inpcb *, void *ptr, uint32_t val); |
| 112 | typedef void (*end_func) (void *ptr, uint32_t val); |
| 113 | |
| 114 | #if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP) |
| 115 | /* whats on the mcore control struct */ |
| 116 | struct sctp_mcore_queue { |
| 117 | TAILQ_ENTRY(sctp_mcore_queue) next; |
| 118 | #if defined(__FreeBSD__) && __FreeBSD_version >= 801000 |
| 119 | struct vnet *vn; |
| 120 | #endif |
| 121 | struct mbuf *m; |
| 122 | int off; |
| 123 | int v6; |
| 124 | }; |
| 125 | |
| 126 | TAILQ_HEAD(sctp_mcore_qhead, sctp_mcore_queue); |
| 127 | |
| 128 | struct sctp_mcore_ctrl { |
| 129 | SCTP_PROCESS_STRUCT thread_proc; |
| 130 | struct sctp_mcore_qhead que; |
| 131 | struct mtx core_mtx; |
| 132 | struct mtx que_mtx; |
| 133 | int running; |
| 134 | int cpuid; |
| 135 | }; |
| 136 | |
| 137 | |
| 138 | #endif |
| 139 | |
| 140 | |
| 141 | struct sctp_iterator { |
| 142 | TAILQ_ENTRY(sctp_iterator) sctp_nxt_itr; |
| 143 | #if defined(__FreeBSD__) && __FreeBSD_version >= 801000 |
| 144 | struct vnet *vn; |
| 145 | #endif |
| 146 | struct sctp_timer tmr; |
| 147 | struct sctp_inpcb *inp; /* current endpoint */ |
| 148 | struct sctp_tcb *stcb; /* current* assoc */ |
| 149 | struct sctp_inpcb *next_inp; /* special hook to skip to */ |
| 150 | asoc_func function_assoc; /* per assoc function */ |
| 151 | inp_func function_inp; /* per endpoint function */ |
| 152 | inp_func function_inp_end; /* end INP function */ |
| 153 | end_func function_atend; /* iterator completion function */ |
| 154 | void *pointer; /* pointer for apply func to use */ |
| 155 | uint32_t val; /* value for apply func to use */ |
| 156 | uint32_t pcb_flags; /* endpoint flags being checked */ |
| 157 | uint32_t pcb_features; /* endpoint features being checked */ |
| 158 | uint32_t asoc_state; /* assoc state being checked */ |
| 159 | uint32_t iterator_flags; |
| 160 | uint8_t no_chunk_output; |
| 161 | uint8_t done_current_ep; |
| 162 | }; |
| 163 | /* iterator_flags values */ |
| 164 | #define SCTP_ITERATOR_DO_ALL_INP 0x00000001 |
| 165 | #define SCTP_ITERATOR_DO_SINGLE_INP 0x00000002 |
| 166 | |
| 167 | |
| 168 | TAILQ_HEAD(sctpiterators, sctp_iterator); |
| 169 | |
| 170 | struct sctp_copy_all { |
| 171 | struct sctp_inpcb *inp; /* ep */ |
| 172 | struct mbuf *m; |
| 173 | struct sctp_sndrcvinfo sndrcv; |
| 174 | int sndlen; |
| 175 | int cnt_sent; |
| 176 | int cnt_failed; |
| 177 | }; |
| 178 | |
| 179 | struct sctp_asconf_iterator { |
| 180 | struct sctpladdr list_of_work; |
| 181 | int cnt; |
| 182 | }; |
| 183 | |
| 184 | struct iterator_control { |
| 185 | #if defined(__FreeBSD__) |
| 186 | struct mtx ipi_iterator_wq_mtx; |
| 187 | struct mtx it_mtx; |
| 188 | #elif defined(__APPLE__) |
| 189 | lck_mtx_t *ipi_iterator_wq_mtx; |
| 190 | lck_mtx_t *it_mtx; |
| 191 | #elif defined(SCTP_PROCESS_LEVEL_LOCKS) |
| 192 | #if defined(__Userspace__) |
| 193 | userland_mutex_t ipi_iterator_wq_mtx; |
| 194 | userland_mutex_t it_mtx; |
| 195 | userland_cond_t iterator_wakeup; |
| 196 | #else |
| 197 | pthread_mutex_t ipi_iterator_wq_mtx; |
| 198 | pthread_mutex_t it_mtx; |
| 199 | pthread_cond_t iterator_wakeup; |
| 200 | #endif |
| 201 | #elif defined(__Windows__) |
| 202 | struct spinlock it_lock; |
| 203 | struct spinlock ipi_iterator_wq_lock; |
| 204 | KEVENT iterator_wakeup[2]; |
| 205 | PFILE_OBJECT iterator_thread_obj; |
| 206 | #else |
| 207 | void *it_mtx; |
| 208 | #endif |
| 209 | #if !defined(__Windows__) |
| 210 | #if !defined(__Userspace__) |
| 211 | SCTP_PROCESS_STRUCT thread_proc; |
| 212 | #else |
| 213 | userland_thread_t thread_proc; |
| 214 | #endif |
| 215 | #endif |
| 216 | struct sctpiterators iteratorhead; |
| 217 | struct sctp_iterator *cur_it; |
| 218 | uint32_t iterator_running; |
| 219 | uint32_t iterator_flags; |
| 220 | }; |
| 221 | #if !defined(__FreeBSD__) |
| 222 | #define SCTP_ITERATOR_MUST_EXIT 0x00000001 |
| 223 | #define SCTP_ITERATOR_EXITED 0x00000002 |
| 224 | #endif |
| 225 | #define SCTP_ITERATOR_STOP_CUR_IT 0x00000004 |
| 226 | #define SCTP_ITERATOR_STOP_CUR_INP 0x00000008 |
| 227 | |
| 228 | struct sctp_net_route { |
| 229 | sctp_rtentry_t *ro_rt; |
| 230 | #if defined(__FreeBSD__) |
| 231 | #if __FreeBSD_version < 1100093 |
| 232 | #if __FreeBSD_version >= 800000 |
| 233 | void *ro_lle; |
| 234 | #endif |
| 235 | #if __FreeBSD_version >= 900000 |
| 236 | void *ro_ia; |
| 237 | int ro_flags; |
| 238 | #endif |
| 239 | #else |
| 240 | #if __FreeBSD_version >= 1100116 |
| 241 | struct llentry *ro_lle; |
| 242 | #endif |
| 243 | char *ro_prepend; |
| 244 | uint16_t ro_plen; |
| 245 | uint16_t ro_flags; |
| 246 | uint16_t ro_mtu; |
| 247 | uint16_t spare; |
| 248 | #endif |
| 249 | #endif |
| 250 | #if defined(__APPLE__) |
| 251 | #if !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) |
| 252 | struct ifaddr *ro_srcia; |
| 253 | #endif |
| 254 | #if !defined(APPLE_LEOPARD) |
| 255 | uint32_t ro_flags; |
| 256 | #endif |
| 257 | #endif |
| 258 | union sctp_sockstore _l_addr; /* remote peer addr */ |
| 259 | struct sctp_ifa *_s_addr; /* our selected src addr */ |
| 260 | }; |
| 261 | |
| 262 | struct htcp { |
| 263 | uint16_t alpha; /* Fixed point arith, << 7 */ |
| 264 | uint8_t beta; /* Fixed point arith, << 7 */ |
| 265 | uint8_t modeswitch; /* Delay modeswitch until we had at least one congestion event */ |
| 266 | uint32_t last_cong; /* Time since last congestion event end */ |
| 267 | uint32_t undo_last_cong; |
| 268 | uint16_t bytes_acked; |
| 269 | uint32_t bytecount; |
| 270 | uint32_t minRTT; |
| 271 | uint32_t maxRTT; |
| 272 | |
| 273 | uint32_t undo_maxRTT; |
| 274 | uint32_t undo_old_maxB; |
| 275 | |
| 276 | /* Bandwidth estimation */ |
| 277 | uint32_t minB; |
| 278 | uint32_t maxB; |
| 279 | uint32_t old_maxB; |
| 280 | uint32_t Bi; |
| 281 | uint32_t lasttime; |
| 282 | }; |
| 283 | |
| 284 | struct rtcc_cc { |
| 285 | struct timeval tls; /* The time we started the sending */ |
| 286 | uint64_t lbw; /* Our last estimated bw */ |
| 287 | uint64_t lbw_rtt; /* RTT at bw estimate */ |
| 288 | uint64_t bw_bytes; /* The total bytes since this sending began */ |
| 289 | uint64_t bw_tot_time; /* The total time since sending began */ |
| 290 | uint64_t new_tot_time; /* temp holding the new value */ |
| 291 | uint64_t bw_bytes_at_last_rttc; /* What bw_bytes was at last rtt calc */ |
| 292 | uint32_t cwnd_at_bw_set; /* Cwnd at last bw saved - lbw */ |
| 293 | uint32_t vol_reduce; /* cnt of voluntary reductions */ |
| 294 | uint16_t steady_step; /* The number required to be in steady state*/ |
| 295 | uint16_t step_cnt; /* The current number */ |
| 296 | uint8_t ret_from_eq; /* When all things are equal what do I return 0/1 - 1 no cc advance */ |
| 297 | uint8_t use_dccc_ecn; /* Flag to enable DCCC ECN */ |
| 298 | uint8_t tls_needs_set; /* Flag to indicate we need to set tls 0 or 1 means set at send 2 not */ |
| 299 | uint8_t last_step_state; /* Last state if steady state stepdown is on */ |
| 300 | uint8_t rtt_set_this_sack; /* Flag saying this sack had RTT calc on it */ |
| 301 | uint8_t last_inst_ind; /* Last saved inst indication */ |
| 302 | }; |
| 303 | |
| 304 | |
| 305 | struct sctp_nets { |
| 306 | TAILQ_ENTRY(sctp_nets) sctp_next; /* next link */ |
| 307 | |
| 308 | /* |
| 309 | * Things on the top half may be able to be split into a common |
| 310 | * structure shared by all. |
| 311 | */ |
| 312 | struct sctp_timer pmtu_timer; |
| 313 | struct sctp_timer hb_timer; |
| 314 | |
| 315 | /* |
| 316 | * The following two in combination equate to a route entry for v6 |
| 317 | * or v4. |
| 318 | */ |
| 319 | struct sctp_net_route ro; |
| 320 | |
| 321 | /* mtu discovered so far */ |
| 322 | uint32_t mtu; |
| 323 | uint32_t ssthresh; /* not sure about this one for split */ |
| 324 | uint32_t last_cwr_tsn; |
| 325 | uint32_t cwr_window_tsn; |
| 326 | uint32_t ecn_ce_pkt_cnt; |
| 327 | uint32_t lost_cnt; |
| 328 | /* smoothed average things for RTT and RTO itself */ |
| 329 | int lastsa; |
| 330 | int lastsv; |
| 331 | uint64_t rtt; /* last measured rtt value in us */ |
| 332 | unsigned int RTO; |
| 333 | |
| 334 | /* This is used for SHUTDOWN/SHUTDOWN-ACK/SEND or INIT timers */ |
| 335 | struct sctp_timer rxt_timer; |
| 336 | |
| 337 | /* last time in seconds I sent to it */ |
| 338 | struct timeval last_sent_time; |
| 339 | union cc_control_data { |
| 340 | struct htcp htcp_ca; /* JRS - struct used in HTCP algorithm */ |
| 341 | struct rtcc_cc rtcc; /* rtcc module cc stuff */ |
| 342 | } cc_mod; |
| 343 | int ref_count; |
| 344 | |
| 345 | /* Congestion stats per destination */ |
| 346 | /* |
| 347 | * flight size variables and such, sorry Vern, I could not avoid |
| 348 | * this if I wanted performance :> |
| 349 | */ |
| 350 | uint32_t flight_size; |
| 351 | uint32_t cwnd; /* actual cwnd */ |
| 352 | uint32_t prev_cwnd; /* cwnd before any processing */ |
| 353 | uint32_t ecn_prev_cwnd; /* ECN prev cwnd at first ecn_echo seen in new window */ |
| 354 | uint32_t partial_bytes_acked; /* in CA tracks when to incr a MTU */ |
| 355 | /* tracking variables to avoid the aloc/free in sack processing */ |
| 356 | unsigned int net_ack; |
| 357 | unsigned int net_ack2; |
| 358 | |
| 359 | /* |
| 360 | * JRS - 5/8/07 - Variable to track last time |
| 361 | * a destination was active for CMT PF |
| 362 | */ |
| 363 | uint32_t last_active; |
| 364 | |
| 365 | /* |
| 366 | * CMT variables (iyengar@cis.udel.edu) |
| 367 | */ |
| 368 | uint32_t this_sack_highest_newack; /* tracks highest TSN newly |
| 369 | * acked for a given dest in |
| 370 | * the current SACK. Used in |
| 371 | * SFR and HTNA algos */ |
| 372 | uint32_t pseudo_cumack; /* CMT CUC algorithm. Maintains next expected |
| 373 | * pseudo-cumack for this destination */ |
| 374 | uint32_t rtx_pseudo_cumack; /* CMT CUC algorithm. Maintains next |
| 375 | * expected pseudo-cumack for this |
| 376 | * destination */ |
| 377 | |
| 378 | /* CMT fast recovery variables */ |
| 379 | uint32_t fast_recovery_tsn; |
| 380 | uint32_t heartbeat_random1; |
| 381 | uint32_t heartbeat_random2; |
| 382 | #ifdef INET6 |
| 383 | uint32_t flowlabel; |
| 384 | #endif |
| 385 | uint8_t dscp; |
| 386 | |
| 387 | struct timeval start_time; /* time when this net was created */ |
| 388 | uint32_t marked_retrans; /* number or DATA chunks marked for |
| 389 | timer based retransmissions */ |
| 390 | uint32_t marked_fastretrans; |
| 391 | uint32_t heart_beat_delay; /* Heart Beat delay in ms */ |
| 392 | |
| 393 | /* if this guy is ok or not ... status */ |
| 394 | uint16_t dest_state; |
| 395 | /* number of timeouts to consider the destination unreachable */ |
| 396 | uint16_t failure_threshold; |
| 397 | /* number of timeouts to consider the destination potentially failed */ |
| 398 | uint16_t pf_threshold; |
| 399 | /* error stats on the destination */ |
| 400 | uint16_t error_count; |
| 401 | /* UDP port number in case of UDP tunneling */ |
| 402 | uint16_t port; |
| 403 | |
| 404 | uint8_t fast_retran_loss_recovery; |
| 405 | uint8_t will_exit_fast_recovery; |
| 406 | /* Flags that probably can be combined into dest_state */ |
| 407 | uint8_t fast_retran_ip; /* fast retransmit in progress */ |
| 408 | uint8_t hb_responded; |
| 409 | uint8_t saw_newack; /* CMT's SFR algorithm flag */ |
| 410 | uint8_t src_addr_selected; /* if we split we move */ |
| 411 | uint8_t indx_of_eligible_next_to_use; |
| 412 | uint8_t addr_is_local; /* its a local address (if known) could move |
| 413 | * in split */ |
| 414 | |
| 415 | /* |
| 416 | * CMT variables (iyengar@cis.udel.edu) |
| 417 | */ |
| 418 | uint8_t find_pseudo_cumack; /* CMT CUC algorithm. Flag used to |
| 419 | * find a new pseudocumack. This flag |
| 420 | * is set after a new pseudo-cumack |
| 421 | * has been received and indicates |
| 422 | * that the sender should find the |
| 423 | * next pseudo-cumack expected for |
| 424 | * this destination */ |
| 425 | uint8_t find_rtx_pseudo_cumack; /* CMT CUCv2 algorithm. Flag used to |
| 426 | * find a new rtx-pseudocumack. This |
| 427 | * flag is set after a new |
| 428 | * rtx-pseudo-cumack has been received |
| 429 | * and indicates that the sender |
| 430 | * should find the next |
| 431 | * rtx-pseudo-cumack expected for this |
| 432 | * destination */ |
| 433 | uint8_t new_pseudo_cumack; /* CMT CUC algorithm. Flag used to |
| 434 | * indicate if a new pseudo-cumack or |
| 435 | * rtx-pseudo-cumack has been received */ |
| 436 | uint8_t window_probe; /* Doing a window probe? */ |
| 437 | uint8_t RTO_measured; /* Have we done the first measure */ |
| 438 | uint8_t last_hs_used; /* index into the last HS table entry we used */ |
| 439 | uint8_t lan_type; |
| 440 | uint8_t rto_needed; |
| 441 | #if defined(__FreeBSD__) |
| 442 | uint32_t flowid; |
| 443 | uint8_t flowtype; |
| 444 | #endif |
| 445 | }; |
| 446 | |
| 447 | |
| 448 | struct sctp_data_chunkrec { |
| 449 | uint32_t tsn; /* the TSN of this transmit */ |
| 450 | uint32_t mid; /* the message identifier of this transmit */ |
| 451 | uint16_t sid; /* the stream number of this guy */ |
| 452 | uint32_t ppid; |
| 453 | uint32_t context; /* from send */ |
| 454 | uint32_t cwnd_at_send; |
| 455 | /* |
| 456 | * part of the Highest sacked algorithm to be able to stroke counts |
| 457 | * on ones that are FR'd. |
| 458 | */ |
| 459 | uint32_t fast_retran_tsn; /* sending_seq at the time of FR */ |
| 460 | struct timeval timetodrop; /* time we drop it from queue */ |
| 461 | uint32_t fsn; /* Fragment Sequence Number */ |
| 462 | uint8_t doing_fast_retransmit; |
| 463 | uint8_t rcv_flags; /* flags pulled from data chunk on inbound for |
| 464 | * outbound holds sending flags for PR-SCTP. |
| 465 | */ |
| 466 | uint8_t state_flags; |
| 467 | uint8_t chunk_was_revoked; |
| 468 | uint8_t fwd_tsn_cnt; |
| 469 | }; |
| 470 | |
| 471 | TAILQ_HEAD(sctpchunk_listhead, sctp_tmit_chunk); |
| 472 | |
| 473 | /* The lower byte is used to enumerate PR_SCTP policies */ |
| 474 | #define CHUNK_FLAGS_PR_SCTP_TTL SCTP_PR_SCTP_TTL |
| 475 | #define CHUNK_FLAGS_PR_SCTP_BUF SCTP_PR_SCTP_BUF |
| 476 | #define CHUNK_FLAGS_PR_SCTP_RTX SCTP_PR_SCTP_RTX |
| 477 | |
| 478 | /* The upper byte is used as a bit mask */ |
| 479 | #define CHUNK_FLAGS_FRAGMENT_OK 0x0100 |
| 480 | |
| 481 | struct chk_id { |
| 482 | uint8_t id; |
| 483 | uint8_t can_take_data; |
| 484 | }; |
| 485 | |
| 486 | |
| 487 | struct sctp_tmit_chunk { |
| 488 | union { |
| 489 | struct sctp_data_chunkrec data; |
| 490 | struct chk_id chunk_id; |
| 491 | } rec; |
| 492 | struct sctp_association *asoc; /* bp to asoc this belongs to */ |
| 493 | struct timeval sent_rcv_time; /* filled in if RTT being calculated */ |
| 494 | struct mbuf *data; /* pointer to mbuf chain of data */ |
| 495 | struct mbuf *last_mbuf; /* pointer to last mbuf in chain */ |
| 496 | struct sctp_nets *whoTo; |
| 497 | TAILQ_ENTRY(sctp_tmit_chunk) sctp_next; /* next link */ |
| 498 | int32_t sent; /* the send status */ |
| 499 | uint16_t snd_count; /* number of times I sent */ |
| 500 | uint16_t flags; /* flags, such as FRAGMENT_OK */ |
| 501 | uint16_t send_size; |
| 502 | uint16_t book_size; |
| 503 | uint16_t mbcnt; |
| 504 | uint16_t auth_keyid; |
| 505 | uint8_t holds_key_ref; /* flag if auth keyid refcount is held */ |
| 506 | uint8_t pad_inplace; |
| 507 | uint8_t do_rtt; |
| 508 | uint8_t book_size_scale; |
| 509 | uint8_t no_fr_allowed; |
| 510 | uint8_t copy_by_ref; |
| 511 | uint8_t window_probe; |
| 512 | }; |
| 513 | |
| 514 | struct sctp_queued_to_read { /* sinfo structure Pluse more */ |
| 515 | uint16_t sinfo_stream; /* off the wire */ |
| 516 | uint16_t sinfo_flags; /* SCTP_UNORDERED from wire use SCTP_EOF for |
| 517 | * EOR */ |
| 518 | uint32_t sinfo_ppid; /* off the wire */ |
| 519 | uint32_t sinfo_context; /* pick this up from assoc def context? */ |
| 520 | uint32_t sinfo_timetolive; /* not used by kernel */ |
| 521 | uint32_t sinfo_tsn; /* Use this in reassembly as first TSN */ |
| 522 | uint32_t sinfo_cumtsn; /* Use this in reassembly as last TSN */ |
| 523 | sctp_assoc_t sinfo_assoc_id; /* our assoc id */ |
| 524 | /* Non sinfo stuff */ |
| 525 | uint32_t mid; /* Fragment Index */ |
| 526 | uint32_t length; /* length of data */ |
| 527 | uint32_t held_length; /* length held in sb */ |
| 528 | uint32_t top_fsn; /* Highest FSN in queue */ |
| 529 | uint32_t fsn_included; /* Highest FSN in *data portion */ |
| 530 | struct sctp_nets *whoFrom; /* where it came from */ |
| 531 | struct mbuf *data; /* front of the mbuf chain of data with |
| 532 | * PKT_HDR */ |
| 533 | struct mbuf *tail_mbuf; /* used for multi-part data */ |
| 534 | struct mbuf *aux_data; /* used to hold/cache control if o/s does not take it from us */ |
| 535 | struct sctp_tcb *stcb; /* assoc, used for window update */ |
| 536 | TAILQ_ENTRY(sctp_queued_to_read) next; |
| 537 | TAILQ_ENTRY(sctp_queued_to_read) next_instrm; |
| 538 | struct sctpchunk_listhead reasm; |
| 539 | uint16_t port_from; |
| 540 | uint16_t spec_flags; /* Flags to hold the notification field */ |
| 541 | uint8_t do_not_ref_stcb; |
| 542 | uint8_t end_added; |
| 543 | uint8_t pdapi_aborted; |
| 544 | uint8_t pdapi_started; |
| 545 | uint8_t some_taken; |
| 546 | uint8_t last_frag_seen; |
| 547 | uint8_t first_frag_seen; |
| 548 | uint8_t on_read_q; |
| 549 | uint8_t on_strm_q; |
| 550 | }; |
| 551 | |
| 552 | #define SCTP_ON_ORDERED 1 |
| 553 | #define SCTP_ON_UNORDERED 2 |
| 554 | |
| 555 | /* This data structure will be on the outbound |
| 556 | * stream queues. Data will be pulled off from |
| 557 | * the front of the mbuf data and chunk-ified |
| 558 | * by the output routines. We will custom |
| 559 | * fit every chunk we pull to the send/sent |
| 560 | * queue to make up the next full packet |
| 561 | * if we can. An entry cannot be removed |
| 562 | * from the stream_out queue until |
| 563 | * the msg_is_complete flag is set. This |
| 564 | * means at times data/tail_mbuf MIGHT |
| 565 | * be NULL.. If that occurs it happens |
| 566 | * for one of two reasons. Either the user |
| 567 | * is blocked on a send() call and has not |
| 568 | * awoken to copy more data down... OR |
| 569 | * the user is in the explict MSG_EOR mode |
| 570 | * and wrote some data, but has not completed |
| 571 | * sending. |
| 572 | */ |
| 573 | struct sctp_stream_queue_pending { |
| 574 | struct mbuf *data; |
| 575 | struct mbuf *tail_mbuf; |
| 576 | struct timeval ts; |
| 577 | struct sctp_nets *net; |
| 578 | TAILQ_ENTRY (sctp_stream_queue_pending) next; |
| 579 | TAILQ_ENTRY (sctp_stream_queue_pending) ss_next; |
| 580 | uint32_t fsn; |
| 581 | uint32_t length; |
| 582 | uint32_t timetolive; |
| 583 | uint32_t ppid; |
| 584 | uint32_t context; |
| 585 | uint16_t sinfo_flags; |
| 586 | uint16_t sid; |
| 587 | uint16_t act_flags; |
| 588 | uint16_t auth_keyid; |
| 589 | uint8_t holds_key_ref; |
| 590 | uint8_t msg_is_complete; |
| 591 | uint8_t some_taken; |
| 592 | uint8_t sender_all_done; |
| 593 | uint8_t put_last_out; |
| 594 | uint8_t discard_rest; |
| 595 | }; |
| 596 | |
| 597 | /* |
| 598 | * this struct contains info that is used to track inbound stream data and |
| 599 | * help with ordering. |
| 600 | */ |
| 601 | TAILQ_HEAD(sctpwheelunrel_listhead, sctp_stream_in); |
| 602 | struct sctp_stream_in { |
| 603 | struct sctp_readhead inqueue; |
| 604 | struct sctp_readhead uno_inqueue; |
| 605 | uint32_t last_mid_delivered; /* used for re-order */ |
| 606 | uint16_t sid; |
| 607 | uint8_t delivery_started; |
| 608 | uint8_t pd_api_started; |
| 609 | }; |
| 610 | |
| 611 | TAILQ_HEAD(sctpwheel_listhead, sctp_stream_out); |
| 612 | TAILQ_HEAD(sctplist_listhead, sctp_stream_queue_pending); |
| 613 | |
| 614 | |
| 615 | /* Round-robin schedulers */ |
| 616 | struct ss_rr { |
| 617 | /* next link in wheel */ |
| 618 | TAILQ_ENTRY(sctp_stream_out) next_spoke; |
| 619 | }; |
| 620 | |
| 621 | /* Priority scheduler */ |
| 622 | struct ss_prio { |
| 623 | /* next link in wheel */ |
| 624 | TAILQ_ENTRY(sctp_stream_out) next_spoke; |
| 625 | /* priority id */ |
| 626 | uint16_t priority; |
| 627 | }; |
| 628 | |
| 629 | /* Fair Bandwidth scheduler */ |
| 630 | struct ss_fb { |
| 631 | /* next link in wheel */ |
| 632 | TAILQ_ENTRY(sctp_stream_out) next_spoke; |
| 633 | /* stores message size */ |
| 634 | int32_t rounds; |
| 635 | }; |
| 636 | |
| 637 | /* |
| 638 | * This union holds all data necessary for |
| 639 | * different stream schedulers. |
| 640 | */ |
| 641 | struct scheduling_data { |
| 642 | struct sctp_stream_out *locked_on_sending; |
| 643 | /* circular looking for output selection */ |
| 644 | struct sctp_stream_out *last_out_stream; |
| 645 | union { |
| 646 | struct sctpwheel_listhead wheel; |
| 647 | struct sctplist_listhead list; |
| 648 | } out; |
| 649 | }; |
| 650 | |
| 651 | /* |
| 652 | * This union holds all parameters per stream |
| 653 | * necessary for different stream schedulers. |
| 654 | */ |
| 655 | union scheduling_parameters { |
| 656 | struct ss_rr rr; |
| 657 | struct ss_prio prio; |
| 658 | struct ss_fb fb; |
| 659 | }; |
| 660 | |
| 661 | /* States for outgoing streams */ |
| 662 | #define SCTP_STREAM_CLOSED 0x00 |
| 663 | #define SCTP_STREAM_OPENING 0x01 |
| 664 | #define SCTP_STREAM_OPEN 0x02 |
| 665 | #define SCTP_STREAM_RESET_PENDING 0x03 |
| 666 | #define SCTP_STREAM_RESET_IN_FLIGHT 0x04 |
| 667 | |
| 668 | #define SCTP_MAX_STREAMS_AT_ONCE_RESET 200 |
| 669 | |
| 670 | /* This struct is used to track the traffic on outbound streams */ |
| 671 | struct sctp_stream_out { |
| 672 | struct sctp_streamhead outqueue; |
| 673 | union scheduling_parameters ss_params; |
| 674 | uint32_t chunks_on_queues; /* send queue and sent queue */ |
| 675 | #if defined(SCTP_DETAILED_STR_STATS) |
| 676 | uint32_t abandoned_unsent[SCTP_PR_SCTP_MAX + 1]; |
| 677 | uint32_t abandoned_sent[SCTP_PR_SCTP_MAX + 1]; |
| 678 | #else |
| 679 | /* Only the aggregation */ |
| 680 | uint32_t abandoned_unsent[1]; |
| 681 | uint32_t abandoned_sent[1]; |
| 682 | #endif |
| 683 | /* For associations using DATA chunks, the lower 16-bit of |
| 684 | * next_mid_ordered are used as the next SSN. |
| 685 | */ |
| 686 | uint32_t next_mid_ordered; |
| 687 | uint32_t next_mid_unordered; |
| 688 | uint16_t sid; |
| 689 | uint8_t last_msg_incomplete; |
| 690 | uint8_t state; |
| 691 | }; |
| 692 | |
| 693 | /* used to keep track of the addresses yet to try to add/delete */ |
| 694 | TAILQ_HEAD(sctp_asconf_addrhead, sctp_asconf_addr); |
| 695 | struct sctp_asconf_addr { |
| 696 | TAILQ_ENTRY(sctp_asconf_addr) next; |
| 697 | struct sctp_asconf_addr_param ap; |
| 698 | struct sctp_ifa *ifa; /* save the ifa for add/del ip */ |
| 699 | uint8_t sent; /* has this been sent yet? */ |
| 700 | uint8_t special_del; /* not to be used in lookup */ |
| 701 | }; |
| 702 | |
| 703 | struct sctp_scoping { |
| 704 | uint8_t ipv4_addr_legal; |
| 705 | uint8_t ipv6_addr_legal; |
| 706 | #if defined(__Userspace__) |
| 707 | uint8_t conn_addr_legal; |
| 708 | #endif |
| 709 | uint8_t loopback_scope; |
| 710 | uint8_t ipv4_local_scope; |
| 711 | uint8_t local_scope; |
| 712 | uint8_t site_scope; |
| 713 | }; |
| 714 | |
| 715 | #define SCTP_TSN_LOG_SIZE 40 |
| 716 | |
| 717 | struct sctp_tsn_log { |
| 718 | void *stcb; |
| 719 | uint32_t tsn; |
| 720 | uint32_t seq; |
| 721 | uint16_t strm; |
| 722 | uint16_t sz; |
| 723 | uint16_t flgs; |
| 724 | uint16_t in_pos; |
| 725 | uint16_t in_out; |
| 726 | uint16_t resv; |
| 727 | }; |
| 728 | |
| 729 | #define SCTP_FS_SPEC_LOG_SIZE 200 |
| 730 | struct sctp_fs_spec_log { |
| 731 | uint32_t sent; |
| 732 | uint32_t total_flight; |
| 733 | uint32_t tsn; |
| 734 | uint16_t book; |
| 735 | uint8_t incr; |
| 736 | uint8_t decr; |
| 737 | }; |
| 738 | |
| 739 | /* This struct is here to cut out the compatiabilty |
| 740 | * pad that bulks up both the inp and stcb. The non |
| 741 | * pad portion MUST stay in complete sync with |
| 742 | * sctp_sndrcvinfo... i.e. if sinfo_xxxx is added |
| 743 | * this must be done here too. |
| 744 | */ |
| 745 | struct sctp_nonpad_sndrcvinfo { |
| 746 | uint16_t sinfo_stream; |
| 747 | uint16_t sinfo_ssn; |
| 748 | uint16_t sinfo_flags; |
| 749 | uint32_t sinfo_ppid; |
| 750 | uint32_t sinfo_context; |
| 751 | uint32_t sinfo_timetolive; |
| 752 | uint32_t sinfo_tsn; |
| 753 | uint32_t sinfo_cumtsn; |
| 754 | sctp_assoc_t sinfo_assoc_id; |
| 755 | uint16_t sinfo_keynumber; |
| 756 | uint16_t sinfo_keynumber_valid; |
| 757 | }; |
| 758 | |
| 759 | /* |
| 760 | * JRS - Structure to hold function pointers to the functions responsible |
| 761 | * for congestion control. |
| 762 | */ |
| 763 | |
| 764 | struct sctp_cc_functions { |
| 765 | void (*sctp_set_initial_cc_param)(struct sctp_tcb *stcb, struct sctp_nets *net); |
| 766 | void (*sctp_cwnd_update_after_sack)(struct sctp_tcb *stcb, |
| 767 | struct sctp_association *asoc, |
| 768 | int accum_moved ,int reneged_all, int will_exit); |
| 769 | void (*sctp_cwnd_update_exit_pf)(struct sctp_tcb *stcb, struct sctp_nets *net); |
| 770 | void (*sctp_cwnd_update_after_fr)(struct sctp_tcb *stcb, |
| 771 | struct sctp_association *asoc); |
| 772 | void (*sctp_cwnd_update_after_timeout)(struct sctp_tcb *stcb, |
| 773 | struct sctp_nets *net); |
| 774 | void (*sctp_cwnd_update_after_ecn_echo)(struct sctp_tcb *stcb, |
| 775 | struct sctp_nets *net, int in_window, int num_pkt_lost); |
| 776 | void (*sctp_cwnd_update_after_packet_dropped)(struct sctp_tcb *stcb, |
| 777 | struct sctp_nets *net, struct sctp_pktdrop_chunk *cp, |
| 778 | uint32_t *bottle_bw, uint32_t *on_queue); |
| 779 | void (*sctp_cwnd_update_after_output)(struct sctp_tcb *stcb, |
| 780 | struct sctp_nets *net, int burst_limit); |
| 781 | void (*sctp_cwnd_update_packet_transmitted)(struct sctp_tcb *stcb, |
| 782 | struct sctp_nets *net); |
| 783 | void (*sctp_cwnd_update_tsn_acknowledged)(struct sctp_nets *net, |
| 784 | struct sctp_tmit_chunk *); |
| 785 | void (*sctp_cwnd_new_transmission_begins)(struct sctp_tcb *stcb, |
| 786 | struct sctp_nets *net); |
| 787 | void (*sctp_cwnd_prepare_net_for_sack)(struct sctp_tcb *stcb, |
| 788 | struct sctp_nets *net); |
| 789 | int (*sctp_cwnd_socket_option)(struct sctp_tcb *stcb, int set, struct sctp_cc_option *); |
| 790 | void (*sctp_rtt_calculated)(struct sctp_tcb *, struct sctp_nets *, struct timeval *); |
| 791 | }; |
| 792 | |
| 793 | /* |
| 794 | * RS - Structure to hold function pointers to the functions responsible |
| 795 | * for stream scheduling. |
| 796 | */ |
| 797 | struct sctp_ss_functions { |
| 798 | void (*sctp_ss_init)(struct sctp_tcb *stcb, struct sctp_association *asoc, |
| 799 | int holds_lock); |
| 800 | void (*sctp_ss_clear)(struct sctp_tcb *stcb, struct sctp_association *asoc, |
| 801 | int clear_values, int holds_lock); |
| 802 | void (*sctp_ss_init_stream)(struct sctp_tcb *stcb, struct sctp_stream_out *strq, struct sctp_stream_out *with_strq); |
| 803 | void (*sctp_ss_add_to_stream)(struct sctp_tcb *stcb, struct sctp_association *asoc, |
| 804 | struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, int holds_lock); |
| 805 | int (*sctp_ss_is_empty)(struct sctp_tcb *stcb, struct sctp_association *asoc); |
| 806 | void (*sctp_ss_remove_from_stream)(struct sctp_tcb *stcb, struct sctp_association *asoc, |
| 807 | struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, int holds_lock); |
| 808 | struct sctp_stream_out* (*sctp_ss_select_stream)(struct sctp_tcb *stcb, |
| 809 | struct sctp_nets *net, struct sctp_association *asoc); |
| 810 | void (*sctp_ss_scheduled)(struct sctp_tcb *stcb, struct sctp_nets *net, |
| 811 | struct sctp_association *asoc, struct sctp_stream_out *strq, int moved_how_much); |
| 812 | void (*sctp_ss_packet_done)(struct sctp_tcb *stcb, struct sctp_nets *net, |
| 813 | struct sctp_association *asoc); |
| 814 | int (*sctp_ss_get_value)(struct sctp_tcb *stcb, struct sctp_association *asoc, |
| 815 | struct sctp_stream_out *strq, uint16_t *value); |
| 816 | int (*sctp_ss_set_value)(struct sctp_tcb *stcb, struct sctp_association *asoc, |
| 817 | struct sctp_stream_out *strq, uint16_t value); |
| 818 | int (*sctp_ss_is_user_msgs_incomplete)(struct sctp_tcb *stcb, struct sctp_association *asoc); |
| 819 | }; |
| 820 | |
| 821 | /* used to save ASCONF chunks for retransmission */ |
| 822 | TAILQ_HEAD(sctp_asconf_head, sctp_asconf); |
| 823 | struct sctp_asconf { |
| 824 | TAILQ_ENTRY(sctp_asconf) next; |
| 825 | uint32_t serial_number; |
| 826 | uint16_t snd_count; |
| 827 | struct mbuf *data; |
| 828 | uint16_t len; |
| 829 | }; |
| 830 | |
| 831 | /* used to save ASCONF-ACK chunks for retransmission */ |
| 832 | TAILQ_HEAD(sctp_asconf_ackhead, sctp_asconf_ack); |
| 833 | struct sctp_asconf_ack { |
| 834 | TAILQ_ENTRY(sctp_asconf_ack) next; |
| 835 | uint32_t serial_number; |
| 836 | struct sctp_nets *last_sent_to; |
| 837 | struct mbuf *data; |
| 838 | uint16_t len; |
| 839 | }; |
| 840 | |
| 841 | /* |
| 842 | * Here we have information about each individual association that we track. |
| 843 | * We probably in production would be more dynamic. But for ease of |
| 844 | * implementation we will have a fixed array that we hunt for in a linear |
| 845 | * fashion. |
| 846 | */ |
| 847 | struct sctp_association { |
| 848 | /* association state */ |
| 849 | int state; |
| 850 | |
| 851 | /* queue of pending addrs to add/delete */ |
| 852 | struct sctp_asconf_addrhead asconf_queue; |
| 853 | |
| 854 | struct timeval time_entered; /* time we entered state */ |
| 855 | struct timeval time_last_rcvd; |
| 856 | struct timeval time_last_sent; |
| 857 | struct timeval time_last_sat_advance; |
| 858 | struct sctp_nonpad_sndrcvinfo def_send; |
| 859 | |
| 860 | /* timers and such */ |
| 861 | struct sctp_timer dack_timer; /* Delayed ack timer */ |
| 862 | struct sctp_timer asconf_timer; /* asconf */ |
| 863 | struct sctp_timer strreset_timer; /* stream reset */ |
| 864 | struct sctp_timer shut_guard_timer; /* shutdown guard */ |
| 865 | struct sctp_timer autoclose_timer; /* automatic close timer */ |
| 866 | struct sctp_timer delayed_event_timer; /* timer for delayed events */ |
| 867 | struct sctp_timer delete_prim_timer; /* deleting primary dst */ |
| 868 | |
| 869 | /* list of restricted local addresses */ |
| 870 | struct sctpladdr sctp_restricted_addrs; |
| 871 | |
| 872 | /* last local address pending deletion (waiting for an address add) */ |
| 873 | struct sctp_ifa *asconf_addr_del_pending; |
| 874 | /* Deleted primary destination (used to stop timer) */ |
| 875 | struct sctp_nets *deleted_primary; |
| 876 | |
| 877 | struct sctpnetlisthead nets; /* remote address list */ |
| 878 | |
| 879 | /* Free chunk list */ |
| 880 | struct sctpchunk_listhead free_chunks; |
| 881 | |
| 882 | /* Control chunk queue */ |
| 883 | struct sctpchunk_listhead control_send_queue; |
| 884 | |
| 885 | /* ASCONF chunk queue */ |
| 886 | struct sctpchunk_listhead asconf_send_queue; |
| 887 | |
| 888 | /* |
| 889 | * Once a TSN hits the wire it is moved to the sent_queue. We |
| 890 | * maintain two counts here (don't know if any but retran_cnt is |
| 891 | * needed). The idea is that the sent_queue_retran_cnt reflects how |
| 892 | * many chunks have been marked for retranmission by either T3-rxt |
| 893 | * or FR. |
| 894 | */ |
| 895 | struct sctpchunk_listhead sent_queue; |
| 896 | struct sctpchunk_listhead send_queue; |
| 897 | |
| 898 | /* Scheduling queues */ |
| 899 | struct scheduling_data ss_data; |
| 900 | |
| 901 | /* If an iterator is looking at me, this is it */ |
| 902 | struct sctp_iterator *stcb_starting_point_for_iterator; |
| 903 | |
| 904 | /* ASCONF save the last ASCONF-ACK so we can resend it if necessary */ |
| 905 | struct sctp_asconf_ackhead asconf_ack_sent; |
| 906 | |
| 907 | /* |
| 908 | * pointer to last stream reset queued to control queue by us with |
| 909 | * requests. |
| 910 | */ |
| 911 | struct sctp_tmit_chunk *str_reset; |
| 912 | /* |
| 913 | * if Source Address Selection happening, this will rotate through |
| 914 | * the link list. |
| 915 | */ |
| 916 | struct sctp_laddr *last_used_address; |
| 917 | |
| 918 | /* stream arrays */ |
| 919 | struct sctp_stream_in *strmin; |
| 920 | struct sctp_stream_out *strmout; |
| 921 | uint8_t *mapping_array; |
| 922 | /* primary destination to use */ |
| 923 | struct sctp_nets *primary_destination; |
| 924 | struct sctp_nets *alternate; /* If primary is down or PF */ |
| 925 | /* For CMT */ |
| 926 | struct sctp_nets *last_net_cmt_send_started; |
| 927 | /* last place I got a data chunk from */ |
| 928 | struct sctp_nets *last_data_chunk_from; |
| 929 | /* last place I got a control from */ |
| 930 | struct sctp_nets *last_control_chunk_from; |
| 931 | |
| 932 | |
| 933 | /* |
| 934 | * wait to the point the cum-ack passes req->send_reset_at_tsn for |
| 935 | * any req on the list. |
| 936 | */ |
| 937 | struct sctp_resethead resetHead; |
| 938 | |
| 939 | /* queue of chunks waiting to be sent into the local stack */ |
| 940 | struct sctp_readhead pending_reply_queue; |
| 941 | |
| 942 | /* JRS - the congestion control functions are in this struct */ |
| 943 | struct sctp_cc_functions cc_functions; |
| 944 | /* JRS - value to store the currently loaded congestion control module */ |
| 945 | uint32_t congestion_control_module; |
| 946 | /* RS - the stream scheduling functions are in this struct */ |
| 947 | struct sctp_ss_functions ss_functions; |
| 948 | /* RS - value to store the currently loaded stream scheduling module */ |
| 949 | uint32_t stream_scheduling_module; |
| 950 | |
| 951 | uint32_t vrf_id; |
| 952 | uint32_t cookie_preserve_req; |
| 953 | /* ASCONF next seq I am sending out, inits at init-tsn */ |
| 954 | uint32_t asconf_seq_out; |
| 955 | uint32_t asconf_seq_out_acked; |
| 956 | /* ASCONF last received ASCONF from peer, starts at peer's TSN-1 */ |
| 957 | uint32_t asconf_seq_in; |
| 958 | |
| 959 | /* next seq I am sending in str reset messages */ |
| 960 | uint32_t str_reset_seq_out; |
| 961 | /* next seq I am expecting in str reset messages */ |
| 962 | uint32_t str_reset_seq_in; |
| 963 | |
| 964 | /* various verification tag information */ |
| 965 | uint32_t my_vtag; /* The tag to be used. if assoc is re-initited |
| 966 | * by remote end, and I have unlocked this |
| 967 | * will be regenerated to a new random value. */ |
| 968 | uint32_t peer_vtag; /* The peers last tag */ |
| 969 | |
| 970 | uint32_t my_vtag_nonce; |
| 971 | uint32_t peer_vtag_nonce; |
| 972 | |
| 973 | uint32_t assoc_id; |
| 974 | |
| 975 | /* This is the SCTP fragmentation threshold */ |
| 976 | uint32_t smallest_mtu; |
| 977 | |
| 978 | /* |
| 979 | * Special hook for Fast retransmit, allows us to track the highest |
| 980 | * TSN that is NEW in this SACK if gap ack blocks are present. |
| 981 | */ |
| 982 | uint32_t this_sack_highest_gap; |
| 983 | |
| 984 | /* |
| 985 | * The highest consecutive TSN that has been acked by peer on my |
| 986 | * sends |
| 987 | */ |
| 988 | uint32_t last_acked_seq; |
| 989 | |
| 990 | /* The next TSN that I will use in sending. */ |
| 991 | uint32_t sending_seq; |
| 992 | |
| 993 | /* Original seq number I used ??questionable to keep?? */ |
| 994 | uint32_t init_seq_number; |
| 995 | |
| 996 | |
| 997 | /* The Advanced Peer Ack Point, as required by the PR-SCTP */ |
| 998 | /* (A1 in Section 4.2) */ |
| 999 | uint32_t advanced_peer_ack_point; |
| 1000 | |
| 1001 | /* |
| 1002 | * The highest consequetive TSN at the bottom of the mapping array |
| 1003 | * (for his sends). |
| 1004 | */ |
| 1005 | uint32_t cumulative_tsn; |
| 1006 | /* |
| 1007 | * Used to track the mapping array and its offset bits. This MAY be |
| 1008 | * lower then cumulative_tsn. |
| 1009 | */ |
| 1010 | uint32_t mapping_array_base_tsn; |
| 1011 | /* |
| 1012 | * used to track highest TSN we have received and is listed in the |
| 1013 | * mapping array. |
| 1014 | */ |
| 1015 | uint32_t highest_tsn_inside_map; |
| 1016 | |
| 1017 | /* EY - new NR variables used for nr_sack based on mapping_array*/ |
| 1018 | uint8_t *nr_mapping_array; |
| 1019 | uint32_t highest_tsn_inside_nr_map; |
| 1020 | |
| 1021 | uint32_t fast_recovery_tsn; |
| 1022 | uint32_t sat_t3_recovery_tsn; |
| 1023 | uint32_t tsn_last_delivered; |
| 1024 | /* |
| 1025 | * For the pd-api we should re-write this a bit more efficient. We |
| 1026 | * could have multiple sctp_queued_to_read's that we are building at |
| 1027 | * once. Now we only do this when we get ready to deliver to the |
| 1028 | * socket buffer. Note that we depend on the fact that the struct is |
| 1029 | * "stuck" on the read queue until we finish all the pd-api. |
| 1030 | */ |
| 1031 | struct sctp_queued_to_read *control_pdapi; |
| 1032 | |
| 1033 | uint32_t tsn_of_pdapi_last_delivered; |
| 1034 | uint32_t pdapi_ppid; |
| 1035 | uint32_t context; |
| 1036 | uint32_t last_reset_action[SCTP_MAX_RESET_PARAMS]; |
| 1037 | uint32_t last_sending_seq[SCTP_MAX_RESET_PARAMS]; |
| 1038 | uint32_t last_base_tsnsent[SCTP_MAX_RESET_PARAMS]; |
| 1039 | #ifdef SCTP_ASOCLOG_OF_TSNS |
| 1040 | /* |
| 1041 | * special log - This adds considerable size |
| 1042 | * to the asoc, but provides a log that you |
| 1043 | * can use to detect problems via kgdb. |
| 1044 | */ |
| 1045 | struct sctp_tsn_log in_tsnlog[SCTP_TSN_LOG_SIZE]; |
| 1046 | struct sctp_tsn_log out_tsnlog[SCTP_TSN_LOG_SIZE]; |
| 1047 | uint32_t cumack_log[SCTP_TSN_LOG_SIZE]; |
| 1048 | uint32_t cumack_logsnt[SCTP_TSN_LOG_SIZE]; |
| 1049 | uint16_t tsn_in_at; |
| 1050 | uint16_t tsn_out_at; |
| 1051 | uint16_t tsn_in_wrapped; |
| 1052 | uint16_t tsn_out_wrapped; |
| 1053 | uint16_t cumack_log_at; |
| 1054 | uint16_t cumack_log_atsnt; |
| 1055 | #endif /* SCTP_ASOCLOG_OF_TSNS */ |
| 1056 | #ifdef SCTP_FS_SPEC_LOG |
| 1057 | struct sctp_fs_spec_log fslog[SCTP_FS_SPEC_LOG_SIZE]; |
| 1058 | uint16_t fs_index; |
| 1059 | #endif |
| 1060 | |
| 1061 | /* |
| 1062 | * window state information and smallest MTU that I use to bound |
| 1063 | * segmentation |
| 1064 | */ |
| 1065 | uint32_t peers_rwnd; |
| 1066 | uint32_t my_rwnd; |
| 1067 | uint32_t my_last_reported_rwnd; |
| 1068 | uint32_t sctp_frag_point; |
| 1069 | |
| 1070 | uint32_t total_output_queue_size; |
| 1071 | |
| 1072 | uint32_t sb_cc; /* shadow of sb_cc */ |
| 1073 | uint32_t sb_send_resv; /* amount reserved on a send */ |
| 1074 | uint32_t my_rwnd_control_len; /* shadow of sb_mbcnt used for rwnd control */ |
| 1075 | #ifdef INET6 |
| 1076 | uint32_t default_flowlabel; |
| 1077 | #endif |
| 1078 | uint32_t pr_sctp_cnt; |
| 1079 | int ctrl_queue_cnt; /* could be removed REM - NO IT CAN'T!! RRS */ |
| 1080 | /* |
| 1081 | * All outbound datagrams queue into this list from the individual |
| 1082 | * stream queue. Here they get assigned a TSN and then await |
| 1083 | * sending. The stream seq comes when it is first put in the |
| 1084 | * individual str queue |
| 1085 | */ |
| 1086 | unsigned int stream_queue_cnt; |
| 1087 | unsigned int send_queue_cnt; |
| 1088 | unsigned int sent_queue_cnt; |
| 1089 | unsigned int sent_queue_cnt_removeable; |
| 1090 | /* |
| 1091 | * Number on sent queue that are marked for retran until this value |
| 1092 | * is 0 we only send one packet of retran'ed data. |
| 1093 | */ |
| 1094 | unsigned int sent_queue_retran_cnt; |
| 1095 | |
| 1096 | unsigned int size_on_reasm_queue; |
| 1097 | unsigned int cnt_on_reasm_queue; |
| 1098 | unsigned int fwd_tsn_cnt; |
| 1099 | /* amount of data (bytes) currently in flight (on all destinations) */ |
| 1100 | unsigned int total_flight; |
| 1101 | /* Total book size in flight */ |
| 1102 | unsigned int total_flight_count; /* count of chunks used with |
| 1103 | * book total */ |
| 1104 | /* count of destinaton nets and list of destination nets */ |
| 1105 | unsigned int numnets; |
| 1106 | |
| 1107 | /* Total error count on this association */ |
| 1108 | unsigned int overall_error_count; |
| 1109 | |
| 1110 | unsigned int cnt_msg_on_sb; |
| 1111 | |
| 1112 | /* All stream count of chunks for delivery */ |
| 1113 | unsigned int size_on_all_streams; |
| 1114 | unsigned int cnt_on_all_streams; |
| 1115 | |
| 1116 | /* Heart Beat delay in ms */ |
| 1117 | uint32_t heart_beat_delay; |
| 1118 | |
| 1119 | /* autoclose */ |
| 1120 | unsigned int sctp_autoclose_ticks; |
| 1121 | |
| 1122 | /* how many preopen streams we have */ |
| 1123 | unsigned int pre_open_streams; |
| 1124 | |
| 1125 | /* How many streams I support coming into me */ |
| 1126 | unsigned int max_inbound_streams; |
| 1127 | |
| 1128 | /* the cookie life I award for any cookie, in seconds */ |
| 1129 | unsigned int cookie_life; |
| 1130 | /* time to delay acks for */ |
| 1131 | unsigned int delayed_ack; |
| 1132 | unsigned int old_delayed_ack; |
| 1133 | unsigned int sack_freq; |
| 1134 | unsigned int data_pkts_seen; |
| 1135 | |
| 1136 | unsigned int numduptsns; |
| 1137 | int dup_tsns[SCTP_MAX_DUP_TSNS]; |
| 1138 | unsigned int initial_init_rto_max; /* initial RTO for INIT's */ |
| 1139 | unsigned int initial_rto; /* initial send RTO */ |
| 1140 | unsigned int minrto; /* per assoc RTO-MIN */ |
| 1141 | unsigned int maxrto; /* per assoc RTO-MAX */ |
| 1142 | |
| 1143 | /* authentication fields */ |
| 1144 | sctp_auth_chklist_t *local_auth_chunks; |
| 1145 | sctp_auth_chklist_t *peer_auth_chunks; |
| 1146 | sctp_hmaclist_t *local_hmacs; /* local HMACs supported */ |
| 1147 | sctp_hmaclist_t *peer_hmacs; /* peer HMACs supported */ |
| 1148 | struct sctp_keyhead shared_keys; /* assoc's shared keys */ |
| 1149 | sctp_authinfo_t authinfo; /* randoms, cached keys */ |
| 1150 | /* |
| 1151 | * refcnt to block freeing when a sender or receiver is off coping |
| 1152 | * user data in. |
| 1153 | */ |
| 1154 | uint32_t refcnt; |
| 1155 | uint32_t chunks_on_out_queue; /* total chunks floating around, |
| 1156 | * locked by send socket buffer */ |
| 1157 | uint32_t peers_adaptation; |
| 1158 | uint16_t peer_hmac_id; /* peer HMAC id to send */ |
| 1159 | |
| 1160 | /* |
| 1161 | * Being that we have no bag to collect stale cookies, and that we |
| 1162 | * really would not want to anyway.. we will count them in this |
| 1163 | * counter. We of course feed them to the pigeons right away (I have |
| 1164 | * always thought of pigeons as flying rats). |
| 1165 | */ |
| 1166 | uint16_t stale_cookie_count; |
| 1167 | |
| 1168 | /* |
| 1169 | * For the partial delivery API, if up, invoked this is what last |
| 1170 | * TSN I delivered |
| 1171 | */ |
| 1172 | uint16_t str_of_pdapi; |
| 1173 | uint16_t ssn_of_pdapi; |
| 1174 | |
| 1175 | /* counts of actual built streams. Allocation may be more however */ |
| 1176 | /* could re-arrange to optimize space here. */ |
| 1177 | uint16_t streamincnt; |
| 1178 | uint16_t streamoutcnt; |
| 1179 | uint16_t strm_realoutsize; |
| 1180 | uint16_t strm_pending_add_size; |
| 1181 | /* my maximum number of retrans of INIT and SEND */ |
| 1182 | /* copied from SCTP but should be individually setable */ |
| 1183 | uint16_t max_init_times; |
| 1184 | uint16_t max_send_times; |
| 1185 | |
| 1186 | uint16_t def_net_failure; |
| 1187 | |
| 1188 | uint16_t def_net_pf_threshold; |
| 1189 | |
| 1190 | /* |
| 1191 | * lock flag: 0 is ok to send, 1+ (duals as a retran count) is |
| 1192 | * awaiting ACK |
| 1193 | */ |
| 1194 | uint16_t mapping_array_size; |
| 1195 | |
| 1196 | uint16_t last_strm_seq_delivered; |
| 1197 | uint16_t last_strm_no_delivered; |
| 1198 | |
| 1199 | uint16_t last_revoke_count; |
| 1200 | int16_t num_send_timers_up; |
| 1201 | |
| 1202 | uint16_t stream_locked_on; |
| 1203 | uint16_t ecn_echo_cnt_onq; |
| 1204 | |
| 1205 | uint16_t free_chunk_cnt; |
| 1206 | uint8_t stream_locked; |
| 1207 | uint8_t authenticated; /* packet authenticated ok */ |
| 1208 | /* |
| 1209 | * This flag indicates that a SACK need to be sent. |
| 1210 | * Initially this is 1 to send the first sACK immediately. |
| 1211 | */ |
| 1212 | uint8_t send_sack; |
| 1213 | |
| 1214 | /* max burst of new packets into the network */ |
| 1215 | uint32_t max_burst; |
| 1216 | /* max burst of fast retransmit packets */ |
| 1217 | uint32_t fr_max_burst; |
| 1218 | |
| 1219 | uint8_t sat_network; /* RTT is in range of sat net or greater */ |
| 1220 | uint8_t sat_network_lockout; /* lockout code */ |
| 1221 | uint8_t burst_limit_applied; /* Burst limit in effect at last send? */ |
| 1222 | /* flag goes on when we are doing a partial delivery api */ |
| 1223 | uint8_t hb_random_values[4]; |
| 1224 | uint8_t fragmented_delivery_inprogress; |
| 1225 | uint8_t fragment_flags; |
| 1226 | uint8_t last_flags_delivered; |
| 1227 | uint8_t hb_ect_randombit; |
| 1228 | uint8_t hb_random_idx; |
| 1229 | uint8_t default_dscp; |
| 1230 | uint8_t asconf_del_pending; /* asconf delete last addr pending */ |
| 1231 | uint8_t trigger_reset; |
| 1232 | /* |
| 1233 | * This value, plus all other ack'd but above cum-ack is added |
| 1234 | * together to cross check against the bit that we have yet to |
| 1235 | * define (probably in the SACK). When the cum-ack is updated, this |
| 1236 | * sum is updated as well. |
| 1237 | */ |
| 1238 | |
| 1239 | /* Flags whether an extension is supported or not */ |
| 1240 | uint8_t ecn_supported; |
| 1241 | uint8_t prsctp_supported; |
| 1242 | uint8_t auth_supported; |
| 1243 | uint8_t asconf_supported; |
| 1244 | uint8_t reconfig_supported; |
| 1245 | uint8_t nrsack_supported; |
| 1246 | uint8_t pktdrop_supported; |
| 1247 | uint8_t idata_supported; |
| 1248 | |
| 1249 | /* Did the peer make the stream config (add out) request */ |
| 1250 | uint8_t peer_req_out; |
| 1251 | |
| 1252 | uint8_t local_strreset_support; |
| 1253 | uint8_t peer_supports_nat; |
| 1254 | |
| 1255 | struct sctp_scoping scope; |
| 1256 | /* flags to handle send alternate net tracking */ |
| 1257 | uint8_t used_alt_asconfack; |
| 1258 | uint8_t fast_retran_loss_recovery; |
| 1259 | uint8_t sat_t3_loss_recovery; |
| 1260 | uint8_t dropped_special_cnt; |
| 1261 | uint8_t seen_a_sack_this_pkt; |
| 1262 | uint8_t stream_reset_outstanding; |
| 1263 | uint8_t stream_reset_out_is_outstanding; |
| 1264 | uint8_t delayed_connection; |
| 1265 | uint8_t ifp_had_enobuf; |
| 1266 | uint8_t saw_sack_with_frags; |
| 1267 | uint8_t saw_sack_with_nr_frags; |
| 1268 | uint8_t in_asocid_hash; |
| 1269 | uint8_t assoc_up_sent; |
| 1270 | uint8_t adaptation_needed; |
| 1271 | uint8_t adaptation_sent; |
| 1272 | /* CMT variables */ |
| 1273 | uint8_t cmt_dac_pkts_rcvd; |
| 1274 | uint8_t sctp_cmt_on_off; |
| 1275 | uint8_t iam_blocking; |
| 1276 | uint8_t cookie_how[8]; |
| 1277 | /* JRS 5/21/07 - CMT PF variable */ |
| 1278 | uint8_t sctp_cmt_pf; |
| 1279 | uint8_t use_precise_time; |
| 1280 | uint64_t sctp_features; |
| 1281 | uint32_t max_cwnd; |
| 1282 | uint16_t port; /* remote UDP encapsulation port */ |
| 1283 | /* |
| 1284 | * The mapping array is used to track out of order sequences above |
| 1285 | * last_acked_seq. 0 indicates packet missing 1 indicates packet |
| 1286 | * rec'd. We slide it up every time we raise last_acked_seq and 0 |
| 1287 | * trailing locactions out. If I get a TSN above the array |
| 1288 | * mappingArraySz, I discard the datagram and let retransmit happen. |
| 1289 | */ |
| 1290 | uint32_t marked_retrans; |
| 1291 | uint32_t timoinit; |
| 1292 | uint32_t timodata; |
| 1293 | uint32_t timosack; |
| 1294 | uint32_t timoshutdown; |
| 1295 | uint32_t timoheartbeat; |
| 1296 | uint32_t timocookie; |
| 1297 | uint32_t timoshutdownack; |
| 1298 | struct timeval start_time; |
| 1299 | struct timeval discontinuity_time; |
| 1300 | uint64_t abandoned_unsent[SCTP_PR_SCTP_MAX + 1]; |
| 1301 | uint64_t abandoned_sent[SCTP_PR_SCTP_MAX + 1]; |
| 1302 | }; |
| 1303 | |
| 1304 | #endif |