2 * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2008-2011, by Randall Stewart. All rights reserved.
4 * Copyright (c) 2008-2011, by Michael Tuexen. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
9 * a) Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
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.
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.
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.
33 /* $KAME: sctp_structs.h,v 1.13 2005/03/06 16:04:18 itojun Exp $ */
35 #include <sys/cdefs.h>
36 __FBSDID("$FreeBSD$");
38 #ifndef __sctp_structs_h__
39 #define __sctp_structs_h__
41 #include <netinet/sctp_os.h>
42 #include <netinet/sctp_header.h>
43 #include <netinet/sctp_auth.h>
46 sctp_os_timer_t timer;
50 * Depending on the timer type these will be setup and cast with the
58 /* for sanity checking */
61 uint32_t stopped_from;
65 struct sctp_foo_stuff {
66 struct sctp_inpcb *inp;
74 * This is the information we track on each interface that we know about from
77 TAILQ_HEAD(sctpnetlisthead, sctp_nets);
79 struct sctp_stream_reset_list {
80 TAILQ_ENTRY(sctp_stream_reset_list) next_resp;
83 struct sctp_stream_reset_out_request req;
86 TAILQ_HEAD(sctp_resethead, sctp_stream_reset_list);
89 * Users of the iterator need to malloc a iterator with a call to
90 * sctp_initiate_iterator(inp_func, assoc_func, inp_func, pcb_flags, pcb_features,
91 * asoc_state, void-ptr-arg, uint32-arg, end_func, inp);
93 * Use the following two defines if you don't care what pcb flags are on the EP
94 * and/or you don't care what state the association is in.
96 * Note that if you specify an INP as the last argument then ONLY each
97 * association of that single INP will be executed upon. Note that the pcb
98 * flags STILL apply so if the inp you specify has different pcb_flags then
99 * what you put in pcb_flags nothing will happen. use SCTP_PCB_ANY_FLAGS to
100 * assure the inp you specify gets treated.
102 #define SCTP_PCB_ANY_FLAGS 0x00000000
103 #define SCTP_PCB_ANY_FEATURES 0x00000000
104 #define SCTP_ASOC_ANY_STATE 0x00000000
106 typedef void (*asoc_func) (struct sctp_inpcb *, struct sctp_tcb *, void *ptr,
108 typedef int (*inp_func) (struct sctp_inpcb *, void *ptr, uint32_t val);
109 typedef void (*end_func) (void *ptr, uint32_t val);
111 #if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP)
112 /* whats on the mcore control struct */
113 struct sctp_mcore_queue {
114 TAILQ_ENTRY(sctp_mcore_queue) next;
121 TAILQ_HEAD(sctp_mcore_qhead, sctp_mcore_queue);
123 struct sctp_mcore_ctrl {
124 SCTP_PROCESS_STRUCT thread_proc;
125 struct sctp_mcore_qhead que;
136 struct sctp_iterator {
137 TAILQ_ENTRY(sctp_iterator) sctp_nxt_itr;
139 struct sctp_timer tmr;
140 struct sctp_inpcb *inp; /* current endpoint */
141 struct sctp_tcb *stcb; /* current* assoc */
142 struct sctp_inpcb *next_inp; /* special hook to skip to */
143 asoc_func function_assoc; /* per assoc function */
144 inp_func function_inp; /* per endpoint function */
145 inp_func function_inp_end; /* end INP function */
146 end_func function_atend;/* iterator completion function */
147 void *pointer; /* pointer for apply func to use */
148 uint32_t val; /* value for apply func to use */
149 uint32_t pcb_flags; /* endpoint flags being checked */
150 uint32_t pcb_features; /* endpoint features being checked */
151 uint32_t asoc_state; /* assoc state being checked */
152 uint32_t iterator_flags;
153 uint8_t no_chunk_output;
154 uint8_t done_current_ep;
157 /* iterator_flags values */
158 #define SCTP_ITERATOR_DO_ALL_INP 0x00000001
159 #define SCTP_ITERATOR_DO_SINGLE_INP 0x00000002
162 TAILQ_HEAD(sctpiterators, sctp_iterator);
164 struct sctp_copy_all {
165 struct sctp_inpcb *inp; /* ep */
167 struct sctp_sndrcvinfo sndrcv;
173 struct sctp_asconf_iterator {
174 struct sctpladdr list_of_work;
178 struct iterator_control {
179 struct mtx ipi_iterator_wq_mtx;
181 SCTP_PROCESS_STRUCT thread_proc;
182 struct sctpiterators iteratorhead;
183 struct sctp_iterator *cur_it;
184 uint32_t iterator_running;
185 uint32_t iterator_flags;
188 #define SCTP_ITERATOR_STOP_CUR_IT 0x00000004
189 #define SCTP_ITERATOR_STOP_CUR_INP 0x00000008
191 struct sctp_net_route {
192 sctp_rtentry_t *ro_rt;
196 union sctp_sockstore _l_addr; /* remote peer addr */
197 struct sctp_ifa *_s_addr; /* our selected src addr */
201 uint16_t alpha; /* Fixed point arith, << 7 */
202 uint8_t beta; /* Fixed point arith, << 7 */
203 uint8_t modeswitch; /* Delay modeswitch until we had at least one
204 * congestion event */
205 uint32_t last_cong; /* Time since last congestion event end */
206 uint32_t undo_last_cong;
207 uint16_t bytes_acked;
212 uint32_t undo_maxRTT;
213 uint32_t undo_old_maxB;
215 /* Bandwidth estimation */
224 struct timeval tls; /* The time we started the sending */
225 uint64_t lbw; /* Our last estimated bw */
226 uint64_t lbw_rtt; /* RTT at bw estimate */
227 uint64_t bw_bytes; /* The total bytes since this sending began */
228 uint64_t bw_tot_time; /* The total time since sending began */
229 uint64_t new_tot_time; /* temp holding the new value */
230 uint64_t bw_bytes_at_last_rttc; /* What bw_bytes was at last rtt calc */
231 uint32_t cwnd_at_bw_set;/* Cwnd at last bw saved - lbw */
232 uint32_t vol_reduce; /* cnt of voluntary reductions */
233 uint16_t steady_step; /* The number required to be in steady state */
234 uint16_t step_cnt; /* The current number */
235 uint8_t ret_from_eq; /* When all things are equal what do I return
236 * 0/1 - 1 no cc advance */
237 uint8_t use_dccc_ecn; /* Flag to enable DCCC ECN */
238 uint8_t tls_needs_set; /* Flag to indicate we need to set tls 0 or 1
239 * means set at send 2 not */
240 uint8_t last_step_state;/* Last state if steady state stepdown is on */
241 uint8_t rtt_set_this_sack; /* Flag saying this sack had RTT calc
243 uint8_t last_inst_ind; /* Last saved inst indication */
248 TAILQ_ENTRY(sctp_nets) sctp_next; /* next link */
251 * Things on the top half may be able to be split into a common
252 * structure shared by all.
254 struct sctp_timer pmtu_timer;
255 struct sctp_timer hb_timer;
258 * The following two in combination equate to a route entry for v6
261 struct sctp_net_route ro;
263 /* mtu discovered so far */
265 uint32_t ssthresh; /* not sure about this one for split */
266 uint32_t last_cwr_tsn;
267 uint32_t cwr_window_tsn;
268 uint32_t ecn_ce_pkt_cnt;
270 /* smoothed average things for RTT and RTO itself */
273 uint64_t rtt; /* last measured rtt value in us */
276 /* This is used for SHUTDOWN/SHUTDOWN-ACK/SEND or INIT timers */
277 struct sctp_timer rxt_timer;
279 /* last time in seconds I sent to it */
280 struct timeval last_sent_time;
281 union cc_control_data {
282 struct htcp htcp_ca; /* JRS - struct used in HTCP algorithm */
283 struct rtcc_cc rtcc; /* rtcc module cc stuff */
287 /* Congestion stats per destination */
289 * flight size variables and such, sorry Vern, I could not avoid
290 * this if I wanted performance :>
292 uint32_t flight_size;
293 uint32_t cwnd; /* actual cwnd */
294 uint32_t prev_cwnd; /* cwnd before any processing */
295 uint32_t ecn_prev_cwnd; /* ECN prev cwnd at first ecn_echo seen in new
297 uint32_t partial_bytes_acked; /* in CA tracks when to incr a MTU */
298 /* tracking variables to avoid the aloc/free in sack processing */
299 unsigned int net_ack;
300 unsigned int net_ack2;
303 * JRS - 5/8/07 - Variable to track last time a destination was
306 uint32_t last_active;
309 * CMT variables (iyengar@cis.udel.edu)
311 uint32_t this_sack_highest_newack; /* tracks highest TSN newly
312 * acked for a given dest in
313 * the current SACK. Used in
314 * SFR and HTNA algos */
315 uint32_t pseudo_cumack; /* CMT CUC algorithm. Maintains next expected
316 * pseudo-cumack for this destination */
317 uint32_t rtx_pseudo_cumack; /* CMT CUC algorithm. Maintains next
318 * expected pseudo-cumack for this
321 /* CMT fast recovery variables */
322 uint32_t fast_recovery_tsn;
323 uint32_t heartbeat_random1;
324 uint32_t heartbeat_random2;
330 struct timeval start_time; /* time when this net was created */
331 uint32_t marked_retrans;/* number or DATA chunks marked for timer
332 * based retransmissions */
333 uint32_t marked_fastretrans;
334 uint32_t heart_beat_delay; /* Heart Beat delay in ms */
336 /* if this guy is ok or not ... status */
338 /* number of timeouts to consider the destination unreachable */
339 uint16_t failure_threshold;
340 /* number of timeouts to consider the destination potentially failed */
341 uint16_t pf_threshold;
342 /* error stats on the destination */
343 uint16_t error_count;
344 /* UDP port number in case of UDP tunneling */
347 uint8_t fast_retran_loss_recovery;
348 uint8_t will_exit_fast_recovery;
349 /* Flags that probably can be combined into dest_state */
350 uint8_t fast_retran_ip; /* fast retransmit in progress */
351 uint8_t hb_responded;
352 uint8_t saw_newack; /* CMT's SFR algorithm flag */
353 uint8_t src_addr_selected; /* if we split we move */
354 uint8_t indx_of_eligible_next_to_use;
355 uint8_t addr_is_local; /* its a local address (if known) could move
359 * CMT variables (iyengar@cis.udel.edu)
361 uint8_t find_pseudo_cumack; /* CMT CUC algorithm. Flag used to
362 * find a new pseudocumack. This flag
363 * is set after a new pseudo-cumack
364 * has been received and indicates
365 * that the sender should find the
366 * next pseudo-cumack expected for
367 * this destination */
368 uint8_t find_rtx_pseudo_cumack; /* CMT CUCv2 algorithm. Flag used to
369 * find a new rtx-pseudocumack. This
370 * flag is set after a new
371 * rtx-pseudo-cumack has been received
372 * and indicates that the sender
373 * should find the next
374 * rtx-pseudo-cumack expected for this
376 uint8_t new_pseudo_cumack; /* CMT CUC algorithm. Flag used to
377 * indicate if a new pseudo-cumack or
378 * rtx-pseudo-cumack has been received */
379 uint8_t window_probe; /* Doing a window probe? */
380 uint8_t RTO_measured; /* Have we done the first measure */
381 uint8_t last_hs_used; /* index into the last HS table entry we used */
391 struct sctp_data_chunkrec {
392 uint32_t TSN_seq; /* the TSN of this transmit */
393 uint16_t stream_seq; /* the stream sequence number of this transmit */
394 uint16_t stream_number; /* the stream number of this guy */
395 uint32_t payloadtype;
396 uint32_t context; /* from send */
397 uint32_t cwnd_at_send;
399 * part of the Highest sacked algorithm to be able to stroke counts
400 * on ones that are FR'd.
402 uint32_t fast_retran_tsn; /* sending_seq at the time of FR */
403 struct timeval timetodrop; /* time we drop it from queue */
404 uint8_t doing_fast_retransmit;
405 uint8_t rcv_flags; /* flags pulled from data chunk on inbound for
406 * outbound holds sending flags for PR-SCTP. */
408 uint8_t chunk_was_revoked;
412 TAILQ_HEAD(sctpchunk_listhead, sctp_tmit_chunk);
414 /* The lower byte is used to enumerate PR_SCTP policies */
415 #define CHUNK_FLAGS_PR_SCTP_TTL SCTP_PR_SCTP_TTL
416 #define CHUNK_FLAGS_PR_SCTP_BUF SCTP_PR_SCTP_BUF
417 #define CHUNK_FLAGS_PR_SCTP_RTX SCTP_PR_SCTP_RTX
419 /* The upper byte is used a a bit mask */
420 #define CHUNK_FLAGS_FRAGMENT_OK 0x0100
424 uint16_t can_take_data;
428 struct sctp_tmit_chunk {
430 struct sctp_data_chunkrec data;
431 struct chk_id chunk_id;
433 struct sctp_association *asoc; /* bp to asoc this belongs to */
434 struct timeval sent_rcv_time; /* filled in if RTT being calculated */
435 struct mbuf *data; /* pointer to mbuf chain of data */
436 struct mbuf *last_mbuf; /* pointer to last mbuf in chain */
437 struct sctp_nets *whoTo;
438 TAILQ_ENTRY(sctp_tmit_chunk) sctp_next; /* next link */
439 int32_t sent; /* the send status */
440 uint16_t snd_count; /* number of times I sent */
441 uint16_t flags; /* flags, such as FRAGMENT_OK */
446 uint8_t holds_key_ref; /* flag if auth keyid refcount is held */
449 uint8_t book_size_scale;
450 uint8_t no_fr_allowed;
453 uint8_t window_probe;
457 * The first part of this structure MUST be the entire sinfo structure. Maybe
458 * I should have made it a sub structure... we can circle back later and do
461 struct sctp_queued_to_read { /* sinfo structure Pluse more */
462 uint16_t sinfo_stream; /* off the wire */
463 uint16_t sinfo_ssn; /* off the wire */
464 uint16_t sinfo_flags; /* SCTP_UNORDERED from wire use SCTP_EOF for
466 uint32_t sinfo_ppid; /* off the wire */
467 uint32_t sinfo_context; /* pick this up from assoc def context? */
468 uint32_t sinfo_timetolive; /* not used by kernel */
469 uint32_t sinfo_tsn; /* Use this in reassembly as first TSN */
470 uint32_t sinfo_cumtsn; /* Use this in reassembly as last TSN */
471 sctp_assoc_t sinfo_assoc_id; /* our assoc id */
472 /* Non sinfo stuff */
473 uint32_t length; /* length of data */
474 uint32_t held_length; /* length held in sb */
475 struct sctp_nets *whoFrom; /* where it came from */
476 struct mbuf *data; /* front of the mbuf chain of data with
478 struct mbuf *tail_mbuf; /* used for multi-part data */
479 struct mbuf *aux_data; /* used to hold/cache control if o/s does not
481 struct sctp_tcb *stcb; /* assoc, used for window update */
482 TAILQ_ENTRY(sctp_queued_to_read) next;
484 uint16_t spec_flags; /* Flags to hold the notification field */
485 uint8_t do_not_ref_stcb;
487 uint8_t pdapi_aborted;
491 /* This data structure will be on the outbound
492 * stream queues. Data will be pulled off from
493 * the front of the mbuf data and chunk-ified
494 * by the output routines. We will custom
495 * fit every chunk we pull to the send/sent
496 * queue to make up the next full packet
497 * if we can. An entry cannot be removed
498 * from the stream_out queue until
499 * the msg_is_complete flag is set. This
500 * means at times data/tail_mbuf MIGHT
501 * be NULL.. If that occurs it happens
502 * for one of two reasons. Either the user
503 * is blocked on a send() call and has not
504 * awoken to copy more data down... OR
505 * the user is in the explict MSG_EOR mode
506 * and wrote some data, but has not completed
509 struct sctp_stream_queue_pending {
511 struct mbuf *tail_mbuf;
513 struct sctp_nets *net;
514 TAILQ_ENTRY(sctp_stream_queue_pending) next;
515 TAILQ_ENTRY(sctp_stream_queue_pending) ss_next;
520 uint16_t sinfo_flags;
525 uint8_t holds_key_ref;
526 uint8_t msg_is_complete;
529 uint8_t sender_all_done;
530 uint8_t put_last_out;
531 uint8_t discard_rest;
535 * this struct contains info that is used to track inbound stream data and
536 * help with ordering.
538 TAILQ_HEAD(sctpwheelunrel_listhead, sctp_stream_in);
539 struct sctp_stream_in {
540 struct sctp_readhead inqueue;
542 uint16_t last_sequence_delivered; /* used for re-order */
543 uint8_t delivery_started;
546 TAILQ_HEAD(sctpwheel_listhead, sctp_stream_out);
547 TAILQ_HEAD(sctplist_listhead, sctp_stream_queue_pending);
549 /* Round-robin schedulers */
551 /* next link in wheel */
552 TAILQ_ENTRY(sctp_stream_out) next_spoke;
555 /* Priority scheduler */
557 /* next link in wheel */
558 TAILQ_ENTRY(sctp_stream_out) next_spoke;
563 /* Fair Bandwidth scheduler */
565 /* next link in wheel */
566 TAILQ_ENTRY(sctp_stream_out) next_spoke;
567 /* stores message size */
572 * This union holds all data necessary for
573 * different stream schedulers.
575 union scheduling_data {
576 struct sctpwheel_listhead out_wheel;
577 struct sctplist_listhead out_list;
581 * This union holds all parameters per stream
582 * necessary for different stream schedulers.
584 union scheduling_parameters {
590 /* This struct is used to track the traffic on outbound streams */
591 struct sctp_stream_out {
592 struct sctp_streamhead outqueue;
593 union scheduling_parameters ss_params;
595 uint16_t next_sequence_sent; /* next one I expect to send out */
596 uint8_t last_msg_incomplete;
599 /* used to keep track of the addresses yet to try to add/delete */
600 TAILQ_HEAD(sctp_asconf_addrhead, sctp_asconf_addr);
601 struct sctp_asconf_addr {
602 TAILQ_ENTRY(sctp_asconf_addr) next;
603 struct sctp_asconf_addr_param ap;
604 struct sctp_ifa *ifa; /* save the ifa for add/del ip */
605 uint8_t sent; /* has this been sent yet? */
606 uint8_t special_del; /* not to be used in lookup */
609 struct sctp_scoping {
610 uint8_t ipv4_addr_legal;
611 uint8_t ipv6_addr_legal;
612 uint8_t loopback_scope;
613 uint8_t ipv4_local_scope;
618 #define SCTP_TSN_LOG_SIZE 40
620 struct sctp_tsn_log {
631 #define SCTP_FS_SPEC_LOG_SIZE 200
632 struct sctp_fs_spec_log {
634 uint32_t total_flight;
641 /* This struct is here to cut out the compatiabilty
642 * pad that bulks up both the inp and stcb. The non
643 * pad portion MUST stay in complete sync with
644 * sctp_sndrcvinfo... i.e. if sinfo_xxxx is added
645 * this must be done here too.
647 struct sctp_nonpad_sndrcvinfo {
648 uint16_t sinfo_stream;
650 uint16_t sinfo_flags;
652 uint32_t sinfo_context;
653 uint32_t sinfo_timetolive;
655 uint32_t sinfo_cumtsn;
656 sctp_assoc_t sinfo_assoc_id;
657 uint16_t sinfo_keynumber;
658 uint16_t sinfo_keynumber_valid;
662 * JRS - Structure to hold function pointers to the functions responsible
663 * for congestion control.
666 struct sctp_cc_functions {
667 void (*sctp_set_initial_cc_param) (struct sctp_tcb *stcb, struct sctp_nets *net);
668 void (*sctp_cwnd_update_after_sack) (struct sctp_tcb *stcb,
669 struct sctp_association *asoc,
670 int accum_moved, int reneged_all, int will_exit);
671 void (*sctp_cwnd_update_exit_pf) (struct sctp_tcb *stcb, struct sctp_nets *net);
672 void (*sctp_cwnd_update_after_fr) (struct sctp_tcb *stcb,
673 struct sctp_association *asoc);
674 void (*sctp_cwnd_update_after_timeout) (struct sctp_tcb *stcb,
675 struct sctp_nets *net);
676 void (*sctp_cwnd_update_after_ecn_echo) (struct sctp_tcb *stcb,
677 struct sctp_nets *net, int in_window, int num_pkt_lost);
678 void (*sctp_cwnd_update_after_packet_dropped) (struct sctp_tcb *stcb,
679 struct sctp_nets *net, struct sctp_pktdrop_chunk *cp,
680 uint32_t * bottle_bw, uint32_t * on_queue);
681 void (*sctp_cwnd_update_after_output) (struct sctp_tcb *stcb,
682 struct sctp_nets *net, int burst_limit);
683 void (*sctp_cwnd_update_packet_transmitted) (struct sctp_tcb *stcb,
684 struct sctp_nets *net);
685 void (*sctp_cwnd_update_tsn_acknowledged) (struct sctp_nets *net,
686 struct sctp_tmit_chunk *);
687 void (*sctp_cwnd_new_transmission_begins) (struct sctp_tcb *stcb,
688 struct sctp_nets *net);
689 void (*sctp_cwnd_prepare_net_for_sack) (struct sctp_tcb *stcb,
690 struct sctp_nets *net);
691 int (*sctp_cwnd_socket_option) (struct sctp_tcb *stcb, int set, struct sctp_cc_option *);
692 void (*sctp_rtt_calculated) (struct sctp_tcb *, struct sctp_nets *, struct timeval *);
696 * RS - Structure to hold function pointers to the functions responsible
697 * for stream scheduling.
699 struct sctp_ss_functions {
700 void (*sctp_ss_init) (struct sctp_tcb *stcb, struct sctp_association *asoc,
702 void (*sctp_ss_clear) (struct sctp_tcb *stcb, struct sctp_association *asoc,
703 int clear_values, int holds_lock);
704 void (*sctp_ss_init_stream) (struct sctp_stream_out *strq, struct sctp_stream_out *with_strq);
705 void (*sctp_ss_add_to_stream) (struct sctp_tcb *stcb, struct sctp_association *asoc,
706 struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, int holds_lock);
707 int (*sctp_ss_is_empty) (struct sctp_tcb *stcb, struct sctp_association *asoc);
708 void (*sctp_ss_remove_from_stream) (struct sctp_tcb *stcb, struct sctp_association *asoc,
709 struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, int holds_lock);
710 struct sctp_stream_out *(*sctp_ss_select_stream) (struct sctp_tcb *stcb,
711 struct sctp_nets *net, struct sctp_association *asoc);
712 void (*sctp_ss_scheduled) (struct sctp_tcb *stcb, struct sctp_nets *net,
713 struct sctp_association *asoc, struct sctp_stream_out *strq, int moved_how_much);
714 void (*sctp_ss_packet_done) (struct sctp_tcb *stcb, struct sctp_nets *net,
715 struct sctp_association *asoc);
716 int (*sctp_ss_get_value) (struct sctp_tcb *stcb, struct sctp_association *asoc,
717 struct sctp_stream_out *strq, uint16_t * value);
718 int (*sctp_ss_set_value) (struct sctp_tcb *stcb, struct sctp_association *asoc,
719 struct sctp_stream_out *strq, uint16_t value);
722 /* used to save ASCONF chunks for retransmission */
723 TAILQ_HEAD(sctp_asconf_head, sctp_asconf);
725 TAILQ_ENTRY(sctp_asconf) next;
726 uint32_t serial_number;
732 /* used to save ASCONF-ACK chunks for retransmission */
733 TAILQ_HEAD(sctp_asconf_ackhead, sctp_asconf_ack);
734 struct sctp_asconf_ack {
735 TAILQ_ENTRY(sctp_asconf_ack) next;
736 uint32_t serial_number;
737 struct sctp_nets *last_sent_to;
743 * Here we have information about each individual association that we track.
744 * We probably in production would be more dynamic. But for ease of
745 * implementation we will have a fixed array that we hunt for in a linear
748 struct sctp_association {
749 /* association state */
752 /* queue of pending addrs to add/delete */
753 struct sctp_asconf_addrhead asconf_queue;
755 struct timeval time_entered; /* time we entered state */
756 struct timeval time_last_rcvd;
757 struct timeval time_last_sent;
758 struct timeval time_last_sat_advance;
759 struct sctp_nonpad_sndrcvinfo def_send;
761 /* timers and such */
762 struct sctp_timer dack_timer; /* Delayed ack timer */
763 struct sctp_timer asconf_timer; /* asconf */
764 struct sctp_timer strreset_timer; /* stream reset */
765 struct sctp_timer shut_guard_timer; /* shutdown guard */
766 struct sctp_timer autoclose_timer; /* automatic close timer */
767 struct sctp_timer delayed_event_timer; /* timer for delayed events */
768 struct sctp_timer delete_prim_timer; /* deleting primary dst */
770 /* list of restricted local addresses */
771 struct sctpladdr sctp_restricted_addrs;
773 /* last local address pending deletion (waiting for an address add) */
774 struct sctp_ifa *asconf_addr_del_pending;
775 /* Deleted primary destination (used to stop timer) */
776 struct sctp_nets *deleted_primary;
778 struct sctpnetlisthead nets; /* remote address list */
780 /* Free chunk list */
781 struct sctpchunk_listhead free_chunks;
783 /* Control chunk queue */
784 struct sctpchunk_listhead control_send_queue;
786 /* ASCONF chunk queue */
787 struct sctpchunk_listhead asconf_send_queue;
790 * Once a TSN hits the wire it is moved to the sent_queue. We
791 * maintain two counts here (don't know if any but retran_cnt is
792 * needed). The idea is that the sent_queue_retran_cnt reflects how
793 * many chunks have been marked for retranmission by either T3-rxt
796 struct sctpchunk_listhead sent_queue;
797 struct sctpchunk_listhead send_queue;
799 /* re-assembly queue for fragmented chunks on the inbound path */
800 struct sctpchunk_listhead reasmqueue;
802 /* Scheduling queues */
803 union scheduling_data ss_data;
806 * This pointer will be set to NULL most of the time. But when we
807 * have a fragmented message, where we could not get out all of the
808 * message at the last send then this will point to the stream to go
811 struct sctp_stream_out *locked_on_sending;
813 /* If an iterator is looking at me, this is it */
814 struct sctp_iterator *stcb_starting_point_for_iterator;
816 /* ASCONF save the last ASCONF-ACK so we can resend it if necessary */
817 struct sctp_asconf_ackhead asconf_ack_sent;
820 * pointer to last stream reset queued to control queue by us with
823 struct sctp_tmit_chunk *str_reset;
825 * if Source Address Selection happening, this will rotate through
828 struct sctp_laddr *last_used_address;
831 struct sctp_stream_in *strmin;
832 struct sctp_stream_out *strmout;
833 uint8_t *mapping_array;
834 /* primary destination to use */
835 struct sctp_nets *primary_destination;
836 struct sctp_nets *alternate; /* If primary is down or PF */
838 struct sctp_nets *last_net_cmt_send_started;
839 /* last place I got a data chunk from */
840 struct sctp_nets *last_data_chunk_from;
841 /* last place I got a control from */
842 struct sctp_nets *last_control_chunk_from;
844 /* circular looking for output selection */
845 struct sctp_stream_out *last_out_stream;
848 * wait to the point the cum-ack passes req->send_reset_at_tsn for
849 * any req on the list.
851 struct sctp_resethead resetHead;
853 /* queue of chunks waiting to be sent into the local stack */
854 struct sctp_readhead pending_reply_queue;
856 /* JRS - the congestion control functions are in this struct */
857 struct sctp_cc_functions cc_functions;
859 * JRS - value to store the currently loaded congestion control
862 uint32_t congestion_control_module;
863 /* RS - the stream scheduling functions are in this struct */
864 struct sctp_ss_functions ss_functions;
865 /* RS - value to store the currently loaded stream scheduling module */
866 uint32_t stream_scheduling_module;
870 uint32_t cookie_preserve_req;
871 /* ASCONF next seq I am sending out, inits at init-tsn */
872 uint32_t asconf_seq_out;
873 uint32_t asconf_seq_out_acked;
874 /* ASCONF last received ASCONF from peer, starts at peer's TSN-1 */
875 uint32_t asconf_seq_in;
877 /* next seq I am sending in str reset messages */
878 uint32_t str_reset_seq_out;
879 /* next seq I am expecting in str reset messages */
880 uint32_t str_reset_seq_in;
882 /* various verification tag information */
883 uint32_t my_vtag; /* The tag to be used. if assoc is re-initited
884 * by remote end, and I have unlocked this
885 * will be regenerated to a new random value. */
886 uint32_t peer_vtag; /* The peers last tag */
888 uint32_t my_vtag_nonce;
889 uint32_t peer_vtag_nonce;
893 /* This is the SCTP fragmentation threshold */
894 uint32_t smallest_mtu;
897 * Special hook for Fast retransmit, allows us to track the highest
898 * TSN that is NEW in this SACK if gap ack blocks are present.
900 uint32_t this_sack_highest_gap;
903 * The highest consecutive TSN that has been acked by peer on my
906 uint32_t last_acked_seq;
908 /* The next TSN that I will use in sending. */
909 uint32_t sending_seq;
911 /* Original seq number I used ??questionable to keep?? */
912 uint32_t init_seq_number;
915 /* The Advanced Peer Ack Point, as required by the PR-SCTP */
916 /* (A1 in Section 4.2) */
917 uint32_t advanced_peer_ack_point;
920 * The highest consequetive TSN at the bottom of the mapping array
923 uint32_t cumulative_tsn;
925 * Used to track the mapping array and its offset bits. This MAY be
926 * lower then cumulative_tsn.
928 uint32_t mapping_array_base_tsn;
930 * used to track highest TSN we have received and is listed in the
933 uint32_t highest_tsn_inside_map;
935 /* EY - new NR variables used for nr_sack based on mapping_array */
936 uint8_t *nr_mapping_array;
937 uint32_t highest_tsn_inside_nr_map;
939 uint32_t fast_recovery_tsn;
940 uint32_t sat_t3_recovery_tsn;
941 uint32_t tsn_last_delivered;
943 * For the pd-api we should re-write this a bit more efficent. We
944 * could have multiple sctp_queued_to_read's that we are building at
945 * once. Now we only do this when we get ready to deliver to the
946 * socket buffer. Note that we depend on the fact that the struct is
947 * "stuck" on the read queue until we finish all the pd-api.
949 struct sctp_queued_to_read *control_pdapi;
951 uint32_t tsn_of_pdapi_last_delivered;
954 uint32_t last_reset_action[SCTP_MAX_RESET_PARAMS];
955 uint32_t last_sending_seq[SCTP_MAX_RESET_PARAMS];
956 uint32_t last_base_tsnsent[SCTP_MAX_RESET_PARAMS];
957 #ifdef SCTP_ASOCLOG_OF_TSNS
959 * special log - This adds considerable size to the asoc, but
960 * provides a log that you can use to detect problems via kgdb.
962 struct sctp_tsn_log in_tsnlog[SCTP_TSN_LOG_SIZE];
963 struct sctp_tsn_log out_tsnlog[SCTP_TSN_LOG_SIZE];
964 uint32_t cumack_log[SCTP_TSN_LOG_SIZE];
965 uint32_t cumack_logsnt[SCTP_TSN_LOG_SIZE];
968 uint16_t tsn_in_wrapped;
969 uint16_t tsn_out_wrapped;
970 uint16_t cumack_log_at;
971 uint16_t cumack_log_atsnt;
972 #endif /* SCTP_ASOCLOG_OF_TSNS */
973 #ifdef SCTP_FS_SPEC_LOG
974 struct sctp_fs_spec_log fslog[SCTP_FS_SPEC_LOG_SIZE];
979 * window state information and smallest MTU that I use to bound
984 uint32_t my_last_reported_rwnd;
985 uint32_t sctp_frag_point;
987 uint32_t total_output_queue_size;
989 uint32_t sb_cc; /* shadow of sb_cc */
990 uint32_t sb_send_resv; /* amount reserved on a send */
991 uint32_t my_rwnd_control_len; /* shadow of sb_mbcnt used for rwnd
994 uint32_t default_flowlabel;
996 uint32_t pr_sctp_cnt;
997 int ctrl_queue_cnt; /* could be removed REM - NO IT CAN'T!! RRS */
999 * All outbound datagrams queue into this list from the individual
1000 * stream queue. Here they get assigned a TSN and then await
1001 * sending. The stream seq comes when it is first put in the
1002 * individual str queue
1004 unsigned int stream_queue_cnt;
1005 unsigned int send_queue_cnt;
1006 unsigned int sent_queue_cnt;
1007 unsigned int sent_queue_cnt_removeable;
1009 * Number on sent queue that are marked for retran until this value
1010 * is 0 we only send one packet of retran'ed data.
1012 unsigned int sent_queue_retran_cnt;
1014 unsigned int size_on_reasm_queue;
1015 unsigned int cnt_on_reasm_queue;
1016 unsigned int fwd_tsn_cnt;
1017 /* amount of data (bytes) currently in flight (on all destinations) */
1018 unsigned int total_flight;
1019 /* Total book size in flight */
1020 unsigned int total_flight_count; /* count of chunks used with
1022 /* count of destinaton nets and list of destination nets */
1023 unsigned int numnets;
1025 /* Total error count on this association */
1026 unsigned int overall_error_count;
1028 unsigned int cnt_msg_on_sb;
1030 /* All stream count of chunks for delivery */
1031 unsigned int size_on_all_streams;
1032 unsigned int cnt_on_all_streams;
1034 /* Heart Beat delay in ms */
1035 uint32_t heart_beat_delay;
1038 unsigned int sctp_autoclose_ticks;
1040 /* how many preopen streams we have */
1041 unsigned int pre_open_streams;
1043 /* How many streams I support coming into me */
1044 unsigned int max_inbound_streams;
1046 /* the cookie life I award for any cookie, in seconds */
1047 unsigned int cookie_life;
1048 /* time to delay acks for */
1049 unsigned int delayed_ack;
1050 unsigned int old_delayed_ack;
1051 unsigned int sack_freq;
1052 unsigned int data_pkts_seen;
1054 unsigned int numduptsns;
1055 int dup_tsns[SCTP_MAX_DUP_TSNS];
1056 unsigned int initial_init_rto_max; /* initial RTO for INIT's */
1057 unsigned int initial_rto; /* initial send RTO */
1058 unsigned int minrto; /* per assoc RTO-MIN */
1059 unsigned int maxrto; /* per assoc RTO-MAX */
1061 /* authentication fields */
1062 sctp_auth_chklist_t *local_auth_chunks;
1063 sctp_auth_chklist_t *peer_auth_chunks;
1064 sctp_hmaclist_t *local_hmacs; /* local HMACs supported */
1065 sctp_hmaclist_t *peer_hmacs; /* peer HMACs supported */
1066 struct sctp_keyhead shared_keys; /* assoc's shared keys */
1067 sctp_authinfo_t authinfo; /* randoms, cached keys */
1069 * refcnt to block freeing when a sender or receiver is off coping
1073 uint32_t chunks_on_out_queue; /* total chunks floating around,
1074 * locked by send socket buffer */
1075 uint32_t peers_adaptation;
1076 uint16_t peer_hmac_id; /* peer HMAC id to send */
1079 * Being that we have no bag to collect stale cookies, and that we
1080 * really would not want to anyway.. we will count them in this
1081 * counter. We of course feed them to the pigeons right away (I have
1082 * always thought of pigeons as flying rats).
1084 uint16_t stale_cookie_count;
1087 * For the partial delivery API, if up, invoked this is what last
1090 uint16_t str_of_pdapi;
1091 uint16_t ssn_of_pdapi;
1093 /* counts of actual built streams. Allocation may be more however */
1094 /* could re-arrange to optimize space here. */
1095 uint16_t streamincnt;
1096 uint16_t streamoutcnt;
1097 uint16_t strm_realoutsize;
1098 /* my maximum number of retrans of INIT and SEND */
1099 /* copied from SCTP but should be individually setable */
1100 uint16_t max_init_times;
1101 uint16_t max_send_times;
1103 uint16_t def_net_failure;
1105 uint16_t def_net_pf_threshold;
1108 * lock flag: 0 is ok to send, 1+ (duals as a retran count) is
1111 uint16_t mapping_array_size;
1113 uint16_t last_strm_seq_delivered;
1114 uint16_t last_strm_no_delivered;
1116 uint16_t last_revoke_count;
1117 int16_t num_send_timers_up;
1119 uint16_t stream_locked_on;
1120 uint16_t ecn_echo_cnt_onq;
1122 uint16_t free_chunk_cnt;
1123 uint8_t stream_locked;
1124 uint8_t authenticated; /* packet authenticated ok */
1126 * This flag indicates that a SACK need to be sent. Initially this
1127 * is 1 to send the first sACK immediately.
1131 /* max burst of new packets into the network */
1133 /* max burst of fast retransmit packets */
1134 uint32_t fr_max_burst;
1136 uint8_t sat_network; /* RTT is in range of sat net or greater */
1137 uint8_t sat_network_lockout; /* lockout code */
1138 uint8_t burst_limit_applied; /* Burst limit in effect at last send? */
1139 /* flag goes on when we are doing a partial delivery api */
1140 uint8_t hb_random_values[4];
1141 uint8_t fragmented_delivery_inprogress;
1142 uint8_t fragment_flags;
1143 uint8_t last_flags_delivered;
1144 uint8_t hb_ect_randombit;
1145 uint8_t hb_random_idx;
1146 uint8_t default_dscp;
1147 uint8_t asconf_del_pending; /* asconf delete last addr pending */
1150 * This value, plus all other ack'd but above cum-ack is added
1151 * together to cross check against the bit that we have yet to
1152 * define (probably in the SACK). When the cum-ack is updated, this
1153 * sum is updated as well.
1156 /* Flag to tell if ECN is allowed */
1157 uint8_t ecn_allowed;
1159 /* flag to indicate if peer can do asconf */
1160 uint8_t peer_supports_asconf;
1161 /* EY - flag to indicate if peer can do nr_sack */
1162 uint8_t peer_supports_nr_sack;
1163 /* pr-sctp support flag */
1164 uint8_t peer_supports_prsctp;
1165 /* peer authentication support flag */
1166 uint8_t peer_supports_auth;
1167 /* stream resets are supported by the peer */
1168 uint8_t peer_supports_strreset;
1170 uint8_t peer_supports_nat;
1172 * packet drop's are supported by the peer, we don't really care
1173 * about this but we bookkeep it anyway.
1175 uint8_t peer_supports_pktdrop;
1177 /* Do we allow V6/V4? */
1178 uint8_t ipv4_addr_legal;
1179 uint8_t ipv6_addr_legal;
1180 /* Address scoping flags */
1181 /* scope value for IPv4 */
1182 uint8_t ipv4_local_scope;
1183 /* scope values for IPv6 */
1184 uint8_t local_scope;
1186 /* loopback scope */
1187 uint8_t loopback_scope;
1188 /* flags to handle send alternate net tracking */
1189 uint8_t used_alt_onsack;
1190 uint8_t used_alt_asconfack;
1191 uint8_t fast_retran_loss_recovery;
1192 uint8_t sat_t3_loss_recovery;
1193 uint8_t dropped_special_cnt;
1194 uint8_t seen_a_sack_this_pkt;
1195 uint8_t stream_reset_outstanding;
1196 uint8_t stream_reset_out_is_outstanding;
1197 uint8_t delayed_connection;
1198 uint8_t ifp_had_enobuf;
1199 uint8_t saw_sack_with_frags;
1200 uint8_t saw_sack_with_nr_frags;
1201 uint8_t in_asocid_hash;
1202 uint8_t assoc_up_sent;
1203 uint8_t adaptation_needed;
1204 uint8_t adaptation_sent;
1206 uint8_t cmt_dac_pkts_rcvd;
1207 uint8_t sctp_cmt_on_off;
1208 uint8_t iam_blocking;
1209 uint8_t cookie_how[8];
1210 /* EY 05/05/08 - NR_SACK variable */
1211 uint8_t sctp_nr_sack_on_off;
1212 /* JRS 5/21/07 - CMT PF variable */
1213 uint8_t sctp_cmt_pf;
1214 uint8_t use_precise_time;
1215 uint32_t sctp_features;
1217 * The mapping array is used to track out of order sequences above
1218 * last_acked_seq. 0 indicates packet missing 1 indicates packet
1219 * rec'd. We slide it up every time we raise last_acked_seq and 0
1220 * trailing locactions out. If I get a TSN above the array
1221 * mappingArraySz, I discard the datagram and let retransmit happen.
1223 uint32_t marked_retrans;
1227 uint32_t timoshutdown;
1228 uint32_t timoheartbeat;
1229 uint32_t timocookie;
1230 uint32_t timoshutdownack;
1231 struct timeval start_time;
1232 struct timeval discontinuity_time;