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