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