xref: /freebsd/sys/netinet/sctp_structs.h (revision 282a3889ebf826db9839be296ff1dd903f6d6d6e)
1 /*-
2  * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * a) Redistributions of source code must retain the above copyright notice,
8  *   this list of conditions and the following disclaimer.
9  *
10  * b) Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in
12  *   the documentation and/or other materials provided with the distribution.
13  *
14  * c) Neither the name of Cisco Systems, Inc. nor the names of its
15  *    contributors may be used to endorse or promote products derived
16  *    from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28  * THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 /* $KAME: sctp_structs.h,v 1.13 2005/03/06 16:04:18 itojun Exp $	 */
32 
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
35 
36 #ifndef __sctp_structs_h__
37 #define __sctp_structs_h__
38 
39 #include <netinet/sctp_os.h>
40 #include <netinet/sctp_header.h>
41 #include <netinet/sctp_auth.h>
42 
43 struct sctp_timer {
44 	sctp_os_timer_t timer;
45 
46 	int type;
47 	/*
48 	 * Depending on the timer type these will be setup and cast with the
49 	 * appropriate entity.
50 	 */
51 	void *ep;
52 	void *tcb;
53 	void *net;
54 
55 	/* for sanity checking */
56 	void *self;
57 	uint32_t ticks;
58 	uint32_t stopped_from;
59 };
60 
61 
62 struct sctp_foo_stuff {
63 	struct sctp_inpcb *inp;
64 	uint32_t lineno;
65 	uint32_t ticks;
66 	int updown;
67 };
68 
69 
70 /*
71  * This is the information we track on each interface that we know about from
72  * the distant end.
73  */
74 TAILQ_HEAD(sctpnetlisthead, sctp_nets);
75 
76 struct sctp_stream_reset_list {
77 	TAILQ_ENTRY(sctp_stream_reset_list) next_resp;
78 	uint32_t tsn;
79 	int number_entries;
80 	struct sctp_stream_reset_out_request req;
81 };
82 
83 TAILQ_HEAD(sctp_resethead, sctp_stream_reset_list);
84 
85 /*
86  * Users of the iterator need to malloc a iterator with a call to
87  * sctp_initiate_iterator(inp_func, assoc_func, inp_func,  pcb_flags, pcb_features,
88  *     asoc_state, void-ptr-arg, uint32-arg, end_func, inp);
89  *
90  * Use the following two defines if you don't care what pcb flags are on the EP
91  * and/or you don't care what state the association is in.
92  *
93  * Note that if you specify an INP as the last argument then ONLY each
94  * association of that single INP will be executed upon. Note that the pcb
95  * flags STILL apply so if the inp you specify has different pcb_flags then
96  * what you put in pcb_flags nothing will happen. use SCTP_PCB_ANY_FLAGS to
97  * assure the inp you specify gets treated.
98  */
99 #define SCTP_PCB_ANY_FLAGS	0x00000000
100 #define SCTP_PCB_ANY_FEATURES	0x00000000
101 #define SCTP_ASOC_ANY_STATE	0x00000000
102 
103 typedef void (*asoc_func) (struct sctp_inpcb *, struct sctp_tcb *, void *ptr,
104          uint32_t val);
105 typedef int (*inp_func) (struct sctp_inpcb *, void *ptr, uint32_t val);
106 typedef void (*end_func) (void *ptr, uint32_t val);
107 
108 struct sctp_iterator {
109 	TAILQ_ENTRY(sctp_iterator) sctp_nxt_itr;
110 	struct sctp_timer tmr;
111 	struct sctp_inpcb *inp;	/* current endpoint */
112 	struct sctp_tcb *stcb;	/* current* assoc */
113 	asoc_func function_assoc;	/* per assoc function */
114 	inp_func function_inp;	/* per endpoint function */
115 	inp_func function_inp_end;	/* end INP function */
116 	end_func function_atend;/* iterator completion function */
117 	void *pointer;		/* pointer for apply func to use */
118 	uint32_t val;		/* value for apply func to use */
119 	uint32_t pcb_flags;	/* endpoint flags being checked */
120 	uint32_t pcb_features;	/* endpoint features being checked */
121 	uint32_t asoc_state;	/* assoc state being checked */
122 	uint32_t iterator_flags;
123 	uint8_t no_chunk_output;
124 	uint8_t done_current_ep;
125 };
126 
127 /* iterator_flags values */
128 #define SCTP_ITERATOR_DO_ALL_INP	0x00000001
129 #define SCTP_ITERATOR_DO_SINGLE_INP	0x00000002
130 
131 TAILQ_HEAD(sctpiterators, sctp_iterator);
132 
133 struct sctp_copy_all {
134 	struct sctp_inpcb *inp;	/* ep */
135 	struct mbuf *m;
136 	struct sctp_sndrcvinfo sndrcv;
137 	int sndlen;
138 	int cnt_sent;
139 	int cnt_failed;
140 };
141 
142 struct sctp_asconf_iterator {
143 	struct sctpladdr list_of_work;
144 	int cnt;
145 };
146 
147 struct sctp_net_route {
148 	sctp_rtentry_t *ro_rt;
149 	union sctp_sockstore _l_addr;	/* remote peer addr */
150 	struct sctp_ifa *_s_addr;	/* our selected src addr */
151 };
152 
153 struct htcp {
154 	uint16_t alpha;		/* Fixed point arith, << 7 */
155 	uint8_t beta;		/* Fixed point arith, << 7 */
156 	uint8_t modeswitch;	/* Delay modeswitch until we had at least one
157 				 * congestion event */
158 	uint32_t last_cong;	/* Time since last congestion event end */
159 	uint32_t undo_last_cong;
160 	uint16_t bytes_acked;
161 	uint32_t bytecount;
162 	uint32_t minRTT;
163 	uint32_t maxRTT;
164 
165 	uint32_t undo_maxRTT;
166 	uint32_t undo_old_maxB;
167 
168 	/* Bandwidth estimation */
169 	uint32_t minB;
170 	uint32_t maxB;
171 	uint32_t old_maxB;
172 	uint32_t Bi;
173 	uint32_t lasttime;
174 };
175 
176 
177 struct sctp_nets {
178 	TAILQ_ENTRY(sctp_nets) sctp_next;	/* next link */
179 
180 	/*
181 	 * Things on the top half may be able to be split into a common
182 	 * structure shared by all.
183 	 */
184 	struct sctp_timer pmtu_timer;
185 
186 	/*
187 	 * The following two in combination equate to a route entry for v6
188 	 * or v4.
189 	 */
190 	struct sctp_net_route ro;
191 
192 	/* mtu discovered so far */
193 	uint32_t mtu;
194 	uint32_t ssthresh;	/* not sure about this one for split */
195 
196 	/* smoothed average things for RTT and RTO itself */
197 	int lastsa;
198 	int lastsv;
199 	unsigned int RTO;
200 
201 	/* This is used for SHUTDOWN/SHUTDOWN-ACK/SEND or INIT timers */
202 	struct sctp_timer rxt_timer;
203 	struct sctp_timer fr_timer;	/* for early fr */
204 
205 	/* last time in seconds I sent to it */
206 	struct timeval last_sent_time;
207 	int ref_count;
208 
209 	/* Congestion stats per destination */
210 	/*
211 	 * flight size variables and such, sorry Vern, I could not avoid
212 	 * this if I wanted performance :>
213 	 */
214 	uint32_t flight_size;
215 	uint32_t cwnd;		/* actual cwnd */
216 	uint32_t prev_cwnd;	/* cwnd before any processing */
217 	uint32_t partial_bytes_acked;	/* in CA tracks when to incr a MTU */
218 	uint32_t prev_rtt;
219 	/* tracking variables to avoid the aloc/free in sack processing */
220 	unsigned int net_ack;
221 	unsigned int net_ack2;
222 
223 	/*
224 	 * JRS - 5/8/07 - Variable to track last time a destination was
225 	 * active for CMT PF
226 	 */
227 	uint32_t last_active;
228 
229 	/*
230 	 * CMT variables (iyengar@cis.udel.edu)
231 	 */
232 	uint32_t this_sack_highest_newack;	/* tracks highest TSN newly
233 						 * acked for a given dest in
234 						 * the current SACK. Used in
235 						 * SFR and HTNA algos */
236 	uint32_t pseudo_cumack;	/* CMT CUC algorithm. Maintains next expected
237 				 * pseudo-cumack for this destination */
238 	uint32_t rtx_pseudo_cumack;	/* CMT CUC algorithm. Maintains next
239 					 * expected pseudo-cumack for this
240 					 * destination */
241 
242 	/* CMT fast recovery variables */
243 	uint32_t fast_recovery_tsn;
244 	uint32_t heartbeat_random1;
245 	uint32_t heartbeat_random2;
246 	uint32_t tos_flowlabel;
247 
248 	struct timeval start_time;	/* time when this net was created */
249 
250 	uint32_t marked_retrans;/* number or DATA chunks marked for timer
251 				 * based retransmissions */
252 	uint32_t marked_fastretrans;
253 
254 	/* if this guy is ok or not ... status */
255 	uint16_t dest_state;
256 	/* number of transmit failures to down this guy */
257 	uint16_t failure_threshold;
258 	/* error stats on destination */
259 	uint16_t error_count;
260 
261 	uint8_t fast_retran_loss_recovery;
262 	uint8_t will_exit_fast_recovery;
263 	/* Flags that probably can be combined into dest_state */
264 	uint8_t fast_retran_ip;	/* fast retransmit in progress */
265 	uint8_t hb_responded;
266 	uint8_t saw_newack;	/* CMT's SFR algorithm flag */
267 	uint8_t src_addr_selected;	/* if we split we move */
268 	uint8_t indx_of_eligible_next_to_use;
269 	uint8_t addr_is_local;	/* its a local address (if known) could move
270 				 * in split */
271 
272 	/*
273 	 * CMT variables (iyengar@cis.udel.edu)
274 	 */
275 	uint8_t find_pseudo_cumack;	/* CMT CUC algorithm. Flag used to
276 					 * find a new pseudocumack. This flag
277 					 * is set after a new pseudo-cumack
278 					 * has been received and indicates
279 					 * that the sender should find the
280 					 * next pseudo-cumack expected for
281 					 * this destination */
282 	uint8_t find_rtx_pseudo_cumack;	/* CMT CUCv2 algorithm. Flag used to
283 					 * find a new rtx-pseudocumack. This
284 					 * flag is set after a new
285 					 * rtx-pseudo-cumack has been received
286 					 * and indicates that the sender
287 					 * should find the next
288 					 * rtx-pseudo-cumack expected for this
289 					 * destination */
290 	uint8_t new_pseudo_cumack;	/* CMT CUC algorithm. Flag used to
291 					 * indicate if a new pseudo-cumack or
292 					 * rtx-pseudo-cumack has been received */
293 	uint8_t window_probe;	/* Doing a window probe? */
294 	uint8_t RTO_measured;	/* Have we done the first measure */
295 	uint8_t last_hs_used;	/* index into the last HS table entry we used */
296 	/* JRS - struct used in HTCP algorithm */
297 	struct htcp htcp_ca;
298 };
299 
300 
301 struct sctp_data_chunkrec {
302 	uint32_t TSN_seq;	/* the TSN of this transmit */
303 	uint16_t stream_seq;	/* the stream sequence number of this transmit */
304 	uint16_t stream_number;	/* the stream number of this guy */
305 	uint32_t payloadtype;
306 	uint32_t context;	/* from send */
307 
308 	/* ECN Nonce: Nonce Value for this chunk */
309 	uint8_t ect_nonce;
310 
311 	/*
312 	 * part of the Highest sacked algorithm to be able to stroke counts
313 	 * on ones that are FR'd.
314 	 */
315 	uint32_t fast_retran_tsn;	/* sending_seq at the time of FR */
316 	struct timeval timetodrop;	/* time we drop it from queue */
317 	uint8_t doing_fast_retransmit;
318 	uint8_t rcv_flags;	/* flags pulled from data chunk on inbound for
319 				 * outbound holds sending flags for PR-SCTP. */
320 	uint8_t state_flags;
321 	uint8_t chunk_was_revoked;
322 };
323 
324 TAILQ_HEAD(sctpchunk_listhead, sctp_tmit_chunk);
325 
326 /* The lower byte is used to enumerate PR_SCTP policies */
327 #define CHUNK_FLAGS_PR_SCTP_TTL	        SCTP_PR_SCTP_TTL
328 #define CHUNK_FLAGS_PR_SCTP_BUF	        SCTP_PR_SCTP_BUF
329 #define CHUNK_FLAGS_PR_SCTP_RTX         SCTP_PR_SCTP_RTX
330 
331 /* The upper byte is used a a bit mask */
332 #define CHUNK_FLAGS_FRAGMENT_OK	        0x0100
333 
334 struct chk_id {
335 	uint16_t id;
336 	uint16_t can_take_data;
337 };
338 
339 
340 struct sctp_tmit_chunk {
341 	union {
342 		struct sctp_data_chunkrec data;
343 		struct chk_id chunk_id;
344 	}     rec;
345 	struct sctp_association *asoc;	/* bp to asoc this belongs to */
346 	struct timeval sent_rcv_time;	/* filled in if RTT being calculated */
347 	struct mbuf *data;	/* pointer to mbuf chain of data */
348 	struct mbuf *last_mbuf;	/* pointer to last mbuf in chain */
349 	struct sctp_nets *whoTo;
350 	          TAILQ_ENTRY(sctp_tmit_chunk) sctp_next;	/* next link */
351 	int32_t sent;		/* the send status */
352 	uint16_t snd_count;	/* number of times I sent */
353 	uint16_t flags;		/* flags, such as FRAGMENT_OK */
354 	uint16_t send_size;
355 	uint16_t book_size;
356 	uint16_t mbcnt;
357 	uint8_t pad_inplace;
358 	uint8_t do_rtt;
359 	uint8_t book_size_scale;
360 	uint8_t addr_over;	/* flag which is set if the dest address for
361 				 * this chunk is overridden by user. Used for
362 				 * CMT (iyengar@cis.udel.edu, 2005/06/21) */
363 	uint8_t no_fr_allowed;
364 	uint8_t pr_sctp_on;
365 	uint8_t copy_by_ref;
366 	uint8_t window_probe;
367 };
368 
369 /*
370  * The first part of this structure MUST be the entire sinfo structure. Maybe
371  * I should have made it a sub structure... we can circle back later and do
372  * that if we want.
373  */
374 struct sctp_queued_to_read {	/* sinfo structure Pluse more */
375 	uint16_t sinfo_stream;	/* off the wire */
376 	uint16_t sinfo_ssn;	/* off the wire */
377 	uint16_t sinfo_flags;	/* SCTP_UNORDERED from wire use SCTP_EOF for
378 				 * EOR */
379 	uint32_t sinfo_ppid;	/* off the wire */
380 	uint32_t sinfo_context;	/* pick this up from assoc def context? */
381 	uint32_t sinfo_timetolive;	/* not used by kernel */
382 	uint32_t sinfo_tsn;	/* Use this in reassembly as first TSN */
383 	uint32_t sinfo_cumtsn;	/* Use this in reassembly as last TSN */
384 	sctp_assoc_t sinfo_assoc_id;	/* our assoc id */
385 	/* Non sinfo stuff */
386 	uint32_t length;	/* length of data */
387 	uint32_t held_length;	/* length held in sb */
388 	struct sctp_nets *whoFrom;	/* where it came from */
389 	struct mbuf *data;	/* front of the mbuf chain of data with
390 				 * PKT_HDR */
391 	struct mbuf *tail_mbuf;	/* used for multi-part data */
392 	struct mbuf *aux_data;	/* used to hold/cache  control if o/s does not
393 				 * take it from us */
394 	struct sctp_tcb *stcb;	/* assoc, used for window update */
395 	         TAILQ_ENTRY(sctp_queued_to_read) next;
396 	uint16_t port_from;
397 	uint16_t spec_flags;	/* Flags to hold the notification field */
398 	uint8_t do_not_ref_stcb;
399 	uint8_t end_added;
400 	uint8_t pdapi_aborted;
401 	uint8_t some_taken;
402 };
403 
404 /* This data structure will be on the outbound
405  * stream queues. Data will be pulled off from
406  * the front of the mbuf data and chunk-ified
407  * by the output routines. We will custom
408  * fit every chunk we pull to the send/sent
409  * queue to make up the next full packet
410  * if we can. An entry cannot be removed
411  * from the stream_out queue until
412  * the msg_is_complete flag is set. This
413  * means at times data/tail_mbuf MIGHT
414  * be NULL.. If that occurs it happens
415  * for one of two reasons. Either the user
416  * is blocked on a send() call and has not
417  * awoken to copy more data down... OR
418  * the user is in the explict MSG_EOR mode
419  * and wrote some data, but has not completed
420  * sending.
421  */
422 struct sctp_stream_queue_pending {
423 	struct mbuf *data;
424 	struct mbuf *tail_mbuf;
425 	struct timeval ts;
426 	struct sctp_nets *net;
427 	          TAILQ_ENTRY(sctp_stream_queue_pending) next;
428 	uint32_t length;
429 	uint32_t timetolive;
430 	uint32_t ppid;
431 	uint32_t context;
432 	uint16_t sinfo_flags;
433 	uint16_t stream;
434 	uint16_t strseq;
435 	uint16_t act_flags;
436 	uint8_t msg_is_complete;
437 	uint8_t some_taken;
438 	uint8_t addr_over;
439 	uint8_t pr_sctp_on;
440 	uint8_t sender_all_done;
441 	uint8_t put_last_out;
442 };
443 
444 /*
445  * this struct contains info that is used to track inbound stream data and
446  * help with ordering.
447  */
448 TAILQ_HEAD(sctpwheelunrel_listhead, sctp_stream_in);
449 struct sctp_stream_in {
450 	struct sctp_readhead inqueue;
451 	uint16_t stream_no;
452 	uint16_t last_sequence_delivered;	/* used for re-order */
453 	uint8_t delivery_started;
454 };
455 
456 /* This struct is used to track the traffic on outbound streams */
457 TAILQ_HEAD(sctpwheel_listhead, sctp_stream_out);
458 struct sctp_stream_out {
459 	struct sctp_streamhead outqueue;
460 	                TAILQ_ENTRY(sctp_stream_out) next_spoke;	/* next link in wheel */
461 	uint16_t stream_no;
462 	uint16_t next_sequence_sent;	/* next one I expect to send out */
463 	uint8_t last_msg_incomplete;
464 };
465 
466 /* used to keep track of the addresses yet to try to add/delete */
467 TAILQ_HEAD(sctp_asconf_addrhead, sctp_asconf_addr);
468 struct sctp_asconf_addr {
469 	TAILQ_ENTRY(sctp_asconf_addr) next;
470 	struct sctp_asconf_addr_param ap;
471 	struct sctp_ifa *ifa;	/* save the ifa for add/del ip */
472 	uint8_t sent;		/* has this been sent yet? */
473 };
474 
475 struct sctp_scoping {
476 	uint8_t ipv4_addr_legal;
477 	uint8_t ipv6_addr_legal;
478 	uint8_t loopback_scope;
479 	uint8_t ipv4_local_scope;
480 	uint8_t local_scope;
481 	uint8_t site_scope;
482 };
483 
484 #define SCTP_TSN_LOG_SIZE 40
485 
486 struct sctp_tsn_log {
487 	void *stcb;
488 	uint32_t tsn;
489 	uint16_t strm;
490 	uint16_t seq;
491 	uint16_t sz;
492 	uint16_t flgs;
493 	uint16_t in_pos;
494 	uint16_t in_out;
495 };
496 
497 #define SCTP_FS_SPEC_LOG_SIZE 200
498 struct sctp_fs_spec_log {
499 	uint32_t sent;
500 	uint32_t total_flight;
501 	uint32_t tsn;
502 	uint16_t book;
503 	uint8_t incr;
504 	uint8_t decr;
505 };
506 
507 /* This struct is here to cut out the compatiabilty
508  * pad that bulks up both the inp and stcb. The non
509  * pad portion MUST stay in complete sync with
510  * sctp_sndrcvinfo... i.e. if sinfo_xxxx is added
511  * this must be done here too.
512  */
513 struct sctp_nonpad_sndrcvinfo {
514 	uint16_t sinfo_stream;
515 	uint16_t sinfo_ssn;
516 	uint16_t sinfo_flags;
517 	uint32_t sinfo_ppid;
518 	uint32_t sinfo_context;
519 	uint32_t sinfo_timetolive;
520 	uint32_t sinfo_tsn;
521 	uint32_t sinfo_cumtsn;
522 	sctp_assoc_t sinfo_assoc_id;
523 };
524 
525 /*
526  * JRS - Structure to hold function pointers to the functions responsible
527  * for congestion control.
528  */
529 
530 struct sctp_cc_functions {
531 	void (*sctp_set_initial_cc_param) (struct sctp_tcb *stcb, struct sctp_nets *net);
532 	void (*sctp_cwnd_update_after_sack) (struct sctp_tcb *stcb,
533 	         struct sctp_association *asoc,
534 	         int accum_moved, int reneged_all, int will_exit);
535 	void (*sctp_cwnd_update_after_fr) (struct sctp_tcb *stcb,
536 	         struct sctp_association *asoc);
537 	void (*sctp_cwnd_update_after_timeout) (struct sctp_tcb *stcb,
538 	         struct sctp_nets *net);
539 	void (*sctp_cwnd_update_after_ecn_echo) (struct sctp_tcb *stcb,
540 	         struct sctp_nets *net);
541 	void (*sctp_cwnd_update_after_packet_dropped) (struct sctp_tcb *stcb,
542 	         struct sctp_nets *net, struct sctp_pktdrop_chunk *cp,
543 	         uint32_t * bottle_bw, uint32_t * on_queue);
544 	void (*sctp_cwnd_update_after_output) (struct sctp_tcb *stcb,
545 	         struct sctp_nets *net, int burst_limit);
546 	void (*sctp_cwnd_update_after_fr_timer) (struct sctp_inpcb *inp,
547 	         struct sctp_tcb *stcb, struct sctp_nets *net);
548 };
549 
550 /*
551  * Here we have information about each individual association that we track.
552  * We probably in production would be more dynamic. But for ease of
553  * implementation we will have a fixed array that we hunt for in a linear
554  * fashion.
555  */
556 struct sctp_association {
557 	/* association state */
558 	int state;
559 	/* queue of pending addrs to add/delete */
560 	struct sctp_asconf_addrhead asconf_queue;
561 	struct timeval time_entered;	/* time we entered state */
562 	struct timeval time_last_rcvd;
563 	struct timeval time_last_sent;
564 	struct timeval time_last_sat_advance;
565 	struct sctp_nonpad_sndrcvinfo def_send;
566 
567 	/* timers and such */
568 	struct sctp_timer hb_timer;	/* hb timer */
569 	struct sctp_timer dack_timer;	/* Delayed ack timer */
570 	struct sctp_timer asconf_timer;	/* Asconf */
571 	struct sctp_timer strreset_timer;	/* stream reset */
572 	struct sctp_timer shut_guard_timer;	/* guard */
573 	struct sctp_timer autoclose_timer;	/* automatic close timer */
574 	struct sctp_timer delayed_event_timer;	/* timer for delayed events */
575 
576 	/* list of local addresses when add/del in progress */
577 	struct sctpladdr sctp_restricted_addrs;
578 
579 	struct sctpnetlisthead nets;
580 
581 	/* Free chunk list */
582 	struct sctpchunk_listhead free_chunks;
583 
584 
585 	/* Control chunk queue */
586 	struct sctpchunk_listhead control_send_queue;
587 
588 	/*
589 	 * Once a TSN hits the wire it is moved to the sent_queue. We
590 	 * maintain two counts here (don't know if any but retran_cnt is
591 	 * needed). The idea is that the sent_queue_retran_cnt reflects how
592 	 * many chunks have been marked for retranmission by either T3-rxt
593 	 * or FR.
594 	 */
595 	struct sctpchunk_listhead sent_queue;
596 	struct sctpchunk_listhead send_queue;
597 
598 
599 	/* re-assembly queue for fragmented chunks on the inbound path */
600 	struct sctpchunk_listhead reasmqueue;
601 
602 	/*
603 	 * this queue is used when we reach a condition that we can NOT put
604 	 * data into the socket buffer. We track the size of this queue and
605 	 * set our rwnd to the space in the socket minus also the
606 	 * size_on_delivery_queue.
607 	 */
608 	struct sctpwheel_listhead out_wheel;
609 
610 	/*
611 	 * This pointer will be set to NULL most of the time. But when we
612 	 * have a fragmented message, where we could not get out all of the
613 	 * message at the last send then this will point to the stream to go
614 	 * get data from.
615 	 */
616 	struct sctp_stream_out *locked_on_sending;
617 
618 	/* If an iterator is looking at me, this is it */
619 	struct sctp_iterator *stcb_starting_point_for_iterator;
620 
621 	/* ASCONF destination address last sent to */
622 /*	struct sctp_nets *asconf_last_sent_to;*/
623 /* Peter, greppign for the above shows only on strange set
624  * I don't think we need it so I have commented it out.
625  */
626 
627 	/* ASCONF save the last ASCONF-ACK so we can resend it if necessary */
628 	struct mbuf *last_asconf_ack_sent;
629 
630 	/*
631 	 * pointer to last stream reset queued to control queue by us with
632 	 * requests.
633 	 */
634 	struct sctp_tmit_chunk *str_reset;
635 	/*
636 	 * if Source Address Selection happening, this will rotate through
637 	 * the link list.
638 	 */
639 	struct sctp_laddr *last_used_address;
640 
641 	/* stream arrays */
642 	struct sctp_stream_in *strmin;
643 	struct sctp_stream_out *strmout;
644 	uint8_t *mapping_array;
645 	/* primary destination to use */
646 	struct sctp_nets *primary_destination;
647 	/* For CMT */
648 	struct sctp_nets *last_net_data_came_from;
649 	/* last place I got a data chunk from */
650 	struct sctp_nets *last_data_chunk_from;
651 	/* last place I got a control from */
652 	struct sctp_nets *last_control_chunk_from;
653 
654 	/* circular looking for output selection */
655 	struct sctp_stream_out *last_out_stream;
656 
657 	/*
658 	 * wait to the point the cum-ack passes req->send_reset_at_tsn for
659 	 * any req on the list.
660 	 */
661 	struct sctp_resethead resetHead;
662 
663 	/* queue of chunks waiting to be sent into the local stack */
664 	struct sctp_readhead pending_reply_queue;
665 
666 	/* JRS - the congestion control functions are in this struct */
667 	struct sctp_cc_functions cc_functions;
668 	/*
669 	 * JRS - value to store the currently loaded congestion control
670 	 * module
671 	 */
672 	uint32_t congestion_control_module;
673 
674 	uint32_t vrf_id;
675 
676 	uint32_t cookie_preserve_req;
677 	/* ASCONF next seq I am sending out, inits at init-tsn */
678 	uint32_t asconf_seq_out;
679 	/* ASCONF last received ASCONF from peer, starts at peer's TSN-1 */
680 	uint32_t asconf_seq_in;
681 
682 	/* next seq I am sending in str reset messages */
683 	uint32_t str_reset_seq_out;
684 	/* next seq I am expecting in str reset messages */
685 	uint32_t str_reset_seq_in;
686 
687 	/* various verification tag information */
688 	uint32_t my_vtag;	/* The tag to be used. if assoc is re-initited
689 				 * by remote end, and I have unlocked this
690 				 * will be regenerated to a new random value. */
691 	uint32_t peer_vtag;	/* The peers last tag */
692 
693 	uint32_t my_vtag_nonce;
694 	uint32_t peer_vtag_nonce;
695 
696 	uint32_t assoc_id;
697 
698 	/* This is the SCTP fragmentation threshold */
699 	uint32_t smallest_mtu;
700 
701 	/*
702 	 * Special hook for Fast retransmit, allows us to track the highest
703 	 * TSN that is NEW in this SACK if gap ack blocks are present.
704 	 */
705 	uint32_t this_sack_highest_gap;
706 
707 	/*
708 	 * The highest consecutive TSN that has been acked by peer on my
709 	 * sends
710 	 */
711 	uint32_t last_acked_seq;
712 
713 	/* The next TSN that I will use in sending. */
714 	uint32_t sending_seq;
715 
716 	/* Original seq number I used ??questionable to keep?? */
717 	uint32_t init_seq_number;
718 
719 
720 	/* The Advanced Peer Ack Point, as required by the PR-SCTP */
721 	/* (A1 in Section 4.2) */
722 	uint32_t advanced_peer_ack_point;
723 
724 	/*
725 	 * The highest consequetive TSN at the bottom of the mapping array
726 	 * (for his sends).
727 	 */
728 	uint32_t cumulative_tsn;
729 	/*
730 	 * Used to track the mapping array and its offset bits. This MAY be
731 	 * lower then cumulative_tsn.
732 	 */
733 	uint32_t mapping_array_base_tsn;
734 	/*
735 	 * used to track highest TSN we have received and is listed in the
736 	 * mapping array.
737 	 */
738 	uint32_t highest_tsn_inside_map;
739 
740 	uint32_t last_echo_tsn;
741 	uint32_t last_cwr_tsn;
742 	uint32_t fast_recovery_tsn;
743 	uint32_t sat_t3_recovery_tsn;
744 	uint32_t tsn_last_delivered;
745 	/*
746 	 * For the pd-api we should re-write this a bit more efficent. We
747 	 * could have multiple sctp_queued_to_read's that we are building at
748 	 * once. Now we only do this when we get ready to deliver to the
749 	 * socket buffer. Note that we depend on the fact that the struct is
750 	 * "stuck" on the read queue until we finish all the pd-api.
751 	 */
752 	struct sctp_queued_to_read *control_pdapi;
753 
754 	uint32_t tsn_of_pdapi_last_delivered;
755 	uint32_t pdapi_ppid;
756 	uint32_t context;
757 	uint32_t last_reset_action[SCTP_MAX_RESET_PARAMS];
758 	uint32_t last_sending_seq[SCTP_MAX_RESET_PARAMS];
759 	uint32_t last_base_tsnsent[SCTP_MAX_RESET_PARAMS];
760 #ifdef SCTP_ASOCLOG_OF_TSNS
761 	/*
762 	 * special log  - This adds considerable size to the asoc, but
763 	 * provides a log that you can use to detect problems via kgdb.
764 	 */
765 	struct sctp_tsn_log in_tsnlog[SCTP_TSN_LOG_SIZE];
766 	struct sctp_tsn_log out_tsnlog[SCTP_TSN_LOG_SIZE];
767 	uint32_t cumack_log[SCTP_TSN_LOG_SIZE];
768 	uint16_t tsn_in_at;
769 	uint16_t tsn_out_at;
770 	uint16_t tsn_in_wrapped;
771 	uint16_t tsn_out_wrapped;
772 	uint16_t cumack_log_at;
773 
774 #endif				/* SCTP_ASOCLOG_OF_TSNS */
775 #ifdef SCTP_FS_SPEC_LOG
776 	struct sctp_fs_spec_log fslog[SCTP_FS_SPEC_LOG_SIZE];
777 	uint16_t fs_index;
778 #endif
779 
780 	/*
781 	 * window state information and smallest MTU that I use to bound
782 	 * segmentation
783 	 */
784 	uint32_t peers_rwnd;
785 	uint32_t my_rwnd;
786 	uint32_t my_last_reported_rwnd;
787 	uint32_t my_rwnd_control_len;
788 	uint32_t sctp_frag_point;
789 
790 	uint32_t total_output_queue_size;
791 
792 	uint32_t sb_cc;		/* shadow of sb_cc in one-2-one */
793 	uint32_t sb_mbcnt;	/* shadow of sb_mbcnt in one-2-one */
794 	/* 32 bit nonce stuff */
795 	uint32_t nonce_resync_tsn;
796 	uint32_t nonce_wait_tsn;
797 	uint32_t default_flowlabel;
798 	uint32_t pr_sctp_cnt;
799 	int ctrl_queue_cnt;	/* could be removed  REM */
800 	/*
801 	 * All outbound datagrams queue into this list from the individual
802 	 * stream queue. Here they get assigned a TSN and then await
803 	 * sending. The stream seq comes when it is first put in the
804 	 * individual str queue
805 	 */
806 	unsigned int stream_queue_cnt;
807 	unsigned int send_queue_cnt;
808 	unsigned int sent_queue_cnt;
809 	unsigned int sent_queue_cnt_removeable;
810 	/*
811 	 * Number on sent queue that are marked for retran until this value
812 	 * is 0 we only send one packet of retran'ed data.
813 	 */
814 	unsigned int sent_queue_retran_cnt;
815 
816 	unsigned int size_on_reasm_queue;
817 	unsigned int cnt_on_reasm_queue;
818 	/* amount of data (bytes) currently in flight (on all destinations) */
819 	unsigned int total_flight;
820 	/* Total book size in flight */
821 	unsigned int total_flight_count;	/* count of chunks used with
822 						 * book total */
823 	/* count of destinaton nets and list of destination nets */
824 	unsigned int numnets;
825 
826 	/* Total error count on this association */
827 	unsigned int overall_error_count;
828 
829 	unsigned int cnt_msg_on_sb;
830 
831 	/* All stream count of chunks for delivery */
832 	unsigned int size_on_all_streams;
833 	unsigned int cnt_on_all_streams;
834 
835 	/* Heart Beat delay in ticks */
836 	unsigned int heart_beat_delay;
837 
838 	/* autoclose */
839 	unsigned int sctp_autoclose_ticks;
840 
841 	/* how many preopen streams we have */
842 	unsigned int pre_open_streams;
843 
844 	/* How many streams I support coming into me */
845 	unsigned int max_inbound_streams;
846 
847 	/* the cookie life I award for any cookie, in seconds */
848 	unsigned int cookie_life;
849 	/* time to delay acks for */
850 	unsigned int delayed_ack;
851 	unsigned int old_delayed_ack;
852 	unsigned int sack_freq;
853 	unsigned int data_pkts_seen;
854 
855 	unsigned int numduptsns;
856 	int dup_tsns[SCTP_MAX_DUP_TSNS];
857 	unsigned int initial_init_rto_max;	/* initial RTO for INIT's */
858 	unsigned int initial_rto;	/* initial send RTO */
859 	unsigned int minrto;	/* per assoc RTO-MIN */
860 	unsigned int maxrto;	/* per assoc RTO-MAX */
861 
862 	/* authentication fields */
863 	sctp_auth_chklist_t *local_auth_chunks;
864 	sctp_auth_chklist_t *peer_auth_chunks;
865 	sctp_hmaclist_t *local_hmacs;	/* local HMACs supported */
866 	sctp_hmaclist_t *peer_hmacs;	/* peer HMACs supported */
867 	struct sctp_keyhead shared_keys;	/* assoc's shared keys */
868 	sctp_authinfo_t authinfo;	/* randoms, cached keys */
869 	/*
870 	 * refcnt to block freeing when a sender or receiver is off coping
871 	 * user data in.
872 	 */
873 	uint32_t refcnt;
874 	uint32_t chunks_on_out_queue;	/* total chunks floating around,
875 					 * locked by send socket buffer */
876 
877 	uint16_t peer_hmac_id;	/* peer HMAC id to send */
878 
879 	/*
880 	 * Being that we have no bag to collect stale cookies, and that we
881 	 * really would not want to anyway.. we will count them in this
882 	 * counter. We of course feed them to the pigeons right away (I have
883 	 * always thought of pigeons as flying rats).
884 	 */
885 	uint16_t stale_cookie_count;
886 
887 	/*
888 	 * For the partial delivery API, if up, invoked this is what last
889 	 * TSN I delivered
890 	 */
891 	uint16_t str_of_pdapi;
892 	uint16_t ssn_of_pdapi;
893 
894 	/* counts of actual built streams. Allocation may be more however */
895 	/* could re-arrange to optimize space here. */
896 	uint16_t streamincnt;
897 	uint16_t streamoutcnt;
898 
899 	/* my maximum number of retrans of INIT and SEND */
900 	/* copied from SCTP but should be individually setable */
901 	uint16_t max_init_times;
902 	uint16_t max_send_times;
903 
904 	uint16_t def_net_failure;
905 
906 	/*
907 	 * lock flag: 0 is ok to send, 1+ (duals as a retran count) is
908 	 * awaiting ACK
909 	 */
910 	uint16_t asconf_sent;	/* possibly removable REM */
911 	uint16_t mapping_array_size;
912 
913 	uint16_t last_strm_seq_delivered;
914 	uint16_t last_strm_no_delivered;
915 
916 	uint16_t last_revoke_count;
917 	int16_t num_send_timers_up;
918 
919 	uint16_t stream_locked_on;
920 	uint16_t ecn_echo_cnt_onq;
921 
922 	uint16_t free_chunk_cnt;
923 
924 	uint8_t stream_locked;
925 	uint8_t authenticated;	/* packet authenticated ok */
926 	/*
927 	 * This flag indicates that a SACK need to be sent. Initially this
928 	 * is 1 to send the first sACK immediately.
929 	 */
930 	uint8_t send_sack;
931 
932 	/* max burst after fast retransmit completes */
933 	uint8_t max_burst;
934 
935 	uint8_t sat_network;	/* RTT is in range of sat net or greater */
936 	uint8_t sat_network_lockout;	/* lockout code */
937 	uint8_t burst_limit_applied;	/* Burst limit in effect at last send? */
938 	/* flag goes on when we are doing a partial delivery api */
939 	uint8_t hb_random_values[4];
940 	uint8_t fragmented_delivery_inprogress;
941 	uint8_t fragment_flags;
942 	uint8_t last_flags_delivered;
943 	uint8_t hb_ect_randombit;
944 	uint8_t hb_random_idx;
945 	uint8_t hb_is_disabled;	/* is the hb disabled? */
946 	uint8_t default_tos;
947 
948 	/* ECN Nonce stuff */
949 	uint8_t receiver_nonce_sum;	/* nonce I sum and put in my sack */
950 	uint8_t ecn_nonce_allowed;	/* Tells us if ECN nonce is on */
951 	uint8_t nonce_sum_check;/* On off switch used during re-sync */
952 	uint8_t nonce_wait_for_ecne;	/* flag when we expect a ECN */
953 	uint8_t peer_supports_ecn_nonce;
954 
955 	/*
956 	 * This value, plus all other ack'd but above cum-ack is added
957 	 * together to cross check against the bit that we have yet to
958 	 * define (probably in the SACK). When the cum-ack is updated, this
959 	 * sum is updated as well.
960 	 */
961 	uint8_t nonce_sum_expect_base;
962 	/* Flag to tell if ECN is allowed */
963 	uint8_t ecn_allowed;
964 
965 	/* flag to indicate if peer can do asconf */
966 	uint8_t peer_supports_asconf;
967 	/* pr-sctp support flag */
968 	uint8_t peer_supports_prsctp;
969 	/* peer authentication support flag */
970 	uint8_t peer_supports_auth;
971 	/* stream resets are supported by the peer */
972 	uint8_t peer_supports_strreset;
973 
974 	/*
975 	 * packet drop's are supported by the peer, we don't really care
976 	 * about this but we bookkeep it anyway.
977 	 */
978 	uint8_t peer_supports_pktdrop;
979 
980 	/* Do we allow V6/V4? */
981 	uint8_t ipv4_addr_legal;
982 	uint8_t ipv6_addr_legal;
983 	/* Address scoping flags */
984 	/* scope value for IPv4 */
985 	uint8_t ipv4_local_scope;
986 	/* scope values for IPv6 */
987 	uint8_t local_scope;
988 	uint8_t site_scope;
989 	/* loopback scope */
990 	uint8_t loopback_scope;
991 	/* flags to handle send alternate net tracking */
992 	uint8_t used_alt_onsack;
993 	uint8_t used_alt_asconfack;
994 	uint8_t fast_retran_loss_recovery;
995 	uint8_t sat_t3_loss_recovery;
996 	uint8_t dropped_special_cnt;
997 	uint8_t seen_a_sack_this_pkt;
998 	uint8_t stream_reset_outstanding;
999 	uint8_t stream_reset_out_is_outstanding;
1000 	uint8_t delayed_connection;
1001 	uint8_t ifp_had_enobuf;
1002 	uint8_t saw_sack_with_frags;
1003 	uint8_t in_restart_hash;
1004 	uint8_t assoc_up_sent;
1005 	/* CMT variables */
1006 	uint8_t cmt_dac_pkts_rcvd;
1007 	uint8_t sctp_cmt_on_off;
1008 	uint8_t iam_blocking;
1009 	uint8_t cookie_how[8];
1010 	/* JRS 5/21/07 - CMT PF variable */
1011 	uint8_t sctp_cmt_pf;
1012 	/*
1013 	 * The mapping array is used to track out of order sequences above
1014 	 * last_acked_seq. 0 indicates packet missing 1 indicates packet
1015 	 * rec'd. We slide it up every time we raise last_acked_seq and 0
1016 	 * trailing locactions out.  If I get a TSN above the array
1017 	 * mappingArraySz, I discard the datagram and let retransmit happen.
1018 	 */
1019 	uint32_t marked_retrans;
1020 	uint32_t timoinit;
1021 	uint32_t timodata;
1022 	uint32_t timosack;
1023 	uint32_t timoshutdown;
1024 	uint32_t timoheartbeat;
1025 	uint32_t timocookie;
1026 	uint32_t timoshutdownack;
1027 	struct timeval start_time;
1028 	struct timeval discontinuity_time;
1029 };
1030 
1031 #endif
1032