xref: /freebsd/sys/netinet/sctp_structs.h (revision 4f14d4b6b7f0ca49b14379e48117121af3ed2669)
1f8829a4aSRandall Stewart /*-
251369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
351369649SPedro F. Giffuni  *
4830d754dSRandall Stewart  * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
5807aad63SMichael Tuexen  * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
6807aad63SMichael Tuexen  * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
7f8829a4aSRandall Stewart  *
8f8829a4aSRandall Stewart  * Redistribution and use in source and binary forms, with or without
9f8829a4aSRandall Stewart  * modification, are permitted provided that the following conditions are met:
10f8829a4aSRandall Stewart  *
11f8829a4aSRandall Stewart  * a) Redistributions of source code must retain the above copyright notice,
12f8829a4aSRandall Stewart  *    this list of conditions and the following disclaimer.
13f8829a4aSRandall Stewart  *
14f8829a4aSRandall Stewart  * b) Redistributions in binary form must reproduce the above copyright
15f8829a4aSRandall Stewart  *    notice, this list of conditions and the following disclaimer in
16f8829a4aSRandall Stewart  *    the documentation and/or other materials provided with the distribution.
17f8829a4aSRandall Stewart  *
18f8829a4aSRandall Stewart  * c) Neither the name of Cisco Systems, Inc. nor the names of its
19f8829a4aSRandall Stewart  *    contributors may be used to endorse or promote products derived
20f8829a4aSRandall Stewart  *    from this software without specific prior written permission.
21f8829a4aSRandall Stewart  *
22f8829a4aSRandall Stewart  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23f8829a4aSRandall Stewart  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24f8829a4aSRandall Stewart  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25f8829a4aSRandall Stewart  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26f8829a4aSRandall Stewart  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27f8829a4aSRandall Stewart  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28f8829a4aSRandall Stewart  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29f8829a4aSRandall Stewart  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30f8829a4aSRandall Stewart  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31f8829a4aSRandall Stewart  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32f8829a4aSRandall Stewart  * THE POSSIBILITY OF SUCH DAMAGE.
33f8829a4aSRandall Stewart  */
34f8829a4aSRandall Stewart 
35807aad63SMichael Tuexen #ifndef _NETINET_SCTP_STRUCTS_H_
36807aad63SMichael Tuexen #define _NETINET_SCTP_STRUCTS_H_
37f8829a4aSRandall Stewart 
38139bc87fSRandall Stewart #include <netinet/sctp_os.h>
39f8829a4aSRandall Stewart #include <netinet/sctp_header.h>
40f8829a4aSRandall Stewart #include <netinet/sctp_auth.h>
41f8829a4aSRandall Stewart 
42f8829a4aSRandall Stewart struct sctp_timer {
43139bc87fSRandall Stewart 	sctp_os_timer_t timer;
44139bc87fSRandall Stewart 
45f8829a4aSRandall Stewart 	int type;
46f8829a4aSRandall Stewart 	/*
47f8829a4aSRandall Stewart 	 * Depending on the timer type these will be setup and cast with the
48f8829a4aSRandall Stewart 	 * appropriate entity.
49f8829a4aSRandall Stewart 	 */
50f8829a4aSRandall Stewart 	void *ep;
51f8829a4aSRandall Stewart 	void *tcb;
52f8829a4aSRandall Stewart 	void *net;
538518270eSMichael Tuexen 	void *vnet;
54f8829a4aSRandall Stewart 
55f8829a4aSRandall Stewart 	/* for sanity checking */
56f8829a4aSRandall Stewart 	void *self;
57f8829a4aSRandall Stewart 	uint32_t ticks;
58a5d547adSRandall Stewart 	uint32_t stopped_from;
59f8829a4aSRandall Stewart };
60f8829a4aSRandall Stewart 
61a5d547adSRandall Stewart struct sctp_foo_stuff {
62a5d547adSRandall Stewart 	struct sctp_inpcb *inp;
63a5d547adSRandall Stewart 	uint32_t lineno;
64a5d547adSRandall Stewart 	uint32_t ticks;
65a5d547adSRandall Stewart 	int updown;
66a5d547adSRandall Stewart };
67a5d547adSRandall Stewart 
68f8829a4aSRandall Stewart /*
69f8829a4aSRandall Stewart  * This is the information we track on each interface that we know about from
70f8829a4aSRandall Stewart  * the distant end.
71f8829a4aSRandall Stewart  */
72f8829a4aSRandall Stewart TAILQ_HEAD(sctpnetlisthead, sctp_nets);
73f8829a4aSRandall Stewart 
74f8829a4aSRandall Stewart struct sctp_stream_reset_list {
75f8829a4aSRandall Stewart 	TAILQ_ENTRY(sctp_stream_reset_list) next_resp;
767cca1775SRandall Stewart 	uint32_t seq;
77f8829a4aSRandall Stewart 	uint32_t tsn;
78a169d6ecSMichael Tuexen 	uint32_t number_entries;
79a169d6ecSMichael Tuexen 	uint16_t list_of_streams[];
80f8829a4aSRandall Stewart };
81f8829a4aSRandall Stewart 
82f8829a4aSRandall Stewart TAILQ_HEAD(sctp_resethead, sctp_stream_reset_list);
83f8829a4aSRandall Stewart 
84f8829a4aSRandall Stewart /*
85f8829a4aSRandall Stewart  * Users of the iterator need to malloc a iterator with a call to
8642551e99SRandall Stewart  * sctp_initiate_iterator(inp_func, assoc_func, inp_func,  pcb_flags, pcb_features,
87f8829a4aSRandall Stewart  *     asoc_state, void-ptr-arg, uint32-arg, end_func, inp);
88f8829a4aSRandall Stewart  *
89f8829a4aSRandall Stewart  * Use the following two defines if you don't care what pcb flags are on the EP
90f8829a4aSRandall Stewart  * and/or you don't care what state the association is in.
91f8829a4aSRandall Stewart  *
92f8829a4aSRandall Stewart  * Note that if you specify an INP as the last argument then ONLY each
93f8829a4aSRandall Stewart  * association of that single INP will be executed upon. Note that the pcb
94f8829a4aSRandall Stewart  * flags STILL apply so if the inp you specify has different pcb_flags then
95f8829a4aSRandall Stewart  * what you put in pcb_flags nothing will happen. use SCTP_PCB_ANY_FLAGS to
96f8829a4aSRandall Stewart  * assure the inp you specify gets treated.
97f8829a4aSRandall Stewart  */
98f8829a4aSRandall Stewart #define SCTP_PCB_ANY_FLAGS	0x00000000
99f8829a4aSRandall Stewart #define SCTP_PCB_ANY_FEATURES	0x00000000
100f8829a4aSRandall Stewart #define SCTP_ASOC_ANY_STATE	0x00000000
101f8829a4aSRandall Stewart 
102f8829a4aSRandall Stewart typedef void (*asoc_func) (struct sctp_inpcb *, struct sctp_tcb *, void *ptr,
103f8829a4aSRandall Stewart     uint32_t val);
10442551e99SRandall Stewart typedef int (*inp_func) (struct sctp_inpcb *, void *ptr, uint32_t val);
105f8829a4aSRandall Stewart typedef void (*end_func) (void *ptr, uint32_t val);
106f8829a4aSRandall Stewart 
1072f9e6db0SMichael Tuexen #if defined(SCTP_MCORE_INPUT) && defined(SMP)
108bfc46083SRandall Stewart /* whats on the mcore control struct */
109bfc46083SRandall Stewart struct sctp_mcore_queue {
110bfc46083SRandall Stewart 	TAILQ_ENTRY(sctp_mcore_queue) next;
111bfc46083SRandall Stewart 	struct vnet *vn;
112bfc46083SRandall Stewart 	struct mbuf *m;
113bfc46083SRandall Stewart 	int off;
114bfc46083SRandall Stewart 	int v6;
115bfc46083SRandall Stewart };
116bfc46083SRandall Stewart 
117bfc46083SRandall Stewart TAILQ_HEAD(sctp_mcore_qhead, sctp_mcore_queue);
118bfc46083SRandall Stewart 
119bfc46083SRandall Stewart struct sctp_mcore_ctrl {
120bfc46083SRandall Stewart 	SCTP_PROCESS_STRUCT thread_proc;
121bfc46083SRandall Stewart 	struct sctp_mcore_qhead que;
122bfc46083SRandall Stewart 	struct mtx core_mtx;
123bfc46083SRandall Stewart 	struct mtx que_mtx;
124bfc46083SRandall Stewart 	int running;
125bfc46083SRandall Stewart 	int cpuid;
126bfc46083SRandall Stewart };
127bfc46083SRandall Stewart #endif
128bfc46083SRandall Stewart 
129ad6ae52dSMichael Tuexen /* This struct is here to cut out the compatiabilty
130ad6ae52dSMichael Tuexen  * pad that bulks up both the inp and stcb. The non
131ad6ae52dSMichael Tuexen  * pad portion MUST stay in complete sync with
132ad6ae52dSMichael Tuexen  * sctp_sndrcvinfo... i.e. if sinfo_xxxx is added
133ad6ae52dSMichael Tuexen  * this must be done here too.
134ad6ae52dSMichael Tuexen  */
135ad6ae52dSMichael Tuexen struct sctp_nonpad_sndrcvinfo {
136ad6ae52dSMichael Tuexen 	uint16_t sinfo_stream;
137ad6ae52dSMichael Tuexen 	uint16_t sinfo_ssn;
138ad6ae52dSMichael Tuexen 	uint16_t sinfo_flags;
139ad6ae52dSMichael Tuexen 	uint32_t sinfo_ppid;
140ad6ae52dSMichael Tuexen 	uint32_t sinfo_context;
141ad6ae52dSMichael Tuexen 	uint32_t sinfo_timetolive;
142ad6ae52dSMichael Tuexen 	uint32_t sinfo_tsn;
143ad6ae52dSMichael Tuexen 	uint32_t sinfo_cumtsn;
144ad6ae52dSMichael Tuexen 	sctp_assoc_t sinfo_assoc_id;
145ad6ae52dSMichael Tuexen 	uint16_t sinfo_keynumber;
146ad6ae52dSMichael Tuexen 	uint16_t sinfo_keynumber_valid;
147ad6ae52dSMichael Tuexen };
148ad6ae52dSMichael Tuexen 
149f8829a4aSRandall Stewart struct sctp_iterator {
15042551e99SRandall Stewart 	TAILQ_ENTRY(sctp_iterator) sctp_nxt_itr;
151f7517433SRandall Stewart 	struct vnet *vn;
152f8829a4aSRandall Stewart 	struct sctp_timer tmr;
153f8829a4aSRandall Stewart 	struct sctp_inpcb *inp;	/* current endpoint */
154f8829a4aSRandall Stewart 	struct sctp_tcb *stcb;	/* current* assoc */
155f7517433SRandall Stewart 	struct sctp_inpcb *next_inp;	/* special hook to skip to */
156f8829a4aSRandall Stewart 	asoc_func function_assoc;	/* per assoc function */
157f8829a4aSRandall Stewart 	inp_func function_inp;	/* per endpoint function */
15842551e99SRandall Stewart 	inp_func function_inp_end;	/* end INP function */
159f8829a4aSRandall Stewart 	end_func function_atend;	/* iterator completion function */
160f8829a4aSRandall Stewart 	void *pointer;		/* pointer for apply func to use */
161f8829a4aSRandall Stewart 	uint32_t val;		/* value for apply func to use */
162f8829a4aSRandall Stewart 	uint32_t pcb_flags;	/* endpoint flags being checked */
163f8829a4aSRandall Stewart 	uint32_t pcb_features;	/* endpoint features being checked */
164f8829a4aSRandall Stewart 	uint32_t asoc_state;	/* assoc state being checked */
165f8829a4aSRandall Stewart 	uint32_t iterator_flags;
166f8829a4aSRandall Stewart 	uint8_t no_chunk_output;
16742551e99SRandall Stewart 	uint8_t done_current_ep;
168f8829a4aSRandall Stewart };
169f8829a4aSRandall Stewart 
170f8829a4aSRandall Stewart /* iterator_flags values */
171f8829a4aSRandall Stewart #define SCTP_ITERATOR_DO_ALL_INP	0x00000001
172f8829a4aSRandall Stewart #define SCTP_ITERATOR_DO_SINGLE_INP	0x00000002
173f8829a4aSRandall Stewart 
17442551e99SRandall Stewart TAILQ_HEAD(sctpiterators, sctp_iterator);
175f8829a4aSRandall Stewart 
176f8829a4aSRandall Stewart struct sctp_copy_all {
177f8829a4aSRandall Stewart 	struct sctp_inpcb *inp;	/* ep */
178f8829a4aSRandall Stewart 	struct mbuf *m;
179ad6ae52dSMichael Tuexen 	struct sctp_nonpad_sndrcvinfo sndrcv;
18058e6eeefSMichael Tuexen 	ssize_t sndlen;
181f8829a4aSRandall Stewart 	int cnt_sent;
182f8829a4aSRandall Stewart 	int cnt_failed;
183f8829a4aSRandall Stewart };
184f8829a4aSRandall Stewart 
18542551e99SRandall Stewart struct sctp_asconf_iterator {
18642551e99SRandall Stewart 	struct sctpladdr list_of_work;
18742551e99SRandall Stewart 	int cnt;
18842551e99SRandall Stewart };
18942551e99SRandall Stewart 
190f7517433SRandall Stewart struct iterator_control {
191f7517433SRandall Stewart 	struct mtx ipi_iterator_wq_mtx;
192f7517433SRandall Stewart 	struct mtx it_mtx;
193f7517433SRandall Stewart 	SCTP_PROCESS_STRUCT thread_proc;
194f7517433SRandall Stewart 	struct sctpiterators iteratorhead;
195f7517433SRandall Stewart 	struct sctp_iterator *cur_it;
196f7517433SRandall Stewart 	uint32_t iterator_running;
197f7517433SRandall Stewart 	uint32_t iterator_flags;
198f7517433SRandall Stewart };
19987eac1ceSMichael Tuexen #define SCTP_ITERATOR_STOP_CUR_IT	0x00000004
20087eac1ceSMichael Tuexen #define SCTP_ITERATOR_STOP_CUR_INP	0x00000008
201f7517433SRandall Stewart 
20217205eccSRandall Stewart struct sctp_net_route {
203983066f0SAlexander V. Chernikov 	struct nhop_object *ro_nh;
204273e3163SMichael Tuexen 	struct llentry *ro_lle;
20579cadff4SMichael Tuexen 	char *ro_prepend;
20679cadff4SMichael Tuexen 	uint16_t ro_plen;
20779cadff4SMichael Tuexen 	uint16_t ro_flags;
20879cadff4SMichael Tuexen 	uint16_t ro_mtu;
20979cadff4SMichael Tuexen 	uint16_t spare;
21017205eccSRandall Stewart 	union sctp_sockstore _l_addr;	/* remote peer addr */
21117205eccSRandall Stewart 	struct sctp_ifa *_s_addr;	/* our selected src addr */
21217205eccSRandall Stewart };
21317205eccSRandall Stewart 
214b54d3a6cSRandall Stewart struct htcp {
215b54d3a6cSRandall Stewart 	uint16_t alpha;		/* Fixed point arith, << 7 */
216b54d3a6cSRandall Stewart 	uint8_t beta;		/* Fixed point arith, << 7 */
217b54d3a6cSRandall Stewart 	uint8_t modeswitch;	/* Delay modeswitch until we had at least one
218b54d3a6cSRandall Stewart 				 * congestion event */
219b54d3a6cSRandall Stewart 	uint32_t last_cong;	/* Time since last congestion event end */
220b54d3a6cSRandall Stewart 	uint32_t undo_last_cong;
221b54d3a6cSRandall Stewart 	uint16_t bytes_acked;
222b54d3a6cSRandall Stewart 	uint32_t bytecount;
223b54d3a6cSRandall Stewart 	uint32_t minRTT;
224b54d3a6cSRandall Stewart 	uint32_t maxRTT;
225b54d3a6cSRandall Stewart 
226b54d3a6cSRandall Stewart 	uint32_t undo_maxRTT;
227b54d3a6cSRandall Stewart 	uint32_t undo_old_maxB;
228b54d3a6cSRandall Stewart 
229b54d3a6cSRandall Stewart 	/* Bandwidth estimation */
230b54d3a6cSRandall Stewart 	uint32_t minB;
231b54d3a6cSRandall Stewart 	uint32_t maxB;
232b54d3a6cSRandall Stewart 	uint32_t old_maxB;
233b54d3a6cSRandall Stewart 	uint32_t Bi;
234b54d3a6cSRandall Stewart 	uint32_t lasttime;
235b54d3a6cSRandall Stewart };
236b54d3a6cSRandall Stewart 
23748b6c649SRandall Stewart struct rtcc_cc {
23848b6c649SRandall Stewart 	struct timeval tls;	/* The time we started the sending  */
23948b6c649SRandall Stewart 	uint64_t lbw;		/* Our last estimated bw */
24048b6c649SRandall Stewart 	uint64_t lbw_rtt;	/* RTT at bw estimate */
24148b6c649SRandall Stewart 	uint64_t bw_bytes;	/* The total bytes since this sending began */
24248b6c649SRandall Stewart 	uint64_t bw_tot_time;	/* The total time since sending began */
24348b6c649SRandall Stewart 	uint64_t new_tot_time;	/* temp holding the new value */
244f79aab18SRandall Stewart 	uint64_t bw_bytes_at_last_rttc;	/* What bw_bytes was at last rtt calc */
245f79aab18SRandall Stewart 	uint32_t cwnd_at_bw_set;	/* Cwnd at last bw saved - lbw */
246f79aab18SRandall Stewart 	uint32_t vol_reduce;	/* cnt of voluntary reductions */
247f79aab18SRandall Stewart 	uint16_t steady_step;	/* The number required to be in steady state */
248f79aab18SRandall Stewart 	uint16_t step_cnt;	/* The current number */
249f79aab18SRandall Stewart 	uint8_t ret_from_eq;	/* When all things are equal what do I return
250f79aab18SRandall Stewart 				 * 0/1 - 1 no cc advance */
251f79aab18SRandall Stewart 	uint8_t use_dccc_ecn;	/* Flag to enable DCCC ECN */
25248b6c649SRandall Stewart 	uint8_t tls_needs_set;	/* Flag to indicate we need to set tls 0 or 1
25348b6c649SRandall Stewart 				 * means set at send 2 not */
2540053ed28SMichael Tuexen 	uint8_t last_step_state;	/* Last state if steady state stepdown
2550053ed28SMichael Tuexen 					 * is on */
256f79aab18SRandall Stewart 	uint8_t rtt_set_this_sack;	/* Flag saying this sack had RTT calc
257f79aab18SRandall Stewart 					 * on it */
258f79aab18SRandall Stewart 	uint8_t last_inst_ind;	/* Last saved inst indication */
25948b6c649SRandall Stewart };
26048b6c649SRandall Stewart 
261f8829a4aSRandall Stewart struct sctp_nets {
262f8829a4aSRandall Stewart 	TAILQ_ENTRY(sctp_nets) sctp_next;	/* next link */
263f8829a4aSRandall Stewart 
264f8829a4aSRandall Stewart 	/*
265f8829a4aSRandall Stewart 	 * Things on the top half may be able to be split into a common
266f8829a4aSRandall Stewart 	 * structure shared by all.
267f8829a4aSRandall Stewart 	 */
268f8829a4aSRandall Stewart 	struct sctp_timer pmtu_timer;
269ca85e948SMichael Tuexen 	struct sctp_timer hb_timer;
270f8829a4aSRandall Stewart 
271f8829a4aSRandall Stewart 	/*
272f8829a4aSRandall Stewart 	 * The following two in combination equate to a route entry for v6
273f8829a4aSRandall Stewart 	 * or v4.
274f8829a4aSRandall Stewart 	 */
27517205eccSRandall Stewart 	struct sctp_net_route ro;
27617205eccSRandall Stewart 
277f8829a4aSRandall Stewart 	/* mtu discovered so far */
278f8829a4aSRandall Stewart 	uint32_t mtu;
279f8829a4aSRandall Stewart 	uint32_t ssthresh;	/* not sure about this one for split */
280a21779f0SRandall Stewart 	uint32_t last_cwr_tsn;
281a21779f0SRandall Stewart 	uint32_t cwr_window_tsn;
282a21779f0SRandall Stewart 	uint32_t ecn_ce_pkt_cnt;
283a21779f0SRandall Stewart 	uint32_t lost_cnt;
284f8829a4aSRandall Stewart 	/* smoothed average things for RTT and RTO itself */
285f8829a4aSRandall Stewart 	int lastsa;
286f8829a4aSRandall Stewart 	int lastsv;
287be1d9176SMichael Tuexen 	uint64_t rtt;		/* last measured rtt value in us */
288239e5865SMichael Tuexen 	uint32_t RTO;
289f8829a4aSRandall Stewart 
290f8829a4aSRandall Stewart 	/* This is used for SHUTDOWN/SHUTDOWN-ACK/SEND or INIT timers */
291f8829a4aSRandall Stewart 	struct sctp_timer rxt_timer;
292f8829a4aSRandall Stewart 
293f8829a4aSRandall Stewart 	/* last time in seconds I sent to it */
294f8829a4aSRandall Stewart 	struct timeval last_sent_time;
295299108c5SRandall Stewart 	union cc_control_data {
296299108c5SRandall Stewart 		struct htcp htcp_ca;	/* JRS - struct used in HTCP algorithm */
29748b6c649SRandall Stewart 		struct rtcc_cc rtcc;	/* rtcc module cc stuff  */
298299108c5SRandall Stewart 	}               cc_mod;
299f8829a4aSRandall Stewart 	int ref_count;
300f8829a4aSRandall Stewart 
301f8829a4aSRandall Stewart 	/* Congestion stats per destination */
302f8829a4aSRandall Stewart 	/*
303f8829a4aSRandall Stewart 	 * flight size variables and such, sorry Vern, I could not avoid
304f8829a4aSRandall Stewart 	 * this if I wanted performance :>
305f8829a4aSRandall Stewart 	 */
306f8829a4aSRandall Stewart 	uint32_t flight_size;
307f8829a4aSRandall Stewart 	uint32_t cwnd;		/* actual cwnd */
308f8829a4aSRandall Stewart 	uint32_t prev_cwnd;	/* cwnd before any processing */
309899288aeSRandall Stewart 	uint32_t ecn_prev_cwnd;	/* ECN prev cwnd at first ecn_echo seen in new
310899288aeSRandall Stewart 				 * window */
311f8829a4aSRandall Stewart 	uint32_t partial_bytes_acked;	/* in CA tracks when to incr a MTU */
312f8829a4aSRandall Stewart 	/* tracking variables to avoid the aloc/free in sack processing */
313f8829a4aSRandall Stewart 	unsigned int net_ack;
314f8829a4aSRandall Stewart 	unsigned int net_ack2;
315f8829a4aSRandall Stewart 
316f8829a4aSRandall Stewart 	/*
317b54d3a6cSRandall Stewart 	 * JRS - 5/8/07 - Variable to track last time a destination was
318b54d3a6cSRandall Stewart 	 * active for CMT PF
319b54d3a6cSRandall Stewart 	 */
320b54d3a6cSRandall Stewart 	uint32_t last_active;
321b54d3a6cSRandall Stewart 
322b54d3a6cSRandall Stewart 	/*
323f8829a4aSRandall Stewart 	 * CMT variables (iyengar@cis.udel.edu)
324f8829a4aSRandall Stewart 	 */
325f8829a4aSRandall Stewart 	uint32_t this_sack_highest_newack;	/* tracks highest TSN newly
326f8829a4aSRandall Stewart 						 * acked for a given dest in
327f8829a4aSRandall Stewart 						 * the current SACK. Used in
328f8829a4aSRandall Stewart 						 * SFR and HTNA algos */
329f8829a4aSRandall Stewart 	uint32_t pseudo_cumack;	/* CMT CUC algorithm. Maintains next expected
330f8829a4aSRandall Stewart 				 * pseudo-cumack for this destination */
331f8829a4aSRandall Stewart 	uint32_t rtx_pseudo_cumack;	/* CMT CUC algorithm. Maintains next
332f8829a4aSRandall Stewart 					 * expected pseudo-cumack for this
333f8829a4aSRandall Stewart 					 * destination */
334f8829a4aSRandall Stewart 
335f8829a4aSRandall Stewart 	/* CMT fast recovery variables */
336f8829a4aSRandall Stewart 	uint32_t fast_recovery_tsn;
337f8829a4aSRandall Stewart 	uint32_t heartbeat_random1;
338f8829a4aSRandall Stewart 	uint32_t heartbeat_random2;
33958bdb691SMichael Tuexen #ifdef INET6
340b10f2dc8SMichael Tuexen 	uint32_t flowlabel;
34158bdb691SMichael Tuexen #endif
342b10f2dc8SMichael Tuexen 	uint8_t dscp;
343f8829a4aSRandall Stewart 
3445e54f665SRandall Stewart 	struct timeval start_time;	/* time when this net was created */
3450053ed28SMichael Tuexen 	uint32_t marked_retrans;	/* number or DATA chunks marked for
3460053ed28SMichael Tuexen 					 * timer based retransmissions */
3475e54f665SRandall Stewart 	uint32_t marked_fastretrans;
348ca85e948SMichael Tuexen 	uint32_t heart_beat_delay;	/* Heart Beat delay in ms */
3495e54f665SRandall Stewart 
350f8829a4aSRandall Stewart 	/* if this guy is ok or not ... status */
351f8829a4aSRandall Stewart 	uint16_t dest_state;
352ca85e948SMichael Tuexen 	/* number of timeouts to consider the destination unreachable */
353f8829a4aSRandall Stewart 	uint16_t failure_threshold;
354ca85e948SMichael Tuexen 	/* number of timeouts to consider the destination potentially failed */
355ca85e948SMichael Tuexen 	uint16_t pf_threshold;
356ca85e948SMichael Tuexen 	/* error stats on the destination */
357f8829a4aSRandall Stewart 	uint16_t error_count;
358c54a18d2SRandall Stewart 	/* UDP port number in case of UDP tunneling */
359c54a18d2SRandall Stewart 	uint16_t port;
360f8829a4aSRandall Stewart 
361f8829a4aSRandall Stewart 	uint8_t fast_retran_loss_recovery;
362f8829a4aSRandall Stewart 	uint8_t will_exit_fast_recovery;
363f8829a4aSRandall Stewart 	/* Flags that probably can be combined into dest_state */
364f8829a4aSRandall Stewart 	uint8_t fast_retran_ip;	/* fast retransmit in progress */
365f8829a4aSRandall Stewart 	uint8_t hb_responded;
366f8829a4aSRandall Stewart 	uint8_t saw_newack;	/* CMT's SFR algorithm flag */
367f8829a4aSRandall Stewart 	uint8_t src_addr_selected;	/* if we split we move */
368f8829a4aSRandall Stewart 	uint8_t indx_of_eligible_next_to_use;
369f8829a4aSRandall Stewart 	uint8_t addr_is_local;	/* its a local address (if known) could move
370f8829a4aSRandall Stewart 				 * in split */
371f8829a4aSRandall Stewart 
372f8829a4aSRandall Stewart 	/*
373f8829a4aSRandall Stewart 	 * CMT variables (iyengar@cis.udel.edu)
374f8829a4aSRandall Stewart 	 */
375f8829a4aSRandall Stewart 	uint8_t find_pseudo_cumack;	/* CMT CUC algorithm. Flag used to
376f8829a4aSRandall Stewart 					 * find a new pseudocumack. This flag
377f8829a4aSRandall Stewart 					 * is set after a new pseudo-cumack
378f8829a4aSRandall Stewart 					 * has been received and indicates
379f8829a4aSRandall Stewart 					 * that the sender should find the
380f8829a4aSRandall Stewart 					 * next pseudo-cumack expected for
381f8829a4aSRandall Stewart 					 * this destination */
382f8829a4aSRandall Stewart 	uint8_t find_rtx_pseudo_cumack;	/* CMT CUCv2 algorithm. Flag used to
383f8829a4aSRandall Stewart 					 * find a new rtx-pseudocumack. This
384f8829a4aSRandall Stewart 					 * flag is set after a new
385f8829a4aSRandall Stewart 					 * rtx-pseudo-cumack has been received
386f8829a4aSRandall Stewart 					 * and indicates that the sender
387f8829a4aSRandall Stewart 					 * should find the next
388f8829a4aSRandall Stewart 					 * rtx-pseudo-cumack expected for this
389f8829a4aSRandall Stewart 					 * destination */
390f8829a4aSRandall Stewart 	uint8_t new_pseudo_cumack;	/* CMT CUC algorithm. Flag used to
391f8829a4aSRandall Stewart 					 * indicate if a new pseudo-cumack or
392f8829a4aSRandall Stewart 					 * rtx-pseudo-cumack has been received */
3935e54f665SRandall Stewart 	uint8_t window_probe;	/* Doing a window probe? */
3949a972525SRandall Stewart 	uint8_t RTO_measured;	/* Have we done the first measure */
395f8829a4aSRandall Stewart 	uint8_t last_hs_used;	/* index into the last HS table entry we used */
396899288aeSRandall Stewart 	uint8_t lan_type;
397f79aab18SRandall Stewart 	uint8_t rto_needed;
398a4ae38f1SMichael Tuexen 	uint32_t flowid;
399457b4b88SMichael Tuexen 	uint8_t flowtype;
400f8829a4aSRandall Stewart };
401f8829a4aSRandall Stewart 
402f8829a4aSRandall Stewart struct sctp_data_chunkrec {
40349656eefSMichael Tuexen 	uint32_t tsn;		/* the TSN of this transmit */
40449656eefSMichael Tuexen 	uint32_t mid;		/* the message identifier of this transmit */
40549656eefSMichael Tuexen 	uint16_t sid;		/* the stream number of this guy */
40649656eefSMichael Tuexen 	uint32_t ppid;
407f8829a4aSRandall Stewart 	uint32_t context;	/* from send */
408899288aeSRandall Stewart 	uint32_t cwnd_at_send;
409f8829a4aSRandall Stewart 	/*
410f8829a4aSRandall Stewart 	 * part of the Highest sacked algorithm to be able to stroke counts
411f8829a4aSRandall Stewart 	 * on ones that are FR'd.
412f8829a4aSRandall Stewart 	 */
413f8829a4aSRandall Stewart 	uint32_t fast_retran_tsn;	/* sending_seq at the time of FR */
414f8829a4aSRandall Stewart 	struct timeval timetodrop;	/* time we drop it from queue */
41549656eefSMichael Tuexen 	uint32_t fsn;		/* Fragment Sequence Number */
416f8829a4aSRandall Stewart 	uint8_t doing_fast_retransmit;
417f8829a4aSRandall Stewart 	uint8_t rcv_flags;	/* flags pulled from data chunk on inbound for
418a5d547adSRandall Stewart 				 * outbound holds sending flags for PR-SCTP. */
419f8829a4aSRandall Stewart 	uint8_t state_flags;
420f8829a4aSRandall Stewart 	uint8_t chunk_was_revoked;
421899288aeSRandall Stewart 	uint8_t fwd_tsn_cnt;
422f8829a4aSRandall Stewart };
423f8829a4aSRandall Stewart 
424f8829a4aSRandall Stewart TAILQ_HEAD(sctpchunk_listhead, sctp_tmit_chunk);
425f8829a4aSRandall Stewart 
426f8829a4aSRandall Stewart /* The lower byte is used to enumerate PR_SCTP policies */
427f8829a4aSRandall Stewart #define CHUNK_FLAGS_PR_SCTP_TTL	        SCTP_PR_SCTP_TTL
428f8829a4aSRandall Stewart #define CHUNK_FLAGS_PR_SCTP_BUF	        SCTP_PR_SCTP_BUF
429f8829a4aSRandall Stewart #define CHUNK_FLAGS_PR_SCTP_RTX         SCTP_PR_SCTP_RTX
430f8829a4aSRandall Stewart 
431f1cf0245SMichael Tuexen /* The upper byte is used as a bit mask */
432f8829a4aSRandall Stewart #define CHUNK_FLAGS_FRAGMENT_OK	        0x0100
433f8829a4aSRandall Stewart 
434f8829a4aSRandall Stewart struct chk_id {
435aa7e5af8SMichael Tuexen 	uint8_t id;
436aa7e5af8SMichael Tuexen 	uint8_t can_take_data;
437f8829a4aSRandall Stewart };
438f8829a4aSRandall Stewart 
439f8829a4aSRandall Stewart struct sctp_tmit_chunk {
440f8829a4aSRandall Stewart 	union {
441f8829a4aSRandall Stewart 		struct sctp_data_chunkrec data;
442f8829a4aSRandall Stewart 		struct chk_id chunk_id;
443f8829a4aSRandall Stewart 	}     rec;
444f8829a4aSRandall Stewart 	struct sctp_association *asoc;	/* bp to asoc this belongs to */
445f8829a4aSRandall Stewart 	struct timeval sent_rcv_time;	/* filled in if RTT being calculated */
446f8829a4aSRandall Stewart 	struct mbuf *data;	/* pointer to mbuf chain of data */
447f8829a4aSRandall Stewart 	struct mbuf *last_mbuf;	/* pointer to last mbuf in chain */
448f8829a4aSRandall Stewart 	struct sctp_nets *whoTo;
449f8829a4aSRandall Stewart 	          TAILQ_ENTRY(sctp_tmit_chunk) sctp_next;	/* next link */
450f8829a4aSRandall Stewart 	int32_t sent;		/* the send status */
451f8829a4aSRandall Stewart 	uint16_t snd_count;	/* number of times I sent */
452f8829a4aSRandall Stewart 	uint16_t flags;		/* flags, such as FRAGMENT_OK */
453f8829a4aSRandall Stewart 	uint16_t send_size;
454f8829a4aSRandall Stewart 	uint16_t book_size;
455f8829a4aSRandall Stewart 	uint16_t mbcnt;
456830d754dSRandall Stewart 	uint16_t auth_keyid;
457830d754dSRandall Stewart 	uint8_t holds_key_ref;	/* flag if auth keyid refcount is held */
458f8829a4aSRandall Stewart 	uint8_t pad_inplace;
459f8829a4aSRandall Stewart 	uint8_t do_rtt;
460f8829a4aSRandall Stewart 	uint8_t book_size_scale;
461f8829a4aSRandall Stewart 	uint8_t no_fr_allowed;
462f8829a4aSRandall Stewart 	uint8_t copy_by_ref;
4635e54f665SRandall Stewart 	uint8_t window_probe;
464f8829a4aSRandall Stewart };
465f8829a4aSRandall Stewart 
466f8829a4aSRandall Stewart struct sctp_queued_to_read {	/* sinfo structure Pluse more */
467f8829a4aSRandall Stewart 	uint16_t sinfo_stream;	/* off the wire */
468f8829a4aSRandall Stewart 	uint16_t sinfo_flags;	/* SCTP_UNORDERED from wire use SCTP_EOF for
469f8829a4aSRandall Stewart 				 * EOR */
470f8829a4aSRandall Stewart 	uint32_t sinfo_ppid;	/* off the wire */
471f8829a4aSRandall Stewart 	uint32_t sinfo_context;	/* pick this up from assoc def context? */
472f8829a4aSRandall Stewart 	uint32_t sinfo_timetolive;	/* not used by kernel */
473f8829a4aSRandall Stewart 	uint32_t sinfo_tsn;	/* Use this in reassembly as first TSN */
474f8829a4aSRandall Stewart 	uint32_t sinfo_cumtsn;	/* Use this in reassembly as last TSN */
475f8829a4aSRandall Stewart 	sctp_assoc_t sinfo_assoc_id;	/* our assoc id */
476f8829a4aSRandall Stewart 	/* Non sinfo stuff */
47749656eefSMichael Tuexen 	uint32_t mid;		/* Fragment Index */
478f8829a4aSRandall Stewart 	uint32_t length;	/* length of data */
479f8829a4aSRandall Stewart 	uint32_t held_length;	/* length held in sb */
48044249214SRandall Stewart 	uint32_t top_fsn;	/* Highest FSN in queue */
48144249214SRandall Stewart 	uint32_t fsn_included;	/* Highest FSN in *data portion */
482f8829a4aSRandall Stewart 	struct sctp_nets *whoFrom;	/* where it came from */
483f8829a4aSRandall Stewart 	struct mbuf *data;	/* front of the mbuf chain of data with
484f8829a4aSRandall Stewart 				 * PKT_HDR */
485f8829a4aSRandall Stewart 	struct mbuf *tail_mbuf;	/* used for multi-part data */
48617205eccSRandall Stewart 	struct mbuf *aux_data;	/* used to hold/cache  control if o/s does not
48717205eccSRandall Stewart 				 * take it from us */
488f8829a4aSRandall Stewart 	struct sctp_tcb *stcb;	/* assoc, used for window update */
489f8829a4aSRandall Stewart 	         TAILQ_ENTRY(sctp_queued_to_read) next;
49044249214SRandall Stewart 	         TAILQ_ENTRY(sctp_queued_to_read) next_instrm;
49144249214SRandall Stewart 	struct sctpchunk_listhead reasm;
492f8829a4aSRandall Stewart 	uint16_t port_from;
493139bc87fSRandall Stewart 	uint16_t spec_flags;	/* Flags to hold the notification field */
494f8829a4aSRandall Stewart 	uint8_t do_not_ref_stcb;
495f8829a4aSRandall Stewart 	uint8_t end_added;
49603b0b021SRandall Stewart 	uint8_t pdapi_aborted;
49744249214SRandall Stewart 	uint8_t pdapi_started;
4989a6142d8SRandall Stewart 	uint8_t some_taken;
49944249214SRandall Stewart 	uint8_t last_frag_seen;
50044249214SRandall Stewart 	uint8_t first_frag_seen;
50144249214SRandall Stewart 	uint8_t on_read_q;
50244249214SRandall Stewart 	uint8_t on_strm_q;
503f8829a4aSRandall Stewart };
504f8829a4aSRandall Stewart 
50544249214SRandall Stewart #define SCTP_ON_ORDERED 1
50644249214SRandall Stewart #define SCTP_ON_UNORDERED 2
50744249214SRandall Stewart 
508f8829a4aSRandall Stewart /* This data structure will be on the outbound
509f8829a4aSRandall Stewart  * stream queues. Data will be pulled off from
510f8829a4aSRandall Stewart  * the front of the mbuf data and chunk-ified
511f8829a4aSRandall Stewart  * by the output routines. We will custom
512f8829a4aSRandall Stewart  * fit every chunk we pull to the send/sent
513f8829a4aSRandall Stewart  * queue to make up the next full packet
514f8829a4aSRandall Stewart  * if we can. An entry cannot be removed
515f8829a4aSRandall Stewart  * from the stream_out queue until
516f8829a4aSRandall Stewart  * the msg_is_complete flag is set. This
517f8829a4aSRandall Stewart  * means at times data/tail_mbuf MIGHT
518f8829a4aSRandall Stewart  * be NULL.. If that occurs it happens
519f8829a4aSRandall Stewart  * for one of two reasons. Either the user
520f8829a4aSRandall Stewart  * is blocked on a send() call and has not
521f8829a4aSRandall Stewart  * awoken to copy more data down... OR
522f8829a4aSRandall Stewart  * the user is in the explict MSG_EOR mode
523f8829a4aSRandall Stewart  * and wrote some data, but has not completed
524f8829a4aSRandall Stewart  * sending.
525414499b3SMichael Tuexen  * ss_next and scheduled are only used by the FCFS stream scheduler.
526f8829a4aSRandall Stewart  */
527f8829a4aSRandall Stewart struct sctp_stream_queue_pending {
528f8829a4aSRandall Stewart 	struct mbuf *data;
529f8829a4aSRandall Stewart 	struct mbuf *tail_mbuf;
530f8829a4aSRandall Stewart 	struct timeval ts;
531f8829a4aSRandall Stewart 	struct sctp_nets *net;
532f8829a4aSRandall Stewart 	          TAILQ_ENTRY(sctp_stream_queue_pending) next;
533252f7f93SMichael Tuexen 	          TAILQ_ENTRY(sctp_stream_queue_pending) ss_next;
53444249214SRandall Stewart 	uint32_t fsn;
535f8829a4aSRandall Stewart 	uint32_t length;
536f8829a4aSRandall Stewart 	uint32_t timetolive;
537f8829a4aSRandall Stewart 	uint32_t ppid;
538f8829a4aSRandall Stewart 	uint32_t context;
539f8829a4aSRandall Stewart 	uint16_t sinfo_flags;
54049656eefSMichael Tuexen 	uint16_t sid;
541a5d547adSRandall Stewart 	uint16_t act_flags;
542830d754dSRandall Stewart 	uint16_t auth_keyid;
543830d754dSRandall Stewart 	uint8_t holds_key_ref;
544f8829a4aSRandall Stewart 	uint8_t msg_is_complete;
545f8829a4aSRandall Stewart 	uint8_t some_taken;
546478d3f09SRandall Stewart 	uint8_t sender_all_done;
547f1f73e57SRandall Stewart 	uint8_t put_last_out;
54849633f4bSRandall Stewart 	uint8_t discard_rest;
549f5d30f7fSMichael Tuexen 	uint8_t processing;
550414499b3SMichael Tuexen 	bool scheduled;
551f8829a4aSRandall Stewart };
552f8829a4aSRandall Stewart 
553f8829a4aSRandall Stewart /*
554f8829a4aSRandall Stewart  * this struct contains info that is used to track inbound stream data and
555f8829a4aSRandall Stewart  * help with ordering.
556f8829a4aSRandall Stewart  */
557f8829a4aSRandall Stewart TAILQ_HEAD(sctpwheelunrel_listhead, sctp_stream_in);
558f8829a4aSRandall Stewart struct sctp_stream_in {
559f8829a4aSRandall Stewart 	struct sctp_readhead inqueue;
56044249214SRandall Stewart 	struct sctp_readhead uno_inqueue;
56149656eefSMichael Tuexen 	uint32_t last_mid_delivered;	/* used for re-order */
56249656eefSMichael Tuexen 	uint16_t sid;
5639a6142d8SRandall Stewart 	uint8_t delivery_started;
56444249214SRandall Stewart 	uint8_t pd_api_started;
565f8829a4aSRandall Stewart };
566f8829a4aSRandall Stewart 
567f8829a4aSRandall Stewart TAILQ_HEAD(sctpwheel_listhead, sctp_stream_out);
568f7a77f6fSMichael Tuexen TAILQ_HEAD(sctplist_listhead, sctp_stream_queue_pending);
569f7a77f6fSMichael Tuexen 
5707a051c0aSMichael Tuexen /*
5717a051c0aSMichael Tuexen  * This union holds all data necessary for
5727a051c0aSMichael Tuexen  * different stream schedulers.
5737a051c0aSMichael Tuexen  */
5747a051c0aSMichael Tuexen struct scheduling_data {
5757a051c0aSMichael Tuexen 	struct sctp_stream_out *locked_on_sending;
5767a051c0aSMichael Tuexen 	/* circular looking for output selection */
5777a051c0aSMichael Tuexen 	struct sctp_stream_out *last_out_stream;
5787a051c0aSMichael Tuexen 	union {
5797a051c0aSMichael Tuexen 		struct sctpwheel_listhead wheel;
5807a051c0aSMichael Tuexen 		struct sctplist_listhead list;
5817a051c0aSMichael Tuexen 	}     out;
5827a051c0aSMichael Tuexen };
5837a051c0aSMichael Tuexen 
584f7a77f6fSMichael Tuexen /* Round-robin schedulers */
585f7a77f6fSMichael Tuexen struct ss_rr {
586f7a77f6fSMichael Tuexen 	/* next link in wheel */
587f7a77f6fSMichael Tuexen 	TAILQ_ENTRY(sctp_stream_out) next_spoke;
588f7a77f6fSMichael Tuexen };
589f7a77f6fSMichael Tuexen 
590f7a77f6fSMichael Tuexen /* Priority scheduler */
591f7a77f6fSMichael Tuexen struct ss_prio {
592f7a77f6fSMichael Tuexen 	/* next link in wheel */
593f7a77f6fSMichael Tuexen 	TAILQ_ENTRY(sctp_stream_out) next_spoke;
594f7a77f6fSMichael Tuexen 	/* priority id */
595f7a77f6fSMichael Tuexen 	uint16_t priority;
596f7a77f6fSMichael Tuexen };
597f7a77f6fSMichael Tuexen 
598f7a77f6fSMichael Tuexen /* Fair Bandwidth scheduler */
599f7a77f6fSMichael Tuexen struct ss_fb {
600f7a77f6fSMichael Tuexen 	/* next link in wheel */
601f7a77f6fSMichael Tuexen 	TAILQ_ENTRY(sctp_stream_out) next_spoke;
602f7a77f6fSMichael Tuexen 	/* stores message size */
603f7a77f6fSMichael Tuexen 	int32_t rounds;
604f7a77f6fSMichael Tuexen };
605f7a77f6fSMichael Tuexen 
606f7a77f6fSMichael Tuexen /*
607f7a77f6fSMichael Tuexen  * This union holds all parameters per stream
608f7a77f6fSMichael Tuexen  * necessary for different stream schedulers.
609f7a77f6fSMichael Tuexen  */
610414499b3SMichael Tuexen struct scheduling_parameters {
611414499b3SMichael Tuexen 	union {
612f7a77f6fSMichael Tuexen 		struct ss_rr rr;
613f7a77f6fSMichael Tuexen 		struct ss_prio prio;
614f7a77f6fSMichael Tuexen 		struct ss_fb fb;
615414499b3SMichael Tuexen 	}     ss;
616414499b3SMichael Tuexen 	bool scheduled;
617f7a77f6fSMichael Tuexen };
618f7a77f6fSMichael Tuexen 
6197cca1775SRandall Stewart /* States for outgoing streams */
6207cca1775SRandall Stewart #define SCTP_STREAM_CLOSED           0x00
6217cca1775SRandall Stewart #define SCTP_STREAM_OPENING          0x01
6227cca1775SRandall Stewart #define SCTP_STREAM_OPEN             0x02
6237cca1775SRandall Stewart #define SCTP_STREAM_RESET_PENDING    0x03
6247cca1775SRandall Stewart #define SCTP_STREAM_RESET_IN_FLIGHT  0x04
6257cca1775SRandall Stewart 
626f7a77f6fSMichael Tuexen /* This struct is used to track the traffic on outbound streams */
627f8829a4aSRandall Stewart struct sctp_stream_out {
628f8829a4aSRandall Stewart 	struct sctp_streamhead outqueue;
629414499b3SMichael Tuexen 	struct scheduling_parameters ss_params;
6307cca1775SRandall Stewart 	uint32_t chunks_on_queues;	/* send queue and sent queue */
631f0396ad1SMichael Tuexen #if defined(SCTP_DETAILED_STR_STATS)
632f0396ad1SMichael Tuexen 	uint32_t abandoned_unsent[SCTP_PR_SCTP_MAX + 1];
633f0396ad1SMichael Tuexen 	uint32_t abandoned_sent[SCTP_PR_SCTP_MAX + 1];
634f0396ad1SMichael Tuexen #else
635f0396ad1SMichael Tuexen 	/* Only the aggregation */
636f0396ad1SMichael Tuexen 	uint32_t abandoned_unsent[1];
637f0396ad1SMichael Tuexen 	uint32_t abandoned_sent[1];
638f0396ad1SMichael Tuexen #endif
63963d5b568SMichael Tuexen 	/*
64063d5b568SMichael Tuexen 	 * For associations using DATA chunks, the lower 16-bit of
64163d5b568SMichael Tuexen 	 * next_mid_ordered are used as the next SSN.
64263d5b568SMichael Tuexen 	 */
64363d5b568SMichael Tuexen 	uint32_t next_mid_ordered;
64463d5b568SMichael Tuexen 	uint32_t next_mid_unordered;
64549656eefSMichael Tuexen 	uint16_t sid;
646f8829a4aSRandall Stewart 	uint8_t last_msg_incomplete;
6477cca1775SRandall Stewart 	uint8_t state;
648f8829a4aSRandall Stewart };
649f8829a4aSRandall Stewart 
6507a051c0aSMichael Tuexen #define SCTP_MAX_STREAMS_AT_ONCE_RESET 200
6517a051c0aSMichael Tuexen 
652f8829a4aSRandall Stewart /* used to keep track of the addresses yet to try to add/delete */
653f8829a4aSRandall Stewart TAILQ_HEAD(sctp_asconf_addrhead, sctp_asconf_addr);
654f8829a4aSRandall Stewart struct sctp_asconf_addr {
655f8829a4aSRandall Stewart 	TAILQ_ENTRY(sctp_asconf_addr) next;
656f8829a4aSRandall Stewart 	struct sctp_asconf_addr_param ap;
65742551e99SRandall Stewart 	struct sctp_ifa *ifa;	/* save the ifa for add/del ip */
658f8829a4aSRandall Stewart 	uint8_t sent;		/* has this been sent yet? */
659830d754dSRandall Stewart 	uint8_t special_del;	/* not to be used in lookup */
660f8829a4aSRandall Stewart };
661f8829a4aSRandall Stewart 
662f8829a4aSRandall Stewart struct sctp_scoping {
663f8829a4aSRandall Stewart 	uint8_t ipv4_addr_legal;
664f8829a4aSRandall Stewart 	uint8_t ipv6_addr_legal;
665f8829a4aSRandall Stewart 	uint8_t loopback_scope;
666f8829a4aSRandall Stewart 	uint8_t ipv4_local_scope;
667f8829a4aSRandall Stewart 	uint8_t local_scope;
668f8829a4aSRandall Stewart 	uint8_t site_scope;
669f8829a4aSRandall Stewart };
670f8829a4aSRandall Stewart 
671f42a358aSRandall Stewart #define SCTP_TSN_LOG_SIZE 40
672f42a358aSRandall Stewart 
673f42a358aSRandall Stewart struct sctp_tsn_log {
67418e198d3SRandall Stewart 	void *stcb;
675f42a358aSRandall Stewart 	uint32_t tsn;
67644249214SRandall Stewart 	uint32_t seq;
677f42a358aSRandall Stewart 	uint16_t strm;
678f1f73e57SRandall Stewart 	uint16_t sz;
679f1f73e57SRandall Stewart 	uint16_t flgs;
68018e198d3SRandall Stewart 	uint16_t in_pos;
68118e198d3SRandall Stewart 	uint16_t in_out;
68244249214SRandall Stewart 	uint16_t resv;
683f42a358aSRandall Stewart };
684f42a358aSRandall Stewart 
685b54d3a6cSRandall Stewart #define SCTP_FS_SPEC_LOG_SIZE 200
686b54d3a6cSRandall Stewart struct sctp_fs_spec_log {
687b54d3a6cSRandall Stewart 	uint32_t sent;
688b54d3a6cSRandall Stewart 	uint32_t total_flight;
689b54d3a6cSRandall Stewart 	uint32_t tsn;
690b54d3a6cSRandall Stewart 	uint16_t book;
691b54d3a6cSRandall Stewart 	uint8_t incr;
692b54d3a6cSRandall Stewart 	uint8_t decr;
693b54d3a6cSRandall Stewart };
694d61a0ae0SRandall Stewart 
695f8829a4aSRandall Stewart /*
696b54d3a6cSRandall Stewart  * JRS - Structure to hold function pointers to the functions responsible
697b54d3a6cSRandall Stewart  * for congestion control.
698b54d3a6cSRandall Stewart  */
699b54d3a6cSRandall Stewart 
700b54d3a6cSRandall Stewart struct sctp_cc_functions {
701b54d3a6cSRandall Stewart 	void (*sctp_set_initial_cc_param) (struct sctp_tcb *stcb, struct sctp_nets *net);
702b54d3a6cSRandall Stewart 	void (*sctp_cwnd_update_after_sack) (struct sctp_tcb *stcb,
703b54d3a6cSRandall Stewart 	    struct sctp_association *asoc,
704b54d3a6cSRandall Stewart 	    int accum_moved, int reneged_all, int will_exit);
705ca85e948SMichael Tuexen 	void (*sctp_cwnd_update_exit_pf) (struct sctp_tcb *stcb, struct sctp_nets *net);
706b54d3a6cSRandall Stewart 	void (*sctp_cwnd_update_after_fr) (struct sctp_tcb *stcb,
707b54d3a6cSRandall Stewart 	    struct sctp_association *asoc);
708b54d3a6cSRandall Stewart 	void (*sctp_cwnd_update_after_timeout) (struct sctp_tcb *stcb,
709b54d3a6cSRandall Stewart 	    struct sctp_nets *net);
710b54d3a6cSRandall Stewart 	void (*sctp_cwnd_update_after_ecn_echo) (struct sctp_tcb *stcb,
711493d8e5aSRandall Stewart 	    struct sctp_nets *net, int in_window, int num_pkt_lost);
712b54d3a6cSRandall Stewart 	void (*sctp_cwnd_update_after_packet_dropped) (struct sctp_tcb *stcb,
713b54d3a6cSRandall Stewart 	    struct sctp_nets *net, struct sctp_pktdrop_chunk *cp,
714b54d3a6cSRandall Stewart 	    uint32_t *bottle_bw, uint32_t *on_queue);
715b54d3a6cSRandall Stewart 	void (*sctp_cwnd_update_after_output) (struct sctp_tcb *stcb,
716b54d3a6cSRandall Stewart 	    struct sctp_nets *net, int burst_limit);
717299108c5SRandall Stewart 	void (*sctp_cwnd_update_packet_transmitted) (struct sctp_tcb *stcb,
718299108c5SRandall Stewart 	    struct sctp_nets *net);
719299108c5SRandall Stewart 	void (*sctp_cwnd_update_tsn_acknowledged) (struct sctp_nets *net,
720299108c5SRandall Stewart 	    struct sctp_tmit_chunk *);
721299108c5SRandall Stewart 	void (*sctp_cwnd_new_transmission_begins) (struct sctp_tcb *stcb,
722299108c5SRandall Stewart 	    struct sctp_nets *net);
723299108c5SRandall Stewart 	void (*sctp_cwnd_prepare_net_for_sack) (struct sctp_tcb *stcb,
724299108c5SRandall Stewart 	    struct sctp_nets *net);
725299108c5SRandall Stewart 	int (*sctp_cwnd_socket_option) (struct sctp_tcb *stcb, int set, struct sctp_cc_option *);
726f79aab18SRandall Stewart 	void (*sctp_rtt_calculated) (struct sctp_tcb *, struct sctp_nets *, struct timeval *);
727b54d3a6cSRandall Stewart };
728b54d3a6cSRandall Stewart 
729f7a77f6fSMichael Tuexen /*
730f7a77f6fSMichael Tuexen  * RS - Structure to hold function pointers to the functions responsible
731f7a77f6fSMichael Tuexen  * for stream scheduling.
732f7a77f6fSMichael Tuexen  */
733f7a77f6fSMichael Tuexen struct sctp_ss_functions {
734762ae0ecSMichael Tuexen 	void (*sctp_ss_init) (struct sctp_tcb *stcb, struct sctp_association *asoc);
735f7a77f6fSMichael Tuexen 	void (*sctp_ss_clear) (struct sctp_tcb *stcb, struct sctp_association *asoc,
736414499b3SMichael Tuexen 	    bool clear_values);
737d1ea5fa9SMichael Tuexen 	void (*sctp_ss_init_stream) (struct sctp_tcb *stcb, struct sctp_stream_out *strq, struct sctp_stream_out *with_strq);
738f7a77f6fSMichael Tuexen 	void (*sctp_ss_add_to_stream) (struct sctp_tcb *stcb, struct sctp_association *asoc,
739762ae0ecSMichael Tuexen 	    struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp);
740414499b3SMichael Tuexen 	bool (*sctp_ss_is_empty) (struct sctp_tcb *stcb, struct sctp_association *asoc);
741f7a77f6fSMichael Tuexen 	void (*sctp_ss_remove_from_stream) (struct sctp_tcb *stcb, struct sctp_association *asoc,
742762ae0ecSMichael Tuexen 	    struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp);
743f7a77f6fSMichael Tuexen struct sctp_stream_out *(*sctp_ss_select_stream) (struct sctp_tcb *stcb,
744f7a77f6fSMichael Tuexen 	    struct sctp_nets *net, struct sctp_association *asoc);
745f7a77f6fSMichael Tuexen 	void (*sctp_ss_scheduled) (struct sctp_tcb *stcb, struct sctp_nets *net,
746f7a77f6fSMichael Tuexen 	    struct sctp_association *asoc, struct sctp_stream_out *strq, int moved_how_much);
747f7a77f6fSMichael Tuexen 	void (*sctp_ss_packet_done) (struct sctp_tcb *stcb, struct sctp_nets *net,
748f7a77f6fSMichael Tuexen 	    struct sctp_association *asoc);
749f7a77f6fSMichael Tuexen 	int (*sctp_ss_get_value) (struct sctp_tcb *stcb, struct sctp_association *asoc,
750f7a77f6fSMichael Tuexen 	    struct sctp_stream_out *strq, uint16_t *value);
751f7a77f6fSMichael Tuexen 	int (*sctp_ss_set_value) (struct sctp_tcb *stcb, struct sctp_association *asoc,
752f7a77f6fSMichael Tuexen 	    struct sctp_stream_out *strq, uint16_t value);
753414499b3SMichael Tuexen 	bool (*sctp_ss_is_user_msgs_incomplete) (struct sctp_tcb *stcb, struct sctp_association *asoc);
754f7a77f6fSMichael Tuexen };
755f7a77f6fSMichael Tuexen 
756c54a18d2SRandall Stewart /* used to save ASCONF chunks for retransmission */
757c54a18d2SRandall Stewart TAILQ_HEAD(sctp_asconf_head, sctp_asconf);
758c54a18d2SRandall Stewart struct sctp_asconf {
759c54a18d2SRandall Stewart 	TAILQ_ENTRY(sctp_asconf) next;
760c54a18d2SRandall Stewart 	uint32_t serial_number;
761c54a18d2SRandall Stewart 	uint16_t snd_count;
762c54a18d2SRandall Stewart 	struct mbuf *data;
763c54a18d2SRandall Stewart 	uint16_t len;
764c54a18d2SRandall Stewart };
765c54a18d2SRandall Stewart 
7662afb3e84SRandall Stewart /* used to save ASCONF-ACK chunks for retransmission */
7672afb3e84SRandall Stewart TAILQ_HEAD(sctp_asconf_ackhead, sctp_asconf_ack);
7682afb3e84SRandall Stewart struct sctp_asconf_ack {
7692afb3e84SRandall Stewart 	TAILQ_ENTRY(sctp_asconf_ack) next;
7702afb3e84SRandall Stewart 	uint32_t serial_number;
7712afb3e84SRandall Stewart 	struct sctp_nets *last_sent_to;
7722afb3e84SRandall Stewart 	struct mbuf *data;
7732afb3e84SRandall Stewart 	uint16_t len;
7742afb3e84SRandall Stewart };
7752afb3e84SRandall Stewart 
776b54d3a6cSRandall Stewart /*
777f8829a4aSRandall Stewart  * Here we have information about each individual association that we track.
778f8829a4aSRandall Stewart  * We probably in production would be more dynamic. But for ease of
779f8829a4aSRandall Stewart  * implementation we will have a fixed array that we hunt for in a linear
780f8829a4aSRandall Stewart  * fashion.
781f8829a4aSRandall Stewart  */
782f8829a4aSRandall Stewart struct sctp_association {
783f8829a4aSRandall Stewart 	/* association state */
784f8829a4aSRandall Stewart 	int state;
7851b649582SRandall Stewart 
786f8829a4aSRandall Stewart 	/* queue of pending addrs to add/delete */
787f8829a4aSRandall Stewart 	struct sctp_asconf_addrhead asconf_queue;
7881b649582SRandall Stewart 
789f8829a4aSRandall Stewart 	struct timeval time_entered;	/* time we entered state */
790f8829a4aSRandall Stewart 	struct timeval time_last_rcvd;
791f8829a4aSRandall Stewart 	struct timeval time_last_sent;
792f8829a4aSRandall Stewart 	struct timeval time_last_sat_advance;
793d61a0ae0SRandall Stewart 	struct sctp_nonpad_sndrcvinfo def_send;
794f8829a4aSRandall Stewart 
795f8829a4aSRandall Stewart 	/* timers and such */
796f8829a4aSRandall Stewart 	struct sctp_timer dack_timer;	/* Delayed ack timer */
7971b649582SRandall Stewart 	struct sctp_timer asconf_timer;	/* asconf */
798f8829a4aSRandall Stewart 	struct sctp_timer strreset_timer;	/* stream reset */
7991b649582SRandall Stewart 	struct sctp_timer shut_guard_timer;	/* shutdown guard */
800f8829a4aSRandall Stewart 	struct sctp_timer autoclose_timer;	/* automatic close timer */
801851b7298SRandall Stewart 	struct sctp_timer delete_prim_timer;	/* deleting primary dst */
802f8829a4aSRandall Stewart 
8031b649582SRandall Stewart 	/* list of restricted local addresses */
80442551e99SRandall Stewart 	struct sctpladdr sctp_restricted_addrs;
80542551e99SRandall Stewart 
8061b649582SRandall Stewart 	/* last local address pending deletion (waiting for an address add) */
8071b649582SRandall Stewart 	struct sctp_ifa *asconf_addr_del_pending;
808851b7298SRandall Stewart 	/* Deleted primary destination (used to stop timer) */
809851b7298SRandall Stewart 	struct sctp_nets *deleted_primary;
8101b649582SRandall Stewart 
8111b649582SRandall Stewart 	struct sctpnetlisthead nets;	/* remote address list */
812f8829a4aSRandall Stewart 
813f8829a4aSRandall Stewart 	/* Free chunk list */
814f8829a4aSRandall Stewart 	struct sctpchunk_listhead free_chunks;
815f8829a4aSRandall Stewart 
816f8829a4aSRandall Stewart 	/* Control chunk queue */
817f8829a4aSRandall Stewart 	struct sctpchunk_listhead control_send_queue;
818f8829a4aSRandall Stewart 
819c54a18d2SRandall Stewart 	/* ASCONF chunk queue */
820c54a18d2SRandall Stewart 	struct sctpchunk_listhead asconf_send_queue;
821c54a18d2SRandall Stewart 
822f8829a4aSRandall Stewart 	/*
823f8829a4aSRandall Stewart 	 * Once a TSN hits the wire it is moved to the sent_queue. We
824f8829a4aSRandall Stewart 	 * maintain two counts here (don't know if any but retran_cnt is
825f8829a4aSRandall Stewart 	 * needed). The idea is that the sent_queue_retran_cnt reflects how
826f8829a4aSRandall Stewart 	 * many chunks have been marked for retranmission by either T3-rxt
827f8829a4aSRandall Stewart 	 * or FR.
828f8829a4aSRandall Stewart 	 */
829f8829a4aSRandall Stewart 	struct sctpchunk_listhead sent_queue;
830f8829a4aSRandall Stewart 	struct sctpchunk_listhead send_queue;
831f8829a4aSRandall Stewart 
832252f7f93SMichael Tuexen 	/* Scheduling queues */
833d1ea5fa9SMichael Tuexen 	struct scheduling_data ss_data;
834f8829a4aSRandall Stewart 
835f8829a4aSRandall Stewart 	/* If an iterator is looking at me, this is it */
836f8829a4aSRandall Stewart 	struct sctp_iterator *stcb_starting_point_for_iterator;
837f8829a4aSRandall Stewart 
838f8829a4aSRandall Stewart 	/* ASCONF save the last ASCONF-ACK so we can resend it if necessary */
8392afb3e84SRandall Stewart 	struct sctp_asconf_ackhead asconf_ack_sent;
840f8829a4aSRandall Stewart 
841f8829a4aSRandall Stewart 	/*
842f8829a4aSRandall Stewart 	 * pointer to last stream reset queued to control queue by us with
843f8829a4aSRandall Stewart 	 * requests.
844f8829a4aSRandall Stewart 	 */
845f8829a4aSRandall Stewart 	struct sctp_tmit_chunk *str_reset;
846f8829a4aSRandall Stewart 	/*
847f8829a4aSRandall Stewart 	 * if Source Address Selection happening, this will rotate through
848f8829a4aSRandall Stewart 	 * the link list.
849f8829a4aSRandall Stewart 	 */
850f8829a4aSRandall Stewart 	struct sctp_laddr *last_used_address;
851f8829a4aSRandall Stewart 
852f8829a4aSRandall Stewart 	/* stream arrays */
853f8829a4aSRandall Stewart 	struct sctp_stream_in *strmin;
854f8829a4aSRandall Stewart 	struct sctp_stream_out *strmout;
855f8829a4aSRandall Stewart 	uint8_t *mapping_array;
856f8829a4aSRandall Stewart 	/* primary destination to use */
857f8829a4aSRandall Stewart 	struct sctp_nets *primary_destination;
858ca85e948SMichael Tuexen 	struct sctp_nets *alternate;	/* If primary is down or PF */
859f8829a4aSRandall Stewart 	/* For CMT */
8608933fa13SRandall Stewart 	struct sctp_nets *last_net_cmt_send_started;
861f8829a4aSRandall Stewart 	/* last place I got a data chunk from */
862f8829a4aSRandall Stewart 	struct sctp_nets *last_data_chunk_from;
863f8829a4aSRandall Stewart 	/* last place I got a control from */
864f8829a4aSRandall Stewart 	struct sctp_nets *last_control_chunk_from;
865f8829a4aSRandall Stewart 
866f8829a4aSRandall Stewart 	/*
867f8829a4aSRandall Stewart 	 * wait to the point the cum-ack passes req->send_reset_at_tsn for
868f8829a4aSRandall Stewart 	 * any req on the list.
869f8829a4aSRandall Stewart 	 */
870f8829a4aSRandall Stewart 	struct sctp_resethead resetHead;
871f8829a4aSRandall Stewart 
872f8829a4aSRandall Stewart 	/* queue of chunks waiting to be sent into the local stack */
873f8829a4aSRandall Stewart 	struct sctp_readhead pending_reply_queue;
874f8829a4aSRandall Stewart 
875b54d3a6cSRandall Stewart 	/* JRS - the congestion control functions are in this struct */
876b54d3a6cSRandall Stewart 	struct sctp_cc_functions cc_functions;
877b7b84c0eSMichael Tuexen 	/*
878b7b84c0eSMichael Tuexen 	 * JRS - value to store the currently loaded congestion control
879b7b84c0eSMichael Tuexen 	 * module
880b7b84c0eSMichael Tuexen 	 */
881b54d3a6cSRandall Stewart 	uint32_t congestion_control_module;
882f7a77f6fSMichael Tuexen 	/* RS - the stream scheduling functions are in this struct */
883f7a77f6fSMichael Tuexen 	struct sctp_ss_functions ss_functions;
884f7a77f6fSMichael Tuexen 	/* RS - value to store the currently loaded stream scheduling module */
885f7a77f6fSMichael Tuexen 	uint32_t stream_scheduling_module;
886b54d3a6cSRandall Stewart 
88742551e99SRandall Stewart 	uint32_t vrf_id;
888f8829a4aSRandall Stewart 	uint32_t cookie_preserve_req;
889f8829a4aSRandall Stewart 	/* ASCONF next seq I am sending out, inits at init-tsn */
890f8829a4aSRandall Stewart 	uint32_t asconf_seq_out;
891c54a18d2SRandall Stewart 	uint32_t asconf_seq_out_acked;
892f8829a4aSRandall Stewart 	/* ASCONF last received ASCONF from peer, starts at peer's TSN-1 */
893f8829a4aSRandall Stewart 	uint32_t asconf_seq_in;
894f8829a4aSRandall Stewart 
895f8829a4aSRandall Stewart 	/* next seq I am sending in str reset messages */
896f8829a4aSRandall Stewart 	uint32_t str_reset_seq_out;
897f8829a4aSRandall Stewart 	/* next seq I am expecting in str reset messages */
898f8829a4aSRandall Stewart 	uint32_t str_reset_seq_in;
899f8829a4aSRandall Stewart 
900f8829a4aSRandall Stewart 	/* various verification tag information */
901f8829a4aSRandall Stewart 	uint32_t my_vtag;	/* The tag to be used. if assoc is re-initited
902f8829a4aSRandall Stewart 				 * by remote end, and I have unlocked this
903f8829a4aSRandall Stewart 				 * will be regenerated to a new random value. */
904f8829a4aSRandall Stewart 	uint32_t peer_vtag;	/* The peers last tag */
905f8829a4aSRandall Stewart 
906f8829a4aSRandall Stewart 	uint32_t my_vtag_nonce;
907f8829a4aSRandall Stewart 	uint32_t peer_vtag_nonce;
908f8829a4aSRandall Stewart 
909f8829a4aSRandall Stewart 	uint32_t assoc_id;
910f8829a4aSRandall Stewart 
911f8829a4aSRandall Stewart 	/* This is the SCTP fragmentation threshold */
912f8829a4aSRandall Stewart 	uint32_t smallest_mtu;
913f8829a4aSRandall Stewart 
914f8829a4aSRandall Stewart 	/*
915f8829a4aSRandall Stewart 	 * Special hook for Fast retransmit, allows us to track the highest
916f8829a4aSRandall Stewart 	 * TSN that is NEW in this SACK if gap ack blocks are present.
917f8829a4aSRandall Stewart 	 */
918f8829a4aSRandall Stewart 	uint32_t this_sack_highest_gap;
919f8829a4aSRandall Stewart 
920f8829a4aSRandall Stewart 	/*
921f8829a4aSRandall Stewart 	 * The highest consecutive TSN that has been acked by peer on my
922f8829a4aSRandall Stewart 	 * sends
923f8829a4aSRandall Stewart 	 */
924f8829a4aSRandall Stewart 	uint32_t last_acked_seq;
925f8829a4aSRandall Stewart 
926f8829a4aSRandall Stewart 	/* The next TSN that I will use in sending. */
927f8829a4aSRandall Stewart 	uint32_t sending_seq;
928f8829a4aSRandall Stewart 
929f8829a4aSRandall Stewart 	/* Original seq number I used ??questionable to keep?? */
930f8829a4aSRandall Stewart 	uint32_t init_seq_number;
931f8829a4aSRandall Stewart 
932f8829a4aSRandall Stewart 	/* The Advanced Peer Ack Point, as required by the PR-SCTP */
933f8829a4aSRandall Stewart 	/* (A1 in Section 4.2) */
934f8829a4aSRandall Stewart 	uint32_t advanced_peer_ack_point;
935f8829a4aSRandall Stewart 
936f8829a4aSRandall Stewart 	/*
937f8829a4aSRandall Stewart 	 * The highest consequetive TSN at the bottom of the mapping array
938f8829a4aSRandall Stewart 	 * (for his sends).
939f8829a4aSRandall Stewart 	 */
940f8829a4aSRandall Stewart 	uint32_t cumulative_tsn;
941f8829a4aSRandall Stewart 	/*
942f8829a4aSRandall Stewart 	 * Used to track the mapping array and its offset bits. This MAY be
943f8829a4aSRandall Stewart 	 * lower then cumulative_tsn.
944f8829a4aSRandall Stewart 	 */
945f8829a4aSRandall Stewart 	uint32_t mapping_array_base_tsn;
946f8829a4aSRandall Stewart 	/*
947f8829a4aSRandall Stewart 	 * used to track highest TSN we have received and is listed in the
948f8829a4aSRandall Stewart 	 * mapping array.
949f8829a4aSRandall Stewart 	 */
950f8829a4aSRandall Stewart 	uint32_t highest_tsn_inside_map;
951f8829a4aSRandall Stewart 
952830d754dSRandall Stewart 	/* EY - new NR variables used for nr_sack based on mapping_array */
953830d754dSRandall Stewart 	uint8_t *nr_mapping_array;
954830d754dSRandall Stewart 	uint32_t highest_tsn_inside_nr_map;
955830d754dSRandall Stewart 
956f8829a4aSRandall Stewart 	uint32_t fast_recovery_tsn;
957f8829a4aSRandall Stewart 	uint32_t sat_t3_recovery_tsn;
958f8829a4aSRandall Stewart 	uint32_t tsn_last_delivered;
959f8829a4aSRandall Stewart 	uint32_t tsn_of_pdapi_last_delivered;
960f8829a4aSRandall Stewart 	uint32_t pdapi_ppid;
961f8829a4aSRandall Stewart 	uint32_t context;
962f8829a4aSRandall Stewart 	uint32_t last_reset_action[SCTP_MAX_RESET_PARAMS];
963f8829a4aSRandall Stewart 	uint32_t last_sending_seq[SCTP_MAX_RESET_PARAMS];
964f8829a4aSRandall Stewart 	uint32_t last_base_tsnsent[SCTP_MAX_RESET_PARAMS];
965f42a358aSRandall Stewart #ifdef SCTP_ASOCLOG_OF_TSNS
966f42a358aSRandall Stewart 	/*
967f42a358aSRandall Stewart 	 * special log  - This adds considerable size to the asoc, but
968f42a358aSRandall Stewart 	 * provides a log that you can use to detect problems via kgdb.
969f42a358aSRandall Stewart 	 */
970f42a358aSRandall Stewart 	struct sctp_tsn_log in_tsnlog[SCTP_TSN_LOG_SIZE];
971f42a358aSRandall Stewart 	struct sctp_tsn_log out_tsnlog[SCTP_TSN_LOG_SIZE];
97218e198d3SRandall Stewart 	uint32_t cumack_log[SCTP_TSN_LOG_SIZE];
973b201f536SRandall Stewart 	uint32_t cumack_logsnt[SCTP_TSN_LOG_SIZE];
974f42a358aSRandall Stewart 	uint16_t tsn_in_at;
975f42a358aSRandall Stewart 	uint16_t tsn_out_at;
976f1f73e57SRandall Stewart 	uint16_t tsn_in_wrapped;
977f1f73e57SRandall Stewart 	uint16_t tsn_out_wrapped;
97818e198d3SRandall Stewart 	uint16_t cumack_log_at;
979b201f536SRandall Stewart 	uint16_t cumack_log_atsnt;
980f42a358aSRandall Stewart #endif				/* SCTP_ASOCLOG_OF_TSNS */
981b54d3a6cSRandall Stewart #ifdef SCTP_FS_SPEC_LOG
982b54d3a6cSRandall Stewart 	struct sctp_fs_spec_log fslog[SCTP_FS_SPEC_LOG_SIZE];
983b54d3a6cSRandall Stewart 	uint16_t fs_index;
984b54d3a6cSRandall Stewart #endif
985b54d3a6cSRandall Stewart 
986f8829a4aSRandall Stewart 	/*
987f8829a4aSRandall Stewart 	 * window state information and smallest MTU that I use to bound
988f8829a4aSRandall Stewart 	 * segmentation
989f8829a4aSRandall Stewart 	 */
990f8829a4aSRandall Stewart 	uint32_t peers_rwnd;
991f8829a4aSRandall Stewart 	uint32_t my_rwnd;
992f8829a4aSRandall Stewart 	uint32_t my_last_reported_rwnd;
993d61a0ae0SRandall Stewart 	uint32_t sctp_frag_point;
994f8829a4aSRandall Stewart 
995f8829a4aSRandall Stewart 	uint32_t total_output_queue_size;
996f8829a4aSRandall Stewart 
9974e88d37aSMichael Tuexen 	uint32_t sb_cc;		/* shadow of sb_cc */
9989f22f500SRandall Stewart 	uint32_t sb_send_resv;	/* amount reserved on a send */
999c4739e2fSRandall Stewart 	uint32_t my_rwnd_control_len;	/* shadow of sb_mbcnt used for rwnd
1000c4739e2fSRandall Stewart 					 * control */
100158bdb691SMichael Tuexen #ifdef INET6
1002f8829a4aSRandall Stewart 	uint32_t default_flowlabel;
100358bdb691SMichael Tuexen #endif
1004f8829a4aSRandall Stewart 	uint32_t pr_sctp_cnt;
1005493d8e5aSRandall Stewart 	int ctrl_queue_cnt;	/* could be removed  REM - NO IT CAN'T!! RRS */
1006f8829a4aSRandall Stewart 	/*
1007f8829a4aSRandall Stewart 	 * All outbound datagrams queue into this list from the individual
1008f8829a4aSRandall Stewart 	 * stream queue. Here they get assigned a TSN and then await
1009f8829a4aSRandall Stewart 	 * sending. The stream seq comes when it is first put in the
1010f8829a4aSRandall Stewart 	 * individual str queue
1011f8829a4aSRandall Stewart 	 */
1012f8829a4aSRandall Stewart 	unsigned int stream_queue_cnt;
1013f8829a4aSRandall Stewart 	unsigned int send_queue_cnt;
1014f8829a4aSRandall Stewart 	unsigned int sent_queue_cnt;
1015f8829a4aSRandall Stewart 	unsigned int sent_queue_cnt_removeable;
1016f8829a4aSRandall Stewart 	/*
1017f8829a4aSRandall Stewart 	 * Number on sent queue that are marked for retran until this value
1018f8829a4aSRandall Stewart 	 * is 0 we only send one packet of retran'ed data.
1019f8829a4aSRandall Stewart 	 */
1020f8829a4aSRandall Stewart 	unsigned int sent_queue_retran_cnt;
1021f8829a4aSRandall Stewart 
1022f8829a4aSRandall Stewart 	unsigned int size_on_reasm_queue;
1023f8829a4aSRandall Stewart 	unsigned int cnt_on_reasm_queue;
102444fbe462SRandall Stewart 	unsigned int fwd_tsn_cnt;
1025f8829a4aSRandall Stewart 	/* amount of data (bytes) currently in flight (on all destinations) */
1026f8829a4aSRandall Stewart 	unsigned int total_flight;
1027f8829a4aSRandall Stewart 	/* Total book size in flight */
1028f8829a4aSRandall Stewart 	unsigned int total_flight_count;	/* count of chunks used with
1029f8829a4aSRandall Stewart 						 * book total */
1030f8829a4aSRandall Stewart 	/* count of destinaton nets and list of destination nets */
1031f8829a4aSRandall Stewart 	unsigned int numnets;
1032f8829a4aSRandall Stewart 
1033f8829a4aSRandall Stewart 	/* Total error count on this association */
1034f8829a4aSRandall Stewart 	unsigned int overall_error_count;
1035f8829a4aSRandall Stewart 
1036f8829a4aSRandall Stewart 	unsigned int cnt_msg_on_sb;
1037f8829a4aSRandall Stewart 
1038f8829a4aSRandall Stewart 	/* All stream count of chunks for delivery */
1039f8829a4aSRandall Stewart 	unsigned int size_on_all_streams;
1040f8829a4aSRandall Stewart 	unsigned int cnt_on_all_streams;
1041f8829a4aSRandall Stewart 
1042ca85e948SMichael Tuexen 	/* Heart Beat delay in ms */
1043ca85e948SMichael Tuexen 	uint32_t heart_beat_delay;
1044f8829a4aSRandall Stewart 
1045f8829a4aSRandall Stewart 	/* autoclose */
1046d5d190f2SMichael Tuexen 	uint32_t sctp_autoclose_ticks;
1047f8829a4aSRandall Stewart 
1048f8829a4aSRandall Stewart 	/* how many preopen streams we have */
1049f8829a4aSRandall Stewart 	unsigned int pre_open_streams;
1050f8829a4aSRandall Stewart 
1051f8829a4aSRandall Stewart 	/* How many streams I support coming into me */
1052f8829a4aSRandall Stewart 	unsigned int max_inbound_streams;
1053f8829a4aSRandall Stewart 
1054f8829a4aSRandall Stewart 	/* the cookie life I award for any cookie, in seconds */
1055239e5865SMichael Tuexen 	uint32_t cookie_life;
1056f8829a4aSRandall Stewart 	/* time to delay acks for */
1057f8829a4aSRandall Stewart 	unsigned int delayed_ack;
105842551e99SRandall Stewart 	unsigned int old_delayed_ack;
105942551e99SRandall Stewart 	unsigned int sack_freq;
106042551e99SRandall Stewart 	unsigned int data_pkts_seen;
1061f8829a4aSRandall Stewart 
1062f8829a4aSRandall Stewart 	unsigned int numduptsns;
1063f8829a4aSRandall Stewart 	int dup_tsns[SCTP_MAX_DUP_TSNS];
1064239e5865SMichael Tuexen 	uint32_t initial_init_rto_max;	/* initial RTO for INIT's */
1065239e5865SMichael Tuexen 	uint32_t initial_rto;	/* initial send RTO */
1066239e5865SMichael Tuexen 	uint32_t minrto;	/* per assoc RTO-MIN */
1067239e5865SMichael Tuexen 	uint32_t maxrto;	/* per assoc RTO-MAX */
1068f8829a4aSRandall Stewart 
1069f8829a4aSRandall Stewart 	/* authentication fields */
1070f8829a4aSRandall Stewart 	sctp_auth_chklist_t *local_auth_chunks;
1071f8829a4aSRandall Stewart 	sctp_auth_chklist_t *peer_auth_chunks;
1072f8829a4aSRandall Stewart 	sctp_hmaclist_t *local_hmacs;	/* local HMACs supported */
1073f8829a4aSRandall Stewart 	sctp_hmaclist_t *peer_hmacs;	/* peer HMACs supported */
1074f8829a4aSRandall Stewart 	struct sctp_keyhead shared_keys;	/* assoc's shared keys */
1075f8829a4aSRandall Stewart 	sctp_authinfo_t authinfo;	/* randoms, cached keys */
1076f8829a4aSRandall Stewart 	/*
1077f8829a4aSRandall Stewart 	 * refcnt to block freeing when a sender or receiver is off coping
1078f8829a4aSRandall Stewart 	 * user data in.
1079f8829a4aSRandall Stewart 	 */
108050cec919SRandall Stewart 	uint32_t refcnt;
108150cec919SRandall Stewart 	uint32_t chunks_on_out_queue;	/* total chunks floating around,
108250cec919SRandall Stewart 					 * locked by send socket buffer */
10832afb3e84SRandall Stewart 	uint32_t peers_adaptation;
108428a6addeSMichael Tuexen 	uint32_t default_mtu;
108550cec919SRandall Stewart 	uint16_t peer_hmac_id;	/* peer HMAC id to send */
1086f8829a4aSRandall Stewart 
1087f8829a4aSRandall Stewart 	/*
1088f8829a4aSRandall Stewart 	 * Being that we have no bag to collect stale cookies, and that we
1089f8829a4aSRandall Stewart 	 * really would not want to anyway.. we will count them in this
1090f8829a4aSRandall Stewart 	 * counter. We of course feed them to the pigeons right away (I have
1091f8829a4aSRandall Stewart 	 * always thought of pigeons as flying rats).
1092f8829a4aSRandall Stewart 	 */
1093f8829a4aSRandall Stewart 	uint16_t stale_cookie_count;
1094f8829a4aSRandall Stewart 
1095f8829a4aSRandall Stewart 	/*
1096f8829a4aSRandall Stewart 	 * For the partial delivery API, if up, invoked this is what last
1097f8829a4aSRandall Stewart 	 * TSN I delivered
1098f8829a4aSRandall Stewart 	 */
1099f8829a4aSRandall Stewart 	uint16_t str_of_pdapi;
1100f8829a4aSRandall Stewart 	uint16_t ssn_of_pdapi;
1101f8829a4aSRandall Stewart 
1102f8829a4aSRandall Stewart 	/* counts of actual built streams. Allocation may be more however */
1103f8829a4aSRandall Stewart 	/* could re-arrange to optimize space here. */
1104f8829a4aSRandall Stewart 	uint16_t streamincnt;
1105f8829a4aSRandall Stewart 	uint16_t streamoutcnt;
1106ea44232bSRandall Stewart 	uint16_t strm_realoutsize;
1107c4e848b7SRandall Stewart 	uint16_t strm_pending_add_size;
1108f8829a4aSRandall Stewart 	/* my maximum number of retrans of INIT and SEND */
1109f8829a4aSRandall Stewart 	/* copied from SCTP but should be individually setable */
1110f8829a4aSRandall Stewart 	uint16_t max_init_times;
1111f8829a4aSRandall Stewart 	uint16_t max_send_times;
1112f8829a4aSRandall Stewart 
1113f8829a4aSRandall Stewart 	uint16_t def_net_failure;
1114f8829a4aSRandall Stewart 
1115ca85e948SMichael Tuexen 	uint16_t def_net_pf_threshold;
1116ca85e948SMichael Tuexen 
1117f8829a4aSRandall Stewart 	/*
1118f8829a4aSRandall Stewart 	 * lock flag: 0 is ok to send, 1+ (duals as a retran count) is
1119f8829a4aSRandall Stewart 	 * awaiting ACK
1120f8829a4aSRandall Stewart 	 */
1121f8829a4aSRandall Stewart 	uint16_t mapping_array_size;
1122f8829a4aSRandall Stewart 
1123f8829a4aSRandall Stewart 	uint16_t last_strm_seq_delivered;
1124f8829a4aSRandall Stewart 	uint16_t last_strm_no_delivered;
1125f8829a4aSRandall Stewart 
1126f8829a4aSRandall Stewart 	uint16_t last_revoke_count;
1127f8829a4aSRandall Stewart 	int16_t num_send_timers_up;
1128f8829a4aSRandall Stewart 
1129f8829a4aSRandall Stewart 	uint16_t stream_locked_on;
1130f8829a4aSRandall Stewart 	uint16_t ecn_echo_cnt_onq;
1131f8829a4aSRandall Stewart 
1132f8829a4aSRandall Stewart 	uint16_t free_chunk_cnt;
1133f8829a4aSRandall Stewart 	uint8_t stream_locked;
1134f8829a4aSRandall Stewart 	uint8_t authenticated;	/* packet authenticated ok */
1135f8829a4aSRandall Stewart 	/*
113642551e99SRandall Stewart 	 * This flag indicates that a SACK need to be sent. Initially this
113742551e99SRandall Stewart 	 * is 1 to send the first sACK immediately.
1138f8829a4aSRandall Stewart 	 */
113942551e99SRandall Stewart 	uint8_t send_sack;
1140f8829a4aSRandall Stewart 
1141899288aeSRandall Stewart 	/* max burst of new packets into the network */
114290fed1d8SMichael Tuexen 	uint32_t max_burst;
1143899288aeSRandall Stewart 	/* max burst of fast retransmit packets */
1144899288aeSRandall Stewart 	uint32_t fr_max_burst;
1145f8829a4aSRandall Stewart 
1146f8829a4aSRandall Stewart 	uint8_t sat_network;	/* RTT is in range of sat net or greater */
1147f8829a4aSRandall Stewart 	uint8_t sat_network_lockout;	/* lockout code */
1148f8829a4aSRandall Stewart 	uint8_t burst_limit_applied;	/* Burst limit in effect at last send? */
1149f8829a4aSRandall Stewart 	/* flag goes on when we are doing a partial delivery api */
1150f8829a4aSRandall Stewart 	uint8_t hb_random_values[4];
1151f8829a4aSRandall Stewart 	uint8_t fragmented_delivery_inprogress;
1152f8829a4aSRandall Stewart 	uint8_t fragment_flags;
1153f8829a4aSRandall Stewart 	uint8_t last_flags_delivered;
1154f8829a4aSRandall Stewart 	uint8_t hb_ect_randombit;
1155f8829a4aSRandall Stewart 	uint8_t hb_random_idx;
1156b10f2dc8SMichael Tuexen 	uint8_t default_dscp;
11571b649582SRandall Stewart 	uint8_t asconf_del_pending;	/* asconf delete last addr pending */
11587cca1775SRandall Stewart 	uint8_t trigger_reset;
1159f8829a4aSRandall Stewart 	/*
1160f8829a4aSRandall Stewart 	 * This value, plus all other ack'd but above cum-ack is added
1161f8829a4aSRandall Stewart 	 * together to cross check against the bit that we have yet to
1162f8829a4aSRandall Stewart 	 * define (probably in the SACK). When the cum-ack is updated, this
1163f8829a4aSRandall Stewart 	 * sum is updated as well.
1164f8829a4aSRandall Stewart 	 */
1165493d8e5aSRandall Stewart 
1166dd973b0eSMichael Tuexen 	/* Flags whether an extension is supported or not */
1167f342355aSMichael Tuexen 	uint8_t ecn_supported;
1168dd973b0eSMichael Tuexen 	uint8_t prsctp_supported;
1169c79bec9cSMichael Tuexen 	uint8_t auth_supported;
1170c79bec9cSMichael Tuexen 	uint8_t asconf_supported;
1171317e00efSMichael Tuexen 	uint8_t reconfig_supported;
1172caea9879SMichael Tuexen 	uint8_t nrsack_supported;
1173cb9b8e6fSMichael Tuexen 	uint8_t pktdrop_supported;
117444249214SRandall Stewart 	uint8_t idata_supported;
1175f8829a4aSRandall Stewart 
1176*52640d61SMichael Tuexen 	/* Zero checksum supported information */
1177*52640d61SMichael Tuexen 	uint8_t rcv_edmid;
1178*52640d61SMichael Tuexen 	uint8_t snd_edmid;
11794a2b92d9SMichael Tuexen 
1180c4e848b7SRandall Stewart 	/* Did the peer make the stream config (add out) request */
1181c4e848b7SRandall Stewart 	uint8_t peer_req_out;
1182c4e848b7SRandall Stewart 
1183c4e848b7SRandall Stewart 	uint8_t local_strreset_support;
1184830d754dSRandall Stewart 	uint8_t peer_supports_nat;
1185f8829a4aSRandall Stewart 
1186a1cb341bSMichael Tuexen 	struct sctp_scoping scope;
1187f8829a4aSRandall Stewart 	/* flags to handle send alternate net tracking */
1188f8829a4aSRandall Stewart 	uint8_t used_alt_asconfack;
1189f8829a4aSRandall Stewart 	uint8_t fast_retran_loss_recovery;
1190f8829a4aSRandall Stewart 	uint8_t sat_t3_loss_recovery;
1191f8829a4aSRandall Stewart 	uint8_t dropped_special_cnt;
1192f8829a4aSRandall Stewart 	uint8_t seen_a_sack_this_pkt;
1193f8829a4aSRandall Stewart 	uint8_t stream_reset_outstanding;
1194f8829a4aSRandall Stewart 	uint8_t stream_reset_out_is_outstanding;
1195f8829a4aSRandall Stewart 	uint8_t delayed_connection;
1196f8829a4aSRandall Stewart 	uint8_t ifp_had_enobuf;
1197f8829a4aSRandall Stewart 	uint8_t saw_sack_with_frags;
1198d9c5cfeaSMichael Tuexen 	uint8_t saw_sack_with_nr_frags;
1199830d754dSRandall Stewart 	uint8_t in_asocid_hash;
1200f8829a4aSRandall Stewart 	uint8_t assoc_up_sent;
12012afb3e84SRandall Stewart 	uint8_t adaptation_needed;
12022afb3e84SRandall Stewart 	uint8_t adaptation_sent;
1203f8829a4aSRandall Stewart 	/* CMT variables */
1204f8829a4aSRandall Stewart 	uint8_t cmt_dac_pkts_rcvd;
1205f8829a4aSRandall Stewart 	uint8_t sctp_cmt_on_off;
1206f8829a4aSRandall Stewart 	uint8_t iam_blocking;
120744b7479bSRandall Stewart 	uint8_t cookie_how[8];
1208b54d3a6cSRandall Stewart 	/* JRS 5/21/07 - CMT PF variable */
1209b54d3a6cSRandall Stewart 	uint8_t sctp_cmt_pf;
1210299108c5SRandall Stewart 	uint8_t use_precise_time;
121106c9f9bdSMichael Tuexen 	uint64_t sctp_features;
121259b6d5beSMichael Tuexen 	uint32_t max_cwnd;
1213c9c58059SMichael Tuexen 	uint16_t port;		/* remote UDP encapsulation port */
1214f8829a4aSRandall Stewart 	/*
1215f8829a4aSRandall Stewart 	 * The mapping array is used to track out of order sequences above
1216f8829a4aSRandall Stewart 	 * last_acked_seq. 0 indicates packet missing 1 indicates packet
1217f8829a4aSRandall Stewart 	 * rec'd. We slide it up every time we raise last_acked_seq and 0
1218f8829a4aSRandall Stewart 	 * trailing locactions out.  If I get a TSN above the array
1219f8829a4aSRandall Stewart 	 * mappingArraySz, I discard the datagram and let retransmit happen.
1220f8829a4aSRandall Stewart 	 */
1221f42a358aSRandall Stewart 	uint32_t marked_retrans;
1222f42a358aSRandall Stewart 	uint32_t timoinit;
1223f42a358aSRandall Stewart 	uint32_t timodata;
1224f42a358aSRandall Stewart 	uint32_t timosack;
1225f42a358aSRandall Stewart 	uint32_t timoshutdown;
1226f42a358aSRandall Stewart 	uint32_t timoheartbeat;
1227f42a358aSRandall Stewart 	uint32_t timocookie;
1228f42a358aSRandall Stewart 	uint32_t timoshutdownack;
1229f42a358aSRandall Stewart 	struct timeval start_time;
1230f42a358aSRandall Stewart 	struct timeval discontinuity_time;
1231f0396ad1SMichael Tuexen 	uint64_t abandoned_unsent[SCTP_PR_SCTP_MAX + 1];
1232f0396ad1SMichael Tuexen 	uint64_t abandoned_sent[SCTP_PR_SCTP_MAX + 1];
1233f8829a4aSRandall Stewart };
1234f8829a4aSRandall Stewart 
1235f8829a4aSRandall Stewart #endif
1236