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