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