Home | History | Annotate | Download | only in netinet
      1 /*-
      2  * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
      3  * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
      4  * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions are met:
      8  *
      9  * a) Redistributions of source code must retain the above copyright notice,
     10  *    this list of conditions and the following disclaimer.
     11  *
     12  * b) Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in
     14  *    the documentation and/or other materials provided with the distribution.
     15  *
     16  * c) Neither the name of Cisco Systems, Inc. nor the names of its
     17  *    contributors may be used to endorse or promote products derived
     18  *    from this software without specific prior written permission.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
     24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     30  * THE POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 #ifdef __FreeBSD__
     34 #include <sys/cdefs.h>
     35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_structs.h 269945 2014-08-13 15:50:16Z tuexen $");
     36 #endif
     37 
     38 #ifndef _NETINET_SCTP_STRUCTS_H_
     39 #define _NETINET_SCTP_STRUCTS_H_
     40 
     41 #include <netinet/sctp_os.h>
     42 #include <netinet/sctp_header.h>
     43 #include <netinet/sctp_auth.h>
     44 
     45 struct sctp_timer {
     46 	sctp_os_timer_t timer;
     47 
     48 	int type;
     49 	/*
     50 	 * Depending on the timer type these will be setup and cast with the
     51 	 * appropriate entity.
     52 	 */
     53 	void *ep;
     54 	void *tcb;
     55 	void *net;
     56 #if defined(__FreeBSD__) && __FreeBSD_version >= 800000
     57 	void *vnet;
     58 #endif
     59 
     60 	/* for sanity checking */
     61 	void *self;
     62 	uint32_t ticks;
     63 	uint32_t stopped_from;
     64 };
     65 
     66 
     67 struct sctp_foo_stuff {
     68 	struct sctp_inpcb *inp;
     69 	uint32_t        lineno;
     70 	uint32_t        ticks;
     71 	int             updown;
     72 };
     73 
     74 
     75 /*
     76  * This is the information we track on each interface that we know about from
     77  * the distant end.
     78  */
     79 TAILQ_HEAD(sctpnetlisthead, sctp_nets);
     80 
     81 struct sctp_stream_reset_list {
     82 	TAILQ_ENTRY(sctp_stream_reset_list) next_resp;
     83 	uint32_t tsn;
     84 	uint32_t number_entries;
     85 	uint16_t list_of_streams[];
     86 };
     87 
     88 TAILQ_HEAD(sctp_resethead, sctp_stream_reset_list);
     89 
     90 /*
     91  * Users of the iterator need to malloc a iterator with a call to
     92  * sctp_initiate_iterator(inp_func, assoc_func, inp_func,  pcb_flags, pcb_features,
     93  *     asoc_state, void-ptr-arg, uint32-arg, end_func, inp);
     94  *
     95  * Use the following two defines if you don't care what pcb flags are on the EP
     96  * and/or you don't care what state the association is in.
     97  *
     98  * Note that if you specify an INP as the last argument then ONLY each
     99  * association of that single INP will be executed upon. Note that the pcb
    100  * flags STILL apply so if the inp you specify has different pcb_flags then
    101  * what you put in pcb_flags nothing will happen. use SCTP_PCB_ANY_FLAGS to
    102  * assure the inp you specify gets treated.
    103  */
    104 #define SCTP_PCB_ANY_FLAGS	0x00000000
    105 #define SCTP_PCB_ANY_FEATURES	0x00000000
    106 #define SCTP_ASOC_ANY_STATE	0x00000000
    107 
    108 typedef void (*asoc_func) (struct sctp_inpcb *, struct sctp_tcb *, void *ptr,
    109          uint32_t val);
    110 typedef int (*inp_func) (struct sctp_inpcb *, void *ptr, uint32_t val);
    111 typedef void (*end_func) (void *ptr, uint32_t val);
    112 
    113 #if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP)
    114 /* whats on the mcore control struct */
    115 struct sctp_mcore_queue {
    116 	TAILQ_ENTRY(sctp_mcore_queue) next;
    117 #if defined(__FreeBSD__) && __FreeBSD_version >= 801000
    118 	struct vnet *vn;
    119 #endif
    120 	struct mbuf *m;
    121 	int off;
    122 	int v6;
    123 };
    124 
    125 TAILQ_HEAD(sctp_mcore_qhead, sctp_mcore_queue);
    126 
    127 struct sctp_mcore_ctrl {
    128 	SCTP_PROCESS_STRUCT thread_proc;
    129 	struct sctp_mcore_qhead que;
    130 	struct mtx core_mtx;
    131 	struct mtx que_mtx;
    132 	int running;
    133 	int cpuid;
    134 };
    135 
    136 
    137 #endif
    138 
    139 
    140 struct sctp_iterator {
    141 	TAILQ_ENTRY(sctp_iterator) sctp_nxt_itr;
    142 #if defined(__FreeBSD__) && __FreeBSD_version >= 801000
    143 	struct vnet *vn;
    144 #endif
    145 	struct sctp_timer tmr;
    146 	struct sctp_inpcb *inp;		/* current endpoint */
    147 	struct sctp_tcb *stcb;		/* current* assoc */
    148 	struct sctp_inpcb *next_inp;    /* special hook to skip to */
    149 	asoc_func function_assoc;	/* per assoc function */
    150 	inp_func function_inp;		/* per endpoint function */
    151 	inp_func function_inp_end;	/* end INP function */
    152 	end_func function_atend;	/* iterator completion function */
    153 	void *pointer;			/* pointer for apply func to use */
    154 	uint32_t val;			/* value for apply func to use */
    155 	uint32_t pcb_flags;		/* endpoint flags being checked */
    156 	uint32_t pcb_features;		/* endpoint features being checked */
    157 	uint32_t asoc_state;		/* assoc state being checked */
    158 	uint32_t iterator_flags;
    159 	uint8_t  no_chunk_output;
    160 	uint8_t  done_current_ep;
    161 };
    162 /* iterator_flags values */
    163 #define SCTP_ITERATOR_DO_ALL_INP	0x00000001
    164 #define SCTP_ITERATOR_DO_SINGLE_INP	0x00000002
    165 
    166 
    167 TAILQ_HEAD(sctpiterators, sctp_iterator);
    168 
    169 struct sctp_copy_all {
    170 	struct sctp_inpcb *inp;	/* ep */
    171 	struct mbuf *m;
    172 	struct sctp_sndrcvinfo sndrcv;
    173 	int sndlen;
    174 	int cnt_sent;
    175 	int cnt_failed;
    176 };
    177 
    178 struct sctp_asconf_iterator {
    179 	struct sctpladdr list_of_work;
    180 	int cnt;
    181 };
    182 
    183 struct iterator_control {
    184 #if defined(__FreeBSD__)
    185 	struct mtx ipi_iterator_wq_mtx;
    186 	struct mtx it_mtx;
    187 #elif defined(__APPLE__)
    188 	lck_mtx_t *ipi_iterator_wq_mtx;
    189 	lck_mtx_t *it_mtx;
    190 #elif defined(SCTP_PROCESS_LEVEL_LOCKS)
    191 #if defined(__Userspace__)
    192 	userland_mutex_t ipi_iterator_wq_mtx;
    193 	userland_mutex_t it_mtx;
    194 	userland_cond_t iterator_wakeup;
    195 #else
    196 	pthread_mutex_t ipi_iterator_wq_mtx;
    197 	pthread_mutex_t it_mtx;
    198 	pthread_cond_t iterator_wakeup;
    199 #endif
    200 #elif defined(__Windows__)
    201 	struct spinlock it_lock;
    202 	struct spinlock ipi_iterator_wq_lock;
    203 	KEVENT iterator_wakeup[2];
    204 	PFILE_OBJECT iterator_thread_obj;
    205 #else
    206 	void *it_mtx;
    207 #endif
    208 #if !defined(__Windows__)
    209 #if !defined(__Userspace__)
    210 	SCTP_PROCESS_STRUCT thread_proc;
    211 #else
    212 	userland_thread_t thread_proc;
    213 #endif
    214 #endif
    215 	struct sctpiterators iteratorhead;
    216 	struct sctp_iterator *cur_it;
    217 	uint32_t iterator_running;
    218 	uint32_t iterator_flags;
    219 };
    220 #if !defined(__FreeBSD__)
    221 #define SCTP_ITERATOR_MUST_EXIT		0x00000001
    222 #define SCTP_ITERATOR_EXITED		0x00000002
    223 #endif
    224 #define SCTP_ITERATOR_STOP_CUR_IT	0x00000004
    225 #define SCTP_ITERATOR_STOP_CUR_INP	0x00000008
    226 
    227 struct sctp_net_route {
    228 	sctp_rtentry_t *ro_rt;
    229 #if defined(__FreeBSD__)
    230 #if __FreeBSD_version >= 800000
    231 	void *ro_lle;
    232 #endif
    233 #if __FreeBSD_version >= 900000
    234 	void *ro_ia;
    235 	int ro_flags;
    236 #endif
    237 #endif
    238 #if defined(__APPLE__)
    239 #if !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION)
    240 	struct ifaddr *ro_srcia;
    241 #endif
    242 #if !defined(APPLE_LEOPARD)
    243 	uint32_t ro_flags;
    244 #endif
    245 #endif
    246 	union sctp_sockstore _l_addr;	/* remote peer addr */
    247 	struct sctp_ifa *_s_addr;	/* our selected src addr */
    248 };
    249 
    250 struct htcp {
    251 	uint16_t	alpha;		/* Fixed point arith, << 7 */
    252 	uint8_t		beta;           /* Fixed point arith, << 7 */
    253 	uint8_t		modeswitch;     /* Delay modeswitch until we had at least one congestion event */
    254 	uint32_t	last_cong;	/* Time since last congestion event end */
    255 	uint32_t	undo_last_cong;
    256 	uint16_t	bytes_acked;
    257 	uint32_t	bytecount;
    258 	uint32_t	minRTT;
    259 	uint32_t	maxRTT;
    260 
    261 	uint32_t	undo_maxRTT;
    262 	uint32_t	undo_old_maxB;
    263 
    264 	/* Bandwidth estimation */
    265 	uint32_t	minB;
    266 	uint32_t	maxB;
    267 	uint32_t	old_maxB;
    268 	uint32_t	Bi;
    269 	uint32_t	lasttime;
    270 };
    271 
    272 struct rtcc_cc {
    273 	struct timeval tls;   /* The time we started the sending  */
    274 	uint64_t lbw;         /* Our last estimated bw */
    275 	uint64_t lbw_rtt;     /* RTT at bw estimate */
    276 	uint64_t bw_bytes;    /* The total bytes since this sending began */
    277 	uint64_t bw_tot_time; /* The total time since sending began */
    278 	uint64_t new_tot_time;  /* temp holding the new value */
    279 	uint64_t bw_bytes_at_last_rttc; /* What bw_bytes was at last rtt calc */
    280 	uint32_t cwnd_at_bw_set; /* Cwnd at last bw saved - lbw */
    281 	uint32_t vol_reduce;  /* cnt of voluntary reductions */
    282 	uint16_t steady_step; /* The number required to be in steady state*/
    283 	uint16_t step_cnt;    /* The current number */
    284 	uint8_t  ret_from_eq;  /* When all things are equal what do I return 0/1 - 1 no cc advance */
    285 	uint8_t  use_dccc_ecn;  /* Flag to enable DCCC ECN */
    286 	uint8_t  tls_needs_set; /* Flag to indicate we need to set tls 0 or 1 means set at send 2 not */
    287 	uint8_t  last_step_state; /* Last state if steady state stepdown is on */
    288 	uint8_t  rtt_set_this_sack; /* Flag saying this sack had RTT calc on it */
    289 	uint8_t  last_inst_ind; /* Last saved inst indication */
    290 };
    291 
    292 
    293 struct sctp_nets {
    294 	TAILQ_ENTRY(sctp_nets) sctp_next;	/* next link */
    295 
    296 	/*
    297 	 * Things on the top half may be able to be split into a common
    298 	 * structure shared by all.
    299 	 */
    300 	struct sctp_timer pmtu_timer;
    301 	struct sctp_timer hb_timer;
    302 
    303 	/*
    304 	 * The following two in combination equate to a route entry for v6
    305 	 * or v4.
    306 	 */
    307 	struct sctp_net_route ro;
    308 
    309 	/* mtu discovered so far */
    310 	uint32_t mtu;
    311 	uint32_t ssthresh;	/* not sure about this one for split */
    312 	uint32_t last_cwr_tsn;
    313 	uint32_t cwr_window_tsn;
    314 	uint32_t ecn_ce_pkt_cnt;
    315 	uint32_t lost_cnt;
    316 	/* smoothed average things for RTT and RTO itself */
    317 	int lastsa;
    318 	int lastsv;
    319 	uint64_t rtt; /* last measured rtt value in us */
    320 	unsigned int RTO;
    321 
    322 	/* This is used for SHUTDOWN/SHUTDOWN-ACK/SEND or INIT timers */
    323 	struct sctp_timer rxt_timer;
    324 
    325 	/* last time in seconds I sent to it */
    326 	struct timeval last_sent_time;
    327 	union cc_control_data {
    328 		struct htcp htcp_ca; 	/* JRS - struct used in HTCP algorithm */
    329 		struct rtcc_cc rtcc;    /* rtcc module cc stuff  */
    330 	} cc_mod;
    331 	int ref_count;
    332 
    333 	/* Congestion stats per destination */
    334 	/*
    335 	 * flight size variables and such, sorry Vern, I could not avoid
    336 	 * this if I wanted performance :>
    337 	 */
    338 	uint32_t flight_size;
    339 	uint32_t cwnd;		/* actual cwnd */
    340 	uint32_t prev_cwnd;	/* cwnd before any processing */
    341 	uint32_t ecn_prev_cwnd;	/* ECN prev cwnd at first ecn_echo seen in new window */
    342 	uint32_t partial_bytes_acked;	/* in CA tracks when to incr a MTU */
    343 	/* tracking variables to avoid the aloc/free in sack processing */
    344 	unsigned int net_ack;
    345 	unsigned int net_ack2;
    346 
    347 	/*
    348 	 * JRS - 5/8/07 - Variable to track last time
    349 	 *  a destination was active for CMT PF
    350 	 */
    351 	uint32_t last_active;
    352 
    353 	/*
    354 	 * CMT variables (iyengar (at) cis.udel.edu)
    355 	 */
    356 	uint32_t this_sack_highest_newack;	/* tracks highest TSN newly
    357 						 * acked for a given dest in
    358 						 * the current SACK. Used in
    359 						 * SFR and HTNA algos */
    360 	uint32_t pseudo_cumack;	/* CMT CUC algorithm. Maintains next expected
    361 				 * pseudo-cumack for this destination */
    362 	uint32_t rtx_pseudo_cumack;	/* CMT CUC algorithm. Maintains next
    363 					 * expected pseudo-cumack for this
    364 					 * destination */
    365 
    366 	/* CMT fast recovery variables */
    367 	uint32_t fast_recovery_tsn;
    368 	uint32_t heartbeat_random1;
    369 	uint32_t heartbeat_random2;
    370 #ifdef INET6
    371 	uint32_t flowlabel;
    372 #endif
    373 	uint8_t dscp;
    374 
    375 	struct timeval start_time;      /* time when this net was created */
    376 	uint32_t marked_retrans;        /* number or DATA chunks marked for
    377 	                                   timer based retransmissions */
    378 	uint32_t marked_fastretrans;
    379 	uint32_t heart_beat_delay;      /* Heart Beat delay in ms */
    380 
    381 	/* if this guy is ok or not ... status */
    382 	uint16_t dest_state;
    383 	/* number of timeouts to consider the destination unreachable */
    384 	uint16_t failure_threshold;
    385 	/* number of timeouts to consider the destination potentially failed */
    386 	uint16_t pf_threshold;
    387 	/* error stats on the destination */
    388 	uint16_t error_count;
    389 	/* UDP port number in case of UDP tunneling */
    390 	uint16_t port;
    391 
    392 	uint8_t fast_retran_loss_recovery;
    393 	uint8_t will_exit_fast_recovery;
    394 	/* Flags that probably can be combined into dest_state */
    395 	uint8_t fast_retran_ip;	/* fast retransmit in progress */
    396 	uint8_t hb_responded;
    397 	uint8_t saw_newack;	/* CMT's SFR algorithm flag */
    398 	uint8_t src_addr_selected;	/* if we split we move */
    399 	uint8_t indx_of_eligible_next_to_use;
    400 	uint8_t addr_is_local;	/* its a local address (if known) could move
    401 				 * in split */
    402 
    403 	/*
    404 	 * CMT variables (iyengar (at) cis.udel.edu)
    405 	 */
    406 	uint8_t find_pseudo_cumack;	/* CMT CUC algorithm. Flag used to
    407 					 * find a new pseudocumack. This flag
    408 					 * is set after a new pseudo-cumack
    409 					 * has been received and indicates
    410 					 * that the sender should find the
    411 					 * next pseudo-cumack expected for
    412 					 * this destination */
    413 	uint8_t find_rtx_pseudo_cumack;	/* CMT CUCv2 algorithm. Flag used to
    414 					 * find a new rtx-pseudocumack. This
    415 					 * flag is set after a new
    416 					 * rtx-pseudo-cumack has been received
    417 					 * and indicates that the sender
    418 					 * should find the next
    419 					 * rtx-pseudo-cumack expected for this
    420 					 * destination */
    421 	uint8_t new_pseudo_cumack;	/* CMT CUC algorithm. Flag used to
    422 					 * indicate if a new pseudo-cumack or
    423 					 * rtx-pseudo-cumack has been received */
    424 	uint8_t window_probe;		/* Doing a window probe? */
    425 	uint8_t RTO_measured;		/* Have we done the first measure */
    426 	uint8_t last_hs_used;	/* index into the last HS table entry we used */
    427 	uint8_t lan_type;
    428 	uint8_t rto_needed;
    429 #if defined(__FreeBSD__)
    430 	uint32_t flowid;
    431 #ifdef INVARIANTS
    432 	uint8_t flowidset;
    433 #endif
    434 #endif
    435 };
    436 
    437 
    438 struct sctp_data_chunkrec {
    439 	uint32_t TSN_seq;	/* the TSN of this transmit */
    440 	uint16_t stream_seq;	/* the stream sequence number of this transmit */
    441 	uint16_t stream_number;	/* the stream number of this guy */
    442 	uint32_t payloadtype;
    443 	uint32_t context;	/* from send */
    444 	uint32_t cwnd_at_send;
    445 	/*
    446 	 * part of the Highest sacked algorithm to be able to stroke counts
    447 	 * on ones that are FR'd.
    448 	 */
    449 	uint32_t fast_retran_tsn;	/* sending_seq at the time of FR */
    450 	struct timeval timetodrop;	/* time we drop it from queue */
    451 	uint8_t doing_fast_retransmit;
    452 	uint8_t rcv_flags;	/* flags pulled from data chunk on inbound for
    453 				 * outbound holds sending flags for PR-SCTP.
    454 				 */
    455 	uint8_t state_flags;
    456 	uint8_t chunk_was_revoked;
    457 	uint8_t fwd_tsn_cnt;
    458 };
    459 
    460 TAILQ_HEAD(sctpchunk_listhead, sctp_tmit_chunk);
    461 
    462 /* The lower byte is used to enumerate PR_SCTP policies */
    463 #define CHUNK_FLAGS_PR_SCTP_TTL	        SCTP_PR_SCTP_TTL
    464 #define CHUNK_FLAGS_PR_SCTP_BUF	        SCTP_PR_SCTP_BUF
    465 #define CHUNK_FLAGS_PR_SCTP_RTX         SCTP_PR_SCTP_RTX
    466 
    467 /* The upper byte is used as a bit mask */
    468 #define CHUNK_FLAGS_FRAGMENT_OK	        0x0100
    469 
    470 struct chk_id {
    471 	uint16_t id;
    472 	uint16_t can_take_data;
    473 };
    474 
    475 
    476 struct sctp_tmit_chunk {
    477 	union {
    478 		struct sctp_data_chunkrec data;
    479 		struct chk_id chunk_id;
    480 	}     rec;
    481 	struct sctp_association *asoc;	/* bp to asoc this belongs to */
    482 	struct timeval sent_rcv_time;	/* filled in if RTT being calculated */
    483 	struct mbuf *data;	/* pointer to mbuf chain of data */
    484 	struct mbuf *last_mbuf;	/* pointer to last mbuf in chain */
    485 	struct sctp_nets *whoTo;
    486 	TAILQ_ENTRY(sctp_tmit_chunk) sctp_next;	/* next link */
    487 	int32_t sent;		/* the send status */
    488 	uint16_t snd_count;	/* number of times I sent */
    489 	uint16_t flags;		/* flags, such as FRAGMENT_OK */
    490 	uint16_t send_size;
    491 	uint16_t book_size;
    492 	uint16_t mbcnt;
    493 	uint16_t auth_keyid;
    494 	uint8_t holds_key_ref;	/* flag if auth keyid refcount is held */
    495 	uint8_t pad_inplace;
    496 	uint8_t do_rtt;
    497 	uint8_t book_size_scale;
    498 	uint8_t no_fr_allowed;
    499 	uint8_t copy_by_ref;
    500 	uint8_t window_probe;
    501 };
    502 
    503 /*
    504  * The first part of this structure MUST be the entire sinfo structure. Maybe
    505  * I should have made it a sub structure... we can circle back later and do
    506  * that if we want.
    507  */
    508 struct sctp_queued_to_read {	/* sinfo structure Pluse more */
    509 	uint16_t sinfo_stream;	/* off the wire */
    510 	uint16_t sinfo_ssn;	/* off the wire */
    511 	uint16_t sinfo_flags;	/* SCTP_UNORDERED from wire use SCTP_EOF for
    512 				 * EOR */
    513 	uint32_t sinfo_ppid;	/* off the wire */
    514 	uint32_t sinfo_context;	/* pick this up from assoc def context? */
    515 	uint32_t sinfo_timetolive;	/* not used by kernel */
    516 	uint32_t sinfo_tsn;	/* Use this in reassembly as first TSN */
    517 	uint32_t sinfo_cumtsn;	/* Use this in reassembly as last TSN */
    518 	sctp_assoc_t sinfo_assoc_id;	/* our assoc id */
    519 	/* Non sinfo stuff */
    520 	uint32_t length;	/* length of data */
    521 	uint32_t held_length;	/* length held in sb */
    522 	struct sctp_nets *whoFrom;	/* where it came from */
    523 	struct mbuf *data;	/* front of the mbuf chain of data with
    524 				 * PKT_HDR */
    525 	struct mbuf *tail_mbuf;	/* used for multi-part data */
    526 	struct mbuf *aux_data;  /* used to hold/cache  control if o/s does not take it from us */
    527 	struct sctp_tcb *stcb;	/* assoc, used for window update */
    528 	TAILQ_ENTRY(sctp_queued_to_read) next;
    529 	uint16_t port_from;
    530 	uint16_t spec_flags;	/* Flags to hold the notification field */
    531 	uint8_t  do_not_ref_stcb;
    532 	uint8_t  end_added;
    533 	uint8_t  pdapi_aborted;
    534 	uint8_t  some_taken;
    535 };
    536 
    537 /* This data structure will be on the outbound
    538  * stream queues. Data will be pulled off from
    539  * the front of the mbuf data and chunk-ified
    540  * by the output routines. We will custom
    541  * fit every chunk we pull to the send/sent
    542  * queue to make up the next full packet
    543  * if we can. An entry cannot be removed
    544  * from the stream_out queue until
    545  * the msg_is_complete flag is set. This
    546  * means at times data/tail_mbuf MIGHT
    547  * be NULL.. If that occurs it happens
    548  * for one of two reasons. Either the user
    549  * is blocked on a send() call and has not
    550  * awoken to copy more data down... OR
    551  * the user is in the explict MSG_EOR mode
    552  * and wrote some data, but has not completed
    553  * sending.
    554  */
    555 struct sctp_stream_queue_pending {
    556 	struct mbuf *data;
    557 	struct mbuf *tail_mbuf;
    558 	struct timeval ts;
    559 	struct sctp_nets *net;
    560 	TAILQ_ENTRY (sctp_stream_queue_pending) next;
    561 	TAILQ_ENTRY (sctp_stream_queue_pending) ss_next;
    562 	uint32_t length;
    563 	uint32_t timetolive;
    564 	uint32_t ppid;
    565 	uint32_t context;
    566 	uint16_t sinfo_flags;
    567 	uint16_t stream;
    568 	uint16_t act_flags;
    569 	uint16_t auth_keyid;
    570 	uint8_t  holds_key_ref;
    571 	uint8_t  msg_is_complete;
    572 	uint8_t  some_taken;
    573 	uint8_t  sender_all_done;
    574 	uint8_t  put_last_out;
    575 	uint8_t  discard_rest;
    576 };
    577 
    578 /*
    579  * this struct contains info that is used to track inbound stream data and
    580  * help with ordering.
    581  */
    582 TAILQ_HEAD(sctpwheelunrel_listhead, sctp_stream_in);
    583 struct sctp_stream_in {
    584 	struct sctp_readhead inqueue;
    585 	uint16_t stream_no;
    586 	uint16_t last_sequence_delivered;	/* used for re-order */
    587 	uint8_t  delivery_started;
    588 };
    589 
    590 TAILQ_HEAD(sctpwheel_listhead, sctp_stream_out);
    591 TAILQ_HEAD(sctplist_listhead, sctp_stream_queue_pending);
    592 
    593 /* Round-robin schedulers */
    594 struct ss_rr {
    595 	/* next link in wheel */
    596 	TAILQ_ENTRY(sctp_stream_out) next_spoke;
    597 };
    598 
    599 /* Priority scheduler */
    600 struct ss_prio {
    601 	/* next link in wheel */
    602 	TAILQ_ENTRY(sctp_stream_out) next_spoke;
    603 	/* priority id */
    604 	uint16_t priority;
    605 };
    606 
    607 /* Fair Bandwidth scheduler */
    608 struct ss_fb {
    609 	/* next link in wheel */
    610 	TAILQ_ENTRY(sctp_stream_out) next_spoke;
    611 	/* stores message size */
    612 	int32_t rounds;
    613 };
    614 
    615 /*
    616  * This union holds all data necessary for
    617  * different stream schedulers.
    618  */
    619 union scheduling_data {
    620 	struct sctpwheel_listhead out_wheel;
    621 	struct sctplist_listhead out_list;
    622 };
    623 
    624 /*
    625  * This union holds all parameters per stream
    626  * necessary for different stream schedulers.
    627  */
    628 union scheduling_parameters {
    629 	struct ss_rr rr;
    630 	struct ss_prio prio;
    631 	struct ss_fb fb;
    632 };
    633 
    634 /* This struct is used to track the traffic on outbound streams */
    635 struct sctp_stream_out {
    636 	struct sctp_streamhead outqueue;
    637 	union scheduling_parameters ss_params;
    638 	uint32_t chunks_on_queues;
    639 #if defined(SCTP_DETAILED_STR_STATS)
    640 	uint32_t abandoned_unsent[SCTP_PR_SCTP_MAX + 1];
    641 	uint32_t abandoned_sent[SCTP_PR_SCTP_MAX + 1];
    642 #else
    643 	/* Only the aggregation */
    644 	uint32_t abandoned_unsent[1];
    645 	uint32_t abandoned_sent[1];
    646 #endif
    647 	uint16_t stream_no;
    648 	uint16_t next_sequence_send;	/* next one I expect to send out */
    649 	uint8_t last_msg_incomplete;
    650 };
    651 
    652 /* used to keep track of the addresses yet to try to add/delete */
    653 TAILQ_HEAD(sctp_asconf_addrhead, sctp_asconf_addr);
    654 struct sctp_asconf_addr {
    655 	TAILQ_ENTRY(sctp_asconf_addr) next;
    656 	struct sctp_asconf_addr_param ap;
    657 	struct sctp_ifa *ifa;	/* save the ifa for add/del ip */
    658 	uint8_t sent;		/* has this been sent yet? */
    659 	uint8_t special_del;	/* not to be used in lookup */
    660 };
    661 
    662 struct sctp_scoping {
    663 	uint8_t ipv4_addr_legal;
    664 	uint8_t ipv6_addr_legal;
    665 #if defined(__Userspace__)
    666 	uint8_t conn_addr_legal;
    667 #endif
    668 	uint8_t loopback_scope;
    669 	uint8_t ipv4_local_scope;
    670 	uint8_t local_scope;
    671 	uint8_t site_scope;
    672 };
    673 
    674 #define SCTP_TSN_LOG_SIZE 40
    675 
    676 struct sctp_tsn_log {
    677 	void     *stcb;
    678 	uint32_t tsn;
    679 	uint16_t strm;
    680 	uint16_t seq;
    681 	uint16_t sz;
    682 	uint16_t flgs;
    683 	uint16_t in_pos;
    684 	uint16_t in_out;
    685 };
    686 
    687 #define SCTP_FS_SPEC_LOG_SIZE 200
    688 struct sctp_fs_spec_log {
    689 	uint32_t sent;
    690 	uint32_t total_flight;
    691 	uint32_t tsn;
    692 	uint16_t book;
    693 	uint8_t incr;
    694 	uint8_t decr;
    695 };
    696 
    697 /* This struct is here to cut out the compatiabilty
    698  * pad that bulks up both the inp and stcb. The non
    699  * pad portion MUST stay in complete sync with
    700  * sctp_sndrcvinfo... i.e. if sinfo_xxxx is added
    701  * this must be done here too.
    702  */
    703 struct sctp_nonpad_sndrcvinfo {
    704 	uint16_t sinfo_stream;
    705 	uint16_t sinfo_ssn;
    706 	uint16_t sinfo_flags;
    707 	uint32_t sinfo_ppid;
    708 	uint32_t sinfo_context;
    709 	uint32_t sinfo_timetolive;
    710 	uint32_t sinfo_tsn;
    711 	uint32_t sinfo_cumtsn;
    712 	sctp_assoc_t sinfo_assoc_id;
    713 	uint16_t sinfo_keynumber;
    714 	uint16_t sinfo_keynumber_valid;
    715 };
    716 
    717 /*
    718  * JRS - Structure to hold function pointers to the functions responsible
    719  * for congestion control.
    720  */
    721 
    722 struct sctp_cc_functions {
    723 	void (*sctp_set_initial_cc_param)(struct sctp_tcb *stcb, struct sctp_nets *net);
    724 	void (*sctp_cwnd_update_after_sack)(struct sctp_tcb *stcb,
    725 	                                    struct sctp_association *asoc,
    726 	                                    int accum_moved ,int reneged_all, int will_exit);
    727 	void (*sctp_cwnd_update_exit_pf)(struct sctp_tcb *stcb, struct sctp_nets *net);
    728 	void (*sctp_cwnd_update_after_fr)(struct sctp_tcb *stcb,
    729 			struct sctp_association *asoc);
    730 	void (*sctp_cwnd_update_after_timeout)(struct sctp_tcb *stcb,
    731 			struct sctp_nets *net);
    732 	void (*sctp_cwnd_update_after_ecn_echo)(struct sctp_tcb *stcb,
    733 			struct sctp_nets *net, int in_window, int num_pkt_lost);
    734 	void (*sctp_cwnd_update_after_packet_dropped)(struct sctp_tcb *stcb,
    735 			struct sctp_nets *net, struct sctp_pktdrop_chunk *cp,
    736 			uint32_t *bottle_bw, uint32_t *on_queue);
    737 	void (*sctp_cwnd_update_after_output)(struct sctp_tcb *stcb,
    738 			struct sctp_nets *net, int burst_limit);
    739 	void (*sctp_cwnd_update_packet_transmitted)(struct sctp_tcb *stcb,
    740 			struct sctp_nets *net);
    741 	void (*sctp_cwnd_update_tsn_acknowledged)(struct sctp_nets *net,
    742 			struct sctp_tmit_chunk *);
    743 	void (*sctp_cwnd_new_transmission_begins)(struct sctp_tcb *stcb,
    744 			struct sctp_nets *net);
    745 	void (*sctp_cwnd_prepare_net_for_sack)(struct sctp_tcb *stcb,
    746 			struct sctp_nets *net);
    747 	int (*sctp_cwnd_socket_option)(struct sctp_tcb *stcb, int set, struct sctp_cc_option *);
    748 	void (*sctp_rtt_calculated)(struct sctp_tcb *, struct sctp_nets *, struct timeval *);
    749 };
    750 
    751 /*
    752  * RS - Structure to hold function pointers to the functions responsible
    753  * for stream scheduling.
    754  */
    755 struct sctp_ss_functions {
    756 	void (*sctp_ss_init)(struct sctp_tcb *stcb, struct sctp_association *asoc,
    757 		int holds_lock);
    758 	void (*sctp_ss_clear)(struct sctp_tcb *stcb, struct sctp_association *asoc,
    759 		int clear_values, int holds_lock);
    760 	void (*sctp_ss_init_stream)(struct sctp_stream_out *strq, struct sctp_stream_out *with_strq);
    761 	void (*sctp_ss_add_to_stream)(struct sctp_tcb *stcb, struct sctp_association *asoc,
    762 		struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, int holds_lock);
    763 	int (*sctp_ss_is_empty)(struct sctp_tcb *stcb, struct sctp_association *asoc);
    764 	void (*sctp_ss_remove_from_stream)(struct sctp_tcb *stcb, struct sctp_association *asoc,
    765 		struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, int holds_lock);
    766 	struct sctp_stream_out* (*sctp_ss_select_stream)(struct sctp_tcb *stcb,
    767 		struct sctp_nets *net, struct sctp_association *asoc);
    768 	void (*sctp_ss_scheduled)(struct sctp_tcb *stcb, struct sctp_nets *net,
    769 		struct sctp_association *asoc, struct sctp_stream_out *strq, int moved_how_much);
    770 	void (*sctp_ss_packet_done)(struct sctp_tcb *stcb, struct sctp_nets *net,
    771 		struct sctp_association *asoc);
    772 	int (*sctp_ss_get_value)(struct sctp_tcb *stcb, struct sctp_association *asoc,
    773 		struct sctp_stream_out *strq, uint16_t *value);
    774 	int (*sctp_ss_set_value)(struct sctp_tcb *stcb, struct sctp_association *asoc,
    775 		struct sctp_stream_out *strq, uint16_t value);
    776 };
    777 
    778 /* used to save ASCONF chunks for retransmission */
    779 TAILQ_HEAD(sctp_asconf_head, sctp_asconf);
    780 struct sctp_asconf {
    781 	TAILQ_ENTRY(sctp_asconf) next;
    782 	uint32_t serial_number;
    783 	uint16_t snd_count;
    784 	struct mbuf *data;
    785 	uint16_t len;
    786 };
    787 
    788 /* used to save ASCONF-ACK chunks for retransmission */
    789 TAILQ_HEAD(sctp_asconf_ackhead, sctp_asconf_ack);
    790 struct sctp_asconf_ack {
    791 	TAILQ_ENTRY(sctp_asconf_ack) next;
    792 	uint32_t serial_number;
    793 	struct sctp_nets *last_sent_to;
    794 	struct mbuf *data;
    795 	uint16_t len;
    796 };
    797 
    798 /*
    799  * Here we have information about each individual association that we track.
    800  * We probably in production would be more dynamic. But for ease of
    801  * implementation we will have a fixed array that we hunt for in a linear
    802  * fashion.
    803  */
    804 struct sctp_association {
    805 	/* association state */
    806 	int state;
    807 
    808 	/* queue of pending addrs to add/delete */
    809 	struct sctp_asconf_addrhead asconf_queue;
    810 
    811 	struct timeval time_entered;	/* time we entered state */
    812 	struct timeval time_last_rcvd;
    813 	struct timeval time_last_sent;
    814 	struct timeval time_last_sat_advance;
    815 	struct sctp_nonpad_sndrcvinfo def_send;
    816 
    817 	/* timers and such */
    818 	struct sctp_timer dack_timer;		/* Delayed ack timer */
    819 	struct sctp_timer asconf_timer;		/* asconf */
    820 	struct sctp_timer strreset_timer;	/* stream reset */
    821 	struct sctp_timer shut_guard_timer;	/* shutdown guard */
    822 	struct sctp_timer autoclose_timer;	/* automatic close timer */
    823 	struct sctp_timer delayed_event_timer;	/* timer for delayed events */
    824 	struct sctp_timer delete_prim_timer;	/* deleting primary dst */
    825 
    826 	/* list of restricted local addresses */
    827 	struct sctpladdr sctp_restricted_addrs;
    828 
    829 	/* last local address pending deletion (waiting for an address add) */
    830 	struct sctp_ifa *asconf_addr_del_pending;
    831 	/* Deleted primary destination (used to stop timer) */
    832 	struct sctp_nets *deleted_primary;
    833 
    834 	struct sctpnetlisthead nets;		/* remote address list */
    835 
    836 	/* Free chunk list */
    837 	struct sctpchunk_listhead free_chunks;
    838 
    839 	/* Control chunk queue */
    840 	struct sctpchunk_listhead control_send_queue;
    841 
    842 	/* ASCONF chunk queue */
    843 	struct sctpchunk_listhead asconf_send_queue;
    844 
    845 	/*
    846 	 * Once a TSN hits the wire it is moved to the sent_queue. We
    847 	 * maintain two counts here (don't know if any but retran_cnt is
    848 	 * needed). The idea is that the sent_queue_retran_cnt reflects how
    849 	 * many chunks have been marked for retranmission by either T3-rxt
    850 	 * or FR.
    851 	 */
    852 	struct sctpchunk_listhead sent_queue;
    853 	struct sctpchunk_listhead send_queue;
    854 
    855 	/* re-assembly queue for fragmented chunks on the inbound path */
    856 	struct sctpchunk_listhead reasmqueue;
    857 
    858 	/* Scheduling queues */
    859 	union scheduling_data ss_data;
    860 
    861 	/* This pointer will be set to NULL
    862 	 * most of the time. But when we have
    863 	 * a fragmented message, where we could
    864 	 * not get out all of the message at
    865 	 * the last send then this will point
    866 	 * to the stream to go get data from.
    867 	 */
    868 	struct sctp_stream_out *locked_on_sending;
    869 
    870 	/* If an iterator is looking at me, this is it */
    871 	struct sctp_iterator *stcb_starting_point_for_iterator;
    872 
    873 	/* ASCONF save the last ASCONF-ACK so we can resend it if necessary */
    874 	struct sctp_asconf_ackhead asconf_ack_sent;
    875 
    876 	/*
    877 	 * pointer to last stream reset queued to control queue by us with
    878 	 * requests.
    879 	 */
    880 	struct sctp_tmit_chunk *str_reset;
    881 	/*
    882 	 * if Source Address Selection happening, this will rotate through
    883 	 * the link list.
    884 	 */
    885 	struct sctp_laddr *last_used_address;
    886 
    887 	/* stream arrays */
    888 	struct sctp_stream_in *strmin;
    889 	struct sctp_stream_out *strmout;
    890 	uint8_t *mapping_array;
    891 	/* primary destination to use */
    892 	struct sctp_nets *primary_destination;
    893 	struct sctp_nets *alternate; /* If primary is down or PF */
    894 	/* For CMT */
    895 	struct sctp_nets *last_net_cmt_send_started;
    896 	/* last place I got a data chunk from */
    897 	struct sctp_nets *last_data_chunk_from;
    898 	/* last place I got a control from */
    899 	struct sctp_nets *last_control_chunk_from;
    900 
    901 	/* circular looking for output selection */
    902 	struct sctp_stream_out *last_out_stream;
    903 
    904 	/*
    905 	 * wait to the point the cum-ack passes req->send_reset_at_tsn for
    906 	 * any req on the list.
    907 	 */
    908 	struct sctp_resethead resetHead;
    909 
    910 	/* queue of chunks waiting to be sent into the local stack */
    911 	struct sctp_readhead pending_reply_queue;
    912 
    913 	/* JRS - the congestion control functions are in this struct */
    914 	struct sctp_cc_functions cc_functions;
    915 	/* JRS - value to store the currently loaded congestion control module */
    916 	uint32_t congestion_control_module;
    917 	/* RS - the stream scheduling functions are in this struct */
    918 	struct sctp_ss_functions ss_functions;
    919 	/* RS - value to store the currently loaded stream scheduling module */
    920 	uint32_t stream_scheduling_module;
    921 
    922 	uint32_t vrf_id;
    923 
    924 	uint32_t cookie_preserve_req;
    925 	/* ASCONF next seq I am sending out, inits at init-tsn */
    926 	uint32_t asconf_seq_out;
    927 	uint32_t asconf_seq_out_acked;
    928 	/* ASCONF last received ASCONF from peer, starts at peer's TSN-1 */
    929 	uint32_t asconf_seq_in;
    930 
    931 	/* next seq I am sending in str reset messages */
    932 	uint32_t str_reset_seq_out;
    933 	/* next seq I am expecting in str reset messages */
    934 	uint32_t str_reset_seq_in;
    935 
    936 	/* various verification tag information */
    937 	uint32_t my_vtag;	/* The tag to be used. if assoc is re-initited
    938 				 * by remote end, and I have unlocked this
    939 				 * will be regenerated to a new random value. */
    940 	uint32_t peer_vtag;	/* The peers last tag */
    941 
    942 	uint32_t my_vtag_nonce;
    943 	uint32_t peer_vtag_nonce;
    944 
    945 	uint32_t assoc_id;
    946 
    947 	/* This is the SCTP fragmentation threshold */
    948 	uint32_t smallest_mtu;
    949 
    950 	/*
    951 	 * Special hook for Fast retransmit, allows us to track the highest
    952 	 * TSN that is NEW in this SACK if gap ack blocks are present.
    953 	 */
    954 	uint32_t this_sack_highest_gap;
    955 
    956 	/*
    957 	 * The highest consecutive TSN that has been acked by peer on my
    958 	 * sends
    959 	 */
    960 	uint32_t last_acked_seq;
    961 
    962 	/* The next TSN that I will use in sending. */
    963 	uint32_t sending_seq;
    964 
    965 	/* Original seq number I used ??questionable to keep?? */
    966 	uint32_t init_seq_number;
    967 
    968 
    969 	/* The Advanced Peer Ack Point, as required by the PR-SCTP */
    970 	/* (A1 in Section 4.2) */
    971 	uint32_t advanced_peer_ack_point;
    972 
    973 	/*
    974 	 * The highest consequetive TSN at the bottom of the mapping array
    975 	 * (for his sends).
    976 	 */
    977 	uint32_t cumulative_tsn;
    978 	/*
    979 	 * Used to track the mapping array and its offset bits. This MAY be
    980 	 * lower then cumulative_tsn.
    981 	 */
    982 	uint32_t mapping_array_base_tsn;
    983 	/*
    984 	 * used to track highest TSN we have received and is listed in the
    985 	 * mapping array.
    986 	 */
    987 	uint32_t highest_tsn_inside_map;
    988 
    989 	/* EY - new NR variables used for nr_sack based on mapping_array*/
    990 	uint8_t *nr_mapping_array;
    991 	uint32_t highest_tsn_inside_nr_map;
    992 
    993 	uint32_t fast_recovery_tsn;
    994 	uint32_t sat_t3_recovery_tsn;
    995 	uint32_t tsn_last_delivered;
    996 	/*
    997 	 * For the pd-api we should re-write this a bit more efficent. We
    998 	 * could have multiple sctp_queued_to_read's that we are building at
    999 	 * once. Now we only do this when we get ready to deliver to the
   1000 	 * socket buffer. Note that we depend on the fact that the struct is
   1001 	 * "stuck" on the read queue until we finish all the pd-api.
   1002 	 */
   1003 	struct sctp_queued_to_read *control_pdapi;
   1004 
   1005 	uint32_t tsn_of_pdapi_last_delivered;
   1006 	uint32_t pdapi_ppid;
   1007 	uint32_t context;
   1008 	uint32_t last_reset_action[SCTP_MAX_RESET_PARAMS];
   1009 	uint32_t last_sending_seq[SCTP_MAX_RESET_PARAMS];
   1010 	uint32_t last_base_tsnsent[SCTP_MAX_RESET_PARAMS];
   1011 #ifdef SCTP_ASOCLOG_OF_TSNS
   1012 	/*
   1013 	 * special log  - This adds considerable size
   1014 	 * to the asoc, but provides a log that you
   1015 	 * can use to detect problems via kgdb.
   1016 	 */
   1017 	struct sctp_tsn_log  in_tsnlog[SCTP_TSN_LOG_SIZE];
   1018 	struct sctp_tsn_log  out_tsnlog[SCTP_TSN_LOG_SIZE];
   1019 	uint32_t cumack_log[SCTP_TSN_LOG_SIZE];
   1020 	uint32_t cumack_logsnt[SCTP_TSN_LOG_SIZE];
   1021 	uint16_t tsn_in_at;
   1022 	uint16_t tsn_out_at;
   1023 	uint16_t tsn_in_wrapped;
   1024 	uint16_t tsn_out_wrapped;
   1025 	uint16_t cumack_log_at;
   1026 	uint16_t cumack_log_atsnt;
   1027 #endif /* SCTP_ASOCLOG_OF_TSNS */
   1028 #ifdef SCTP_FS_SPEC_LOG
   1029 	struct sctp_fs_spec_log fslog[SCTP_FS_SPEC_LOG_SIZE];
   1030 	uint16_t fs_index;
   1031 #endif
   1032 
   1033 	/*
   1034 	 * window state information and smallest MTU that I use to bound
   1035 	 * segmentation
   1036 	 */
   1037 	uint32_t peers_rwnd;
   1038 	uint32_t my_rwnd;
   1039 	uint32_t my_last_reported_rwnd;
   1040 	uint32_t sctp_frag_point;
   1041 
   1042 	uint32_t total_output_queue_size;
   1043 
   1044 	uint32_t sb_cc;		       /* shadow of sb_cc */
   1045 	uint32_t sb_send_resv;     /* amount reserved on a send */
   1046 	uint32_t my_rwnd_control_len; /* shadow of sb_mbcnt used for rwnd control */
   1047 #ifdef INET6
   1048 	uint32_t default_flowlabel;
   1049 #endif
   1050 	uint32_t pr_sctp_cnt;
   1051 	int ctrl_queue_cnt;	/* could be removed  REM - NO IT CAN'T!! RRS */
   1052 	/*
   1053 	 * All outbound datagrams queue into this list from the individual
   1054 	 * stream queue. Here they get assigned a TSN and then await
   1055 	 * sending. The stream seq comes when it is first put in the
   1056 	 * individual str queue
   1057 	 */
   1058 	unsigned int stream_queue_cnt;
   1059 	unsigned int send_queue_cnt;
   1060 	unsigned int sent_queue_cnt;
   1061 	unsigned int sent_queue_cnt_removeable;
   1062 	/*
   1063 	 * Number on sent queue that are marked for retran until this value
   1064 	 * is 0 we only send one packet of retran'ed data.
   1065 	 */
   1066 	unsigned int sent_queue_retran_cnt;
   1067 
   1068 	unsigned int size_on_reasm_queue;
   1069 	unsigned int cnt_on_reasm_queue;
   1070 	unsigned int fwd_tsn_cnt;
   1071 	/* amount of data (bytes) currently in flight (on all destinations) */
   1072 	unsigned int total_flight;
   1073 	/* Total book size in flight */
   1074 	unsigned int total_flight_count;	/* count of chunks used with
   1075 						 * book total */
   1076 	/* count of destinaton nets and list of destination nets */
   1077 	unsigned int numnets;
   1078 
   1079 	/* Total error count on this association */
   1080 	unsigned int overall_error_count;
   1081 
   1082 	unsigned int cnt_msg_on_sb;
   1083 
   1084 	/* All stream count of chunks for delivery */
   1085 	unsigned int size_on_all_streams;
   1086 	unsigned int cnt_on_all_streams;
   1087 
   1088 	/* Heart Beat delay in ms */
   1089 	uint32_t heart_beat_delay;
   1090 
   1091 	/* autoclose */
   1092 	unsigned int sctp_autoclose_ticks;
   1093 
   1094 	/* how many preopen streams we have */
   1095 	unsigned int pre_open_streams;
   1096 
   1097 	/* How many streams I support coming into me */
   1098 	unsigned int max_inbound_streams;
   1099 
   1100 	/* the cookie life I award for any cookie, in seconds */
   1101 	unsigned int cookie_life;
   1102 	/* time to delay acks for */
   1103 	unsigned int delayed_ack;
   1104 	unsigned int old_delayed_ack;
   1105 	unsigned int sack_freq;
   1106 	unsigned int data_pkts_seen;
   1107 
   1108 	unsigned int numduptsns;
   1109 	int dup_tsns[SCTP_MAX_DUP_TSNS];
   1110 	unsigned int initial_init_rto_max;	/* initial RTO for INIT's */
   1111 	unsigned int initial_rto;	/* initial send RTO */
   1112 	unsigned int minrto;	/* per assoc RTO-MIN */
   1113 	unsigned int maxrto;	/* per assoc RTO-MAX */
   1114 
   1115 	/* authentication fields */
   1116 	sctp_auth_chklist_t *local_auth_chunks;
   1117 	sctp_auth_chklist_t *peer_auth_chunks;
   1118 	sctp_hmaclist_t *local_hmacs;	/* local HMACs supported */
   1119 	sctp_hmaclist_t *peer_hmacs;	/* peer HMACs supported */
   1120 	struct sctp_keyhead shared_keys;	/* assoc's shared keys */
   1121 	sctp_authinfo_t authinfo;	/* randoms, cached keys */
   1122 	/*
   1123 	 * refcnt to block freeing when a sender or receiver is off coping
   1124 	 * user data in.
   1125 	 */
   1126 	uint32_t refcnt;
   1127 	uint32_t chunks_on_out_queue;	/* total chunks floating around,
   1128 					 * locked by send socket buffer */
   1129 	uint32_t peers_adaptation;
   1130 	uint16_t peer_hmac_id;	/* peer HMAC id to send */
   1131 
   1132 	/*
   1133 	 * Being that we have no bag to collect stale cookies, and that we
   1134 	 * really would not want to anyway.. we will count them in this
   1135 	 * counter. We of course feed them to the pigeons right away (I have
   1136 	 * always thought of pigeons as flying rats).
   1137 	 */
   1138 	uint16_t stale_cookie_count;
   1139 
   1140 	/*
   1141 	 * For the partial delivery API, if up, invoked this is what last
   1142 	 * TSN I delivered
   1143 	 */
   1144 	uint16_t str_of_pdapi;
   1145 	uint16_t ssn_of_pdapi;
   1146 
   1147 	/* counts of actual built streams. Allocation may be more however */
   1148 	/* could re-arrange to optimize space here. */
   1149 	uint16_t streamincnt;
   1150 	uint16_t streamoutcnt;
   1151 	uint16_t strm_realoutsize;
   1152 	uint16_t strm_pending_add_size;
   1153 	/* my maximum number of retrans of INIT and SEND */
   1154 	/* copied from SCTP but should be individually setable */
   1155 	uint16_t max_init_times;
   1156 	uint16_t max_send_times;
   1157 
   1158 	uint16_t def_net_failure;
   1159 
   1160 	uint16_t def_net_pf_threshold;
   1161 
   1162 	/*
   1163 	 * lock flag: 0 is ok to send, 1+ (duals as a retran count) is
   1164 	 * awaiting ACK
   1165 	 */
   1166 	uint16_t mapping_array_size;
   1167 
   1168 	uint16_t last_strm_seq_delivered;
   1169 	uint16_t last_strm_no_delivered;
   1170 
   1171 	uint16_t last_revoke_count;
   1172 	int16_t num_send_timers_up;
   1173 
   1174 	uint16_t stream_locked_on;
   1175 	uint16_t ecn_echo_cnt_onq;
   1176 
   1177 	uint16_t free_chunk_cnt;
   1178 	uint8_t stream_locked;
   1179 	uint8_t authenticated;	/* packet authenticated ok */
   1180 	/*
   1181 	 * This flag indicates that a SACK need to be sent.
   1182 	 * Initially this is 1 to send the first sACK immediately.
   1183 	 */
   1184 	uint8_t send_sack;
   1185 
   1186 	/* max burst of new packets into the network */
   1187 	uint32_t max_burst;
   1188 	/* max burst of fast retransmit packets */
   1189 	uint32_t fr_max_burst;
   1190 
   1191 	uint8_t sat_network;	/* RTT is in range of sat net or greater */
   1192 	uint8_t sat_network_lockout;	/* lockout code */
   1193 	uint8_t burst_limit_applied;	/* Burst limit in effect at last send? */
   1194 	/* flag goes on when we are doing a partial delivery api */
   1195 	uint8_t hb_random_values[4];
   1196 	uint8_t fragmented_delivery_inprogress;
   1197 	uint8_t fragment_flags;
   1198 	uint8_t last_flags_delivered;
   1199 	uint8_t hb_ect_randombit;
   1200 	uint8_t hb_random_idx;
   1201 	uint8_t default_dscp;
   1202 	uint8_t asconf_del_pending;	/* asconf delete last addr pending */
   1203 
   1204 	/*
   1205 	 * This value, plus all other ack'd but above cum-ack is added
   1206 	 * together to cross check against the bit that we have yet to
   1207 	 * define (probably in the SACK). When the cum-ack is updated, this
   1208 	 * sum is updated as well.
   1209 	 */
   1210 
   1211 	/* Flags whether an extension is supported or not */
   1212 	uint8_t ecn_supported;
   1213 	uint8_t prsctp_supported;
   1214 	uint8_t auth_supported;
   1215 	uint8_t asconf_supported;
   1216 	uint8_t reconfig_supported;
   1217 	uint8_t nrsack_supported;
   1218 	uint8_t pktdrop_supported;
   1219 
   1220 	/* Did the peer make the stream config (add out) request */
   1221 	uint8_t peer_req_out;
   1222 
   1223 	uint8_t local_strreset_support;
   1224 
   1225 	uint8_t peer_supports_nat;
   1226 
   1227 	struct sctp_scoping scope;
   1228 	/* flags to handle send alternate net tracking */
   1229 	uint8_t used_alt_onsack;
   1230 	uint8_t used_alt_asconfack;
   1231 	uint8_t fast_retran_loss_recovery;
   1232 	uint8_t sat_t3_loss_recovery;
   1233 	uint8_t dropped_special_cnt;
   1234 	uint8_t seen_a_sack_this_pkt;
   1235 	uint8_t stream_reset_outstanding;
   1236 	uint8_t stream_reset_out_is_outstanding;
   1237 	uint8_t delayed_connection;
   1238 	uint8_t ifp_had_enobuf;
   1239 	uint8_t saw_sack_with_frags;
   1240 	uint8_t saw_sack_with_nr_frags;
   1241 	uint8_t in_asocid_hash;
   1242 	uint8_t assoc_up_sent;
   1243 	uint8_t adaptation_needed;
   1244 	uint8_t adaptation_sent;
   1245 	/* CMT variables */
   1246 	uint8_t cmt_dac_pkts_rcvd;
   1247 	uint8_t sctp_cmt_on_off;
   1248 	uint8_t iam_blocking;
   1249 	uint8_t cookie_how[8];
   1250 	/* JRS 5/21/07 - CMT PF variable */
   1251 	uint8_t sctp_cmt_pf;
   1252 	uint8_t use_precise_time;
   1253 	uint64_t sctp_features;
   1254 	uint16_t port; /* remote UDP encapsulation port */
   1255 	/*
   1256 	 * The mapping array is used to track out of order sequences above
   1257 	 * last_acked_seq. 0 indicates packet missing 1 indicates packet
   1258 	 * rec'd. We slide it up every time we raise last_acked_seq and 0
   1259 	 * trailing locactions out.  If I get a TSN above the array
   1260 	 * mappingArraySz, I discard the datagram and let retransmit happen.
   1261 	 */
   1262 	uint32_t marked_retrans;
   1263 	uint32_t timoinit;
   1264 	uint32_t timodata;
   1265 	uint32_t timosack;
   1266 	uint32_t timoshutdown;
   1267 	uint32_t timoheartbeat;
   1268 	uint32_t timocookie;
   1269 	uint32_t timoshutdownack;
   1270 	struct timeval start_time;
   1271 	struct timeval discontinuity_time;
   1272 	uint64_t abandoned_unsent[SCTP_PR_SCTP_MAX + 1];
   1273 	uint64_t abandoned_sent[SCTP_PR_SCTP_MAX + 1];
   1274 };
   1275 
   1276 #endif
   1277