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