1 /*- 2 * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * a) Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. 9 * 10 * b) Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in 12 * the documentation and/or other materials provided with the distribution. 13 * 14 * c) Neither the name of Cisco Systems, Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived 16 * from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28 * THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 /* $KAME: sctp_structs.h,v 1.13 2005/03/06 16:04:18 itojun Exp $ */ 32 33 #include <sys/cdefs.h> 34 __FBSDID("$FreeBSD$"); 35 36 #ifndef __sctp_structs_h__ 37 #define __sctp_structs_h__ 38 39 #include <netinet/sctp_os.h> 40 #include <netinet/sctp_header.h> 41 #include <netinet/sctp_auth.h> 42 43 struct sctp_timer { 44 sctp_os_timer_t timer; 45 46 int type; 47 /* 48 * Depending on the timer type these will be setup and cast with the 49 * appropriate entity. 50 */ 51 void *ep; 52 void *tcb; 53 void *net; 54 55 /* for sanity checking */ 56 void *self; 57 uint32_t ticks; 58 uint32_t stopped_from; 59 }; 60 61 struct sctp_nonpad_sndrcvinfo { 62 uint16_t sinfo_stream; 63 uint16_t sinfo_ssn; 64 uint16_t sinfo_flags; 65 uint32_t sinfo_ppid; 66 uint32_t sinfo_context; 67 uint32_t sinfo_timetolive; 68 uint32_t sinfo_tsn; 69 uint32_t sinfo_cumtsn; 70 sctp_assoc_t sinfo_assoc_id; 71 }; 72 73 struct sctp_foo_stuff { 74 struct sctp_inpcb *inp; 75 uint32_t lineno; 76 uint32_t ticks; 77 int updown; 78 }; 79 80 81 /* 82 * This is the information we track on each interface that we know about from 83 * the distant end. 84 */ 85 TAILQ_HEAD(sctpnetlisthead, sctp_nets); 86 87 struct sctp_stream_reset_list { 88 TAILQ_ENTRY(sctp_stream_reset_list) next_resp; 89 uint32_t tsn; 90 int number_entries; 91 struct sctp_stream_reset_out_request req; 92 }; 93 94 TAILQ_HEAD(sctp_resethead, sctp_stream_reset_list); 95 96 /* 97 * Users of the iterator need to malloc a iterator with a call to 98 * sctp_initiate_iterator(inp_func, assoc_func, inp_func, pcb_flags, pcb_features, 99 * asoc_state, void-ptr-arg, uint32-arg, end_func, inp); 100 * 101 * Use the following two defines if you don't care what pcb flags are on the EP 102 * and/or you don't care what state the association is in. 103 * 104 * Note that if you specify an INP as the last argument then ONLY each 105 * association of that single INP will be executed upon. Note that the pcb 106 * flags STILL apply so if the inp you specify has different pcb_flags then 107 * what you put in pcb_flags nothing will happen. use SCTP_PCB_ANY_FLAGS to 108 * assure the inp you specify gets treated. 109 */ 110 #define SCTP_PCB_ANY_FLAGS 0x00000000 111 #define SCTP_PCB_ANY_FEATURES 0x00000000 112 #define SCTP_ASOC_ANY_STATE 0x00000000 113 114 typedef void (*asoc_func) (struct sctp_inpcb *, struct sctp_tcb *, void *ptr, 115 uint32_t val); 116 typedef int (*inp_func) (struct sctp_inpcb *, void *ptr, uint32_t val); 117 typedef void (*end_func) (void *ptr, uint32_t val); 118 119 struct sctp_iterator { 120 TAILQ_ENTRY(sctp_iterator) sctp_nxt_itr; 121 struct sctp_timer tmr; 122 struct sctp_inpcb *inp; /* current endpoint */ 123 struct sctp_tcb *stcb; /* current* assoc */ 124 asoc_func function_assoc; /* per assoc function */ 125 inp_func function_inp; /* per endpoint function */ 126 inp_func function_inp_end; /* end INP function */ 127 end_func function_atend;/* iterator completion function */ 128 void *pointer; /* pointer for apply func to use */ 129 uint32_t val; /* value for apply func to use */ 130 uint32_t pcb_flags; /* endpoint flags being checked */ 131 uint32_t pcb_features; /* endpoint features being checked */ 132 uint32_t asoc_state; /* assoc state being checked */ 133 uint32_t iterator_flags; 134 uint8_t no_chunk_output; 135 uint8_t done_current_ep; 136 }; 137 138 /* iterator_flags values */ 139 #define SCTP_ITERATOR_DO_ALL_INP 0x00000001 140 #define SCTP_ITERATOR_DO_SINGLE_INP 0x00000002 141 142 TAILQ_HEAD(sctpiterators, sctp_iterator); 143 144 struct sctp_copy_all { 145 struct sctp_inpcb *inp; /* ep */ 146 struct mbuf *m; 147 struct sctp_sndrcvinfo sndrcv; 148 int sndlen; 149 int cnt_sent; 150 int cnt_failed; 151 }; 152 153 struct sctp_asconf_iterator { 154 struct sctpladdr list_of_work; 155 int cnt; 156 }; 157 158 159 struct sctp_net_route { 160 sctp_rtentry_t *ro_rt; 161 union sctp_sockstore _l_addr; /* remote peer addr */ 162 struct sctp_ifa *_s_addr; /* our selected src addr */ 163 }; 164 165 struct sctp_nets { 166 TAILQ_ENTRY(sctp_nets) sctp_next; /* next link */ 167 168 /* 169 * Things on the top half may be able to be split into a common 170 * structure shared by all. 171 */ 172 struct sctp_timer pmtu_timer; 173 174 /* 175 * The following two in combination equate to a route entry for v6 176 * or v4. 177 */ 178 struct sctp_net_route ro; 179 180 /* mtu discovered so far */ 181 uint32_t mtu; 182 uint32_t ssthresh; /* not sure about this one for split */ 183 184 /* smoothed average things for RTT and RTO itself */ 185 int lastsa; 186 int lastsv; 187 unsigned int RTO; 188 189 /* This is used for SHUTDOWN/SHUTDOWN-ACK/SEND or INIT timers */ 190 struct sctp_timer rxt_timer; 191 struct sctp_timer fr_timer; /* for early fr */ 192 193 /* last time in seconds I sent to it */ 194 struct timeval last_sent_time; 195 int ref_count; 196 197 /* Congestion stats per destination */ 198 /* 199 * flight size variables and such, sorry Vern, I could not avoid 200 * this if I wanted performance :> 201 */ 202 uint32_t flight_size; 203 uint32_t cwnd; /* actual cwnd */ 204 uint32_t prev_cwnd; /* cwnd before any processing */ 205 uint32_t partial_bytes_acked; /* in CA tracks when to incr a MTU */ 206 uint32_t prev_rtt; 207 /* tracking variables to avoid the aloc/free in sack processing */ 208 unsigned int net_ack; 209 unsigned int net_ack2; 210 211 /* 212 * CMT variables (iyengar@cis.udel.edu) 213 */ 214 uint32_t this_sack_highest_newack; /* tracks highest TSN newly 215 * acked for a given dest in 216 * the current SACK. Used in 217 * SFR and HTNA algos */ 218 uint32_t pseudo_cumack; /* CMT CUC algorithm. Maintains next expected 219 * pseudo-cumack for this destination */ 220 uint32_t rtx_pseudo_cumack; /* CMT CUC algorithm. Maintains next 221 * expected pseudo-cumack for this 222 * destination */ 223 224 /* CMT fast recovery variables */ 225 uint32_t fast_recovery_tsn; 226 uint32_t heartbeat_random1; 227 uint32_t heartbeat_random2; 228 uint32_t tos_flowlabel; 229 230 struct timeval start_time; /* time when this net was created */ 231 232 uint32_t marked_retrans;/* number or DATA chunks marked for timer 233 * based retransmissions */ 234 uint32_t marked_fastretrans; 235 236 /* if this guy is ok or not ... status */ 237 uint16_t dest_state; 238 /* number of transmit failures to down this guy */ 239 uint16_t failure_threshold; 240 /* error stats on destination */ 241 uint16_t error_count; 242 243 uint8_t fast_retran_loss_recovery; 244 uint8_t will_exit_fast_recovery; 245 /* Flags that probably can be combined into dest_state */ 246 uint8_t fast_retran_ip; /* fast retransmit in progress */ 247 uint8_t hb_responded; 248 uint8_t saw_newack; /* CMT's SFR algorithm flag */ 249 uint8_t src_addr_selected; /* if we split we move */ 250 uint8_t indx_of_eligible_next_to_use; 251 uint8_t addr_is_local; /* its a local address (if known) could move 252 * in split */ 253 254 /* 255 * CMT variables (iyengar@cis.udel.edu) 256 */ 257 uint8_t find_pseudo_cumack; /* CMT CUC algorithm. Flag used to 258 * find a new pseudocumack. This flag 259 * is set after a new pseudo-cumack 260 * has been received and indicates 261 * that the sender should find the 262 * next pseudo-cumack expected for 263 * this destination */ 264 uint8_t find_rtx_pseudo_cumack; /* CMT CUCv2 algorithm. Flag used to 265 * find a new rtx-pseudocumack. This 266 * flag is set after a new 267 * rtx-pseudo-cumack has been received 268 * and indicates that the sender 269 * should find the next 270 * rtx-pseudo-cumack expected for this 271 * destination */ 272 uint8_t new_pseudo_cumack; /* CMT CUC algorithm. Flag used to 273 * indicate if a new pseudo-cumack or 274 * rtx-pseudo-cumack has been received */ 275 uint8_t window_probe; /* Doing a window probe? */ 276 #ifdef SCTP_HIGH_SPEED 277 uint8_t last_hs_used; /* index into the last HS table entry we used */ 278 #endif 279 }; 280 281 282 struct sctp_data_chunkrec { 283 uint32_t TSN_seq; /* the TSN of this transmit */ 284 uint16_t stream_seq; /* the stream sequence number of this transmit */ 285 uint16_t stream_number; /* the stream number of this guy */ 286 uint32_t payloadtype; 287 uint32_t context; /* from send */ 288 289 /* ECN Nonce: Nonce Value for this chunk */ 290 uint8_t ect_nonce; 291 292 /* 293 * part of the Highest sacked algorithm to be able to stroke counts 294 * on ones that are FR'd. 295 */ 296 uint32_t fast_retran_tsn; /* sending_seq at the time of FR */ 297 struct timeval timetodrop; /* time we drop it from queue */ 298 uint8_t doing_fast_retransmit; 299 uint8_t rcv_flags; /* flags pulled from data chunk on inbound for 300 * outbound holds sending flags for PR-SCTP. */ 301 uint8_t state_flags; 302 uint8_t chunk_was_revoked; 303 }; 304 305 TAILQ_HEAD(sctpchunk_listhead, sctp_tmit_chunk); 306 307 /* The lower byte is used to enumerate PR_SCTP policies */ 308 #define CHUNK_FLAGS_PR_SCTP_TTL SCTP_PR_SCTP_TTL 309 #define CHUNK_FLAGS_PR_SCTP_BUF SCTP_PR_SCTP_BUF 310 #define CHUNK_FLAGS_PR_SCTP_RTX SCTP_PR_SCTP_RTX 311 312 /* The upper byte is used a a bit mask */ 313 #define CHUNK_FLAGS_FRAGMENT_OK 0x0100 314 315 struct chk_id { 316 uint16_t id; 317 uint16_t can_take_data; 318 }; 319 320 321 struct sctp_tmit_chunk { 322 union { 323 struct sctp_data_chunkrec data; 324 struct chk_id chunk_id; 325 } rec; 326 struct sctp_association *asoc; /* bp to asoc this belongs to */ 327 struct timeval sent_rcv_time; /* filled in if RTT being calculated */ 328 struct mbuf *data; /* pointer to mbuf chain of data */ 329 struct mbuf *last_mbuf; /* pointer to last mbuf in chain */ 330 struct sctp_nets *whoTo; 331 TAILQ_ENTRY(sctp_tmit_chunk) sctp_next; /* next link */ 332 int32_t sent; /* the send status */ 333 uint16_t snd_count; /* number of times I sent */ 334 uint16_t flags; /* flags, such as FRAGMENT_OK */ 335 uint16_t send_size; 336 uint16_t book_size; 337 uint16_t mbcnt; 338 uint8_t pad_inplace; 339 uint8_t do_rtt; 340 uint8_t book_size_scale; 341 uint8_t addr_over; /* flag which is set if the dest address for 342 * this chunk is overridden by user. Used for 343 * CMT (iyengar@cis.udel.edu, 2005/06/21) */ 344 uint8_t no_fr_allowed; 345 uint8_t pr_sctp_on; 346 uint8_t copy_by_ref; 347 uint8_t window_probe; 348 }; 349 350 /* 351 * The first part of this structure MUST be the entire sinfo structure. Maybe 352 * I should have made it a sub structure... we can circle back later and do 353 * that if we want. 354 */ 355 struct sctp_queued_to_read { /* sinfo structure Pluse more */ 356 uint16_t sinfo_stream; /* off the wire */ 357 uint16_t sinfo_ssn; /* off the wire */ 358 uint16_t sinfo_flags; /* SCTP_UNORDERED from wire use SCTP_EOF for 359 * EOR */ 360 uint32_t sinfo_ppid; /* off the wire */ 361 uint32_t sinfo_context; /* pick this up from assoc def context? */ 362 uint32_t sinfo_timetolive; /* not used by kernel */ 363 uint32_t sinfo_tsn; /* Use this in reassembly as first TSN */ 364 uint32_t sinfo_cumtsn; /* Use this in reassembly as last TSN */ 365 sctp_assoc_t sinfo_assoc_id; /* our assoc id */ 366 /* Non sinfo stuff */ 367 uint32_t length; /* length of data */ 368 uint32_t held_length; /* length held in sb */ 369 struct sctp_nets *whoFrom; /* where it came from */ 370 struct mbuf *data; /* front of the mbuf chain of data with 371 * PKT_HDR */ 372 struct mbuf *tail_mbuf; /* used for multi-part data */ 373 struct mbuf *aux_data; /* used to hold/cache control if o/s does not 374 * take it from us */ 375 struct sctp_tcb *stcb; /* assoc, used for window update */ 376 TAILQ_ENTRY(sctp_queued_to_read) next; 377 uint16_t port_from; 378 uint16_t spec_flags; /* Flags to hold the notification field */ 379 uint8_t do_not_ref_stcb; 380 uint8_t end_added; 381 uint8_t pdapi_aborted; 382 uint8_t some_taken; 383 }; 384 385 /* This data structure will be on the outbound 386 * stream queues. Data will be pulled off from 387 * the front of the mbuf data and chunk-ified 388 * by the output routines. We will custom 389 * fit every chunk we pull to the send/sent 390 * queue to make up the next full packet 391 * if we can. An entry cannot be removed 392 * from the stream_out queue until 393 * the msg_is_complete flag is set. This 394 * means at times data/tail_mbuf MIGHT 395 * be NULL.. If that occurs it happens 396 * for one of two reasons. Either the user 397 * is blocked on a send() call and has not 398 * awoken to copy more data down... OR 399 * the user is in the explict MSG_EOR mode 400 * and wrote some data, but has not completed 401 * sending. 402 */ 403 struct sctp_stream_queue_pending { 404 struct mbuf *data; 405 struct mbuf *tail_mbuf; 406 struct timeval ts; 407 struct sctp_nets *net; 408 TAILQ_ENTRY(sctp_stream_queue_pending) next; 409 uint32_t length; 410 uint32_t timetolive; 411 uint32_t ppid; 412 uint32_t context; 413 uint16_t sinfo_flags; 414 uint16_t stream; 415 uint16_t strseq; 416 uint16_t act_flags; 417 uint8_t msg_is_complete; 418 uint8_t some_taken; 419 uint8_t addr_over; 420 uint8_t pr_sctp_on; 421 uint8_t sender_all_done; 422 uint8_t put_last_out; 423 }; 424 425 /* 426 * this struct contains info that is used to track inbound stream data and 427 * help with ordering. 428 */ 429 TAILQ_HEAD(sctpwheelunrel_listhead, sctp_stream_in); 430 struct sctp_stream_in { 431 struct sctp_readhead inqueue; 432 uint16_t stream_no; 433 uint16_t last_sequence_delivered; /* used for re-order */ 434 uint8_t delivery_started; 435 }; 436 437 /* This struct is used to track the traffic on outbound streams */ 438 TAILQ_HEAD(sctpwheel_listhead, sctp_stream_out); 439 struct sctp_stream_out { 440 struct sctp_streamhead outqueue; 441 TAILQ_ENTRY(sctp_stream_out) next_spoke; /* next link in wheel */ 442 uint16_t stream_no; 443 uint16_t next_sequence_sent; /* next one I expect to send out */ 444 uint8_t last_msg_incomplete; 445 }; 446 447 /* used to keep track of the addresses yet to try to add/delete */ 448 TAILQ_HEAD(sctp_asconf_addrhead, sctp_asconf_addr); 449 struct sctp_asconf_addr { 450 TAILQ_ENTRY(sctp_asconf_addr) next; 451 struct sctp_asconf_addr_param ap; 452 struct sctp_ifa *ifa; /* save the ifa for add/del ip */ 453 uint8_t sent; /* has this been sent yet? */ 454 }; 455 456 struct sctp_scoping { 457 uint8_t ipv4_addr_legal; 458 uint8_t ipv6_addr_legal; 459 uint8_t loopback_scope; 460 uint8_t ipv4_local_scope; 461 uint8_t local_scope; 462 uint8_t site_scope; 463 }; 464 465 #define SCTP_TSN_LOG_SIZE 40 466 467 struct sctp_tsn_log { 468 uint32_t tsn; 469 uint16_t strm; 470 uint16_t seq; 471 uint16_t sz; 472 uint16_t flgs; 473 }; 474 475 /* 476 * Here we have information about each individual association that we track. 477 * We probably in production would be more dynamic. But for ease of 478 * implementation we will have a fixed array that we hunt for in a linear 479 * fashion. 480 */ 481 struct sctp_association { 482 /* association state */ 483 int state; 484 /* queue of pending addrs to add/delete */ 485 struct sctp_asconf_addrhead asconf_queue; 486 struct timeval time_entered; /* time we entered state */ 487 struct timeval time_last_rcvd; 488 struct timeval time_last_sent; 489 struct timeval time_last_sat_advance; 490 struct sctp_sndrcvinfo def_send; /* default send parameters */ 491 492 /* timers and such */ 493 struct sctp_timer hb_timer; /* hb timer */ 494 struct sctp_timer dack_timer; /* Delayed ack timer */ 495 struct sctp_timer asconf_timer; /* Asconf */ 496 struct sctp_timer strreset_timer; /* stream reset */ 497 struct sctp_timer shut_guard_timer; /* guard */ 498 struct sctp_timer autoclose_timer; /* automatic close timer */ 499 struct sctp_timer delayed_event_timer; /* timer for delayed events */ 500 501 /* list of local addresses when add/del in progress */ 502 struct sctpladdr sctp_restricted_addrs; 503 504 struct sctpnetlisthead nets; 505 506 /* Free chunk list */ 507 struct sctpchunk_listhead free_chunks; 508 509 510 /* Control chunk queue */ 511 struct sctpchunk_listhead control_send_queue; 512 513 /* 514 * Once a TSN hits the wire it is moved to the sent_queue. We 515 * maintain two counts here (don't know if any but retran_cnt is 516 * needed). The idea is that the sent_queue_retran_cnt reflects how 517 * many chunks have been marked for retranmission by either T3-rxt 518 * or FR. 519 */ 520 struct sctpchunk_listhead sent_queue; 521 struct sctpchunk_listhead send_queue; 522 523 524 /* re-assembly queue for fragmented chunks on the inbound path */ 525 struct sctpchunk_listhead reasmqueue; 526 527 /* 528 * this queue is used when we reach a condition that we can NOT put 529 * data into the socket buffer. We track the size of this queue and 530 * set our rwnd to the space in the socket minus also the 531 * size_on_delivery_queue. 532 */ 533 struct sctpwheel_listhead out_wheel; 534 535 /* 536 * This pointer will be set to NULL most of the time. But when we 537 * have a fragmented message, where we could not get out all of the 538 * message at the last send then this will point to the stream to go 539 * get data from. 540 */ 541 struct sctp_stream_out *locked_on_sending; 542 543 /* If an iterator is looking at me, this is it */ 544 struct sctp_iterator *stcb_starting_point_for_iterator; 545 546 /* ASCONF destination address last sent to */ 547 /* struct sctp_nets *asconf_last_sent_to;*/ 548 /* Peter, greppign for the above shows only on strange set 549 * I don't think we need it so I have commented it out. 550 */ 551 552 /* ASCONF save the last ASCONF-ACK so we can resend it if necessary */ 553 struct mbuf *last_asconf_ack_sent; 554 555 /* 556 * pointer to last stream reset queued to control queue by us with 557 * requests. 558 */ 559 struct sctp_tmit_chunk *str_reset; 560 /* 561 * if Source Address Selection happening, this will rotate through 562 * the link list. 563 */ 564 struct sctp_laddr *last_used_address; 565 566 /* stream arrays */ 567 struct sctp_stream_in *strmin; 568 struct sctp_stream_out *strmout; 569 uint8_t *mapping_array; 570 /* primary destination to use */ 571 struct sctp_nets *primary_destination; 572 /* For CMT */ 573 struct sctp_nets *last_net_data_came_from; 574 /* last place I got a data chunk from */ 575 struct sctp_nets *last_data_chunk_from; 576 /* last place I got a control from */ 577 struct sctp_nets *last_control_chunk_from; 578 579 /* circular looking for output selection */ 580 struct sctp_stream_out *last_out_stream; 581 582 /* 583 * wait to the point the cum-ack passes req->send_reset_at_tsn for 584 * any req on the list. 585 */ 586 struct sctp_resethead resetHead; 587 588 /* queue of chunks waiting to be sent into the local stack */ 589 struct sctp_readhead pending_reply_queue; 590 591 uint32_t vrf_id; 592 uint32_t table_id; 593 594 uint32_t cookie_preserve_req; 595 /* ASCONF next seq I am sending out, inits at init-tsn */ 596 uint32_t asconf_seq_out; 597 /* ASCONF last received ASCONF from peer, starts at peer's TSN-1 */ 598 uint32_t asconf_seq_in; 599 600 /* next seq I am sending in str reset messages */ 601 uint32_t str_reset_seq_out; 602 /* next seq I am expecting in str reset messages */ 603 uint32_t str_reset_seq_in; 604 605 /* various verification tag information */ 606 uint32_t my_vtag; /* The tag to be used. if assoc is re-initited 607 * by remote end, and I have unlocked this 608 * will be regenerated to a new random value. */ 609 uint32_t peer_vtag; /* The peers last tag */ 610 611 uint32_t my_vtag_nonce; 612 uint32_t peer_vtag_nonce; 613 614 uint32_t assoc_id; 615 616 /* This is the SCTP fragmentation threshold */ 617 uint32_t smallest_mtu; 618 619 /* 620 * Special hook for Fast retransmit, allows us to track the highest 621 * TSN that is NEW in this SACK if gap ack blocks are present. 622 */ 623 uint32_t this_sack_highest_gap; 624 625 /* 626 * The highest consecutive TSN that has been acked by peer on my 627 * sends 628 */ 629 uint32_t last_acked_seq; 630 631 /* The next TSN that I will use in sending. */ 632 uint32_t sending_seq; 633 634 /* Original seq number I used ??questionable to keep?? */ 635 uint32_t init_seq_number; 636 637 638 /* The Advanced Peer Ack Point, as required by the PR-SCTP */ 639 /* (A1 in Section 4.2) */ 640 uint32_t advanced_peer_ack_point; 641 642 /* 643 * The highest consequetive TSN at the bottom of the mapping array 644 * (for his sends). 645 */ 646 uint32_t cumulative_tsn; 647 /* 648 * Used to track the mapping array and its offset bits. This MAY be 649 * lower then cumulative_tsn. 650 */ 651 uint32_t mapping_array_base_tsn; 652 /* 653 * used to track highest TSN we have received and is listed in the 654 * mapping array. 655 */ 656 uint32_t highest_tsn_inside_map; 657 658 uint32_t last_echo_tsn; 659 uint32_t last_cwr_tsn; 660 uint32_t fast_recovery_tsn; 661 uint32_t sat_t3_recovery_tsn; 662 uint32_t tsn_last_delivered; 663 /* 664 * For the pd-api we should re-write this a bit more efficent. We 665 * could have multiple sctp_queued_to_read's that we are building at 666 * once. Now we only do this when we get ready to deliver to the 667 * socket buffer. Note that we depend on the fact that the struct is 668 * "stuck" on the read queue until we finish all the pd-api. 669 */ 670 struct sctp_queued_to_read *control_pdapi; 671 672 uint32_t tsn_of_pdapi_last_delivered; 673 uint32_t pdapi_ppid; 674 uint32_t context; 675 uint32_t last_reset_action[SCTP_MAX_RESET_PARAMS]; 676 uint32_t last_sending_seq[SCTP_MAX_RESET_PARAMS]; 677 uint32_t last_base_tsnsent[SCTP_MAX_RESET_PARAMS]; 678 #ifdef SCTP_ASOCLOG_OF_TSNS 679 /* 680 * special log - This adds considerable size to the asoc, but 681 * provides a log that you can use to detect problems via kgdb. 682 */ 683 struct sctp_tsn_log in_tsnlog[SCTP_TSN_LOG_SIZE]; 684 struct sctp_tsn_log out_tsnlog[SCTP_TSN_LOG_SIZE]; 685 uint16_t tsn_in_at; 686 uint16_t tsn_out_at; 687 uint16_t tsn_in_wrapped; 688 uint16_t tsn_out_wrapped; 689 #endif /* SCTP_ASOCLOG_OF_TSNS */ 690 /* 691 * window state information and smallest MTU that I use to bound 692 * segmentation 693 */ 694 uint32_t peers_rwnd; 695 uint32_t my_rwnd; 696 uint32_t my_last_reported_rwnd; 697 uint32_t my_rwnd_control_len; 698 699 uint32_t total_output_queue_size; 700 701 uint32_t sb_cc; /* shadow of sb_cc in one-2-one */ 702 uint32_t sb_mbcnt; /* shadow of sb_mbcnt in one-2-one */ 703 /* 32 bit nonce stuff */ 704 uint32_t nonce_resync_tsn; 705 uint32_t nonce_wait_tsn; 706 uint32_t default_flowlabel; 707 uint32_t pr_sctp_cnt; 708 int ctrl_queue_cnt; /* could be removed REM */ 709 /* 710 * All outbound datagrams queue into this list from the individual 711 * stream queue. Here they get assigned a TSN and then await 712 * sending. The stream seq comes when it is first put in the 713 * individual str queue 714 */ 715 unsigned int stream_queue_cnt; 716 unsigned int send_queue_cnt; 717 unsigned int sent_queue_cnt; 718 unsigned int sent_queue_cnt_removeable; 719 /* 720 * Number on sent queue that are marked for retran until this value 721 * is 0 we only send one packet of retran'ed data. 722 */ 723 unsigned int sent_queue_retran_cnt; 724 725 unsigned int size_on_reasm_queue; 726 unsigned int cnt_on_reasm_queue; 727 /* amount of data (bytes) currently in flight (on all destinations) */ 728 unsigned int total_flight; 729 /* Total book size in flight */ 730 unsigned int total_flight_count; /* count of chunks used with 731 * book total */ 732 /* count of destinaton nets and list of destination nets */ 733 unsigned int numnets; 734 735 /* Total error count on this association */ 736 unsigned int overall_error_count; 737 738 unsigned int cnt_msg_on_sb; 739 740 /* All stream count of chunks for delivery */ 741 unsigned int size_on_all_streams; 742 unsigned int cnt_on_all_streams; 743 744 /* Heart Beat delay in ticks */ 745 unsigned int heart_beat_delay; 746 747 /* autoclose */ 748 unsigned int sctp_autoclose_ticks; 749 750 /* how many preopen streams we have */ 751 unsigned int pre_open_streams; 752 753 /* How many streams I support coming into me */ 754 unsigned int max_inbound_streams; 755 756 /* the cookie life I award for any cookie, in seconds */ 757 unsigned int cookie_life; 758 /* time to delay acks for */ 759 unsigned int delayed_ack; 760 unsigned int old_delayed_ack; 761 unsigned int sack_freq; 762 unsigned int data_pkts_seen; 763 764 unsigned int numduptsns; 765 int dup_tsns[SCTP_MAX_DUP_TSNS]; 766 unsigned int initial_init_rto_max; /* initial RTO for INIT's */ 767 unsigned int initial_rto; /* initial send RTO */ 768 unsigned int minrto; /* per assoc RTO-MIN */ 769 unsigned int maxrto; /* per assoc RTO-MAX */ 770 771 /* authentication fields */ 772 sctp_auth_chklist_t *local_auth_chunks; 773 sctp_auth_chklist_t *peer_auth_chunks; 774 sctp_hmaclist_t *local_hmacs; /* local HMACs supported */ 775 sctp_hmaclist_t *peer_hmacs; /* peer HMACs supported */ 776 struct sctp_keyhead shared_keys; /* assoc's shared keys */ 777 sctp_authinfo_t authinfo; /* randoms, cached keys */ 778 /* 779 * refcnt to block freeing when a sender or receiver is off coping 780 * user data in. 781 */ 782 uint32_t refcnt; 783 uint32_t chunks_on_out_queue; /* total chunks floating around, 784 * locked by send socket buffer */ 785 786 uint16_t peer_hmac_id; /* peer HMAC id to send */ 787 788 /* 789 * Being that we have no bag to collect stale cookies, and that we 790 * really would not want to anyway.. we will count them in this 791 * counter. We of course feed them to the pigeons right away (I have 792 * always thought of pigeons as flying rats). 793 */ 794 uint16_t stale_cookie_count; 795 796 /* 797 * For the partial delivery API, if up, invoked this is what last 798 * TSN I delivered 799 */ 800 uint16_t str_of_pdapi; 801 uint16_t ssn_of_pdapi; 802 803 /* counts of actual built streams. Allocation may be more however */ 804 /* could re-arrange to optimize space here. */ 805 uint16_t streamincnt; 806 uint16_t streamoutcnt; 807 808 /* my maximum number of retrans of INIT and SEND */ 809 /* copied from SCTP but should be individually setable */ 810 uint16_t max_init_times; 811 uint16_t max_send_times; 812 813 uint16_t def_net_failure; 814 815 /* 816 * lock flag: 0 is ok to send, 1+ (duals as a retran count) is 817 * awaiting ACK 818 */ 819 uint16_t asconf_sent; /* possibly removable REM */ 820 uint16_t mapping_array_size; 821 822 uint16_t last_strm_seq_delivered; 823 uint16_t last_strm_no_delivered; 824 825 uint16_t last_revoke_count; 826 int16_t num_send_timers_up; 827 828 uint16_t stream_locked_on; 829 uint16_t ecn_echo_cnt_onq; 830 831 uint16_t free_chunk_cnt; 832 833 uint8_t stream_locked; 834 uint8_t authenticated; /* packet authenticated ok */ 835 /* 836 * This flag indicates that a SACK need to be sent. Initially this 837 * is 1 to send the first sACK immediately. 838 */ 839 uint8_t send_sack; 840 841 /* max burst after fast retransmit completes */ 842 uint8_t max_burst; 843 844 uint8_t sat_network; /* RTT is in range of sat net or greater */ 845 uint8_t sat_network_lockout; /* lockout code */ 846 uint8_t burst_limit_applied; /* Burst limit in effect at last send? */ 847 /* flag goes on when we are doing a partial delivery api */ 848 uint8_t hb_random_values[4]; 849 uint8_t fragmented_delivery_inprogress; 850 uint8_t fragment_flags; 851 uint8_t last_flags_delivered; 852 uint8_t hb_ect_randombit; 853 uint8_t hb_random_idx; 854 uint8_t hb_is_disabled; /* is the hb disabled? */ 855 uint8_t default_tos; 856 857 /* ECN Nonce stuff */ 858 uint8_t receiver_nonce_sum; /* nonce I sum and put in my sack */ 859 uint8_t ecn_nonce_allowed; /* Tells us if ECN nonce is on */ 860 uint8_t nonce_sum_check;/* On off switch used during re-sync */ 861 uint8_t nonce_wait_for_ecne; /* flag when we expect a ECN */ 862 uint8_t peer_supports_ecn_nonce; 863 864 /* 865 * This value, plus all other ack'd but above cum-ack is added 866 * together to cross check against the bit that we have yet to 867 * define (probably in the SACK). When the cum-ack is updated, this 868 * sum is updated as well. 869 */ 870 uint8_t nonce_sum_expect_base; 871 /* Flag to tell if ECN is allowed */ 872 uint8_t ecn_allowed; 873 874 /* flag to indicate if peer can do asconf */ 875 uint8_t peer_supports_asconf; 876 /* pr-sctp support flag */ 877 uint8_t peer_supports_prsctp; 878 /* peer authentication support flag */ 879 uint8_t peer_supports_auth; 880 /* stream resets are supported by the peer */ 881 uint8_t peer_supports_strreset; 882 883 /* 884 * packet drop's are supported by the peer, we don't really care 885 * about this but we bookkeep it anyway. 886 */ 887 uint8_t peer_supports_pktdrop; 888 889 /* Do we allow V6/V4? */ 890 uint8_t ipv4_addr_legal; 891 uint8_t ipv6_addr_legal; 892 /* Address scoping flags */ 893 /* scope value for IPv4 */ 894 uint8_t ipv4_local_scope; 895 /* scope values for IPv6 */ 896 uint8_t local_scope; 897 uint8_t site_scope; 898 /* loopback scope */ 899 uint8_t loopback_scope; 900 /* flags to handle send alternate net tracking */ 901 uint8_t used_alt_onsack; 902 uint8_t used_alt_asconfack; 903 uint8_t fast_retran_loss_recovery; 904 uint8_t sat_t3_loss_recovery; 905 uint8_t dropped_special_cnt; 906 uint8_t seen_a_sack_this_pkt; 907 uint8_t stream_reset_outstanding; 908 uint8_t stream_reset_out_is_outstanding; 909 uint8_t delayed_connection; 910 uint8_t ifp_had_enobuf; 911 uint8_t saw_sack_with_frags; 912 uint8_t in_restart_hash; 913 uint8_t assoc_up_sent; 914 /* CMT variables */ 915 uint8_t cmt_dac_pkts_rcvd; 916 uint8_t sctp_cmt_on_off; 917 uint8_t iam_blocking; 918 uint8_t cookie_how[8]; 919 /* 920 * The mapping array is used to track out of order sequences above 921 * last_acked_seq. 0 indicates packet missing 1 indicates packet 922 * rec'd. We slide it up every time we raise last_acked_seq and 0 923 * trailing locactions out. If I get a TSN above the array 924 * mappingArraySz, I discard the datagram and let retransmit happen. 925 */ 926 uint32_t marked_retrans; 927 uint32_t timoinit; 928 uint32_t timodata; 929 uint32_t timosack; 930 uint32_t timoshutdown; 931 uint32_t timoheartbeat; 932 uint32_t timocookie; 933 uint32_t timoshutdownack; 934 struct timeval start_time; 935 struct timeval discontinuity_time; 936 }; 937 938 #endif 939