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