1163953Srrs/*-
2185694Srrs * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
3235828Stuexen * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
4235828Stuexen * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
5163953Srrs *
6163953Srrs * Redistribution and use in source and binary forms, with or without
7163953Srrs * modification, are permitted provided that the following conditions are met:
8163953Srrs *
9163953Srrs * a) Redistributions of source code must retain the above copyright notice,
10228653Stuexen *    this list of conditions and the following disclaimer.
11163953Srrs *
12163953Srrs * b) Redistributions in binary form must reproduce the above copyright
13163953Srrs *    notice, this list of conditions and the following disclaimer in
14228653Stuexen *    the documentation and/or other materials provided with the distribution.
15163953Srrs *
16163953Srrs * c) Neither the name of Cisco Systems, Inc. nor the names of its
17163953Srrs *    contributors may be used to endorse or promote products derived
18163953Srrs *    from this software without specific prior written permission.
19163953Srrs *
20163953Srrs * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21163953Srrs * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22163953Srrs * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23163953Srrs * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24163953Srrs * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25163953Srrs * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26163953Srrs * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27163953Srrs * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28163953Srrs * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29163953Srrs * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30163953Srrs * THE POSSIBILITY OF SUCH DAMAGE.
31163953Srrs */
32163953Srrs
33163953Srrs#include <sys/cdefs.h>
34163953Srrs__FBSDID("$FreeBSD$");
35163953Srrs
36235828Stuexen#ifndef _NETINET_SCTP_STRUCTS_H_
37235828Stuexen#define _NETINET_SCTP_STRUCTS_H_
38163953Srrs
39165647Srrs#include <netinet/sctp_os.h>
40163953Srrs#include <netinet/sctp_header.h>
41163953Srrs#include <netinet/sctp_auth.h>
42163953Srrs
43163953Srrsstruct sctp_timer {
44165647Srrs	sctp_os_timer_t timer;
45165647Srrs
46163953Srrs	int type;
47163953Srrs	/*
48163953Srrs	 * Depending on the timer type these will be setup and cast with the
49163953Srrs	 * appropriate entity.
50163953Srrs	 */
51163953Srrs	void *ep;
52163953Srrs	void *tcb;
53163953Srrs	void *net;
54197326Stuexen	void *vnet;
55163953Srrs
56163953Srrs	/* for sanity checking */
57163953Srrs	void *self;
58163953Srrs	uint32_t ticks;
59165220Srrs	uint32_t stopped_from;
60163953Srrs};
61163953Srrs
62163953Srrs
63165220Srrsstruct sctp_foo_stuff {
64165220Srrs	struct sctp_inpcb *inp;
65165220Srrs	uint32_t lineno;
66165220Srrs	uint32_t ticks;
67165220Srrs	int updown;
68165220Srrs};
69163953Srrs
70165220Srrs
71163953Srrs/*
72163953Srrs * This is the information we track on each interface that we know about from
73163953Srrs * the distant end.
74163953Srrs */
75163953SrrsTAILQ_HEAD(sctpnetlisthead, sctp_nets);
76163953Srrs
77163953Srrsstruct sctp_stream_reset_list {
78163953Srrs	TAILQ_ENTRY(sctp_stream_reset_list) next_resp;
79294140Stuexen	uint32_t seq;
80163953Srrs	uint32_t tsn;
81240198Stuexen	uint32_t number_entries;
82240198Stuexen	uint16_t list_of_streams[];
83163953Srrs};
84163953Srrs
85163953SrrsTAILQ_HEAD(sctp_resethead, sctp_stream_reset_list);
86163953Srrs
87163953Srrs/*
88163953Srrs * Users of the iterator need to malloc a iterator with a call to
89167598Srrs * sctp_initiate_iterator(inp_func, assoc_func, inp_func,  pcb_flags, pcb_features,
90163953Srrs *     asoc_state, void-ptr-arg, uint32-arg, end_func, inp);
91163953Srrs *
92163953Srrs * Use the following two defines if you don't care what pcb flags are on the EP
93163953Srrs * and/or you don't care what state the association is in.
94163953Srrs *
95163953Srrs * Note that if you specify an INP as the last argument then ONLY each
96163953Srrs * association of that single INP will be executed upon. Note that the pcb
97163953Srrs * flags STILL apply so if the inp you specify has different pcb_flags then
98163953Srrs * what you put in pcb_flags nothing will happen. use SCTP_PCB_ANY_FLAGS to
99163953Srrs * assure the inp you specify gets treated.
100163953Srrs */
101163953Srrs#define SCTP_PCB_ANY_FLAGS	0x00000000
102163953Srrs#define SCTP_PCB_ANY_FEATURES	0x00000000
103163953Srrs#define SCTP_ASOC_ANY_STATE	0x00000000
104163953Srrs
105163953Srrstypedef void (*asoc_func) (struct sctp_inpcb *, struct sctp_tcb *, void *ptr,
106163953Srrs         uint32_t val);
107167598Srrstypedef int (*inp_func) (struct sctp_inpcb *, void *ptr, uint32_t val);
108163953Srrstypedef void (*end_func) (void *ptr, uint32_t val);
109163953Srrs
110218211Srrs#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP)
111218211Srrs/* whats on the mcore control struct */
112218211Srrsstruct sctp_mcore_queue {
113218211Srrs	TAILQ_ENTRY(sctp_mcore_queue) next;
114218211Srrs	struct vnet *vn;
115218211Srrs	struct mbuf *m;
116218211Srrs	int off;
117218211Srrs	int v6;
118218211Srrs};
119218211Srrs
120218211SrrsTAILQ_HEAD(sctp_mcore_qhead, sctp_mcore_queue);
121218211Srrs
122218211Srrsstruct sctp_mcore_ctrl {
123218211Srrs	SCTP_PROCESS_STRUCT thread_proc;
124218211Srrs	struct sctp_mcore_qhead que;
125218211Srrs	struct mtx core_mtx;
126218211Srrs	struct mtx que_mtx;
127218211Srrs	int running;
128218211Srrs	int cpuid;
129218211Srrs};
130218211Srrs
131218211Srrs
132218211Srrs#endif
133218211Srrs
134218211Srrs
135163953Srrsstruct sctp_iterator {
136167598Srrs	TAILQ_ENTRY(sctp_iterator) sctp_nxt_itr;
137208160Srrs	struct vnet *vn;
138163953Srrs	struct sctp_timer tmr;
139163953Srrs	struct sctp_inpcb *inp;	/* current endpoint */
140163953Srrs	struct sctp_tcb *stcb;	/* current* assoc */
141208160Srrs	struct sctp_inpcb *next_inp;	/* special hook to skip to */
142163953Srrs	asoc_func function_assoc;	/* per assoc function */
143163953Srrs	inp_func function_inp;	/* per endpoint function */
144167598Srrs	inp_func function_inp_end;	/* end INP function */
145163953Srrs	end_func function_atend;/* iterator completion function */
146163953Srrs	void *pointer;		/* pointer for apply func to use */
147163953Srrs	uint32_t val;		/* value for apply func to use */
148163953Srrs	uint32_t pcb_flags;	/* endpoint flags being checked */
149163953Srrs	uint32_t pcb_features;	/* endpoint features being checked */
150163953Srrs	uint32_t asoc_state;	/* assoc state being checked */
151163953Srrs	uint32_t iterator_flags;
152163953Srrs	uint8_t no_chunk_output;
153167598Srrs	uint8_t done_current_ep;
154163953Srrs};
155163953Srrs
156163953Srrs/* iterator_flags values */
157163953Srrs#define SCTP_ITERATOR_DO_ALL_INP	0x00000001
158163953Srrs#define SCTP_ITERATOR_DO_SINGLE_INP	0x00000002
159163953Srrs
160208160Srrs
161167598SrrsTAILQ_HEAD(sctpiterators, sctp_iterator);
162163953Srrs
163163953Srrsstruct sctp_copy_all {
164163953Srrs	struct sctp_inpcb *inp;	/* ep */
165163953Srrs	struct mbuf *m;
166163953Srrs	struct sctp_sndrcvinfo sndrcv;
167163953Srrs	int sndlen;
168163953Srrs	int cnt_sent;
169163953Srrs	int cnt_failed;
170163953Srrs};
171163953Srrs
172167598Srrsstruct sctp_asconf_iterator {
173167598Srrs	struct sctpladdr list_of_work;
174167598Srrs	int cnt;
175167598Srrs};
176167598Srrs
177208160Srrsstruct iterator_control {
178208160Srrs	struct mtx ipi_iterator_wq_mtx;
179208160Srrs	struct mtx it_mtx;
180208160Srrs	SCTP_PROCESS_STRUCT thread_proc;
181208160Srrs	struct sctpiterators iteratorhead;
182208160Srrs	struct sctp_iterator *cur_it;
183208160Srrs	uint32_t iterator_running;
184208160Srrs	uint32_t iterator_flags;
185208160Srrs};
186208160Srrs
187225676Stuexen#define SCTP_ITERATOR_STOP_CUR_IT	0x00000004
188225676Stuexen#define SCTP_ITERATOR_STOP_CUR_INP	0x00000008
189208160Srrs
190169352Srrsstruct sctp_net_route {
191169352Srrs	sctp_rtentry_t *ro_rt;
192191117Skmacy	void *ro_lle;
193226222Stuexen	void *ro_ia;
194226222Stuexen	int ro_flags;
195169352Srrs	union sctp_sockstore _l_addr;	/* remote peer addr */
196169352Srrs	struct sctp_ifa *_s_addr;	/* our selected src addr */
197169352Srrs};
198169352Srrs
199171440Srrsstruct htcp {
200171440Srrs	uint16_t alpha;		/* Fixed point arith, << 7 */
201171440Srrs	uint8_t beta;		/* Fixed point arith, << 7 */
202171440Srrs	uint8_t modeswitch;	/* Delay modeswitch until we had at least one
203171440Srrs				 * congestion event */
204171440Srrs	uint32_t last_cong;	/* Time since last congestion event end */
205171440Srrs	uint32_t undo_last_cong;
206171440Srrs	uint16_t bytes_acked;
207171440Srrs	uint32_t bytecount;
208171440Srrs	uint32_t minRTT;
209171440Srrs	uint32_t maxRTT;
210171440Srrs
211171440Srrs	uint32_t undo_maxRTT;
212171440Srrs	uint32_t undo_old_maxB;
213171440Srrs
214171440Srrs	/* Bandwidth estimation */
215171440Srrs	uint32_t minB;
216171440Srrs	uint32_t maxB;
217171440Srrs	uint32_t old_maxB;
218171440Srrs	uint32_t Bi;
219171440Srrs	uint32_t lasttime;
220171440Srrs};
221171440Srrs
222219120Srrsstruct rtcc_cc {
223219120Srrs	struct timeval tls;	/* The time we started the sending  */
224219120Srrs	uint64_t lbw;		/* Our last estimated bw */
225219120Srrs	uint64_t lbw_rtt;	/* RTT at bw estimate */
226219120Srrs	uint64_t bw_bytes;	/* The total bytes since this sending began */
227219120Srrs	uint64_t bw_tot_time;	/* The total time since sending began */
228219120Srrs	uint64_t new_tot_time;	/* temp holding the new value */
229219397Srrs	uint64_t bw_bytes_at_last_rttc;	/* What bw_bytes was at last rtt calc */
230219397Srrs	uint32_t cwnd_at_bw_set;/* Cwnd at last bw saved - lbw */
231219397Srrs	uint32_t vol_reduce;	/* cnt of voluntary reductions */
232219397Srrs	uint16_t steady_step;	/* The number required to be in steady state */
233219397Srrs	uint16_t step_cnt;	/* The current number */
234219397Srrs	uint8_t ret_from_eq;	/* When all things are equal what do I return
235219397Srrs				 * 0/1 - 1 no cc advance */
236219397Srrs	uint8_t use_dccc_ecn;	/* Flag to enable DCCC ECN */
237219120Srrs	uint8_t tls_needs_set;	/* Flag to indicate we need to set tls 0 or 1
238219120Srrs				 * means set at send 2 not */
239219397Srrs	uint8_t last_step_state;/* Last state if steady state stepdown is on */
240219397Srrs	uint8_t rtt_set_this_sack;	/* Flag saying this sack had RTT calc
241219397Srrs					 * on it */
242219397Srrs	uint8_t last_inst_ind;	/* Last saved inst indication */
243219120Srrs};
244219120Srrs
245219120Srrs
246163953Srrsstruct sctp_nets {
247163953Srrs	TAILQ_ENTRY(sctp_nets) sctp_next;	/* next link */
248163953Srrs
249163953Srrs	/*
250163953Srrs	 * Things on the top half may be able to be split into a common
251163953Srrs	 * structure shared by all.
252163953Srrs	 */
253163953Srrs	struct sctp_timer pmtu_timer;
254224641Stuexen	struct sctp_timer hb_timer;
255163953Srrs
256163953Srrs	/*
257163953Srrs	 * The following two in combination equate to a route entry for v6
258163953Srrs	 * or v4.
259163953Srrs	 */
260169352Srrs	struct sctp_net_route ro;
261169352Srrs
262163953Srrs	/* mtu discovered so far */
263163953Srrs	uint32_t mtu;
264163953Srrs	uint32_t ssthresh;	/* not sure about this one for split */
265218072Srrs	uint32_t last_cwr_tsn;
266218072Srrs	uint32_t cwr_window_tsn;
267218072Srrs	uint32_t ecn_ce_pkt_cnt;
268218072Srrs	uint32_t lost_cnt;
269163953Srrs	/* smoothed average things for RTT and RTO itself */
270163953Srrs	int lastsa;
271163953Srrs	int lastsv;
272219013Stuexen	uint64_t rtt;		/* last measured rtt value in us */
273163953Srrs	unsigned int RTO;
274163953Srrs
275163953Srrs	/* This is used for SHUTDOWN/SHUTDOWN-ACK/SEND or INIT timers */
276163953Srrs	struct sctp_timer rxt_timer;
277163953Srrs
278163953Srrs	/* last time in seconds I sent to it */
279163953Srrs	struct timeval last_sent_time;
280219057Srrs	union cc_control_data {
281219057Srrs		struct htcp htcp_ca;	/* JRS - struct used in HTCP algorithm */
282219120Srrs		struct rtcc_cc rtcc;	/* rtcc module cc stuff  */
283219057Srrs	}               cc_mod;
284163953Srrs	int ref_count;
285163953Srrs
286163953Srrs	/* Congestion stats per destination */
287163953Srrs	/*
288163953Srrs	 * flight size variables and such, sorry Vern, I could not avoid
289163953Srrs	 * this if I wanted performance :>
290163953Srrs	 */
291163953Srrs	uint32_t flight_size;
292163953Srrs	uint32_t cwnd;		/* actual cwnd */
293163953Srrs	uint32_t prev_cwnd;	/* cwnd before any processing */
294218186Srrs	uint32_t ecn_prev_cwnd;	/* ECN prev cwnd at first ecn_echo seen in new
295218186Srrs				 * window */
296163953Srrs	uint32_t partial_bytes_acked;	/* in CA tracks when to incr a MTU */
297163953Srrs	/* tracking variables to avoid the aloc/free in sack processing */
298163953Srrs	unsigned int net_ack;
299163953Srrs	unsigned int net_ack2;
300163953Srrs
301163953Srrs	/*
302171440Srrs	 * JRS - 5/8/07 - Variable to track last time a destination was
303171440Srrs	 * active for CMT PF
304171440Srrs	 */
305171440Srrs	uint32_t last_active;
306171440Srrs
307171440Srrs	/*
308163953Srrs	 * CMT variables (iyengar@cis.udel.edu)
309163953Srrs	 */
310163953Srrs	uint32_t this_sack_highest_newack;	/* tracks highest TSN newly
311163953Srrs						 * acked for a given dest in
312163953Srrs						 * the current SACK. Used in
313163953Srrs						 * SFR and HTNA algos */
314163953Srrs	uint32_t pseudo_cumack;	/* CMT CUC algorithm. Maintains next expected
315163953Srrs				 * pseudo-cumack for this destination */
316163953Srrs	uint32_t rtx_pseudo_cumack;	/* CMT CUC algorithm. Maintains next
317163953Srrs					 * expected pseudo-cumack for this
318163953Srrs					 * destination */
319163953Srrs
320163953Srrs	/* CMT fast recovery variables */
321163953Srrs	uint32_t fast_recovery_tsn;
322163953Srrs	uint32_t heartbeat_random1;
323163953Srrs	uint32_t heartbeat_random2;
324225549Stuexen#ifdef INET6
325224870Stuexen	uint32_t flowlabel;
326225549Stuexen#endif
327224870Stuexen	uint8_t dscp;
328163953Srrs
329168124Srrs	struct timeval start_time;	/* time when this net was created */
330168124Srrs	uint32_t marked_retrans;/* number or DATA chunks marked for timer
331168124Srrs				 * based retransmissions */
332168124Srrs	uint32_t marked_fastretrans;
333224641Stuexen	uint32_t heart_beat_delay;	/* Heart Beat delay in ms */
334168124Srrs
335163953Srrs	/* if this guy is ok or not ... status */
336163953Srrs	uint16_t dest_state;
337224641Stuexen	/* number of timeouts to consider the destination unreachable */
338163953Srrs	uint16_t failure_threshold;
339224641Stuexen	/* number of timeouts to consider the destination potentially failed */
340224641Stuexen	uint16_t pf_threshold;
341224641Stuexen	/* error stats on the destination */
342163953Srrs	uint16_t error_count;
343179157Srrs	/* UDP port number in case of UDP tunneling */
344179157Srrs	uint16_t port;
345163953Srrs
346163953Srrs	uint8_t fast_retran_loss_recovery;
347163953Srrs	uint8_t will_exit_fast_recovery;
348163953Srrs	/* Flags that probably can be combined into dest_state */
349163953Srrs	uint8_t fast_retran_ip;	/* fast retransmit in progress */
350163953Srrs	uint8_t hb_responded;
351163953Srrs	uint8_t saw_newack;	/* CMT's SFR algorithm flag */
352163953Srrs	uint8_t src_addr_selected;	/* if we split we move */
353163953Srrs	uint8_t indx_of_eligible_next_to_use;
354163953Srrs	uint8_t addr_is_local;	/* its a local address (if known) could move
355163953Srrs				 * in split */
356163953Srrs
357163953Srrs	/*
358163953Srrs	 * CMT variables (iyengar@cis.udel.edu)
359163953Srrs	 */
360163953Srrs	uint8_t find_pseudo_cumack;	/* CMT CUC algorithm. Flag used to
361163953Srrs					 * find a new pseudocumack. This flag
362163953Srrs					 * is set after a new pseudo-cumack
363163953Srrs					 * has been received and indicates
364163953Srrs					 * that the sender should find the
365163953Srrs					 * next pseudo-cumack expected for
366163953Srrs					 * this destination */
367163953Srrs	uint8_t find_rtx_pseudo_cumack;	/* CMT CUCv2 algorithm. Flag used to
368163953Srrs					 * find a new rtx-pseudocumack. This
369163953Srrs					 * flag is set after a new
370163953Srrs					 * rtx-pseudo-cumack has been received
371163953Srrs					 * and indicates that the sender
372163953Srrs					 * should find the next
373163953Srrs					 * rtx-pseudo-cumack expected for this
374163953Srrs					 * destination */
375163953Srrs	uint8_t new_pseudo_cumack;	/* CMT CUC algorithm. Flag used to
376163953Srrs					 * indicate if a new pseudo-cumack or
377163953Srrs					 * rtx-pseudo-cumack has been received */
378168124Srrs	uint8_t window_probe;	/* Doing a window probe? */
379170642Srrs	uint8_t RTO_measured;	/* Have we done the first measure */
380163953Srrs	uint8_t last_hs_used;	/* index into the last HS table entry we used */
381218186Srrs	uint8_t lan_type;
382219397Srrs	uint8_t rto_needed;
383218335Stuexen	uint32_t flowid;
384281955Shiren	uint8_t flowtype;
385163953Srrs};
386163953Srrs
387163953Srrs
388163953Srrsstruct sctp_data_chunkrec {
389163953Srrs	uint32_t TSN_seq;	/* the TSN of this transmit */
390163953Srrs	uint16_t stream_seq;	/* the stream sequence number of this transmit */
391163953Srrs	uint16_t stream_number;	/* the stream number of this guy */
392163953Srrs	uint32_t payloadtype;
393163953Srrs	uint32_t context;	/* from send */
394218186Srrs	uint32_t cwnd_at_send;
395163953Srrs	/*
396163953Srrs	 * part of the Highest sacked algorithm to be able to stroke counts
397163953Srrs	 * on ones that are FR'd.
398163953Srrs	 */
399163953Srrs	uint32_t fast_retran_tsn;	/* sending_seq at the time of FR */
400163953Srrs	struct timeval timetodrop;	/* time we drop it from queue */
401163953Srrs	uint8_t doing_fast_retransmit;
402163953Srrs	uint8_t rcv_flags;	/* flags pulled from data chunk on inbound for
403165220Srrs				 * outbound holds sending flags for PR-SCTP. */
404163953Srrs	uint8_t state_flags;
405163953Srrs	uint8_t chunk_was_revoked;
406218186Srrs	uint8_t fwd_tsn_cnt;
407163953Srrs};
408163953Srrs
409163953SrrsTAILQ_HEAD(sctpchunk_listhead, sctp_tmit_chunk);
410163953Srrs
411163953Srrs/* The lower byte is used to enumerate PR_SCTP policies */
412163953Srrs#define CHUNK_FLAGS_PR_SCTP_TTL	        SCTP_PR_SCTP_TTL
413163953Srrs#define CHUNK_FLAGS_PR_SCTP_BUF	        SCTP_PR_SCTP_BUF
414163953Srrs#define CHUNK_FLAGS_PR_SCTP_RTX         SCTP_PR_SCTP_RTX
415163953Srrs
416231074Stuexen/* The upper byte is used as a bit mask */
417163953Srrs#define CHUNK_FLAGS_FRAGMENT_OK	        0x0100
418163953Srrs
419163953Srrsstruct chk_id {
420271750Stuexen	uint8_t id;
421271750Stuexen	uint8_t can_take_data;
422163953Srrs};
423163953Srrs
424163953Srrs
425163953Srrsstruct sctp_tmit_chunk {
426163953Srrs	union {
427163953Srrs		struct sctp_data_chunkrec data;
428163953Srrs		struct chk_id chunk_id;
429163953Srrs	}     rec;
430163953Srrs	struct sctp_association *asoc;	/* bp to asoc this belongs to */
431163953Srrs	struct timeval sent_rcv_time;	/* filled in if RTT being calculated */
432163953Srrs	struct mbuf *data;	/* pointer to mbuf chain of data */
433163953Srrs	struct mbuf *last_mbuf;	/* pointer to last mbuf in chain */
434163953Srrs	struct sctp_nets *whoTo;
435163953Srrs	          TAILQ_ENTRY(sctp_tmit_chunk) sctp_next;	/* next link */
436163953Srrs	int32_t sent;		/* the send status */
437163953Srrs	uint16_t snd_count;	/* number of times I sent */
438163953Srrs	uint16_t flags;		/* flags, such as FRAGMENT_OK */
439163953Srrs	uint16_t send_size;
440163953Srrs	uint16_t book_size;
441163953Srrs	uint16_t mbcnt;
442185694Srrs	uint16_t auth_keyid;
443185694Srrs	uint8_t holds_key_ref;	/* flag if auth keyid refcount is held */
444163953Srrs	uint8_t pad_inplace;
445163953Srrs	uint8_t do_rtt;
446163953Srrs	uint8_t book_size_scale;
447163953Srrs	uint8_t no_fr_allowed;
448163953Srrs	uint8_t copy_by_ref;
449168124Srrs	uint8_t window_probe;
450163953Srrs};
451163953Srrs
452163953Srrs/*
453163953Srrs * The first part of this structure MUST be the entire sinfo structure. Maybe
454163953Srrs * I should have made it a sub structure... we can circle back later and do
455163953Srrs * that if we want.
456163953Srrs */
457163953Srrsstruct sctp_queued_to_read {	/* sinfo structure Pluse more */
458163953Srrs	uint16_t sinfo_stream;	/* off the wire */
459163953Srrs	uint16_t sinfo_ssn;	/* off the wire */
460163953Srrs	uint16_t sinfo_flags;	/* SCTP_UNORDERED from wire use SCTP_EOF for
461163953Srrs				 * EOR */
462163953Srrs	uint32_t sinfo_ppid;	/* off the wire */
463163953Srrs	uint32_t sinfo_context;	/* pick this up from assoc def context? */
464163953Srrs	uint32_t sinfo_timetolive;	/* not used by kernel */
465163953Srrs	uint32_t sinfo_tsn;	/* Use this in reassembly as first TSN */
466163953Srrs	uint32_t sinfo_cumtsn;	/* Use this in reassembly as last TSN */
467163953Srrs	sctp_assoc_t sinfo_assoc_id;	/* our assoc id */
468163953Srrs	/* Non sinfo stuff */
469163953Srrs	uint32_t length;	/* length of data */
470163953Srrs	uint32_t held_length;	/* length held in sb */
471163953Srrs	struct sctp_nets *whoFrom;	/* where it came from */
472163953Srrs	struct mbuf *data;	/* front of the mbuf chain of data with
473163953Srrs				 * PKT_HDR */
474163953Srrs	struct mbuf *tail_mbuf;	/* used for multi-part data */
475169352Srrs	struct mbuf *aux_data;	/* used to hold/cache  control if o/s does not
476169352Srrs				 * take it from us */
477163953Srrs	struct sctp_tcb *stcb;	/* assoc, used for window update */
478163953Srrs	         TAILQ_ENTRY(sctp_queued_to_read) next;
479163953Srrs	uint16_t port_from;
480165647Srrs	uint16_t spec_flags;	/* Flags to hold the notification field */
481163953Srrs	uint8_t do_not_ref_stcb;
482163953Srrs	uint8_t end_added;
483164085Srrs	uint8_t pdapi_aborted;
484168943Srrs	uint8_t some_taken;
485163953Srrs};
486163953Srrs
487163953Srrs/* This data structure will be on the outbound
488163953Srrs * stream queues. Data will be pulled off from
489163953Srrs * the front of the mbuf data and chunk-ified
490163953Srrs * by the output routines. We will custom
491163953Srrs * fit every chunk we pull to the send/sent
492163953Srrs * queue to make up the next full packet
493163953Srrs * if we can. An entry cannot be removed
494163953Srrs * from the stream_out queue until
495163953Srrs * the msg_is_complete flag is set. This
496163953Srrs * means at times data/tail_mbuf MIGHT
497163953Srrs * be NULL.. If that occurs it happens
498163953Srrs * for one of two reasons. Either the user
499163953Srrs * is blocked on a send() call and has not
500163953Srrs * awoken to copy more data down... OR
501163953Srrs * the user is in the explict MSG_EOR mode
502163953Srrs * and wrote some data, but has not completed
503163953Srrs * sending.
504163953Srrs */
505163953Srrsstruct sctp_stream_queue_pending {
506163953Srrs	struct mbuf *data;
507163953Srrs	struct mbuf *tail_mbuf;
508163953Srrs	struct timeval ts;
509163953Srrs	struct sctp_nets *net;
510163953Srrs	          TAILQ_ENTRY(sctp_stream_queue_pending) next;
511218241Stuexen	          TAILQ_ENTRY(sctp_stream_queue_pending) ss_next;
512163953Srrs	uint32_t length;
513163953Srrs	uint32_t timetolive;
514163953Srrs	uint32_t ppid;
515163953Srrs	uint32_t context;
516163953Srrs	uint16_t sinfo_flags;
517163953Srrs	uint16_t stream;
518165220Srrs	uint16_t act_flags;
519185694Srrs	uint16_t auth_keyid;
520185694Srrs	uint8_t holds_key_ref;
521163953Srrs	uint8_t msg_is_complete;
522163953Srrs	uint8_t some_taken;
523168755Srrs	uint8_t sender_all_done;
524168859Srrs	uint8_t put_last_out;
525189836Srrs	uint8_t discard_rest;
526163953Srrs};
527163953Srrs
528163953Srrs/*
529163953Srrs * this struct contains info that is used to track inbound stream data and
530163953Srrs * help with ordering.
531163953Srrs */
532163953SrrsTAILQ_HEAD(sctpwheelunrel_listhead, sctp_stream_in);
533163953Srrsstruct sctp_stream_in {
534163953Srrs	struct sctp_readhead inqueue;
535163953Srrs	uint16_t stream_no;
536163953Srrs	uint16_t last_sequence_delivered;	/* used for re-order */
537168943Srrs	uint8_t delivery_started;
538163953Srrs};
539163953Srrs
540217760StuexenTAILQ_HEAD(sctpwheel_listhead, sctp_stream_out);
541217760StuexenTAILQ_HEAD(sctplist_listhead, sctp_stream_queue_pending);
542217760Stuexen
543217760Stuexen/* Round-robin schedulers */
544217760Stuexenstruct ss_rr {
545217760Stuexen	/* next link in wheel */
546217760Stuexen	TAILQ_ENTRY(sctp_stream_out) next_spoke;
547217760Stuexen};
548217760Stuexen
549217760Stuexen/* Priority scheduler */
550217760Stuexenstruct ss_prio {
551217760Stuexen	/* next link in wheel */
552217760Stuexen	TAILQ_ENTRY(sctp_stream_out) next_spoke;
553217760Stuexen	/* priority id */
554217760Stuexen	uint16_t priority;
555217760Stuexen};
556217760Stuexen
557217760Stuexen/* Fair Bandwidth scheduler */
558217760Stuexenstruct ss_fb {
559217760Stuexen	/* next link in wheel */
560217760Stuexen	TAILQ_ENTRY(sctp_stream_out) next_spoke;
561217760Stuexen	/* stores message size */
562217760Stuexen	int32_t rounds;
563217760Stuexen};
564217760Stuexen
565217760Stuexen/*
566217760Stuexen * This union holds all data necessary for
567217760Stuexen * different stream schedulers.
568217760Stuexen */
569217760Stuexenunion scheduling_data {
570217760Stuexen	struct sctpwheel_listhead out_wheel;
571217760Stuexen	struct sctplist_listhead out_list;
572217760Stuexen};
573217760Stuexen
574217760Stuexen/*
575217760Stuexen * This union holds all parameters per stream
576217760Stuexen * necessary for different stream schedulers.
577217760Stuexen */
578217760Stuexenunion scheduling_parameters {
579217760Stuexen	struct ss_rr rr;
580217760Stuexen	struct ss_prio prio;
581217760Stuexen	struct ss_fb fb;
582217760Stuexen};
583217760Stuexen
584294140Stuexen/* States for outgoing streams */
585294140Stuexen#define SCTP_STREAM_CLOSED           0x00
586294140Stuexen#define SCTP_STREAM_OPENING          0x01
587294140Stuexen#define SCTP_STREAM_OPEN             0x02
588294140Stuexen#define SCTP_STREAM_RESET_PENDING    0x03
589294140Stuexen#define SCTP_STREAM_RESET_IN_FLIGHT  0x04
590294140Stuexen
591294140Stuexen#define SCTP_MAX_STREAMS_AT_ONCE_RESET 200
592294140Stuexen
593163953Srrs/* This struct is used to track the traffic on outbound streams */
594163953Srrsstruct sctp_stream_out {
595163953Srrs	struct sctp_streamhead outqueue;
596217760Stuexen	union scheduling_parameters ss_params;
597294140Stuexen	uint32_t chunks_on_queues;	/* send queue and sent queue */
598270363Stuexen#if defined(SCTP_DETAILED_STR_STATS)
599270363Stuexen	uint32_t abandoned_unsent[SCTP_PR_SCTP_MAX + 1];
600270363Stuexen	uint32_t abandoned_sent[SCTP_PR_SCTP_MAX + 1];
601270363Stuexen#else
602270363Stuexen	/* Only the aggregation */
603270363Stuexen	uint32_t abandoned_unsent[1];
604270363Stuexen	uint32_t abandoned_sent[1];
605270363Stuexen#endif
606163953Srrs	uint16_t stream_no;
607242627Stuexen	uint16_t next_sequence_send;	/* next one I expect to send out */
608163953Srrs	uint8_t last_msg_incomplete;
609294140Stuexen	uint8_t state;
610163953Srrs};
611163953Srrs
612163953Srrs/* used to keep track of the addresses yet to try to add/delete */
613163953SrrsTAILQ_HEAD(sctp_asconf_addrhead, sctp_asconf_addr);
614163953Srrsstruct sctp_asconf_addr {
615163953Srrs	TAILQ_ENTRY(sctp_asconf_addr) next;
616163953Srrs	struct sctp_asconf_addr_param ap;
617167598Srrs	struct sctp_ifa *ifa;	/* save the ifa for add/del ip */
618163953Srrs	uint8_t sent;		/* has this been sent yet? */
619185694Srrs	uint8_t special_del;	/* not to be used in lookup */
620163953Srrs};
621163953Srrs
622163953Srrsstruct sctp_scoping {
623163953Srrs	uint8_t ipv4_addr_legal;
624163953Srrs	uint8_t ipv6_addr_legal;
625163953Srrs	uint8_t loopback_scope;
626163953Srrs	uint8_t ipv4_local_scope;
627163953Srrs	uint8_t local_scope;
628163953Srrs	uint8_t site_scope;
629163953Srrs};
630163953Srrs
631166675Srrs#define SCTP_TSN_LOG_SIZE 40
632166675Srrs
633166675Srrsstruct sctp_tsn_log {
634171477Srrs	void *stcb;
635166675Srrs	uint32_t tsn;
636166675Srrs	uint16_t strm;
637166675Srrs	uint16_t seq;
638168859Srrs	uint16_t sz;
639168859Srrs	uint16_t flgs;
640171477Srrs	uint16_t in_pos;
641171477Srrs	uint16_t in_out;
642166675Srrs};
643166675Srrs
644171440Srrs#define SCTP_FS_SPEC_LOG_SIZE 200
645171440Srrsstruct sctp_fs_spec_log {
646171440Srrs	uint32_t sent;
647171440Srrs	uint32_t total_flight;
648171440Srrs	uint32_t tsn;
649171440Srrs	uint16_t book;
650171440Srrs	uint8_t incr;
651171440Srrs	uint8_t decr;
652171440Srrs};
653170056Srrs
654170056Srrs/* This struct is here to cut out the compatiabilty
655170056Srrs * pad that bulks up both the inp and stcb. The non
656170056Srrs * pad portion MUST stay in complete sync with
657170056Srrs * sctp_sndrcvinfo... i.e. if sinfo_xxxx is added
658170056Srrs * this must be done here too.
659170056Srrs */
660170056Srrsstruct sctp_nonpad_sndrcvinfo {
661170056Srrs	uint16_t sinfo_stream;
662170056Srrs	uint16_t sinfo_ssn;
663170056Srrs	uint16_t sinfo_flags;
664170056Srrs	uint32_t sinfo_ppid;
665170056Srrs	uint32_t sinfo_context;
666170056Srrs	uint32_t sinfo_timetolive;
667170056Srrs	uint32_t sinfo_tsn;
668170056Srrs	uint32_t sinfo_cumtsn;
669170056Srrs	sctp_assoc_t sinfo_assoc_id;
670223132Stuexen	uint16_t sinfo_keynumber;
671223132Stuexen	uint16_t sinfo_keynumber_valid;
672170056Srrs};
673170056Srrs
674163953Srrs/*
675171440Srrs * JRS - Structure to hold function pointers to the functions responsible
676171440Srrs * for congestion control.
677171440Srrs */
678171440Srrs
679171440Srrsstruct sctp_cc_functions {
680171440Srrs	void (*sctp_set_initial_cc_param) (struct sctp_tcb *stcb, struct sctp_nets *net);
681171440Srrs	void (*sctp_cwnd_update_after_sack) (struct sctp_tcb *stcb,
682171440Srrs	         struct sctp_association *asoc,
683171440Srrs	         int accum_moved, int reneged_all, int will_exit);
684224641Stuexen	void (*sctp_cwnd_update_exit_pf) (struct sctp_tcb *stcb, struct sctp_nets *net);
685171440Srrs	void (*sctp_cwnd_update_after_fr) (struct sctp_tcb *stcb,
686171440Srrs	         struct sctp_association *asoc);
687171440Srrs	void (*sctp_cwnd_update_after_timeout) (struct sctp_tcb *stcb,
688171440Srrs	         struct sctp_nets *net);
689171440Srrs	void (*sctp_cwnd_update_after_ecn_echo) (struct sctp_tcb *stcb,
690218129Srrs	         struct sctp_nets *net, int in_window, int num_pkt_lost);
691171440Srrs	void (*sctp_cwnd_update_after_packet_dropped) (struct sctp_tcb *stcb,
692171440Srrs	         struct sctp_nets *net, struct sctp_pktdrop_chunk *cp,
693171440Srrs	         uint32_t * bottle_bw, uint32_t * on_queue);
694171440Srrs	void (*sctp_cwnd_update_after_output) (struct sctp_tcb *stcb,
695171440Srrs	         struct sctp_nets *net, int burst_limit);
696219057Srrs	void (*sctp_cwnd_update_packet_transmitted) (struct sctp_tcb *stcb,
697219057Srrs	         struct sctp_nets *net);
698219057Srrs	void (*sctp_cwnd_update_tsn_acknowledged) (struct sctp_nets *net,
699219057Srrs	         struct sctp_tmit_chunk *);
700219057Srrs	void (*sctp_cwnd_new_transmission_begins) (struct sctp_tcb *stcb,
701219057Srrs	         struct sctp_nets *net);
702219057Srrs	void (*sctp_cwnd_prepare_net_for_sack) (struct sctp_tcb *stcb,
703219057Srrs	         struct sctp_nets *net);
704219057Srrs	int (*sctp_cwnd_socket_option) (struct sctp_tcb *stcb, int set, struct sctp_cc_option *);
705219397Srrs	void (*sctp_rtt_calculated) (struct sctp_tcb *, struct sctp_nets *, struct timeval *);
706171440Srrs};
707171440Srrs
708217760Stuexen/*
709217760Stuexen * RS - Structure to hold function pointers to the functions responsible
710217760Stuexen * for stream scheduling.
711217760Stuexen */
712217760Stuexenstruct sctp_ss_functions {
713217760Stuexen	void (*sctp_ss_init) (struct sctp_tcb *stcb, struct sctp_association *asoc,
714217760Stuexen	         int holds_lock);
715217760Stuexen	void (*sctp_ss_clear) (struct sctp_tcb *stcb, struct sctp_association *asoc,
716217760Stuexen	         int clear_values, int holds_lock);
717218241Stuexen	void (*sctp_ss_init_stream) (struct sctp_stream_out *strq, struct sctp_stream_out *with_strq);
718217760Stuexen	void (*sctp_ss_add_to_stream) (struct sctp_tcb *stcb, struct sctp_association *asoc,
719217760Stuexen	         struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, int holds_lock);
720217760Stuexen	int (*sctp_ss_is_empty) (struct sctp_tcb *stcb, struct sctp_association *asoc);
721217760Stuexen	void (*sctp_ss_remove_from_stream) (struct sctp_tcb *stcb, struct sctp_association *asoc,
722217760Stuexen	         struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, int holds_lock);
723217760Stuexen	struct sctp_stream_out *(*sctp_ss_select_stream) (struct sctp_tcb *stcb,
724217760Stuexen	                    struct sctp_nets *net, struct sctp_association *asoc);
725217760Stuexen	void (*sctp_ss_scheduled) (struct sctp_tcb *stcb, struct sctp_nets *net,
726217760Stuexen	         struct sctp_association *asoc, struct sctp_stream_out *strq, int moved_how_much);
727217760Stuexen	void (*sctp_ss_packet_done) (struct sctp_tcb *stcb, struct sctp_nets *net,
728217760Stuexen	         struct sctp_association *asoc);
729217760Stuexen	int (*sctp_ss_get_value) (struct sctp_tcb *stcb, struct sctp_association *asoc,
730217760Stuexen	        struct sctp_stream_out *strq, uint16_t * value);
731217760Stuexen	int (*sctp_ss_set_value) (struct sctp_tcb *stcb, struct sctp_association *asoc,
732217760Stuexen	        struct sctp_stream_out *strq, uint16_t value);
733217760Stuexen};
734217760Stuexen
735179157Srrs/* used to save ASCONF chunks for retransmission */
736179157SrrsTAILQ_HEAD(sctp_asconf_head, sctp_asconf);
737179157Srrsstruct sctp_asconf {
738179157Srrs	TAILQ_ENTRY(sctp_asconf) next;
739179157Srrs	uint32_t serial_number;
740179157Srrs	uint16_t snd_count;
741179157Srrs	struct mbuf *data;
742179157Srrs	uint16_t len;
743179157Srrs};
744179157Srrs
745171990Srrs/* used to save ASCONF-ACK chunks for retransmission */
746171990SrrsTAILQ_HEAD(sctp_asconf_ackhead, sctp_asconf_ack);
747171990Srrsstruct sctp_asconf_ack {
748171990Srrs	TAILQ_ENTRY(sctp_asconf_ack) next;
749171990Srrs	uint32_t serial_number;
750171990Srrs	struct sctp_nets *last_sent_to;
751171990Srrs	struct mbuf *data;
752171990Srrs	uint16_t len;
753171990Srrs};
754171990Srrs
755171440Srrs/*
756163953Srrs * Here we have information about each individual association that we track.
757163953Srrs * We probably in production would be more dynamic. But for ease of
758163953Srrs * implementation we will have a fixed array that we hunt for in a linear
759163953Srrs * fashion.
760163953Srrs */
761163953Srrsstruct sctp_association {
762163953Srrs	/* association state */
763163953Srrs	int state;
764171572Srrs
765163953Srrs	/* queue of pending addrs to add/delete */
766163953Srrs	struct sctp_asconf_addrhead asconf_queue;
767171572Srrs
768163953Srrs	struct timeval time_entered;	/* time we entered state */
769163953Srrs	struct timeval time_last_rcvd;
770163953Srrs	struct timeval time_last_sent;
771163953Srrs	struct timeval time_last_sat_advance;
772170056Srrs	struct sctp_nonpad_sndrcvinfo def_send;
773163953Srrs
774163953Srrs	/* timers and such */
775163953Srrs	struct sctp_timer dack_timer;	/* Delayed ack timer */
776171572Srrs	struct sctp_timer asconf_timer;	/* asconf */
777163953Srrs	struct sctp_timer strreset_timer;	/* stream reset */
778171572Srrs	struct sctp_timer shut_guard_timer;	/* shutdown guard */
779163953Srrs	struct sctp_timer autoclose_timer;	/* automatic close timer */
780163953Srrs	struct sctp_timer delayed_event_timer;	/* timer for delayed events */
781172091Srrs	struct sctp_timer delete_prim_timer;	/* deleting primary dst */
782163953Srrs
783171572Srrs	/* list of restricted local addresses */
784167598Srrs	struct sctpladdr sctp_restricted_addrs;
785167598Srrs
786171572Srrs	/* last local address pending deletion (waiting for an address add) */
787171572Srrs	struct sctp_ifa *asconf_addr_del_pending;
788172091Srrs	/* Deleted primary destination (used to stop timer) */
789172091Srrs	struct sctp_nets *deleted_primary;
790163953Srrs
791171572Srrs	struct sctpnetlisthead nets;	/* remote address list */
792171572Srrs
793163953Srrs	/* Free chunk list */
794163953Srrs	struct sctpchunk_listhead free_chunks;
795163953Srrs
796163953Srrs	/* Control chunk queue */
797163953Srrs	struct sctpchunk_listhead control_send_queue;
798163953Srrs
799179157Srrs	/* ASCONF chunk queue */
800179157Srrs	struct sctpchunk_listhead asconf_send_queue;
801179157Srrs
802163953Srrs	/*
803163953Srrs	 * Once a TSN hits the wire it is moved to the sent_queue. We
804163953Srrs	 * maintain two counts here (don't know if any but retran_cnt is
805163953Srrs	 * needed). The idea is that the sent_queue_retran_cnt reflects how
806163953Srrs	 * many chunks have been marked for retranmission by either T3-rxt
807163953Srrs	 * or FR.
808163953Srrs	 */
809163953Srrs	struct sctpchunk_listhead sent_queue;
810163953Srrs	struct sctpchunk_listhead send_queue;
811163953Srrs
812163953Srrs	/* re-assembly queue for fragmented chunks on the inbound path */
813163953Srrs	struct sctpchunk_listhead reasmqueue;
814163953Srrs
815218241Stuexen	/* Scheduling queues */
816217760Stuexen	union scheduling_data ss_data;
817163953Srrs
818163953Srrs	/*
819163953Srrs	 * This pointer will be set to NULL most of the time. But when we
820163953Srrs	 * have a fragmented message, where we could not get out all of the
821163953Srrs	 * message at the last send then this will point to the stream to go
822163953Srrs	 * get data from.
823163953Srrs	 */
824163953Srrs	struct sctp_stream_out *locked_on_sending;
825163953Srrs
826163953Srrs	/* If an iterator is looking at me, this is it */
827163953Srrs	struct sctp_iterator *stcb_starting_point_for_iterator;
828163953Srrs
829163953Srrs	/* ASCONF save the last ASCONF-ACK so we can resend it if necessary */
830171990Srrs	struct sctp_asconf_ackhead asconf_ack_sent;
831163953Srrs
832163953Srrs	/*
833163953Srrs	 * pointer to last stream reset queued to control queue by us with
834163953Srrs	 * requests.
835163953Srrs	 */
836163953Srrs	struct sctp_tmit_chunk *str_reset;
837163953Srrs	/*
838163953Srrs	 * if Source Address Selection happening, this will rotate through
839163953Srrs	 * the link list.
840163953Srrs	 */
841163953Srrs	struct sctp_laddr *last_used_address;
842163953Srrs
843163953Srrs	/* stream arrays */
844163953Srrs	struct sctp_stream_in *strmin;
845163953Srrs	struct sctp_stream_out *strmout;
846163953Srrs	uint8_t *mapping_array;
847163953Srrs	/* primary destination to use */
848163953Srrs	struct sctp_nets *primary_destination;
849224641Stuexen	struct sctp_nets *alternate;	/* If primary is down or PF */
850163953Srrs	/* For CMT */
851190689Srrs	struct sctp_nets *last_net_cmt_send_started;
852163953Srrs	/* last place I got a data chunk from */
853163953Srrs	struct sctp_nets *last_data_chunk_from;
854163953Srrs	/* last place I got a control from */
855163953Srrs	struct sctp_nets *last_control_chunk_from;
856163953Srrs
857163953Srrs	/* circular looking for output selection */
858163953Srrs	struct sctp_stream_out *last_out_stream;
859163953Srrs
860163953Srrs	/*
861163953Srrs	 * wait to the point the cum-ack passes req->send_reset_at_tsn for
862163953Srrs	 * any req on the list.
863163953Srrs	 */
864163953Srrs	struct sctp_resethead resetHead;
865163953Srrs
866163953Srrs	/* queue of chunks waiting to be sent into the local stack */
867163953Srrs	struct sctp_readhead pending_reply_queue;
868163953Srrs
869171440Srrs	/* JRS - the congestion control functions are in this struct */
870171440Srrs	struct sctp_cc_functions cc_functions;
871171440Srrs	/*
872171440Srrs	 * JRS - value to store the currently loaded congestion control
873171440Srrs	 * module
874171440Srrs	 */
875171440Srrs	uint32_t congestion_control_module;
876217760Stuexen	/* RS - the stream scheduling functions are in this struct */
877217760Stuexen	struct sctp_ss_functions ss_functions;
878217760Stuexen	/* RS - value to store the currently loaded stream scheduling module */
879217760Stuexen	uint32_t stream_scheduling_module;
880171440Srrs
881167598Srrs	uint32_t vrf_id;
882167598Srrs
883163953Srrs	uint32_t cookie_preserve_req;
884163953Srrs	/* ASCONF next seq I am sending out, inits at init-tsn */
885163953Srrs	uint32_t asconf_seq_out;
886179157Srrs	uint32_t asconf_seq_out_acked;
887163953Srrs	/* ASCONF last received ASCONF from peer, starts at peer's TSN-1 */
888163953Srrs	uint32_t asconf_seq_in;
889163953Srrs
890163953Srrs	/* next seq I am sending in str reset messages */
891163953Srrs	uint32_t str_reset_seq_out;
892163953Srrs	/* next seq I am expecting in str reset messages */
893163953Srrs	uint32_t str_reset_seq_in;
894163953Srrs
895163953Srrs	/* various verification tag information */
896163953Srrs	uint32_t my_vtag;	/* The tag to be used. if assoc is re-initited
897163953Srrs				 * by remote end, and I have unlocked this
898163953Srrs				 * will be regenerated to a new random value. */
899163953Srrs	uint32_t peer_vtag;	/* The peers last tag */
900163953Srrs
901163953Srrs	uint32_t my_vtag_nonce;
902163953Srrs	uint32_t peer_vtag_nonce;
903163953Srrs
904163953Srrs	uint32_t assoc_id;
905163953Srrs
906163953Srrs	/* This is the SCTP fragmentation threshold */
907163953Srrs	uint32_t smallest_mtu;
908163953Srrs
909163953Srrs	/*
910163953Srrs	 * Special hook for Fast retransmit, allows us to track the highest
911163953Srrs	 * TSN that is NEW in this SACK if gap ack blocks are present.
912163953Srrs	 */
913163953Srrs	uint32_t this_sack_highest_gap;
914163953Srrs
915163953Srrs	/*
916163953Srrs	 * The highest consecutive TSN that has been acked by peer on my
917163953Srrs	 * sends
918163953Srrs	 */
919163953Srrs	uint32_t last_acked_seq;
920163953Srrs
921163953Srrs	/* The next TSN that I will use in sending. */
922163953Srrs	uint32_t sending_seq;
923163953Srrs
924163953Srrs	/* Original seq number I used ??questionable to keep?? */
925163953Srrs	uint32_t init_seq_number;
926163953Srrs
927163953Srrs
928163953Srrs	/* The Advanced Peer Ack Point, as required by the PR-SCTP */
929163953Srrs	/* (A1 in Section 4.2) */
930163953Srrs	uint32_t advanced_peer_ack_point;
931163953Srrs
932163953Srrs	/*
933163953Srrs	 * The highest consequetive TSN at the bottom of the mapping array
934163953Srrs	 * (for his sends).
935163953Srrs	 */
936163953Srrs	uint32_t cumulative_tsn;
937163953Srrs	/*
938163953Srrs	 * Used to track the mapping array and its offset bits. This MAY be
939163953Srrs	 * lower then cumulative_tsn.
940163953Srrs	 */
941163953Srrs	uint32_t mapping_array_base_tsn;
942163953Srrs	/*
943163953Srrs	 * used to track highest TSN we have received and is listed in the
944163953Srrs	 * mapping array.
945163953Srrs	 */
946163953Srrs	uint32_t highest_tsn_inside_map;
947163953Srrs
948185694Srrs	/* EY - new NR variables used for nr_sack based on mapping_array */
949185694Srrs	uint8_t *nr_mapping_array;
950185694Srrs	uint32_t highest_tsn_inside_nr_map;
951185694Srrs
952163953Srrs	uint32_t fast_recovery_tsn;
953163953Srrs	uint32_t sat_t3_recovery_tsn;
954163953Srrs	uint32_t tsn_last_delivered;
955163953Srrs	/*
956163953Srrs	 * For the pd-api we should re-write this a bit more efficent. We
957163953Srrs	 * could have multiple sctp_queued_to_read's that we are building at
958163953Srrs	 * once. Now we only do this when we get ready to deliver to the
959163953Srrs	 * socket buffer. Note that we depend on the fact that the struct is
960163953Srrs	 * "stuck" on the read queue until we finish all the pd-api.
961163953Srrs	 */
962163953Srrs	struct sctp_queued_to_read *control_pdapi;
963163953Srrs
964163953Srrs	uint32_t tsn_of_pdapi_last_delivered;
965163953Srrs	uint32_t pdapi_ppid;
966163953Srrs	uint32_t context;
967163953Srrs	uint32_t last_reset_action[SCTP_MAX_RESET_PARAMS];
968163953Srrs	uint32_t last_sending_seq[SCTP_MAX_RESET_PARAMS];
969163953Srrs	uint32_t last_base_tsnsent[SCTP_MAX_RESET_PARAMS];
970166675Srrs#ifdef SCTP_ASOCLOG_OF_TSNS
971163953Srrs	/*
972166675Srrs	 * special log  - This adds considerable size to the asoc, but
973166675Srrs	 * provides a log that you can use to detect problems via kgdb.
974166675Srrs	 */
975166675Srrs	struct sctp_tsn_log in_tsnlog[SCTP_TSN_LOG_SIZE];
976166675Srrs	struct sctp_tsn_log out_tsnlog[SCTP_TSN_LOG_SIZE];
977171477Srrs	uint32_t cumack_log[SCTP_TSN_LOG_SIZE];
978172703Srrs	uint32_t cumack_logsnt[SCTP_TSN_LOG_SIZE];
979166675Srrs	uint16_t tsn_in_at;
980166675Srrs	uint16_t tsn_out_at;
981168859Srrs	uint16_t tsn_in_wrapped;
982168859Srrs	uint16_t tsn_out_wrapped;
983171477Srrs	uint16_t cumack_log_at;
984172703Srrs	uint16_t cumack_log_atsnt;
985166675Srrs#endif				/* SCTP_ASOCLOG_OF_TSNS */
986171440Srrs#ifdef SCTP_FS_SPEC_LOG
987171440Srrs	struct sctp_fs_spec_log fslog[SCTP_FS_SPEC_LOG_SIZE];
988171440Srrs	uint16_t fs_index;
989171440Srrs#endif
990171440Srrs
991166675Srrs	/*
992163953Srrs	 * window state information and smallest MTU that I use to bound
993163953Srrs	 * segmentation
994163953Srrs	 */
995163953Srrs	uint32_t peers_rwnd;
996163953Srrs	uint32_t my_rwnd;
997163953Srrs	uint32_t my_last_reported_rwnd;
998170056Srrs	uint32_t sctp_frag_point;
999163953Srrs
1000163953Srrs	uint32_t total_output_queue_size;
1001163953Srrs
1002171943Srrs	uint32_t sb_cc;		/* shadow of sb_cc */
1003174257Srrs	uint32_t sb_send_resv;	/* amount reserved on a send */
1004171943Srrs	uint32_t my_rwnd_control_len;	/* shadow of sb_mbcnt used for rwnd
1005171943Srrs					 * control */
1006225549Stuexen#ifdef INET6
1007163953Srrs	uint32_t default_flowlabel;
1008225549Stuexen#endif
1009163953Srrs	uint32_t pr_sctp_cnt;
1010218129Srrs	int ctrl_queue_cnt;	/* could be removed  REM - NO IT CAN'T!! RRS */
1011163953Srrs	/*
1012163953Srrs	 * All outbound datagrams queue into this list from the individual
1013163953Srrs	 * stream queue. Here they get assigned a TSN and then await
1014163953Srrs	 * sending. The stream seq comes when it is first put in the
1015163953Srrs	 * individual str queue
1016163953Srrs	 */
1017163953Srrs	unsigned int stream_queue_cnt;
1018163953Srrs	unsigned int send_queue_cnt;
1019163953Srrs	unsigned int sent_queue_cnt;
1020163953Srrs	unsigned int sent_queue_cnt_removeable;
1021163953Srrs	/*
1022163953Srrs	 * Number on sent queue that are marked for retran until this value
1023163953Srrs	 * is 0 we only send one packet of retran'ed data.
1024163953Srrs	 */
1025163953Srrs	unsigned int sent_queue_retran_cnt;
1026163953Srrs
1027163953Srrs	unsigned int size_on_reasm_queue;
1028163953Srrs	unsigned int cnt_on_reasm_queue;
1029210599Srrs	unsigned int fwd_tsn_cnt;
1030163953Srrs	/* amount of data (bytes) currently in flight (on all destinations) */
1031163953Srrs	unsigned int total_flight;
1032163953Srrs	/* Total book size in flight */
1033163953Srrs	unsigned int total_flight_count;	/* count of chunks used with
1034163953Srrs						 * book total */
1035163953Srrs	/* count of destinaton nets and list of destination nets */
1036163953Srrs	unsigned int numnets;
1037163953Srrs
1038163953Srrs	/* Total error count on this association */
1039163953Srrs	unsigned int overall_error_count;
1040163953Srrs
1041163953Srrs	unsigned int cnt_msg_on_sb;
1042163953Srrs
1043163953Srrs	/* All stream count of chunks for delivery */
1044163953Srrs	unsigned int size_on_all_streams;
1045163953Srrs	unsigned int cnt_on_all_streams;
1046163953Srrs
1047224641Stuexen	/* Heart Beat delay in ms */
1048224641Stuexen	uint32_t heart_beat_delay;
1049163953Srrs
1050163953Srrs	/* autoclose */
1051163953Srrs	unsigned int sctp_autoclose_ticks;
1052163953Srrs
1053163953Srrs	/* how many preopen streams we have */
1054163953Srrs	unsigned int pre_open_streams;
1055163953Srrs
1056163953Srrs	/* How many streams I support coming into me */
1057163953Srrs	unsigned int max_inbound_streams;
1058163953Srrs
1059163953Srrs	/* the cookie life I award for any cookie, in seconds */
1060163953Srrs	unsigned int cookie_life;
1061163953Srrs	/* time to delay acks for */
1062163953Srrs	unsigned int delayed_ack;
1063167598Srrs	unsigned int old_delayed_ack;
1064167598Srrs	unsigned int sack_freq;
1065167598Srrs	unsigned int data_pkts_seen;
1066163953Srrs
1067163953Srrs	unsigned int numduptsns;
1068163953Srrs	int dup_tsns[SCTP_MAX_DUP_TSNS];
1069163953Srrs	unsigned int initial_init_rto_max;	/* initial RTO for INIT's */
1070163953Srrs	unsigned int initial_rto;	/* initial send RTO */
1071163953Srrs	unsigned int minrto;	/* per assoc RTO-MIN */
1072163953Srrs	unsigned int maxrto;	/* per assoc RTO-MAX */
1073163953Srrs
1074163953Srrs	/* authentication fields */
1075163953Srrs	sctp_auth_chklist_t *local_auth_chunks;
1076163953Srrs	sctp_auth_chklist_t *peer_auth_chunks;
1077163953Srrs	sctp_hmaclist_t *local_hmacs;	/* local HMACs supported */
1078163953Srrs	sctp_hmaclist_t *peer_hmacs;	/* peer HMACs supported */
1079163953Srrs	struct sctp_keyhead shared_keys;	/* assoc's shared keys */
1080163953Srrs	sctp_authinfo_t authinfo;	/* randoms, cached keys */
1081163953Srrs	/*
1082163953Srrs	 * refcnt to block freeing when a sender or receiver is off coping
1083163953Srrs	 * user data in.
1084163953Srrs	 */
1085163996Srrs	uint32_t refcnt;
1086163996Srrs	uint32_t chunks_on_out_queue;	/* total chunks floating around,
1087163996Srrs					 * locked by send socket buffer */
1088171990Srrs	uint32_t peers_adaptation;
1089163996Srrs	uint16_t peer_hmac_id;	/* peer HMAC id to send */
1090163996Srrs
1091163953Srrs	/*
1092163953Srrs	 * Being that we have no bag to collect stale cookies, and that we
1093163953Srrs	 * really would not want to anyway.. we will count them in this
1094163953Srrs	 * counter. We of course feed them to the pigeons right away (I have
1095163953Srrs	 * always thought of pigeons as flying rats).
1096163953Srrs	 */
1097163953Srrs	uint16_t stale_cookie_count;
1098163953Srrs
1099163953Srrs	/*
1100163953Srrs	 * For the partial delivery API, if up, invoked this is what last
1101163953Srrs	 * TSN I delivered
1102163953Srrs	 */
1103163953Srrs	uint16_t str_of_pdapi;
1104163953Srrs	uint16_t ssn_of_pdapi;
1105163953Srrs
1106163953Srrs	/* counts of actual built streams. Allocation may be more however */
1107163953Srrs	/* could re-arrange to optimize space here. */
1108163953Srrs	uint16_t streamincnt;
1109163953Srrs	uint16_t streamoutcnt;
1110188854Srrs	uint16_t strm_realoutsize;
1111233660Srrs	uint16_t strm_pending_add_size;
1112163953Srrs	/* my maximum number of retrans of INIT and SEND */
1113163953Srrs	/* copied from SCTP but should be individually setable */
1114163953Srrs	uint16_t max_init_times;
1115163953Srrs	uint16_t max_send_times;
1116163953Srrs
1117163953Srrs	uint16_t def_net_failure;
1118163953Srrs
1119224641Stuexen	uint16_t def_net_pf_threshold;
1120224641Stuexen
1121163953Srrs	/*
1122163953Srrs	 * lock flag: 0 is ok to send, 1+ (duals as a retran count) is
1123163953Srrs	 * awaiting ACK
1124163953Srrs	 */
1125163953Srrs	uint16_t mapping_array_size;
1126163953Srrs
1127163953Srrs	uint16_t last_strm_seq_delivered;
1128163953Srrs	uint16_t last_strm_no_delivered;
1129163953Srrs
1130163953Srrs	uint16_t last_revoke_count;
1131163953Srrs	int16_t num_send_timers_up;
1132163953Srrs
1133163953Srrs	uint16_t stream_locked_on;
1134163953Srrs	uint16_t ecn_echo_cnt_onq;
1135163953Srrs
1136163953Srrs	uint16_t free_chunk_cnt;
1137163953Srrs	uint8_t stream_locked;
1138163953Srrs	uint8_t authenticated;	/* packet authenticated ok */
1139163953Srrs	/*
1140167598Srrs	 * This flag indicates that a SACK need to be sent. Initially this
1141167598Srrs	 * is 1 to send the first sACK immediately.
1142163953Srrs	 */
1143167598Srrs	uint8_t send_sack;
1144163953Srrs
1145218186Srrs	/* max burst of new packets into the network */
1146217894Stuexen	uint32_t max_burst;
1147218186Srrs	/* max burst of fast retransmit packets */
1148218186Srrs	uint32_t fr_max_burst;
1149163953Srrs
1150163953Srrs	uint8_t sat_network;	/* RTT is in range of sat net or greater */
1151163953Srrs	uint8_t sat_network_lockout;	/* lockout code */
1152163953Srrs	uint8_t burst_limit_applied;	/* Burst limit in effect at last send? */
1153163953Srrs	/* flag goes on when we are doing a partial delivery api */
1154163953Srrs	uint8_t hb_random_values[4];
1155163953Srrs	uint8_t fragmented_delivery_inprogress;
1156163953Srrs	uint8_t fragment_flags;
1157163953Srrs	uint8_t last_flags_delivered;
1158163953Srrs	uint8_t hb_ect_randombit;
1159163953Srrs	uint8_t hb_random_idx;
1160224870Stuexen	uint8_t default_dscp;
1161171572Srrs	uint8_t asconf_del_pending;	/* asconf delete last addr pending */
1162294140Stuexen	uint8_t trigger_reset;
1163163953Srrs	/*
1164163953Srrs	 * This value, plus all other ack'd but above cum-ack is added
1165163953Srrs	 * together to cross check against the bit that we have yet to
1166163953Srrs	 * define (probably in the SACK). When the cum-ack is updated, this
1167163953Srrs	 * sum is updated as well.
1168163953Srrs	 */
1169218129Srrs
1170270357Stuexen	/* Flags whether an extension is supported or not */
1171270356Stuexen	uint8_t ecn_supported;
1172270357Stuexen	uint8_t prsctp_supported;
1173270362Stuexen	uint8_t auth_supported;
1174270362Stuexen	uint8_t asconf_supported;
1175270361Stuexen	uint8_t reconfig_supported;
1176270359Stuexen	uint8_t nrsack_supported;
1177270360Stuexen	uint8_t pktdrop_supported;
1178163953Srrs
1179233660Srrs	/* Did the peer make the stream config (add out) request */
1180233660Srrs	uint8_t peer_req_out;
1181233660Srrs
1182233660Srrs	uint8_t local_strreset_support;
1183163953Srrs
1184185694Srrs	uint8_t peer_supports_nat;
1185163953Srrs
1186246595Stuexen	struct sctp_scoping scope;
1187163953Srrs	/* flags to handle send alternate net tracking */
1188163953Srrs	uint8_t used_alt_asconfack;
1189163953Srrs	uint8_t fast_retran_loss_recovery;
1190163953Srrs	uint8_t sat_t3_loss_recovery;
1191163953Srrs	uint8_t dropped_special_cnt;
1192163953Srrs	uint8_t seen_a_sack_this_pkt;
1193163953Srrs	uint8_t stream_reset_outstanding;
1194163953Srrs	uint8_t stream_reset_out_is_outstanding;
1195163953Srrs	uint8_t delayed_connection;
1196163953Srrs	uint8_t ifp_had_enobuf;
1197163953Srrs	uint8_t saw_sack_with_frags;
1198216188Stuexen	uint8_t saw_sack_with_nr_frags;
1199185694Srrs	uint8_t in_asocid_hash;
1200163953Srrs	uint8_t assoc_up_sent;
1201171990Srrs	uint8_t adaptation_needed;
1202171990Srrs	uint8_t adaptation_sent;
1203163953Srrs	/* CMT variables */
1204163953Srrs	uint8_t cmt_dac_pkts_rcvd;
1205163953Srrs	uint8_t sctp_cmt_on_off;
1206163953Srrs	uint8_t iam_blocking;
1207166023Srrs	uint8_t cookie_how[8];
1208171440Srrs	/* JRS 5/21/07 - CMT PF variable */
1209171440Srrs	uint8_t sctp_cmt_pf;
1210219057Srrs	uint8_t use_precise_time;
1211254670Stuexen	uint64_t sctp_features;
1212283724Stuexen	uint32_t max_cwnd;
1213227755Stuexen	uint16_t port;		/* remote UDP encapsulation port */
1214163953Srrs	/*
1215163953Srrs	 * The mapping array is used to track out of order sequences above
1216163953Srrs	 * last_acked_seq. 0 indicates packet missing 1 indicates packet
1217163953Srrs	 * rec'd. We slide it up every time we raise last_acked_seq and 0
1218163953Srrs	 * trailing locactions out.  If I get a TSN above the array
1219163953Srrs	 * mappingArraySz, I discard the datagram and let retransmit happen.
1220163953Srrs	 */
1221166675Srrs	uint32_t marked_retrans;
1222166675Srrs	uint32_t timoinit;
1223166675Srrs	uint32_t timodata;
1224166675Srrs	uint32_t timosack;
1225166675Srrs	uint32_t timoshutdown;
1226166675Srrs	uint32_t timoheartbeat;
1227166675Srrs	uint32_t timocookie;
1228166675Srrs	uint32_t timoshutdownack;
1229166675Srrs	struct timeval start_time;
1230166675Srrs	struct timeval discontinuity_time;
1231270363Stuexen	uint64_t abandoned_unsent[SCTP_PR_SCTP_MAX + 1];
1232270363Stuexen	uint64_t abandoned_sent[SCTP_PR_SCTP_MAX + 1];
1233163953Srrs};
1234163953Srrs
1235163953Srrs#endif
1236