tcp_var.h revision 109175
11541Srgrimes/*
210937Swollman * Copyright (c) 1982, 1986, 1993, 1994, 1995
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes *
51541Srgrimes * Redistribution and use in source and binary forms, with or without
61541Srgrimes * modification, are permitted provided that the following conditions
71541Srgrimes * are met:
81541Srgrimes * 1. Redistributions of source code must retain the above copyright
91541Srgrimes *    notice, this list of conditions and the following disclaimer.
101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111541Srgrimes *    notice, this list of conditions and the following disclaimer in the
121541Srgrimes *    documentation and/or other materials provided with the distribution.
131541Srgrimes * 3. All advertising materials mentioning features or use of this software
141541Srgrimes *    must display the following acknowledgement:
151541Srgrimes *	This product includes software developed by the University of
161541Srgrimes *	California, Berkeley and its contributors.
171541Srgrimes * 4. Neither the name of the University nor the names of its contributors
181541Srgrimes *    may be used to endorse or promote products derived from this software
191541Srgrimes *    without specific prior written permission.
201541Srgrimes *
211541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311541Srgrimes * SUCH DAMAGE.
321541Srgrimes *
3310937Swollman *	@(#)tcp_var.h	8.4 (Berkeley) 5/24/95
3450477Speter * $FreeBSD: head/sys/netinet/tcp_var.h 109175 2003-01-13 11:01:20Z hsu $
351541Srgrimes */
361541Srgrimes
372169Spaul#ifndef _NETINET_TCP_VAR_H_
382169Spaul#define _NETINET_TCP_VAR_H_
3986764Sjlemon
4086764Sjlemon#include <netinet/in_pcb.h>		/* needed for in_conninfo, inp_gen_t */
4198102Shsu#include <netinet/tcp.h>
4286764Sjlemon
431541Srgrimes/*
441541Srgrimes * Kernel variables for tcp.
451541Srgrimes */
4686764Sjlemonextern int	tcp_do_rfc1323;
4786764Sjlemonextern int	tcp_do_rfc1644;
481541Srgrimes
4955679Sshin/* TCP segment queue entry */
5055679Sshinstruct tseg_qent {
5160938Sjake	LIST_ENTRY(tseg_qent) tqe_q;
5255679Sshin	int	tqe_len;		/* TCP segment data length */
5355679Sshin	struct	tcphdr *tqe_th;		/* a pointer to tcp header */
5455679Sshin	struct	mbuf	*tqe_m;		/* mbuf contains packet */
5555679Sshin};
5660938SjakeLIST_HEAD(tsegqe_head, tseg_qent);
5755679Sshin#ifdef MALLOC_DECLARE
5855679SshinMALLOC_DECLARE(M_TSEGQ);
5955679Sshin#endif
6055679Sshin
6155679Sshinstruct tcptemp {
6255679Sshin	u_char	tt_ipgen[40]; /* the size must be of max ip header, now IPv6 */
6355679Sshin	struct	tcphdr tt_t;
6455679Sshin};
6555679Sshin
6655679Sshin#define tcp6cb		tcpcb  /* for KAME src sync over BSD*'s */
6755679Sshin
681541Srgrimes/*
691541Srgrimes * Tcp control block, one per tcp; fields:
7032821Sdg * Organized for 16 byte cacheline efficiency.
711541Srgrimes */
721541Srgrimesstruct tcpcb {
7355679Sshin	struct	tsegqe_head t_segq;
7432821Sdg	int	t_dupacks;		/* consecutive dup acks recd */
7578642Ssilby	struct	tcptemp	*unused;	/* unused */
7632821Sdg
7750673Sjlemon	struct	callout *tt_rexmt;	/* retransmit timer */
7850673Sjlemon	struct	callout *tt_persist;	/* retransmit persistence */
7950673Sjlemon	struct	callout *tt_keep;	/* keepalive */
8050673Sjlemon	struct	callout *tt_2msl;	/* 2*msl TIME_WAIT timer */
8150673Sjlemon	struct	callout *tt_delack;	/* delayed ACK timer */
8232821Sdg
8332821Sdg	struct	inpcb *t_inpcb;		/* back pointer to internet pcb */
8411187Swollman	int	t_state;		/* state of this connection */
8511187Swollman	u_int	t_flags;
8642902Sfenner#define	TF_ACKNOW	0x00001		/* ack peer immediately */
8742902Sfenner#define	TF_DELACK	0x00002		/* ack, but try to delay it */
8842902Sfenner#define	TF_NODELAY	0x00004		/* don't delay packets to coalesce */
8942902Sfenner#define	TF_NOOPT	0x00008		/* don't use tcp options */
9042902Sfenner#define	TF_SENTFIN	0x00010		/* have sent FIN */
9142902Sfenner#define	TF_REQ_SCALE	0x00020		/* have/will request window scaling */
9242902Sfenner#define	TF_RCVD_SCALE	0x00040		/* other side has requested scaling */
9342902Sfenner#define	TF_REQ_TSTMP	0x00080		/* have/will request timestamps */
9442902Sfenner#define	TF_RCVD_TSTMP	0x00100		/* a timestamp was received in SYN */
9542902Sfenner#define	TF_SACK_PERMIT	0x00200		/* other side said I could SACK */
9642902Sfenner#define	TF_NEEDSYN	0x00400		/* send SYN (implicit state) */
9742902Sfenner#define	TF_NEEDFIN	0x00800		/* send FIN (implicit state) */
9842902Sfenner#define	TF_NOPUSH	0x01000		/* don't push */
9942902Sfenner#define	TF_REQ_CC	0x02000		/* have/will request CC */
10042902Sfenner#define	TF_RCVD_CC	0x04000		/* a CC was received in SYN */
10142902Sfenner#define	TF_SENDCCNEW	0x08000		/* send CCnew instead of CC in SYN */
10242902Sfenner#define	TF_MORETOCOME	0x10000		/* More data to be appended to sock */
10363745Sjayanth#define	TF_LQ_OVERFLOW	0x20000		/* listen queue overflow */
10484564Sjayanth#define	TF_LASTIDLE	0x40000		/* connection was previously idle */
10587193Sdillon#define TF_RXWIN0SENT	0x80000		/* sent a receiver win 0 in response */
10632821Sdg	int	t_force;		/* 1 if forcing out a byte */
1071541Srgrimes
1081541Srgrimes	tcp_seq	snd_una;		/* send unacknowledged */
10932821Sdg	tcp_seq	snd_max;		/* highest sequence number sent;
11032821Sdg					 * used to recognize retransmits
11132821Sdg					 */
1121541Srgrimes	tcp_seq	snd_nxt;		/* send next */
1131541Srgrimes	tcp_seq	snd_up;			/* send urgent pointer */
11432821Sdg
1151541Srgrimes	tcp_seq	snd_wl1;		/* window update seg seq number */
1161541Srgrimes	tcp_seq	snd_wl2;		/* window update seg ack number */
1171541Srgrimes	tcp_seq	iss;			/* initial send sequence number */
11832821Sdg	tcp_seq	irs;			/* initial receive sequence number */
11932821Sdg
12032821Sdg	tcp_seq	rcv_nxt;		/* receive next */
12132821Sdg	tcp_seq	rcv_adv;		/* advertised window */
1221541Srgrimes	u_long	rcv_wnd;		/* receive window */
1231541Srgrimes	tcp_seq	rcv_up;			/* receive urgent pointer */
12432821Sdg
12532821Sdg	u_long	snd_wnd;		/* send window */
1261541Srgrimes	u_long	snd_cwnd;		/* congestion-controlled window */
127102017Sdillon	u_long	snd_bwnd;		/* bandwidth-controlled window */
12813765Smpp	u_long	snd_ssthresh;		/* snd_cwnd size threshold for
1291541Srgrimes					 * for slow start exponential to
1301541Srgrimes					 * linear switch
1311541Srgrimes					 */
132102017Sdillon	u_long	snd_bandwidth;		/* calculated bandwidth or 0 */
133109175Shsu	tcp_seq	snd_recover;		/* for use in NewReno Fast Recovery */
134109175Shsu	tcp_seq snd_high;		/* for use in NewReno Fast Recovery */
13560067Sjlemon
13632821Sdg	u_int	t_maxopd;		/* mss plus options */
13732821Sdg
13850673Sjlemon	u_long	t_rcvtime;		/* inactivity time */
13950673Sjlemon	u_long	t_starttime;		/* time connection was established */
14050673Sjlemon	int	t_rtttime;		/* round trip time */
1411541Srgrimes	tcp_seq	t_rtseq;		/* sequence number being timed */
14232821Sdg
143102017Sdillon	int	t_bw_rtttime;		/* used for bandwidth calculation */
144102017Sdillon	tcp_seq	t_bw_rtseq;		/* used for bandwidth calculation */
145102017Sdillon
14650673Sjlemon	int	t_rxtcur;		/* current retransmit value (ticks) */
14732821Sdg	u_int	t_maxseg;		/* maximum segment size */
14811187Swollman	int	t_srtt;			/* smoothed round-trip time */
14911187Swollman	int	t_rttvar;		/* variance in round-trip time */
15032821Sdg
15132821Sdg	int	t_rxtshift;		/* log(2) of rexmt exp. backoff */
15211187Swollman	u_int	t_rttmin;		/* minimum rtt allowed */
153102017Sdillon	u_int	t_rttbest;		/* best rtt we've seen */
15432821Sdg	u_long	t_rttupdated;		/* number of times rtt sampled */
1551541Srgrimes	u_long	max_sndwnd;		/* largest window peer has offered */
1561541Srgrimes
15732821Sdg	int	t_softerror;		/* possible error not yet reported */
1581541Srgrimes/* out-of-band data */
1591541Srgrimes	char	t_oobflags;		/* have some */
1601541Srgrimes	char	t_iobc;			/* input character */
1611541Srgrimes#define	TCPOOB_HAVEDATA	0x01
1621541Srgrimes#define	TCPOOB_HADDATA	0x02
1631541Srgrimes/* RFC 1323 variables */
1641541Srgrimes	u_char	snd_scale;		/* window scaling for send window */
1651541Srgrimes	u_char	rcv_scale;		/* window scaling for recv window */
1661541Srgrimes	u_char	request_r_scale;	/* pending window scaling */
1671541Srgrimes	u_char	requested_s_scale;
1681541Srgrimes	u_long	ts_recent;		/* timestamp echo data */
16932821Sdg
1701541Srgrimes	u_long	ts_recent_age;		/* when last updated */
1711541Srgrimes	tcp_seq	last_ack_sent;
1726247Swollman/* RFC 1644 variables */
1736247Swollman	tcp_cc	cc_send;		/* send connection count */
1746247Swollman	tcp_cc	cc_recv;		/* receive connection count */
17550673Sjlemon/* experimental */
17650673Sjlemon	u_long	snd_cwnd_prev;		/* cwnd prior to retransmit */
17750673Sjlemon	u_long	snd_ssthresh_prev;	/* ssthresh prior to retransmit */
178109175Shsu	tcp_seq	snd_high_prev;		/* snd_high prior to retransmit */
17950673Sjlemon	u_long	t_badrxtwin;		/* window for retransmit recovery */
1801541Srgrimes};
1811541Srgrimes
1826247Swollman/*
1836247Swollman * Structure to hold TCP options that are only used during segment
1846247Swollman * processing (in tcp_input), but not held in the tcpcb.
1856247Swollman * It's basically used to reduce the number of parameters
1866247Swollman * to tcp_dooptions.
1876247Swollman */
1886247Swollmanstruct tcpopt {
18986764Sjlemon	u_long		to_flags;	/* which options are present */
1906247Swollman#define TOF_TS		0x0001		/* timestamp */
1916247Swollman#define TOF_CC		0x0002		/* CC and CCnew are exclusive */
1926247Swollman#define TOF_CCNEW	0x0004
1936247Swollman#define	TOF_CCECHO	0x0008
19486764Sjlemon#define	TOF_MSS		0x0010
19586764Sjlemon#define	TOF_SCALE	0x0020
19686764Sjlemon	u_int32_t	to_tsval;
19786764Sjlemon	u_int32_t	to_tsecr;
19886764Sjlemon	tcp_cc		to_cc;		/* holds CC or CCnew */
19986764Sjlemon	tcp_cc		to_ccecho;
20086764Sjlemon	u_int16_t	to_mss;
20186764Sjlemon	u_int8_t 	to_requested_s_scale;
20286764Sjlemon	u_int8_t 	to_pad;
2036247Swollman};
2046247Swollman
20586764Sjlemonstruct syncache {
20686764Sjlemon	inp_gen_t	sc_inp_gencnt;		/* pointer check */
20786764Sjlemon	struct 		tcpcb *sc_tp;		/* tcb for listening socket */
20886764Sjlemon	struct		mbuf *sc_ipopts;	/* source route */
20986764Sjlemon	struct 		in_conninfo sc_inc;	/* addresses */
21086764Sjlemon#define sc_route	sc_inc.inc_route
21186764Sjlemon#define sc_route6	sc_inc.inc6_route
21286764Sjlemon	u_int32_t	sc_tsrecent;
21386764Sjlemon	tcp_cc		sc_cc_send;		/* holds CC or CCnew */
21486764Sjlemon	tcp_cc		sc_cc_recv;
21586764Sjlemon	tcp_seq 	sc_irs;			/* seq from peer */
21686764Sjlemon	tcp_seq 	sc_iss;			/* our ISS */
21786764Sjlemon	u_long		sc_rxttime;		/* retransmit time */
21886764Sjlemon	u_int16_t	sc_rxtslot; 		/* retransmit counter */
21986764Sjlemon	u_int16_t	sc_peer_mss;		/* peer's MSS */
22086764Sjlemon	u_int16_t	sc_wnd;			/* advertised window */
22186764Sjlemon	u_int8_t 	sc_requested_s_scale:4,
22286764Sjlemon			sc_request_r_scale:4;
22386764Sjlemon	u_int8_t	sc_flags;
22486764Sjlemon#define SCF_NOOPT	0x01			/* no TCP options */
22586764Sjlemon#define SCF_WINSCALE	0x02			/* negotiated window scaling */
22686764Sjlemon#define SCF_TIMESTAMP	0x04			/* negotiated timestamps */
22786764Sjlemon#define SCF_CC		0x08			/* negotiated CC */
22886764Sjlemon#define SCF_UNREACH	0x10			/* icmp unreachable received */
22986764Sjlemon#define SCF_KEEPROUTE	0x20			/* keep cloned route */
23086764Sjlemon	TAILQ_ENTRY(syncache)	sc_hash;
23186764Sjlemon	TAILQ_ENTRY(syncache)	sc_timerq;
23286764Sjlemon};
23386764Sjlemon
23486764Sjlemonstruct syncache_head {
23586764Sjlemon	TAILQ_HEAD(, syncache)	sch_bucket;
23686764Sjlemon	u_int		sch_length;
23786764Sjlemon};
23886764Sjlemon
2396247Swollman/*
2406247Swollman * The TAO cache entry which is stored in the protocol family specific
2416247Swollman * portion of the route metrics.
2426247Swollman */
2436247Swollmanstruct rmxp_tao {
2446247Swollman	tcp_cc	tao_cc;			/* latest CC in valid SYN */
2456247Swollman	tcp_cc	tao_ccsent;		/* latest CC sent to peer */
2466247Swollman	u_short	tao_mssopt;		/* peer's cached MSS */
2476247Swollman#ifdef notyet
2486247Swollman	u_short	tao_flags;		/* cache status flags */
2496247Swollman#define	TAOF_DONT	0x0001		/* peer doesn't understand rfc1644 */
2506247Swollman#define	TAOF_OK		0x0002		/* peer does understand rfc1644 */
2516247Swollman#define	TAOF_UNDEF	0		/* we don't know yet */
2526247Swollman#endif /* notyet */
2536247Swollman};
2546283Swollman#define rmx_taop(r)	((struct rmxp_tao *)(r).rmx_filler)
2556247Swollman
2561541Srgrimes#define	intotcpcb(ip)	((struct tcpcb *)(ip)->inp_ppcb)
2571541Srgrimes#define	sototcpcb(so)	(intotcpcb(sotoinpcb(so)))
2581541Srgrimes
2591541Srgrimes/*
2601541Srgrimes * The smoothed round-trip time and estimated variance
2611541Srgrimes * are stored as fixed point numbers scaled by the values below.
2621541Srgrimes * For convenience, these scales are also used in smoothing the average
2631541Srgrimes * (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed).
2641541Srgrimes * With these scales, srtt has 3 bits to the right of the binary point,
2651541Srgrimes * and thus an "ALPHA" of 0.875.  rttvar has 2 bits to the right of the
2661541Srgrimes * binary point, and is smoothed with an ALPHA of 0.75.
2671541Srgrimes */
26814753Swollman#define	TCP_RTT_SCALE		32	/* multiplier for srtt; 3 bits frac. */
26914753Swollman#define	TCP_RTT_SHIFT		5	/* shift for srtt; 3 bits frac. */
27014753Swollman#define	TCP_RTTVAR_SCALE	16	/* multiplier for rttvar; 2 bits */
27114753Swollman#define	TCP_RTTVAR_SHIFT	4	/* shift for rttvar; 2 bits */
27214753Swollman#define	TCP_DELTA_SHIFT		2	/* see tcp_input.c */
2731541Srgrimes
2741541Srgrimes/*
2751541Srgrimes * The initial retransmission should happen at rtt + 4 * rttvar.
2761541Srgrimes * Because of the way we do the smoothing, srtt and rttvar
2771541Srgrimes * will each average +1/2 tick of bias.  When we compute
2781541Srgrimes * the retransmit timer, we want 1/2 tick of rounding and
2791541Srgrimes * 1 extra tick because of +-1/2 tick uncertainty in the
2801541Srgrimes * firing of the timer.  The bias will give us exactly the
2811541Srgrimes * 1.5 tick we need.  But, because the bias is
2821541Srgrimes * statistical, we have to test that we don't drop below
2831541Srgrimes * the minimum feasible timer (which is 2 ticks).
28414753Swollman * This version of the macro adapted from a paper by Lawrence
28514753Swollman * Brakmo and Larry Peterson which outlines a problem caused
28614753Swollman * by insufficient precision in the original implementation,
28714753Swollman * which results in inappropriately large RTO values for very
28814753Swollman * fast networks.
2891541Srgrimes */
2901541Srgrimes#define	TCP_REXMTVAL(tp) \
29135419Sdg	max((tp)->t_rttmin, (((tp)->t_srtt >> (TCP_RTT_SHIFT - TCP_DELTA_SHIFT))  \
29216141Swollman	  + (tp)->t_rttvar) >> TCP_DELTA_SHIFT)
2931541Srgrimes
2941541Srgrimes/*
2951541Srgrimes * TCP statistics.
2961541Srgrimes * Many of these should be kept per connection,
2971541Srgrimes * but that's inconvenient at the moment.
2981541Srgrimes */
2991541Srgrimesstruct	tcpstat {
3001541Srgrimes	u_long	tcps_connattempt;	/* connections initiated */
3011541Srgrimes	u_long	tcps_accepts;		/* connections accepted */
3021541Srgrimes	u_long	tcps_connects;		/* connections established */
3031541Srgrimes	u_long	tcps_drops;		/* connections dropped */
3041541Srgrimes	u_long	tcps_conndrops;		/* embryonic connections dropped */
3051541Srgrimes	u_long	tcps_closed;		/* conn. closed (includes drops) */
3061541Srgrimes	u_long	tcps_segstimed;		/* segs where we tried to get rtt */
3071541Srgrimes	u_long	tcps_rttupdated;	/* times we succeeded */
3081541Srgrimes	u_long	tcps_delack;		/* delayed acks sent */
3091541Srgrimes	u_long	tcps_timeoutdrop;	/* conn. dropped in rxmt timeout */
3101541Srgrimes	u_long	tcps_rexmttimeo;	/* retransmit timeouts */
3111541Srgrimes	u_long	tcps_persisttimeo;	/* persist timeouts */
3121541Srgrimes	u_long	tcps_keeptimeo;		/* keepalive timeouts */
3131541Srgrimes	u_long	tcps_keepprobe;		/* keepalive probes sent */
3141541Srgrimes	u_long	tcps_keepdrops;		/* connections dropped in keepalive */
3151541Srgrimes
3161541Srgrimes	u_long	tcps_sndtotal;		/* total packets sent */
3171541Srgrimes	u_long	tcps_sndpack;		/* data packets sent */
3181541Srgrimes	u_long	tcps_sndbyte;		/* data bytes sent */
3191541Srgrimes	u_long	tcps_sndrexmitpack;	/* data packets retransmitted */
3201541Srgrimes	u_long	tcps_sndrexmitbyte;	/* data bytes retransmitted */
321100373Sdillon	u_long	tcps_sndrexmitbad;	/* unnecessary packet retransmissions */
3221541Srgrimes	u_long	tcps_sndacks;		/* ack-only packets sent */
3231541Srgrimes	u_long	tcps_sndprobe;		/* window probes sent */
3241541Srgrimes	u_long	tcps_sndurg;		/* packets sent with URG only */
3251541Srgrimes	u_long	tcps_sndwinup;		/* window update-only packets sent */
3261541Srgrimes	u_long	tcps_sndctrl;		/* control (SYN|FIN|RST) packets sent */
3271541Srgrimes
3281541Srgrimes	u_long	tcps_rcvtotal;		/* total packets received */
3291541Srgrimes	u_long	tcps_rcvpack;		/* packets received in sequence */
3301541Srgrimes	u_long	tcps_rcvbyte;		/* bytes received in sequence */
3311541Srgrimes	u_long	tcps_rcvbadsum;		/* packets received with ccksum errs */
3321541Srgrimes	u_long	tcps_rcvbadoff;		/* packets received with bad offset */
33352904Sshin	u_long	tcps_rcvmemdrop;	/* packets dropped for lack of memory */
3341541Srgrimes	u_long	tcps_rcvshort;		/* packets received too short */
3351541Srgrimes	u_long	tcps_rcvduppack;	/* duplicate-only packets received */
3361541Srgrimes	u_long	tcps_rcvdupbyte;	/* duplicate-only bytes received */
3371541Srgrimes	u_long	tcps_rcvpartduppack;	/* packets with some duplicate data */
3381541Srgrimes	u_long	tcps_rcvpartdupbyte;	/* dup. bytes in part-dup. packets */
3391541Srgrimes	u_long	tcps_rcvoopack;		/* out-of-order packets received */
3401541Srgrimes	u_long	tcps_rcvoobyte;		/* out-of-order bytes received */
3411541Srgrimes	u_long	tcps_rcvpackafterwin;	/* packets with data after window */
3421541Srgrimes	u_long	tcps_rcvbyteafterwin;	/* bytes rcvd after window */
3431541Srgrimes	u_long	tcps_rcvafterclose;	/* packets rcvd after "close" */
3441541Srgrimes	u_long	tcps_rcvwinprobe;	/* rcvd window probe packets */
3451541Srgrimes	u_long	tcps_rcvdupack;		/* rcvd duplicate acks */
3461541Srgrimes	u_long	tcps_rcvacktoomuch;	/* rcvd acks for unsent data */
3471541Srgrimes	u_long	tcps_rcvackpack;	/* rcvd ack packets */
3481541Srgrimes	u_long	tcps_rcvackbyte;	/* bytes acked by rcvd acks */
3491541Srgrimes	u_long	tcps_rcvwinupd;		/* rcvd window update packets */
3501541Srgrimes	u_long	tcps_pawsdrop;		/* segments dropped due to PAWS */
3511541Srgrimes	u_long	tcps_predack;		/* times hdr predict ok for acks */
3521541Srgrimes	u_long	tcps_preddat;		/* times hdr predict ok for data pkts */
3531541Srgrimes	u_long	tcps_pcbcachemiss;
3549263Swollman	u_long	tcps_cachedrtt;		/* times cached RTT in route updated */
3559263Swollman	u_long	tcps_cachedrttvar;	/* times cached rttvar updated */
3569263Swollman	u_long	tcps_cachedssthresh;	/* times cached ssthresh updated */
3579470Swollman	u_long	tcps_usedrtt;		/* times RTT initialized from route */
3589470Swollman	u_long	tcps_usedrttvar;	/* times RTTVAR initialized from rt */
3599470Swollman	u_long	tcps_usedssthresh;	/* times ssthresh initialized from rt*/
36010937Swollman	u_long	tcps_persistdrop;	/* timeout in persist state */
36110937Swollman	u_long	tcps_badsyn;		/* bogus SYN, e.g. premature ACK */
36211415Swollman	u_long	tcps_mturesent;		/* resends due to MTU discovery */
36314281Sbde	u_long	tcps_listendrop;	/* listen queue overflows */
36486764Sjlemon
36586764Sjlemon	u_long	tcps_sc_added;		/* entry added to syncache */
36686764Sjlemon	u_long	tcps_sc_retransmitted;	/* syncache entry was retransmitted */
36786764Sjlemon	u_long	tcps_sc_dupsyn;		/* duplicate SYN packet */
36886764Sjlemon	u_long	tcps_sc_dropped;	/* could not reply to packet */
36986764Sjlemon	u_long	tcps_sc_completed;	/* successful extraction of entry */
37086764Sjlemon	u_long	tcps_sc_bucketoverflow;	/* syncache per-bucket limit hit */
37186764Sjlemon	u_long	tcps_sc_cacheoverflow;	/* syncache cache limit hit */
37286764Sjlemon	u_long	tcps_sc_reset;		/* RST removed entry from syncache */
37386764Sjlemon	u_long	tcps_sc_stale;		/* timed out or listen socket gone */
37486764Sjlemon	u_long	tcps_sc_aborted;	/* syncache entry aborted */
37586764Sjlemon	u_long	tcps_sc_badack;		/* removed due to bad ACK */
37686764Sjlemon	u_long	tcps_sc_unreach;	/* ICMP unreachable received */
37786764Sjlemon	u_long	tcps_sc_zonefail;	/* zalloc() failed */
37886764Sjlemon	u_long	tcps_sc_sendcookie;	/* SYN cookie sent */
37986764Sjlemon	u_long	tcps_sc_recvcookie;	/* SYN cookie received */
3801541Srgrimes};
3811541Srgrimes
3826247Swollman/*
38336079Swollman * TCB structure exported to user-land via sysctl(3).
38437183Sjhay * Evil hack: declare only if in_pcb.h and sys/socketvar.h have been
38537183Sjhay * included.  Not all of our clients do.
38636079Swollman */
38737183Sjhay#if defined(_NETINET_IN_PCB_H_) && defined(_SYS_SOCKETVAR_H_)
38836079Swollmanstruct	xtcpcb {
38936079Swollman	size_t	xt_len;
39036079Swollman	struct	inpcb	xt_inp;
39136079Swollman	struct	tcpcb	xt_tp;
39236079Swollman	struct	xsocket	xt_socket;
39336079Swollman	u_quad_t	xt_alignment_hack;
39436079Swollman};
39536079Swollman#endif
39636079Swollman
39736079Swollman/*
3986247Swollman * Names for TCP sysctl objects
3996247Swollman */
4006247Swollman#define	TCPCTL_DO_RFC1323	1	/* use RFC-1323 extensions */
4016247Swollman#define	TCPCTL_DO_RFC1644	2	/* use RFC-1644 extensions */
4026247Swollman#define	TCPCTL_MSSDFLT		3	/* MSS default */
4036472Swollman#define TCPCTL_STATS		4	/* statistics (read-only) */
4046472Swollman#define	TCPCTL_RTTDFLT		5	/* default RTT estimate */
4056472Swollman#define	TCPCTL_KEEPIDLE		6	/* keepalive idle timer */
4066472Swollman#define	TCPCTL_KEEPINTVL	7	/* interval to send keepalives */
40718281Spst#define	TCPCTL_SENDSPACE	8	/* send buffer space */
40818281Spst#define	TCPCTL_RECVSPACE	9	/* receive buffer space */
40963431Ssheldonh#define	TCPCTL_KEEPINIT		10	/* timeout for establishing syn */
41036079Swollman#define	TCPCTL_PCBLIST		11	/* list of all outstanding PCBs */
41150673Sjlemon#define	TCPCTL_DELACKTIME	12	/* time before sending delayed ACK */
41252904Sshin#define	TCPCTL_V6MSSDFLT	13	/* MSS default for IPv6 */
41352904Sshin#define	TCPCTL_MAXID		14
4146247Swollman
4156247Swollman#define TCPCTL_NAMES { \
4166247Swollman	{ 0, 0 }, \
4176348Swollman	{ "rfc1323", CTLTYPE_INT }, \
4186348Swollman	{ "rfc1644", CTLTYPE_INT }, \
4196247Swollman	{ "mssdflt", CTLTYPE_INT }, \
4206472Swollman	{ "stats", CTLTYPE_STRUCT }, \
4216472Swollman	{ "rttdflt", CTLTYPE_INT }, \
4226472Swollman	{ "keepidle", CTLTYPE_INT }, \
4236472Swollman	{ "keepintvl", CTLTYPE_INT }, \
4246472Swollman	{ "sendspace", CTLTYPE_INT }, \
4256472Swollman	{ "recvspace", CTLTYPE_INT }, \
42618281Spst	{ "keepinit", CTLTYPE_INT }, \
42736079Swollman	{ "pcblist", CTLTYPE_STRUCT }, \
42850673Sjlemon	{ "delacktime", CTLTYPE_INT }, \
42952904Sshin	{ "v6mssdflt", CTLTYPE_INT }, \
4306247Swollman}
4316247Swollman
43244078Sdfr
43355205Speter#ifdef _KERNEL
43444078Sdfr#ifdef SYSCTL_DECL
43544078SdfrSYSCTL_DECL(_net_inet_tcp);
43644078Sdfr#endif
43744078Sdfr
4387684Sdgextern	struct inpcbhead tcb;		/* head of queue of active tcpcb's */
4397684Sdgextern	struct inpcbinfo tcbinfo;
4406348Swollmanextern	struct tcpstat tcpstat;	/* tcp statistics */
4417090Sbdeextern	int tcp_mssdflt;	/* XXX */
44233846Sdgextern	int tcp_delack_enabled;
44360067Sjlemonextern	int tcp_do_newreno;
44498204Ssilbyextern	int path_mtu_discovery;
44550673Sjlemonextern	int ss_fltsz;
44650673Sjlemonextern	int ss_fltsz_local;
4471541Srgrimes
44892723Salfredvoid	 tcp_canceltimers(struct tcpcb *);
4491541Srgrimesstruct tcpcb *
45092723Salfred	 tcp_close(struct tcpcb *);
45192723Salfredvoid	 tcp_ctlinput(int, struct sockaddr *, void *);
45292723Salfredint	 tcp_ctloutput(struct socket *, struct sockopt *);
4531541Srgrimesstruct tcpcb *
45492723Salfred	 tcp_drop(struct tcpcb *, int);
45592723Salfredvoid	 tcp_drain(void);
45692723Salfredvoid	 tcp_fasttimo(void);
4576247Swollmanstruct rmxp_tao *
45892723Salfred	 tcp_gettaocache(struct in_conninfo *);
45992723Salfredvoid	 tcp_init(void);
46092723Salfredvoid	 tcp_input(struct mbuf *, int);
46192723Salfredvoid	 tcp_mss(struct tcpcb *, int);
46292723Salfredint	 tcp_mssopt(struct tcpcb *);
46398211Shsustruct inpcb *
46498211Shsu	 tcp_drop_syn_sent(struct inpcb *, int);
46598211Shsustruct inpcb *
46698211Shsu	 tcp_mtudisc(struct inpcb *, int);
4671541Srgrimesstruct tcpcb *
46892723Salfred	 tcp_newtcpcb(struct inpcb *);
46992723Salfredint	 tcp_output(struct tcpcb *);
47098211Shsustruct inpcb *
47198211Shsu	 tcp_quench(struct inpcb *, int);
47292723Salfredvoid	 tcp_respond(struct tcpcb *, void *,
47392723Salfred	    struct tcphdr *, struct mbuf *, tcp_seq, tcp_seq, int);
4746247Swollmanstruct rtentry *
47592723Salfred	 tcp_rtlookup(struct in_conninfo *);
47692723Salfredvoid	 tcp_setpersist(struct tcpcb *);
47792723Salfredvoid	 tcp_slowtimo(void);
47855679Sshinstruct tcptemp *
47992723Salfred	 tcp_maketemplate(struct tcpcb *);
48092723Salfredvoid	 tcp_fillheaders(struct tcpcb *, void *, void *);
4811541Srgrimesstruct tcpcb *
48292723Salfred	 tcp_timers(struct tcpcb *, int);
48392723Salfredvoid	 tcp_trace(int, int, struct tcpcb *, void *, struct tcphdr *, int);
484102017Sdillonvoid	 tcp_xmit_bandwidth_limit(struct tcpcb *tp, tcp_seq ack_seq);
48586764Sjlemonvoid	 syncache_init(void);
48686764Sjlemonvoid	 syncache_unreach(struct in_conninfo *, struct tcphdr *);
48786764Sjlemonint	 syncache_expand(struct in_conninfo *, struct tcphdr *,
48886764Sjlemon	     struct socket **, struct mbuf *);
48986764Sjlemonint	 syncache_add(struct in_conninfo *, struct tcpopt *,
49086764Sjlemon	     struct tcphdr *, struct socket **, struct mbuf *);
49186764Sjlemonvoid	 syncache_chkrst(struct in_conninfo *, struct tcphdr *);
49286764Sjlemonvoid	 syncache_badack(struct in_conninfo *);
4939470Swollman
49417096Swollmanextern	struct pr_usrreqs tcp_usrreqs;
4959470Swollmanextern	u_long tcp_sendspace;
4969470Swollmanextern	u_long tcp_recvspace;
49792723Salfredtcp_seq tcp_new_isn(struct tcpcb *);
4989470Swollman
49955205Speter#endif /* _KERNEL */
5002169Spaul
5016348Swollman#endif /* _NETINET_TCP_VAR_H_ */
502