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