xref: /netbsd-src/sys/netinet/sctp_structs.h (revision f0dcd50e0ea5f1222ec4c7a8741a1744d0850ddf)
18c2654abSrjs /*	$KAME: sctp_structs.h,v 1.13 2005/03/06 16:04:18 itojun Exp $	*/
2*f0dcd50eSandvar /*	$NetBSD: sctp_structs.h,v 1.4 2023/08/10 06:44:12 andvar Exp $ */
38c2654abSrjs 
48c2654abSrjs #ifndef __SCTP_STRUCTS_H__
58c2654abSrjs #define __SCTP_STRUCTS_H__
68c2654abSrjs 
78c2654abSrjs /*
88c2654abSrjs  * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
98c2654abSrjs  * All rights reserved.
108c2654abSrjs  *
118c2654abSrjs  * Redistribution and use in source and binary forms, with or without
128c2654abSrjs  * modification, are permitted provided that the following conditions
138c2654abSrjs  * are met:
148c2654abSrjs  * 1. Redistributions of source code must retain the above copyright
158c2654abSrjs  *    notice, this list of conditions and the following disclaimer.
168c2654abSrjs  * 2. Redistributions in binary form must reproduce the above copyright
178c2654abSrjs  *    notice, this list of conditions and the following disclaimer in the
188c2654abSrjs  *    documentation and/or other materials provided with the distribution.
198c2654abSrjs  * 3. All advertising materials mentioning features or use of this software
208c2654abSrjs  *    must display the following acknowledgement:
218c2654abSrjs  *      This product includes software developed by Cisco Systems, Inc.
228c2654abSrjs  * 4. Neither the name of the project nor the names of its contributors
238c2654abSrjs  *    may be used to endorse or promote products derived from this software
248c2654abSrjs  *    without specific prior written permission.
258c2654abSrjs  *
268c2654abSrjs  * THIS SOFTWARE IS PROVIDED BY CISCO SYSTEMS AND CONTRIBUTORS ``AS IS'' AND
278c2654abSrjs  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
288c2654abSrjs  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
298c2654abSrjs  * ARE DISCLAIMED.  IN NO EVENT SHALL CISCO SYSTEMS OR CONTRIBUTORS BE LIABLE
308c2654abSrjs  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
318c2654abSrjs  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
328c2654abSrjs  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
338c2654abSrjs  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
348c2654abSrjs  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
358c2654abSrjs  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
368c2654abSrjs  * SUCH DAMAGE.
378c2654abSrjs  */
388c2654abSrjs #include <sys/queue.h>
398c2654abSrjs 
408c2654abSrjs #include <sys/callout.h>
418c2654abSrjs 
428c2654abSrjs #ifdef IPSEC
43505ea976Srjs #include <netipsec/ipsec.h>
44505ea976Srjs #include <netipsec/key.h>
458c2654abSrjs #endif
468c2654abSrjs 
478c2654abSrjs #include <netinet/sctp_header.h>
488c2654abSrjs #include <netinet/sctp_uio.h>
498c2654abSrjs 
508c2654abSrjs struct sctp_timer {
518c2654abSrjs 	struct callout timer;
528c2654abSrjs 	int type;
538c2654abSrjs 	/*
548c2654abSrjs 	 * Depending on the timer type these will be setup and cast with
558c2654abSrjs 	 * the appropriate entity.
568c2654abSrjs 	 */
578c2654abSrjs 	void *ep;
588c2654abSrjs 	void *tcb;
598c2654abSrjs 	void *net;
608c2654abSrjs };
618c2654abSrjs 
628c2654abSrjs /*
638c2654abSrjs  * This is the information we track on each interface that we know about	* from the distant end.
648c2654abSrjs  */
658c2654abSrjs TAILQ_HEAD(sctpnetlisthead, sctp_nets);
668c2654abSrjs 
678c2654abSrjs /*
688c2654abSrjs  * Users of the iterator need to malloc a iterator with a call to
698c2654abSrjs  * sctp_initiate_iterator(func, pcb_flags, asoc_state, void-ptr-arg, u_int32_t,
708c2654abSrjs  *                        u_int32-arg, end_func, inp);
718c2654abSrjs  *
728c2654abSrjs  * Use the following two defines if you don't care what pcb flags are on the
738c2654abSrjs  * EP and/or you don't care what state the association is in.
748c2654abSrjs  *
758c2654abSrjs  * Note that if you specify an INP as the last argument then ONLY each
768c2654abSrjs  * association of that single INP will be executed upon. Note that the
778c2654abSrjs  * pcb flags STILL apply so if the inp you specify has different pcb_flags
788c2654abSrjs  * then what you put in pcb_flags nothing will happen. use SCTP_PCB_ANY_FLAGS
798c2654abSrjs  * to assure the inp you specify gets treated.
808c2654abSrjs  */
818c2654abSrjs #define SCTP_PCB_ANY_FLAGS  0x00000000
828c2654abSrjs #define SCTP_ASOC_ANY_STATE 0x00000000
838c2654abSrjs 
848c2654abSrjs typedef void (*asoc_func)(struct sctp_inpcb *, struct sctp_tcb *, void *ptr,
858c2654abSrjs 			  u_int32_t val);
868c2654abSrjs typedef void (*end_func)(void *ptr, u_int32_t val);
878c2654abSrjs 
888c2654abSrjs #define SCTP_ITERATOR_DO_ALL_INP	0x00000001
898c2654abSrjs #define SCTP_ITERATOR_DO_SINGLE_INP	0x00000002
908c2654abSrjs 
918c2654abSrjs struct sctp_iterator {
928c2654abSrjs         LIST_ENTRY(sctp_iterator) sctp_nxt_itr;
938c2654abSrjs 	struct sctp_timer tmr;
948c2654abSrjs 	struct sctp_inpcb *inp;	/* ep */
958c2654abSrjs 	struct sctp_tcb *stcb;	/* assoc */
968c2654abSrjs 	asoc_func function_toapply;
978c2654abSrjs 	end_func function_atend;
988c2654abSrjs 	void *pointer;		/* pointer for apply func to use */
998c2654abSrjs 	u_int32_t val;		/* value for apply func to use */
1008c2654abSrjs 	u_int32_t pcb_flags;
1018c2654abSrjs 	u_int32_t asoc_state;
1028c2654abSrjs 	u_int32_t iterator_flags;
1038c2654abSrjs };
1048c2654abSrjs 
1058c2654abSrjs LIST_HEAD(sctpiterators, sctp_iterator);
1068c2654abSrjs 
1078c2654abSrjs struct sctp_copy_all {
1088c2654abSrjs 	struct sctp_inpcb *inp;	/* ep */
1098c2654abSrjs 	struct mbuf *m;
1108c2654abSrjs 	struct sctp_sndrcvinfo sndrcv;
1118c2654abSrjs 	int sndlen;
1128c2654abSrjs 	int cnt_sent;
1138c2654abSrjs 	int cnt_failed;
1148c2654abSrjs };
1158c2654abSrjs 
1168c2654abSrjs union sctp_sockstore {
1178c2654abSrjs #ifdef AF_INET
1188c2654abSrjs 	struct sockaddr_in  sin;
1198c2654abSrjs #endif
1208c2654abSrjs #ifdef AF_INET6
1218c2654abSrjs 	struct sockaddr_in6 sin6;
1228c2654abSrjs #endif
1238c2654abSrjs 	struct sockaddr     sa;
1248c2654abSrjs };
1258c2654abSrjs 
1268c2654abSrjs struct sctp_nets {
1278c2654abSrjs 	TAILQ_ENTRY(sctp_nets) sctp_next;	/* next link */
1288c2654abSrjs 
1298c2654abSrjs         /* Things on the top half may be able to be split
1308c2654abSrjs 	 * into a common structure shared by all.
1318c2654abSrjs 	 */
1328c2654abSrjs 	struct sctp_timer pmtu_timer;
1338c2654abSrjs 
1348c2654abSrjs 	/*
1358c2654abSrjs 	 * The following two in combination equate to a route entry for
1368c2654abSrjs 	 * v6 or v4.
1378c2654abSrjs 	 */
1388c2654abSrjs #if 0
1398c2654abSrjs 	struct sctp_route {
1408c2654abSrjs 		struct rtentry *ro_rt;
1418c2654abSrjs 		union sctp_sockstore _l_addr;	/* remote peer addr */
1428c2654abSrjs 		union sctp_sockstore _s_addr;	/* our selected src addr */
1438c2654abSrjs 	} ro;
1448c2654abSrjs #endif
1458c2654abSrjs 	struct route ro;
1468c2654abSrjs 	/* union sctp_sockstore _l_addr; */
1478c2654abSrjs 	union sctp_sockstore _s_addr;
1488c2654abSrjs 	/* mtu discovered so far */
1498c2654abSrjs 	u_int32_t mtu;
1508c2654abSrjs         u_int32_t ssthresh;		/* not sure about this one for split */
1518c2654abSrjs 
1528c2654abSrjs 	/* smoothed average things for RTT and RTO itself */
1538c2654abSrjs 	int lastsa;
1548c2654abSrjs 	int lastsv;
1558c2654abSrjs 	unsigned int RTO;
1568c2654abSrjs 
1578c2654abSrjs 	/* This is used for SHUTDOWN/SHUTDOWN-ACK/SEND or INIT timers */
1588c2654abSrjs 	struct sctp_timer rxt_timer;
1598c2654abSrjs 
1608c2654abSrjs 	/* last time in seconds I sent to it */
1618c2654abSrjs 	struct timeval last_sent_time;
1628c2654abSrjs 	int ref_count;
1638c2654abSrjs 
1648c2654abSrjs 	/* Congestion stats per destination */
1658c2654abSrjs 	/*
1668c2654abSrjs 	 * flight size variables and such, sorry Vern, I could not avoid
1678c2654abSrjs 	 * this if I wanted performance :>
1688c2654abSrjs 	 */
1698c2654abSrjs 	u_int32_t flight_size;
1708c2654abSrjs 	u_int32_t cwnd; /* actual cwnd */
1718c2654abSrjs 	u_int32_t prev_cwnd; /* cwnd before any processing */
1728c2654abSrjs 	u_int32_t partial_bytes_acked; /* in CA tracks when to incr a MTU */
1738c2654abSrjs 
1748c2654abSrjs 	/* tracking variables to avoid the aloc/free in sack processing */
1758c2654abSrjs 	unsigned int net_ack;
1768c2654abSrjs 	unsigned int net_ack2;
1778c2654abSrjs 	/*
1788c2654abSrjs 	 * These only are valid if the primary dest_sstate holds the
1798c2654abSrjs 	 * SCTP_ADDR_SWITCH_PRIMARY flag
1808c2654abSrjs 	 */
1818c2654abSrjs 	u_int32_t next_tsn_at_change;
1828c2654abSrjs 	u_int32_t heartbeat_random1;
1838c2654abSrjs 	u_int32_t heartbeat_random2;
1848c2654abSrjs 
1858c2654abSrjs 	/* if this guy is ok or not ... status */
1868c2654abSrjs 	u_int16_t dest_state;
1878c2654abSrjs 	/* number of transmit failures to down this guy */
1888c2654abSrjs 	u_int16_t failure_threshold;
1898c2654abSrjs 	/* error stats on destination */
1908c2654abSrjs 	u_int16_t error_count;
1918c2654abSrjs 
1928c2654abSrjs 	/* Flags that probably can be combined into dest_state */
1938c2654abSrjs 	u_int8_t rto_pending;		/* is segment marked for RTO update  ** if we split?*/
1948c2654abSrjs 	u_int8_t fast_retran_ip;	/* fast retransmit in progress */
1958c2654abSrjs 	u_int8_t hb_responded;
1968c2654abSrjs 	u_int8_t cacc_saw_newack;	/* CACC algorithm flag */
1978c2654abSrjs         u_int8_t src_addr_selected;	/* if we split we move */
1988c2654abSrjs 	u_int8_t indx_of_eligible_next_to_use;
1998c2654abSrjs 	u_int8_t addr_is_local;		/* its a local address (if known) could move in split */
2008c2654abSrjs #ifdef SCTP_HIGH_SPEED
2018c2654abSrjs 	u_int8_t last_hs_used;		/* index into the last HS table entry we used */
2028c2654abSrjs #endif
2038c2654abSrjs };
2048c2654abSrjs 
2058c2654abSrjs 
2068c2654abSrjs struct sctp_data_chunkrec {
2078c2654abSrjs 	u_int32_t TSN_seq;  /* the TSN of this transmit */
2088c2654abSrjs 	u_int16_t stream_seq; /* the stream sequence number of this transmit */
2098c2654abSrjs 	u_int16_t stream_number; /* the stream number of this guy */
2108c2654abSrjs 	u_int32_t payloadtype;
2118c2654abSrjs 	u_int32_t context;	/* from send */
2128c2654abSrjs 
2138c2654abSrjs        /* ECN Nonce: Nonce Value for this chunk */
2148c2654abSrjs         u_int8_t ect_nonce;
2158c2654abSrjs 
2168c2654abSrjs 	/* part of the Highest sacked algorithm to be able to
2178c2654abSrjs 	 * stroke counts on ones that are FR'd.
2188c2654abSrjs 	 */
2198c2654abSrjs 	u_int32_t fast_retran_tsn;	/* sending_seq at the time of FR */
2208c2654abSrjs 	struct timeval timetodrop;	/* time we drop it from queue */
2218c2654abSrjs 	u_int8_t doing_fast_retransmit;
2228c2654abSrjs 	u_int8_t rcv_flags; /* flags pulled from data chunk on inbound
2238c2654abSrjs 			   * for outbound holds sending flags.
2248c2654abSrjs 			   */
2258c2654abSrjs 	u_int8_t state_flags;
2268c2654abSrjs };
2278c2654abSrjs 
2288c2654abSrjs TAILQ_HEAD(sctpchunk_listhead, sctp_tmit_chunk);
2298c2654abSrjs 
2308c2654abSrjs #define CHUNK_FLAGS_FRAGMENT_OK	0x0001
2318c2654abSrjs 
2328c2654abSrjs struct sctp_tmit_chunk {
2338c2654abSrjs 	union {
2348c2654abSrjs 		struct sctp_data_chunkrec data;
2358c2654abSrjs 		int chunk_id;
2368c2654abSrjs 	} rec;
2378c2654abSrjs 	int32_t   sent;		/* the send status */
2388c2654abSrjs 	int32_t   snd_count;			/* number of times I sent */
2398c2654abSrjs 	u_int32_t flags;		/* flags, such as FRAGMENT_OK */
2408c2654abSrjs 	u_int32_t   send_size;
2418c2654abSrjs 	u_int32_t   book_size;
2428c2654abSrjs 	u_int32_t   mbcnt;
2438c2654abSrjs 	struct sctp_association *asoc;	/* bp to asoc this belongs to */
2448c2654abSrjs 	struct timeval sent_rcv_time;	/* filled in if RTT being calculated */
2458c2654abSrjs 	struct mbuf *data;		/* pointer to mbuf chain of data */
2468c2654abSrjs 	struct sctp_nets *whoTo;
2478c2654abSrjs 	TAILQ_ENTRY(sctp_tmit_chunk) sctp_next;	/* next link */
2488c2654abSrjs 	uint8_t do_rtt;
2498c2654abSrjs };
2508c2654abSrjs 
2518c2654abSrjs 
2528c2654abSrjs /*
2538c2654abSrjs  * this struct contains info that is used to track inbound stream data
2548c2654abSrjs  * and help with ordering.
2558c2654abSrjs  */
2568c2654abSrjs TAILQ_HEAD(sctpwheelunrel_listhead, sctp_stream_in);
2578c2654abSrjs struct sctp_stream_in {
2588c2654abSrjs 	struct sctpchunk_listhead inqueue;
2598c2654abSrjs 	TAILQ_ENTRY(sctp_stream_in) next_spoke;
2608c2654abSrjs 	uint16_t stream_no;
2618c2654abSrjs 	uint16_t last_sequence_delivered;	/* used for re-order */
2628c2654abSrjs };
2638c2654abSrjs 
2648c2654abSrjs /* This struct is used to track the traffic on outbound streams */
2658c2654abSrjs TAILQ_HEAD(sctpwheel_listhead, sctp_stream_out);
2668c2654abSrjs struct sctp_stream_out {
2678c2654abSrjs 	struct sctpchunk_listhead outqueue;
2688c2654abSrjs 	TAILQ_ENTRY(sctp_stream_out) next_spoke; /* next link in wheel */
2698c2654abSrjs 	uint16_t stream_no;
2708c2654abSrjs 	uint16_t next_sequence_sent; /* next one I expect to send out */
2718c2654abSrjs };
2728c2654abSrjs 
2738c2654abSrjs /* used to keep track of the addresses yet to try to add/delete */
2748c2654abSrjs TAILQ_HEAD(sctp_asconf_addrhead, sctp_asconf_addr);
2758c2654abSrjs struct sctp_asconf_addr {
2768c2654abSrjs 	TAILQ_ENTRY(sctp_asconf_addr) next;
2778c2654abSrjs 	struct sctp_asconf_addr_param ap;
2788c2654abSrjs 	struct ifaddr *ifa;	/* save the ifa for add/del ip */
2798c2654abSrjs 	uint8_t	sent;		/* has this been sent yet? */
2808c2654abSrjs };
2818c2654abSrjs 
2828c2654abSrjs 
2838c2654abSrjs /*
2848c2654abSrjs  * Here we have information about each individual association that we
2858c2654abSrjs  * track. We probably in production would be more dynamic. But for ease
2868c2654abSrjs  * of implementation we will have a fixed array that we hunt for in a
2878c2654abSrjs  * linear fashion.
2888c2654abSrjs  */
2898c2654abSrjs struct sctp_association {
2908c2654abSrjs 	/* association state */
2918c2654abSrjs 	int state;
2928c2654abSrjs 	/* queue of pending addrs to add/delete */
2938c2654abSrjs 	struct sctp_asconf_addrhead asconf_queue;
2948c2654abSrjs 	struct timeval time_entered;		/* time we entered state */
2958c2654abSrjs 	struct timeval time_last_rcvd;
2968c2654abSrjs 	struct timeval time_last_sent;
2978c2654abSrjs 	struct timeval time_last_sat_advance;
2988c2654abSrjs 	struct sctp_sndrcvinfo def_send;	/* default send parameters */
2998c2654abSrjs 
3008c2654abSrjs 	/* timers and such */
3018c2654abSrjs 	struct sctp_timer hb_timer;		/* hb timer */
3028c2654abSrjs 	struct sctp_timer dack_timer;		/* Delayed ack timer */
3038c2654abSrjs 	struct sctp_timer asconf_timer;		/* Asconf */
3048c2654abSrjs 	struct sctp_timer strreset_timer;	/* stream reset */
3058c2654abSrjs 	struct sctp_timer shut_guard_timer;	/* guard */
3068c2654abSrjs 	struct sctp_timer autoclose_timer;	/* automatic close timer */
3078c2654abSrjs 	struct sctp_timer delayed_event_timer;	/* timer for delayed events */
3088c2654abSrjs 
3098c2654abSrjs 	/* list of local addresses when add/del in progress */
3108c2654abSrjs 	struct sctpladdr sctp_local_addr_list;
3118c2654abSrjs 	struct sctpnetlisthead nets;
3128c2654abSrjs 
3138c2654abSrjs 	/* Control chunk queue */
3148c2654abSrjs 	struct sctpchunk_listhead control_send_queue;
3158c2654abSrjs 
3168c2654abSrjs 	/* Once a TSN hits the wire it is moved to the sent_queue. We
3178c2654abSrjs 	 * maintain two counts here (don't know if any but retran_cnt
3188c2654abSrjs 	 * is needed). The idea is that the sent_queue_retran_cnt
3198c2654abSrjs 	 * reflects how many chunks have been marked for retranmission
3208c2654abSrjs 	 * by either T3-rxt or FR.
3218c2654abSrjs 	 */
3228c2654abSrjs 	struct sctpchunk_listhead sent_queue;
3238c2654abSrjs 	struct sctpchunk_listhead send_queue;
3248c2654abSrjs 
3258c2654abSrjs 
3268c2654abSrjs 	/* re-assembly queue for fragmented chunks on the inbound path */
3278c2654abSrjs 	struct sctpchunk_listhead reasmqueue;
3288c2654abSrjs 
3298c2654abSrjs 	/*
3308c2654abSrjs 	 * this queue is used when we reach a condition that we can NOT
3318c2654abSrjs 	 * put data into the socket buffer. We track the size of this
3328c2654abSrjs 	 * queue and set our rwnd to the space in the socket minus also
3338c2654abSrjs 	 * the size_on_delivery_queue.
3348c2654abSrjs 	 */
3358c2654abSrjs 	struct sctpchunk_listhead delivery_queue;
3368c2654abSrjs 
3378c2654abSrjs 	struct sctpwheel_listhead out_wheel;
3388c2654abSrjs 
3398c2654abSrjs 	/* If an iterator is looking at me, this is it */
3408c2654abSrjs 	struct sctp_iterator *stcb_starting_point_for_iterator;
3418c2654abSrjs 
3428c2654abSrjs 	/* ASCONF destination address last sent to */
3438c2654abSrjs 	struct sctp_nets *asconf_last_sent_to;
3448c2654abSrjs 
3458c2654abSrjs 	/* ASCONF save the last ASCONF-ACK so we can resend it if necessary */
3468c2654abSrjs 	struct mbuf *last_asconf_ack_sent;
3478c2654abSrjs 
3488c2654abSrjs 	/*
3498c2654abSrjs 	 * if Source Address Selection happening, this will rotate through
3508c2654abSrjs 	 * the link list.
3518c2654abSrjs 	 */
3528c2654abSrjs 	struct sctp_laddr *last_used_address;
3538c2654abSrjs 
3548c2654abSrjs 	/* stream arrays */
3558c2654abSrjs         struct sctp_stream_in  *strmin;
3568c2654abSrjs 	struct sctp_stream_out *strmout;
3578c2654abSrjs 	u_int8_t *mapping_array;
3588c2654abSrjs 	/* primary destination to use */
3598c2654abSrjs 	struct sctp_nets *primary_destination;
3608c2654abSrjs 
3618c2654abSrjs 	/* last place I got a data chunk from */
3628c2654abSrjs 	struct sctp_nets *last_data_chunk_from;
3638c2654abSrjs 	/* last place I got a control from */
3648c2654abSrjs 	struct sctp_nets *last_control_chunk_from;
3658c2654abSrjs 
3668c2654abSrjs 	/* circular looking for output selection */
3678c2654abSrjs 	struct sctp_stream_out *last_out_stream;
3688c2654abSrjs 
3698c2654abSrjs 	/* wait to the point the cum-ack passes
3708c2654abSrjs 	 * pending_reply->sr_resp.reset_at_tsn.
3718c2654abSrjs 	 */
3728c2654abSrjs 	struct sctp_stream_reset_response *pending_reply;
3738c2654abSrjs 	struct sctpchunk_listhead pending_reply_queue;
3748c2654abSrjs 
3758c2654abSrjs 	u_int32_t cookie_preserve_req;
3768c2654abSrjs 	/* ASCONF next seq I am sending out, inits at init-tsn */
3778c2654abSrjs 	uint32_t asconf_seq_out;
3788c2654abSrjs 	/* ASCONF last received ASCONF from peer, starts at peer's TSN-1 */
3798c2654abSrjs 	uint32_t asconf_seq_in;
3808c2654abSrjs 
3818c2654abSrjs 	/* next seq I am sending in str reset messages */
3828c2654abSrjs 	uint32_t str_reset_seq_out;
3838c2654abSrjs 
3848c2654abSrjs 	/* next seq I am expecting in str reset messages */
3858c2654abSrjs 	uint32_t str_reset_seq_in;
3868c2654abSrjs 	u_int32_t str_reset_sending_seq;
3878c2654abSrjs 
3888c2654abSrjs 	/* various verification tag information */
3898c2654abSrjs 	u_int32_t my_vtag;	/*
3908c2654abSrjs 				 * The tag to be used. if assoc is
3918c2654abSrjs 				 * re-initited by remote end, and
3928c2654abSrjs 				 * I have unlocked this will be
393d1b93babSmsaitoh 				 * regenerated to a new random value.
3948c2654abSrjs 				 */
3958c2654abSrjs 	u_int32_t peer_vtag;	/* The peers last tag */
3968c2654abSrjs 
3978c2654abSrjs 	u_int32_t my_vtag_nonce;
3988c2654abSrjs 	u_int32_t peer_vtag_nonce;
3998c2654abSrjs 
4008c2654abSrjs 
4018c2654abSrjs 	/* This is the SCTP fragmentation threshold */
4028c2654abSrjs 	u_int32_t smallest_mtu;
4038c2654abSrjs 
4048c2654abSrjs 	/*
4058c2654abSrjs 	 * Special hook for Fast retransmit, allows us to track the highest
4068c2654abSrjs 	 * TSN that is NEW in this SACK if gap ack blocks are present.
4078c2654abSrjs 	 */
4088c2654abSrjs 	u_int32_t this_sack_highest_gap;
4098c2654abSrjs 
4108c2654abSrjs 	/*
4118c2654abSrjs 	 * The highest consecutive TSN that has been acked by peer on my
4128c2654abSrjs 	 * sends
4138c2654abSrjs 	 */
4148c2654abSrjs 	u_int32_t last_acked_seq;
4158c2654abSrjs 
4168c2654abSrjs 	/* The next TSN that I will use in sending. */
4178c2654abSrjs 	u_int32_t sending_seq;
4188c2654abSrjs 
4198c2654abSrjs 	/* Original seq number I used ??questionable to keep?? */
4208c2654abSrjs 	u_int32_t init_seq_number;
4218c2654abSrjs 
4228c2654abSrjs 	/*
4238c2654abSrjs 	 * We use this value to know if FR's are allowed, i.e. did the
4248c2654abSrjs 	 * cum-ack pass this point or equal it so FR's are now allowed.
4258c2654abSrjs 	 */
4268c2654abSrjs 	u_int32_t t3timeout_highest_marked;
4278c2654abSrjs 
4288c2654abSrjs 	/* The Advanced Peer Ack Point, as required by the PR-SCTP */
4298c2654abSrjs 	/* (A1 in Section 4.2) */
4308c2654abSrjs 	u_int32_t advanced_peer_ack_point;
4318c2654abSrjs 
4328c2654abSrjs 	/*
4338c2654abSrjs 	 * The highest consequetive TSN at the bottom of the mapping
4348c2654abSrjs 	 * array (for his sends).
4358c2654abSrjs 	 */
4368c2654abSrjs 	u_int32_t cumulative_tsn;
4378c2654abSrjs 	/*
4388c2654abSrjs 	 * Used to track the mapping array and its offset bits. This
4398c2654abSrjs 	 * MAY be lower then cumulative_tsn.
4408c2654abSrjs 	 */
4418c2654abSrjs 	u_int32_t mapping_array_base_tsn;
4428c2654abSrjs 	/*
4438c2654abSrjs 	 * used to track highest TSN we have received and is listed in
4448c2654abSrjs 	 * the mapping array.
4458c2654abSrjs 	 */
4468c2654abSrjs 	u_int32_t highest_tsn_inside_map;
4478c2654abSrjs 
4488c2654abSrjs 	u_int32_t last_echo_tsn;
4498c2654abSrjs 	u_int32_t last_cwr_tsn;
4508c2654abSrjs 	u_int32_t fast_recovery_tsn;
4518c2654abSrjs 	u_int32_t sat_t3_recovery_tsn;
4528c2654abSrjs 
4538c2654abSrjs 	u_int32_t tsn_last_delivered;
4548c2654abSrjs 
4558c2654abSrjs 	/*
4568c2654abSrjs 	 * window state information and smallest MTU that I use to bound
4578c2654abSrjs 	 * segmentation
4588c2654abSrjs 	 */
4598c2654abSrjs 	u_int32_t peers_rwnd;
4608c2654abSrjs 	u_int32_t my_rwnd;
4618c2654abSrjs 	u_int32_t my_last_reported_rwnd;
4628c2654abSrjs 	u_int32_t my_rwnd_control_len;
4638c2654abSrjs 
4648c2654abSrjs 	u_int32_t total_output_queue_size;
4658c2654abSrjs 	u_int32_t total_output_mbuf_queue_size;
4668c2654abSrjs 
4678c2654abSrjs 	/* 32 bit nonce stuff */
4688c2654abSrjs 	u_int32_t nonce_resync_tsn;
4698c2654abSrjs 	u_int32_t nonce_wait_tsn;
4708c2654abSrjs 
4718c2654abSrjs 	int ctrl_queue_cnt; /* could be removed  REM */
4728c2654abSrjs 	/*
4738c2654abSrjs 	 * All outbound datagrams queue into this list from the
4748c2654abSrjs 	 * individual stream queue. Here they get assigned a TSN
4758c2654abSrjs 	 * and then await sending. The stream seq comes when it
4768c2654abSrjs 	 * is first put in the individual str queue
4778c2654abSrjs 	 */
4788c2654abSrjs 	unsigned int stream_queue_cnt;
4798c2654abSrjs 	unsigned int send_queue_cnt;
4808c2654abSrjs 	unsigned int sent_queue_cnt;
4818c2654abSrjs 	unsigned int sent_queue_cnt_removeable;
4828c2654abSrjs 	/*
4838c2654abSrjs 	 * Number on sent queue that are marked for retran until this
4848c2654abSrjs 	 * value is 0 we only send one packet of retran'ed data.
4858c2654abSrjs 	 */
4868c2654abSrjs 	unsigned int sent_queue_retran_cnt;
4878c2654abSrjs 
4888c2654abSrjs 	unsigned int size_on_reasm_queue;
4898c2654abSrjs 	unsigned int cnt_on_reasm_queue;
4908c2654abSrjs 	/* amount of data (bytes) currently in flight (on all destinations) */
4918c2654abSrjs 	unsigned int total_flight;
4928c2654abSrjs 	/* Total book size in flight */
4938c2654abSrjs 	unsigned int total_flight_count;	/* count of chunks used with book total */
494*f0dcd50eSandvar 	/* count of destination nets and list of destination nets */
4958c2654abSrjs 	unsigned int numnets;
4968c2654abSrjs 
4978c2654abSrjs 	/* Total error count on this association */
4988c2654abSrjs 	unsigned int overall_error_count;
4998c2654abSrjs 
5008c2654abSrjs 	unsigned int size_on_delivery_queue;
5018c2654abSrjs 	unsigned int cnt_on_delivery_queue;
5028c2654abSrjs 
5038c2654abSrjs 	unsigned int cnt_msg_on_sb;
5048c2654abSrjs 
5058c2654abSrjs 	/* All stream count of chunks for delivery */
5068c2654abSrjs 	unsigned int size_on_all_streams;
5078c2654abSrjs 	unsigned int cnt_on_all_streams;
5088c2654abSrjs 
5098c2654abSrjs 	/* Heart Beat delay in ticks */
5108c2654abSrjs 	unsigned int heart_beat_delay;
5118c2654abSrjs 
5128c2654abSrjs 	/* autoclose */
5138c2654abSrjs 	unsigned int sctp_autoclose_ticks;
5148c2654abSrjs 
5158c2654abSrjs 	/* how many preopen streams we have */
5168c2654abSrjs 	unsigned int pre_open_streams;
5178c2654abSrjs 
5188c2654abSrjs 	/* How many streams I support coming into me */
5198c2654abSrjs 	unsigned int max_inbound_streams;
5208c2654abSrjs 
5218c2654abSrjs 	/* the cookie life I award for any cookie, in seconds */
5228c2654abSrjs 	unsigned int cookie_life;
5238c2654abSrjs 
5248c2654abSrjs 	unsigned int numduptsns;
5258c2654abSrjs 	int dup_tsns[SCTP_MAX_DUP_TSNS];
5268c2654abSrjs 	unsigned int initial_init_rto_max;	/* initial RTO for INIT's */
5278c2654abSrjs 	unsigned int initial_rto;		/* initial send RTO */
5288c2654abSrjs 	unsigned int minrto;			/* per assoc RTO-MIN */
5298c2654abSrjs 	unsigned int maxrto;			/* per assoc RTO-MAX */
5308c2654abSrjs 	/* Being that we have no bag to collect stale cookies, and
5318c2654abSrjs 	 * that we really would not want to anyway.. we will count
5328c2654abSrjs 	 * them in this counter. We of course feed them to the
5338c2654abSrjs 	 * pigeons right away (I have always thought of pigeons
5348c2654abSrjs 	 * as flying rats).
5358c2654abSrjs 	 */
5368c2654abSrjs 	u_int16_t stale_cookie_count;
5378c2654abSrjs 
5388c2654abSrjs 	/* For the partial delivery API, if up, invoked
5398c2654abSrjs 	 * this is what last TSN I delivered
5408c2654abSrjs 	 */
5418c2654abSrjs 	u_int16_t str_of_pdapi;
5428c2654abSrjs 	u_int16_t ssn_of_pdapi;
5438c2654abSrjs 
5448c2654abSrjs 
5458c2654abSrjs 	/* counts of actual built streams. Allocation may be more however */
5468c2654abSrjs 	/* could re-arrange to optimize space here. */
5478c2654abSrjs 	u_int16_t streamincnt;
5488c2654abSrjs 	u_int16_t streamoutcnt;
5498c2654abSrjs 
5508c2654abSrjs 	/* my maximum number of retrans of INIT and SEND */
5518c2654abSrjs 	/* copied from SCTP but should be individually setable */
5528c2654abSrjs 	u_int16_t max_init_times;
5538c2654abSrjs 	u_int16_t max_send_times;
5548c2654abSrjs 
5558c2654abSrjs 	u_int16_t def_net_failure;
5568c2654abSrjs 
5578c2654abSrjs 	/*
5588c2654abSrjs 	 * lock flag: 0 is ok to send, 1+ (duals as a retran count) is
5598c2654abSrjs 	 * awaiting ACK
5608c2654abSrjs 	 */
5618c2654abSrjs 	u_int16_t asconf_sent;   /* possibly removable REM */
5628c2654abSrjs 	u_int16_t mapping_array_size;
5638c2654abSrjs 
5648c2654abSrjs 	u_int16_t chunks_on_out_queue; /* total chunks floating around */
5658c2654abSrjs 	int16_t num_send_timers_up;
5668c2654abSrjs 	/*
5678c2654abSrjs 	 * This flag indicates that we need to send the first SACK. If
5688c2654abSrjs 	 * in place it says we have NOT yet sent a SACK and need to.
5698c2654abSrjs 	 */
5708c2654abSrjs 	u_int8_t first_ack_sent;
5718c2654abSrjs 
5728c2654abSrjs 	/* max burst after fast retransmit completes */
5738c2654abSrjs 	u_int8_t max_burst;
5748c2654abSrjs 
5758c2654abSrjs 	u_int8_t sat_network;	/* RTT is in range of sat net or greater */
5768c2654abSrjs 	u_int8_t sat_network_lockout;/* lockout code */
5778c2654abSrjs 	u_int8_t burst_limit_applied;	/* Burst limit in effect at last send? */
5788c2654abSrjs 	/* flag goes on when we are doing a partial delivery api */
5798c2654abSrjs 	u_int8_t hb_random_values[4];
5808c2654abSrjs 	u_int8_t fragmented_delivery_inprogress;
5818c2654abSrjs 	u_int8_t fragment_flags;
5828c2654abSrjs 	u_int8_t hb_ect_randombit;
5838c2654abSrjs         u_int8_t hb_random_idx;
5848c2654abSrjs 
5858c2654abSrjs 	/* ECN Nonce stuff */
5868c2654abSrjs 	u_int8_t receiver_nonce_sum; /* nonce I sum and put in my sack */
5878c2654abSrjs 	u_int8_t ecn_nonce_allowed;  /* Tells us if ECN nonce is on */
5888c2654abSrjs 	u_int8_t nonce_sum_check;    /* On off switch used during re-sync */
5898c2654abSrjs 	u_int8_t nonce_wait_for_ecne;/* flag when we expect a ECN */
5908c2654abSrjs 	u_int8_t peer_supports_ecn_nonce;
5918c2654abSrjs 
5928c2654abSrjs 	/*
5938c2654abSrjs 	 * This value, plus all other ack'd but above cum-ack is added
5948c2654abSrjs 	 * together to cross check against the bit that we have yet to
5958c2654abSrjs 	 * define (probably in the SACK).
5968c2654abSrjs 	 * When the cum-ack is updated, this sum is updated as well.
5978c2654abSrjs 	 */
5988c2654abSrjs 	u_int8_t nonce_sum_expect_base;
5998c2654abSrjs 	/* Flag to tell if ECN is allowed */
6008c2654abSrjs 	u_int8_t ecn_allowed;
6018c2654abSrjs 
6028c2654abSrjs 	/* flag to indicate if peer can do asconf */
6038c2654abSrjs 	uint8_t peer_supports_asconf;
6048c2654abSrjs 	uint8_t peer_supports_asconf_setprim; /* possibly removable REM */
6058c2654abSrjs 	/* pr-sctp support flag */
6068c2654abSrjs 	uint8_t peer_supports_prsctp;
6078c2654abSrjs 
6088c2654abSrjs 	/* stream resets are supported by the peer */
6098c2654abSrjs 	uint8_t peer_supports_strreset;
6108c2654abSrjs 
6118c2654abSrjs 	/*
6128c2654abSrjs 	 * packet drop's are supported by the peer, we don't really care
6138c2654abSrjs 	 * about this but we bookkeep it anyway.
6148c2654abSrjs 	 */
6158c2654abSrjs 	uint8_t peer_supports_pktdrop;
6168c2654abSrjs 
6178c2654abSrjs 	/* Do we allow V6/V4? */
6188c2654abSrjs 	u_int8_t ipv4_addr_legal;
6198c2654abSrjs 	u_int8_t ipv6_addr_legal;
6208c2654abSrjs 	/* Address scoping flags */
6218c2654abSrjs 	/* scope value for IPv4 */
6228c2654abSrjs 	u_int8_t ipv4_local_scope;
6238c2654abSrjs 	/* scope values for IPv6 */
6248c2654abSrjs 	u_int8_t local_scope;
6258c2654abSrjs 	u_int8_t site_scope;
6268c2654abSrjs 	/* loopback scope */
6278c2654abSrjs 	u_int8_t loopback_scope;
6288c2654abSrjs 	/* flags to handle send alternate net tracking */
6298c2654abSrjs 	u_int8_t used_alt_onsack;
6308c2654abSrjs 	u_int8_t used_alt_asconfack;
6318c2654abSrjs 	u_int8_t fast_retran_loss_recovery;
6328c2654abSrjs 	u_int8_t sat_t3_loss_recovery;
6338c2654abSrjs         u_int8_t dropped_special_cnt;
6348c2654abSrjs 	u_int8_t seen_a_sack_this_pkt;
6358c2654abSrjs 	u_int8_t stream_reset_outstanding;
6368c2654abSrjs 	u_int8_t delayed_connection;
6378c2654abSrjs 	u_int8_t ifp_had_enobuf;
6388c2654abSrjs 	u_int8_t saw_sack_with_frags;
6398c2654abSrjs 	/*
6408c2654abSrjs 	 * The mapping array is used to track out of order sequences above
6418c2654abSrjs 	 * last_acked_seq. 0 indicates packet missing 1 indicates packet
6428c2654abSrjs 	 * rec'd. We slide it up every time we raise last_acked_seq and 0
6438c2654abSrjs 	 * trailing locactions out.  If I get a TSN above the array
6448c2654abSrjs 	 * mappingArraySz, I discard the datagram and let retransmit happen.
6458c2654abSrjs 	 */
6468c2654abSrjs };
6478c2654abSrjs 
6488c2654abSrjs #endif
649