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