tcp_var.h revision 224151
1139823Simp/*-
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 * 4. Neither the name of the University nor the names of its contributors
141541Srgrimes *    may be used to endorse or promote products derived from this software
151541Srgrimes *    without specific prior written permission.
161541Srgrimes *
171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271541Srgrimes * SUCH DAMAGE.
281541Srgrimes *
2910937Swollman *	@(#)tcp_var.h	8.4 (Berkeley) 5/24/95
3050477Speter * $FreeBSD: head/sys/netinet/tcp_var.h 224151 2011-07-17 21:15:20Z bz $
311541Srgrimes */
321541Srgrimes
332169Spaul#ifndef _NETINET_TCP_VAR_H_
342169Spaul#define _NETINET_TCP_VAR_H_
3586764Sjlemon
3698102Shsu#include <netinet/tcp.h>
3786764Sjlemon
38195699Srwatson#ifdef _KERNEL
39195699Srwatson#include <net/vnet.h>
40191688Szec
411541Srgrimes/*
421541Srgrimes * Kernel variables for tcp.
431541Srgrimes */
44195699SrwatsonVNET_DECLARE(int, tcp_do_rfc1323);
45207369Sbz#define	V_tcp_do_rfc1323	VNET(tcp_do_rfc1323)
46207369Sbz
47195699Srwatson#endif /* _KERNEL */
48195699Srwatson
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
58130989Spsstruct sackblk {
59130989Sps	tcp_seq start;		/* start seq no. of sack block */
60131078Sbms	tcp_seq end;		/* end seq no. */
61130989Sps};
62130989Sps
63130989Spsstruct sackhole {
64130989Sps	tcp_seq start;		/* start seq no. of hole */
65130989Sps	tcp_seq end;		/* end seq no. */
66130989Sps	tcp_seq rxmit;		/* next seq. no in hole to be retransmitted */
67145370Sps	TAILQ_ENTRY(sackhole) scblink;	/* scoreboard linkage */
68130989Sps};
69131078Sbms
70146123Spsstruct sackhint {
71146123Sps	struct sackhole	*nexthole;
72146123Sps	int		sack_bytes_rexmit;
73216753Slstewart	tcp_seq		last_sack_ack;	/* Most recent/largest sacked ack */
74195634Slstewart
75195634Slstewart	int		ispare;		/* explicit pad for 64bit alignment */
76195634Slstewart	uint64_t	_pad[2];	/* 1 sacked_bytes, 1 TBD */
77146123Sps};
78146123Sps
7955679Sshinstruct tcptemp {
8055679Sshin	u_char	tt_ipgen[40]; /* the size must be of max ip header, now IPv6 */
8155679Sshin	struct	tcphdr tt_t;
8255679Sshin};
8355679Sshin
8455679Sshin#define tcp6cb		tcpcb  /* for KAME src sync over BSD*'s */
8555679Sshin
86169541Sandre/* Neighbor Discovery, Neighbor Unreachability Detection Upper layer hint. */
87169541Sandre#ifdef INET6
88169541Sandre#define ND6_HINT(tp)						\
89169541Sandredo {								\
90169541Sandre	if ((tp) && (tp)->t_inpcb &&				\
91169541Sandre	    ((tp)->t_inpcb->inp_vflag & INP_IPV6) != 0)		\
92169541Sandre		nd6_nud_hint(NULL, NULL, 0);			\
93169541Sandre} while (0)
94169541Sandre#else
95169541Sandre#define ND6_HINT(tp)
96169541Sandre#endif
97169541Sandre
981541Srgrimes/*
991541Srgrimes * Tcp control block, one per tcp; fields:
10032821Sdg * Organized for 16 byte cacheline efficiency.
1011541Srgrimes */
1021541Srgrimesstruct tcpcb {
103126193Sandre	struct	tsegqe_head t_segq;	/* segment reassembly queue */
104195634Slstewart	void	*t_pspare[2];		/* new reassembly queue */
105126193Sandre	int	t_segqlen;		/* segment reassembly queue length */
10632821Sdg	int	t_dupacks;		/* consecutive dup acks recd */
10732821Sdg
108172309Ssilby	struct tcp_timer *t_timers;	/* All the TCP timers in one struct */
10932821Sdg
11032821Sdg	struct	inpcb *t_inpcb;		/* back pointer to internet pcb */
11111187Swollman	int	t_state;		/* state of this connection */
11211187Swollman	u_int	t_flags;
1131541Srgrimes
114191688Szec	struct	vnet *t_vnet;		/* back pointer to parent vnet */
115191688Szec
1161541Srgrimes	tcp_seq	snd_una;		/* send unacknowledged */
11732821Sdg	tcp_seq	snd_max;		/* highest sequence number sent;
11832821Sdg					 * used to recognize retransmits
11932821Sdg					 */
1201541Srgrimes	tcp_seq	snd_nxt;		/* send next */
1211541Srgrimes	tcp_seq	snd_up;			/* send urgent pointer */
12232821Sdg
1231541Srgrimes	tcp_seq	snd_wl1;		/* window update seg seq number */
1241541Srgrimes	tcp_seq	snd_wl2;		/* window update seg ack number */
1251541Srgrimes	tcp_seq	iss;			/* initial send sequence number */
12632821Sdg	tcp_seq	irs;			/* initial receive sequence number */
12732821Sdg
12832821Sdg	tcp_seq	rcv_nxt;		/* receive next */
12932821Sdg	tcp_seq	rcv_adv;		/* advertised window */
1301541Srgrimes	u_long	rcv_wnd;		/* receive window */
1311541Srgrimes	tcp_seq	rcv_up;			/* receive urgent pointer */
13232821Sdg
13332821Sdg	u_long	snd_wnd;		/* send window */
1341541Srgrimes	u_long	snd_cwnd;		/* congestion-controlled window */
135212765Sandre	u_long	snd_spare1;		/* unused */
13613765Smpp	u_long	snd_ssthresh;		/* snd_cwnd size threshold for
1371541Srgrimes					 * for slow start exponential to
1381541Srgrimes					 * linear switch
1391541Srgrimes					 */
140212765Sandre	u_long	snd_spare2;		/* unused */
141109175Shsu	tcp_seq	snd_recover;		/* for use in NewReno Fast Recovery */
14260067Sjlemon
14332821Sdg	u_int	t_maxopd;		/* mss plus options */
14432821Sdg
145194303Sjhb	u_int	t_rcvtime;		/* inactivity time */
146194303Sjhb	u_int	t_starttime;		/* time connection was established */
147194303Sjhb	u_int	t_rtttime;		/* RTT measurement start time */
1481541Srgrimes	tcp_seq	t_rtseq;		/* sequence number being timed */
14932821Sdg
150212765Sandre	u_int	t_bw_spare1;		/* unused */
151212765Sandre	tcp_seq	t_bw_spare2;		/* unused */
152102017Sdillon
15350673Sjlemon	int	t_rxtcur;		/* current retransmit value (ticks) */
15432821Sdg	u_int	t_maxseg;		/* maximum segment size */
15511187Swollman	int	t_srtt;			/* smoothed round-trip time */
15611187Swollman	int	t_rttvar;		/* variance in round-trip time */
15732821Sdg
15832821Sdg	int	t_rxtshift;		/* log(2) of rexmt exp. backoff */
15911187Swollman	u_int	t_rttmin;		/* minimum rtt allowed */
160102017Sdillon	u_int	t_rttbest;		/* best rtt we've seen */
16132821Sdg	u_long	t_rttupdated;		/* number of times rtt sampled */
1621541Srgrimes	u_long	max_sndwnd;		/* largest window peer has offered */
1631541Srgrimes
16432821Sdg	int	t_softerror;		/* possible error not yet reported */
1651541Srgrimes/* out-of-band data */
1661541Srgrimes	char	t_oobflags;		/* have some */
1671541Srgrimes	char	t_iobc;			/* input character */
1681541Srgrimes/* RFC 1323 variables */
1691541Srgrimes	u_char	snd_scale;		/* window scaling for send window */
1701541Srgrimes	u_char	rcv_scale;		/* window scaling for recv window */
1711541Srgrimes	u_char	request_r_scale;	/* pending window scaling */
172162277Sandre	u_int32_t  ts_recent;		/* timestamp echo data */
173194303Sjhb	u_int	ts_recent_age;		/* when last updated */
174162277Sandre	u_int32_t  ts_offset;		/* our timestamp offset */
17532821Sdg
1761541Srgrimes	tcp_seq	last_ack_sent;
17750673Sjlemon/* experimental */
17850673Sjlemon	u_long	snd_cwnd_prev;		/* cwnd prior to retransmit */
17950673Sjlemon	u_long	snd_ssthresh_prev;	/* ssthresh prior to retransmit */
180117650Shsu	tcp_seq	snd_recover_prev;	/* snd_recover prior to retransmit */
181215434Sgnn	int	t_sndzerowin;		/* zero-window updates sent */
182194303Sjhb	u_int	t_badrxtwin;		/* window for retransmit recovery */
183112957Shsu	u_char	snd_limited;		/* segments limited transmitted */
184131078Sbms/* SACK related state */
185130989Sps	int	snd_numholes;		/* number of holes seen by sender */
186146953Sps	TAILQ_HEAD(sackhole_head, sackhole) snd_holes;
187146953Sps					/* SACK scoreboard (sorted) */
188146630Sps	tcp_seq	snd_fack;		/* last seq number(+1) sack'd by rcv'r*/
189130989Sps	int	rcv_numsacks;		/* # distinct sack blks present */
190130989Sps	struct sackblk sackblks[MAX_SACK_BLKS]; /* seq nos. of sack blocks */
191136151Sps	tcp_seq sack_newdata;		/* New data xmitted in this recovery
192136151Sps					   episode starts at this seq number */
193146123Sps	struct sackhint	sackhint;	/* SACK scoreboard hint */
194155767Sandre	int	t_rttlow;		/* smallest observerved RTT */
195166405Sandre	u_int32_t	rfbuf_ts;	/* recv buffer autoscaling timestamp */
196166405Sandre	int	rfbuf_cnt;		/* recv buffer autoscaling byte count */
197191688Szec	struct toe_usrreqs *t_tu;	/* offload operations vector */
198215434Sgnn	int	t_sndrexmitpack;	/* retransmit packets sent */
199215434Sgnn	int	t_rcvoopack;		/* out-of-order packets received */
200174560Skmacy	void	*t_toe;			/* TOE pcb pointer */
201187289Slstewart	int	t_bytes_acked;		/* # bytes acked during current RTT */
202215166Slstewart	struct cc_algo	*cc_algo;	/* congestion control algorithm */
203216760Slstewart	struct cc_var	*ccv;		/* congestion control specific vars */
204216758Slstewart	struct osd	*osd;		/* storage for Khelp module data */
205195634Slstewart
206224151Sbz	uint32_t t_ispare[12];		/* 4 keep timers, 5 UTO, 3 TBD */
207215166Slstewart	void	*t_pspare2[4];		/* 4 TBD */
208224151Sbz	uint64_t _pad[6];		/* 6 TBD (1-2 CC/RTT?) */
2091541Srgrimes};
2101541Srgrimes
211185855Srwatson/*
212185855Srwatson * Flags and utility macros for the t_flags field.
213185855Srwatson */
214185855Srwatson#define	TF_ACKNOW	0x000001	/* ack peer immediately */
215185855Srwatson#define	TF_DELACK	0x000002	/* ack, but try to delay it */
216185855Srwatson#define	TF_NODELAY	0x000004	/* don't delay packets to coalesce */
217185855Srwatson#define	TF_NOOPT	0x000008	/* don't use tcp options */
218185855Srwatson#define	TF_SENTFIN	0x000010	/* have sent FIN */
219185855Srwatson#define	TF_REQ_SCALE	0x000020	/* have/will request window scaling */
220185855Srwatson#define	TF_RCVD_SCALE	0x000040	/* other side has requested scaling */
221185855Srwatson#define	TF_REQ_TSTMP	0x000080	/* have/will request timestamps */
222185855Srwatson#define	TF_RCVD_TSTMP	0x000100	/* a timestamp was received in SYN */
223185855Srwatson#define	TF_SACK_PERMIT	0x000200	/* other side said I could SACK */
224185855Srwatson#define	TF_NEEDSYN	0x000400	/* send SYN (implicit state) */
225185855Srwatson#define	TF_NEEDFIN	0x000800	/* send FIN (implicit state) */
226185855Srwatson#define	TF_NOPUSH	0x001000	/* don't push */
227221209Sjhb#define	TF_PREVVALID	0x002000	/* saved values for bad rxmit valid */
228185855Srwatson#define	TF_MORETOCOME	0x010000	/* More data to be appended to sock */
229185855Srwatson#define	TF_LQ_OVERFLOW	0x020000	/* listen queue overflow */
230185855Srwatson#define	TF_LASTIDLE	0x040000	/* connection was previously idle */
231185855Srwatson#define	TF_RXWIN0SENT	0x080000	/* sent a receiver win 0 in response */
232185855Srwatson#define	TF_FASTRECOVERY	0x100000	/* in NewReno Fast Recovery */
233185855Srwatson#define	TF_WASFRECOVERY	0x200000	/* was in NewReno Fast Recovery */
234185855Srwatson#define	TF_SIGNATURE	0x400000	/* require MD5 digests (RFC2385) */
235185855Srwatson#define	TF_FORCEDATA	0x800000	/* force out a byte */
236185855Srwatson#define	TF_TSO		0x1000000	/* TSO enabled on this connection */
237185855Srwatson#define	TF_TOE		0x2000000	/* this connection is offloaded */
238185855Srwatson#define	TF_ECN_PERMIT	0x4000000	/* connection ECN-ready */
239185855Srwatson#define	TF_ECN_SND_CWR	0x8000000	/* ECN CWR in queue */
240185855Srwatson#define	TF_ECN_SND_ECE	0x10000000	/* ECN ECE in queue */
241215166Slstewart#define	TF_CONGRECOVERY	0x20000000	/* congestion recovery mode */
242215166Slstewart#define	TF_WASCRECOVERY	0x40000000	/* was in congestion recovery */
243185855Srwatson
244215166Slstewart#define	IN_FASTRECOVERY(t_flags)	(t_flags & TF_FASTRECOVERY)
245215166Slstewart#define	ENTER_FASTRECOVERY(t_flags)	t_flags |= TF_FASTRECOVERY
246215166Slstewart#define	EXIT_FASTRECOVERY(t_flags)	t_flags &= ~TF_FASTRECOVERY
247117650Shsu
248215166Slstewart#define	IN_CONGRECOVERY(t_flags)	(t_flags & TF_CONGRECOVERY)
249215166Slstewart#define	ENTER_CONGRECOVERY(t_flags)	t_flags |= TF_CONGRECOVERY
250215166Slstewart#define	EXIT_CONGRECOVERY(t_flags)	t_flags &= ~TF_CONGRECOVERY
251215166Slstewart
252215166Slstewart#define	IN_RECOVERY(t_flags) (t_flags & (TF_CONGRECOVERY | TF_FASTRECOVERY))
253215166Slstewart#define	ENTER_RECOVERY(t_flags) t_flags |= (TF_CONGRECOVERY | TF_FASTRECOVERY)
254215166Slstewart#define	EXIT_RECOVERY(t_flags) t_flags &= ~(TF_CONGRECOVERY | TF_FASTRECOVERY)
255215166Slstewart
256215166Slstewart#define	BYTES_THIS_ACK(tp, th)	(th->th_ack - tp->snd_una)
257215166Slstewart
258185855Srwatson/*
259185855Srwatson * Flags for the t_oobflags field.
260185855Srwatson */
261185855Srwatson#define	TCPOOB_HAVEDATA	0x01
262185855Srwatson#define	TCPOOB_HADDATA	0x02
263185855Srwatson
264125680Sbms#ifdef TCP_SIGNATURE
2656247Swollman/*
266125680Sbms * Defines which are needed by the xform_tcp module and tcp_[in|out]put
267125680Sbms * for SADB verification and lookup.
268125680Sbms */
269125680Sbms#define	TCP_SIGLEN	16	/* length of computed digest in bytes */
270125680Sbms#define	TCP_KEYLEN_MIN	1	/* minimum length of TCP-MD5 key */
271125680Sbms#define	TCP_KEYLEN_MAX	80	/* maximum length of TCP-MD5 key */
272125680Sbms/*
273125680Sbms * Only a single SA per host may be specified at this time. An SPI is
274125680Sbms * needed in order for the KEY_ALLOCSA() lookup to work.
275125680Sbms */
276125680Sbms#define	TCP_SIG_SPI	0x1000
277125680Sbms#endif /* TCP_SIGNATURE */
278125680Sbms
279125680Sbms/*
2806247Swollman * Structure to hold TCP options that are only used during segment
2816247Swollman * processing (in tcp_input), but not held in the tcpcb.
2826247Swollman * It's basically used to reduce the number of parameters
283167606Sandre * to tcp_dooptions and tcp_addoptions.
284167606Sandre * The binary order of the to_flags is relevant for packing of the
285167606Sandre * options in tcp_addoptions.
2866247Swollman */
2876247Swollmanstruct tcpopt {
288195654Slstewart	u_int64_t	to_flags;	/* which options are present */
289167606Sandre#define	TOF_MSS		0x0001		/* maximum segment size */
290167606Sandre#define	TOF_SCALE	0x0002		/* window scaling */
291178349Sbz#define	TOF_SACKPERM	0x0004		/* SACK permitted */
292167606Sandre#define	TOF_TS		0x0010		/* timestamp */
293178349Sbz#define	TOF_SIGNATURE	0x0040		/* TCP-MD5 signature option (RFC2385) */
294168906Sandre#define	TOF_SACK	0x0080		/* Peer sent SACK option */
295168906Sandre#define	TOF_MAXOPT	0x0100
296168906Sandre	u_int32_t	to_tsval;	/* new timestamp */
297167606Sandre	u_int32_t	to_tsecr;	/* reflected timestamp */
298195654Slstewart	u_char		*to_sacks;	/* pointer to the first SACK blocks */
299195654Slstewart	u_char		*to_signature;	/* pointer to the TCP-MD5 signature */
300167606Sandre	u_int16_t	to_mss;		/* maximum segment size */
301167606Sandre	u_int8_t	to_wscale;	/* window scaling */
302147637Sps	u_int8_t	to_nsacks;	/* number of SACK blocks */
303224151Sbz	u_int32_t	to_spare;	/* UTO */
3046247Swollman};
3056247Swollman
306159949Sandre/*
307159949Sandre * Flags for tcp_dooptions.
308159949Sandre */
309159949Sandre#define	TO_SYN		0x01		/* parse SYN-only options */
310159949Sandre
311122922Sandrestruct hc_metrics_lite {	/* must stay in sync with hc_metrics */
312122922Sandre	u_long	rmx_mtu;	/* MTU for this path */
313122922Sandre	u_long	rmx_ssthresh;	/* outbound gateway buffer limit */
314122922Sandre	u_long	rmx_rtt;	/* estimated round trip time */
315122922Sandre	u_long	rmx_rttvar;	/* estimated rtt variance */
316122922Sandre	u_long	rmx_bandwidth;	/* estimated bandwidth */
317122922Sandre	u_long	rmx_cwnd;	/* congestion window */
318122922Sandre	u_long	rmx_sendpipe;   /* outbound delay-bandwidth product */
319122922Sandre	u_long	rmx_recvpipe;   /* inbound delay-bandwidth product */
320122922Sandre};
321122922Sandre
322159725Sandre#ifndef _NETINET_IN_PCB_H_
323159725Sandrestruct in_conninfo;
324159725Sandre#endif /* _NETINET_IN_PCB_H_ */
325159725Sandre
326111145Sjlemonstruct tcptw {
327111145Sjlemon	struct inpcb	*tw_inpcb;	/* XXX back pointer to internet pcb */
328111145Sjlemon	tcp_seq		snd_nxt;
329111145Sjlemon	tcp_seq		rcv_nxt;
330121850Ssilby	tcp_seq		iss;
331121884Ssilby	tcp_seq		irs;
332111145Sjlemon	u_short		last_win;	/* cached window value */
333111145Sjlemon	u_short		tw_so_options;	/* copy of so_options */
334111145Sjlemon	struct ucred	*tw_cred;	/* user credentials */
335194303Sjhb	u_int32_t	t_recent;
336169477Sandre	u_int32_t	ts_offset;	/* our timestamp offset */
337194303Sjhb	u_int		t_starttime;
338112009Sjlemon	int		tw_time;
339162111Sru	TAILQ_ENTRY(tcptw) tw_2msl;
340111145Sjlemon};
341133874Srwatson
3421541Srgrimes#define	intotcpcb(ip)	((struct tcpcb *)(ip)->inp_ppcb)
343111145Sjlemon#define	intotw(ip)	((struct tcptw *)(ip)->inp_ppcb)
3441541Srgrimes#define	sototcpcb(so)	(intotcpcb(sotoinpcb(so)))
3451541Srgrimes
3461541Srgrimes/*
3471541Srgrimes * The smoothed round-trip time and estimated variance
3481541Srgrimes * are stored as fixed point numbers scaled by the values below.
3491541Srgrimes * For convenience, these scales are also used in smoothing the average
3501541Srgrimes * (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed).
3511541Srgrimes * With these scales, srtt has 3 bits to the right of the binary point,
3521541Srgrimes * and thus an "ALPHA" of 0.875.  rttvar has 2 bits to the right of the
3531541Srgrimes * binary point, and is smoothed with an ALPHA of 0.75.
3541541Srgrimes */
35514753Swollman#define	TCP_RTT_SCALE		32	/* multiplier for srtt; 3 bits frac. */
35614753Swollman#define	TCP_RTT_SHIFT		5	/* shift for srtt; 3 bits frac. */
35714753Swollman#define	TCP_RTTVAR_SCALE	16	/* multiplier for rttvar; 2 bits */
35814753Swollman#define	TCP_RTTVAR_SHIFT	4	/* shift for rttvar; 2 bits */
35914753Swollman#define	TCP_DELTA_SHIFT		2	/* see tcp_input.c */
3601541Srgrimes
3611541Srgrimes/*
3621541Srgrimes * The initial retransmission should happen at rtt + 4 * rttvar.
3631541Srgrimes * Because of the way we do the smoothing, srtt and rttvar
3641541Srgrimes * will each average +1/2 tick of bias.  When we compute
3651541Srgrimes * the retransmit timer, we want 1/2 tick of rounding and
3661541Srgrimes * 1 extra tick because of +-1/2 tick uncertainty in the
3671541Srgrimes * firing of the timer.  The bias will give us exactly the
3681541Srgrimes * 1.5 tick we need.  But, because the bias is
3691541Srgrimes * statistical, we have to test that we don't drop below
3701541Srgrimes * the minimum feasible timer (which is 2 ticks).
37114753Swollman * This version of the macro adapted from a paper by Lawrence
37214753Swollman * Brakmo and Larry Peterson which outlines a problem caused
37314753Swollman * by insufficient precision in the original implementation,
37414753Swollman * which results in inappropriately large RTO values for very
37514753Swollman * fast networks.
3761541Srgrimes */
3771541Srgrimes#define	TCP_REXMTVAL(tp) \
37835419Sdg	max((tp)->t_rttmin, (((tp)->t_srtt >> (TCP_RTT_SHIFT - TCP_DELTA_SHIFT))  \
37916141Swollman	  + (tp)->t_rttvar) >> TCP_DELTA_SHIFT)
3801541Srgrimes
3811541Srgrimes/*
3821541Srgrimes * TCP statistics.
3831541Srgrimes * Many of these should be kept per connection,
3841541Srgrimes * but that's inconvenient at the moment.
3851541Srgrimes */
3861541Srgrimesstruct	tcpstat {
3871541Srgrimes	u_long	tcps_connattempt;	/* connections initiated */
3881541Srgrimes	u_long	tcps_accepts;		/* connections accepted */
3891541Srgrimes	u_long	tcps_connects;		/* connections established */
3901541Srgrimes	u_long	tcps_drops;		/* connections dropped */
3911541Srgrimes	u_long	tcps_conndrops;		/* embryonic connections dropped */
392124258Sandre	u_long	tcps_minmssdrops;	/* average minmss too low drops */
3931541Srgrimes	u_long	tcps_closed;		/* conn. closed (includes drops) */
3941541Srgrimes	u_long	tcps_segstimed;		/* segs where we tried to get rtt */
3951541Srgrimes	u_long	tcps_rttupdated;	/* times we succeeded */
3961541Srgrimes	u_long	tcps_delack;		/* delayed acks sent */
3971541Srgrimes	u_long	tcps_timeoutdrop;	/* conn. dropped in rxmt timeout */
3981541Srgrimes	u_long	tcps_rexmttimeo;	/* retransmit timeouts */
3991541Srgrimes	u_long	tcps_persisttimeo;	/* persist timeouts */
4001541Srgrimes	u_long	tcps_keeptimeo;		/* keepalive timeouts */
4011541Srgrimes	u_long	tcps_keepprobe;		/* keepalive probes sent */
4021541Srgrimes	u_long	tcps_keepdrops;		/* connections dropped in keepalive */
4031541Srgrimes
4041541Srgrimes	u_long	tcps_sndtotal;		/* total packets sent */
4051541Srgrimes	u_long	tcps_sndpack;		/* data packets sent */
4061541Srgrimes	u_long	tcps_sndbyte;		/* data bytes sent */
4071541Srgrimes	u_long	tcps_sndrexmitpack;	/* data packets retransmitted */
4081541Srgrimes	u_long	tcps_sndrexmitbyte;	/* data bytes retransmitted */
409100373Sdillon	u_long	tcps_sndrexmitbad;	/* unnecessary packet retransmissions */
4101541Srgrimes	u_long	tcps_sndacks;		/* ack-only packets sent */
4111541Srgrimes	u_long	tcps_sndprobe;		/* window probes sent */
4121541Srgrimes	u_long	tcps_sndurg;		/* packets sent with URG only */
4131541Srgrimes	u_long	tcps_sndwinup;		/* window update-only packets sent */
4141541Srgrimes	u_long	tcps_sndctrl;		/* control (SYN|FIN|RST) packets sent */
4151541Srgrimes
4161541Srgrimes	u_long	tcps_rcvtotal;		/* total packets received */
4171541Srgrimes	u_long	tcps_rcvpack;		/* packets received in sequence */
4181541Srgrimes	u_long	tcps_rcvbyte;		/* bytes received in sequence */
4191541Srgrimes	u_long	tcps_rcvbadsum;		/* packets received with ccksum errs */
4201541Srgrimes	u_long	tcps_rcvbadoff;		/* packets received with bad offset */
42152904Sshin	u_long	tcps_rcvmemdrop;	/* packets dropped for lack of memory */
4221541Srgrimes	u_long	tcps_rcvshort;		/* packets received too short */
4231541Srgrimes	u_long	tcps_rcvduppack;	/* duplicate-only packets received */
4241541Srgrimes	u_long	tcps_rcvdupbyte;	/* duplicate-only bytes received */
4251541Srgrimes	u_long	tcps_rcvpartduppack;	/* packets with some duplicate data */
4261541Srgrimes	u_long	tcps_rcvpartdupbyte;	/* dup. bytes in part-dup. packets */
4271541Srgrimes	u_long	tcps_rcvoopack;		/* out-of-order packets received */
4281541Srgrimes	u_long	tcps_rcvoobyte;		/* out-of-order bytes received */
4291541Srgrimes	u_long	tcps_rcvpackafterwin;	/* packets with data after window */
4301541Srgrimes	u_long	tcps_rcvbyteafterwin;	/* bytes rcvd after window */
4311541Srgrimes	u_long	tcps_rcvafterclose;	/* packets rcvd after "close" */
4321541Srgrimes	u_long	tcps_rcvwinprobe;	/* rcvd window probe packets */
4331541Srgrimes	u_long	tcps_rcvdupack;		/* rcvd duplicate acks */
4341541Srgrimes	u_long	tcps_rcvacktoomuch;	/* rcvd acks for unsent data */
4351541Srgrimes	u_long	tcps_rcvackpack;	/* rcvd ack packets */
4361541Srgrimes	u_long	tcps_rcvackbyte;	/* bytes acked by rcvd acks */
4371541Srgrimes	u_long	tcps_rcvwinupd;		/* rcvd window update packets */
4381541Srgrimes	u_long	tcps_pawsdrop;		/* segments dropped due to PAWS */
4391541Srgrimes	u_long	tcps_predack;		/* times hdr predict ok for acks */
4401541Srgrimes	u_long	tcps_preddat;		/* times hdr predict ok for data pkts */
4411541Srgrimes	u_long	tcps_pcbcachemiss;
4429263Swollman	u_long	tcps_cachedrtt;		/* times cached RTT in route updated */
4439263Swollman	u_long	tcps_cachedrttvar;	/* times cached rttvar updated */
4449263Swollman	u_long	tcps_cachedssthresh;	/* times cached ssthresh updated */
4459470Swollman	u_long	tcps_usedrtt;		/* times RTT initialized from route */
4469470Swollman	u_long	tcps_usedrttvar;	/* times RTTVAR initialized from rt */
4479470Swollman	u_long	tcps_usedssthresh;	/* times ssthresh initialized from rt*/
44810937Swollman	u_long	tcps_persistdrop;	/* timeout in persist state */
44910937Swollman	u_long	tcps_badsyn;		/* bogus SYN, e.g. premature ACK */
45011415Swollman	u_long	tcps_mturesent;		/* resends due to MTU discovery */
45114281Sbde	u_long	tcps_listendrop;	/* listen queue overflows */
452128653Ssilby	u_long	tcps_badrst;		/* ignored RSTs in the window */
45386764Sjlemon
45486764Sjlemon	u_long	tcps_sc_added;		/* entry added to syncache */
45586764Sjlemon	u_long	tcps_sc_retransmitted;	/* syncache entry was retransmitted */
45686764Sjlemon	u_long	tcps_sc_dupsyn;		/* duplicate SYN packet */
45786764Sjlemon	u_long	tcps_sc_dropped;	/* could not reply to packet */
45886764Sjlemon	u_long	tcps_sc_completed;	/* successful extraction of entry */
45986764Sjlemon	u_long	tcps_sc_bucketoverflow;	/* syncache per-bucket limit hit */
46086764Sjlemon	u_long	tcps_sc_cacheoverflow;	/* syncache cache limit hit */
46186764Sjlemon	u_long	tcps_sc_reset;		/* RST removed entry from syncache */
46286764Sjlemon	u_long	tcps_sc_stale;		/* timed out or listen socket gone */
46386764Sjlemon	u_long	tcps_sc_aborted;	/* syncache entry aborted */
46486764Sjlemon	u_long	tcps_sc_badack;		/* removed due to bad ACK */
46586764Sjlemon	u_long	tcps_sc_unreach;	/* ICMP unreachable received */
46686764Sjlemon	u_long	tcps_sc_zonefail;	/* zalloc() failed */
46786764Sjlemon	u_long	tcps_sc_sendcookie;	/* SYN cookie sent */
46886764Sjlemon	u_long	tcps_sc_recvcookie;	/* SYN cookie received */
469122922Sandre
470122922Sandre	u_long	tcps_hc_added;		/* entry added to hostcache */
471122922Sandre	u_long	tcps_hc_bucketoverflow;	/* hostcache per bucket limit hit */
472130989Sps
473167036Smohans	u_long  tcps_finwait2_drops;    /* Drop FIN_WAIT_2 connection after time limit */
474167036Smohans
475130989Sps	/* SACK related stats */
476130989Sps	u_long	tcps_sack_recovery_episode; /* SACK recovery episodes */
477130989Sps	u_long  tcps_sack_rexmits;	    /* SACK rexmit segments   */
478133874Srwatson	u_long  tcps_sack_rexmit_bytes;	    /* SACK rexmit bytes      */
479130989Sps	u_long  tcps_sack_rcv_blocks;	    /* SACK blocks (options) received */
480130989Sps	u_long  tcps_sack_send_blocks;	    /* SACK blocks (options) sent     */
481217126Sjhb	u_long  tcps_sack_sboverflow;	    /* times scoreboard overflowed */
482181056Srpaulo
483181056Srpaulo	/* ECN related stats */
484181056Srpaulo	u_long	tcps_ecn_ce;		/* ECN Congestion Experienced */
485181056Srpaulo	u_long	tcps_ecn_ect0;		/* ECN Capable Transport */
486181056Srpaulo	u_long	tcps_ecn_ect1;		/* ECN Capable Transport */
487181056Srpaulo	u_long	tcps_ecn_shs;		/* ECN successful handshakes */
488181056Srpaulo	u_long	tcps_ecn_rcwnd;		/* # times ECN reduced the cwnd */
489195634Slstewart
490221023Sattilio	/* TCP_SIGNATURE related stats */
491221023Sattilio	u_long	tcps_sig_rcvgoodsig;	/* Total matching signature received */
492221023Sattilio	u_long	tcps_sig_rcvbadsig;	/* Total bad signature received */
493221023Sattilio	u_long	tcps_sig_err_buildsig;	/* Mismatching signature received */
494221023Sattilio	u_long	tcps_sig_err_sigopt;	/* No signature expected by socket */
495221023Sattilio	u_long	tcps_sig_err_nosigopt;	/* No signature provided by segment */
496221023Sattilio
497195634Slstewart	u_long	_pad[12];		/* 6 UTO, 6 TBD */
4981541Srgrimes};
4991541Srgrimes
500190978Srwatson#ifdef _KERNEL
501196039Srwatson/*
502196039Srwatson * In-kernel consumers can use these accessor macros directly to update
503196039Srwatson * stats.
504196039Srwatson */
505190948Srwatson#define	TCPSTAT_ADD(name, val)	V_tcpstat.name += (val)
506190948Srwatson#define	TCPSTAT_INC(name)	TCPSTAT_ADD(name, 1)
507196039Srwatson
508196039Srwatson/*
509196039Srwatson * Kernel module consumers must use this accessor macro.
510196039Srwatson */
511196039Srwatsonvoid	kmod_tcpstat_inc(int statnum);
512196039Srwatson#define	KMOD_TCPSTAT_INC(name)						\
513196039Srwatson	kmod_tcpstat_inc(offsetof(struct tcpstat, name) / sizeof(u_long))
514216758Slstewart
515216758Slstewart/*
516216758Slstewart * TCP specific helper hook point identifiers.
517216758Slstewart */
518216758Slstewart#define	HHOOK_TCP_EST_IN		0
519216758Slstewart#define	HHOOK_TCP_EST_OUT		1
520216758Slstewart#define	HHOOK_TCP_LAST			HHOOK_TCP_EST_OUT
521216758Slstewart
522216758Slstewartstruct tcp_hhook_data {
523217252Slstewart	struct tcpcb	*tp;
524217252Slstewart	struct tcphdr	*th;
525217252Slstewart	struct tcpopt	*to;
526217252Slstewart	long		len;
527217252Slstewart	int		tso;
528217252Slstewart	tcp_seq		curack;
529216758Slstewart};
530190978Srwatson#endif
531190948Srwatson
5326247Swollman/*
53336079Swollman * TCB structure exported to user-land via sysctl(3).
53437183Sjhay * Evil hack: declare only if in_pcb.h and sys/socketvar.h have been
53537183Sjhay * included.  Not all of our clients do.
53636079Swollman */
53737183Sjhay#if defined(_NETINET_IN_PCB_H_) && defined(_SYS_SOCKETVAR_H_)
538197244Ssilbystruct xtcp_timer {
539197244Ssilby	int tt_rexmt;	/* retransmit timer */
540197244Ssilby	int tt_persist;	/* retransmit persistence */
541197244Ssilby	int tt_keep;	/* keepalive */
542197244Ssilby	int tt_2msl;	/* 2*msl TIME_WAIT timer */
543197244Ssilby	int tt_delack;	/* delayed ACK timer */
544217126Sjhb	int t_rcvtime;	/* Time since last packet received */
545197244Ssilby};
54636079Swollmanstruct	xtcpcb {
54736079Swollman	size_t	xt_len;
54836079Swollman	struct	inpcb	xt_inp;
54936079Swollman	struct	tcpcb	xt_tp;
55036079Swollman	struct	xsocket	xt_socket;
551197244Ssilby	struct	xtcp_timer xt_timer;
55236079Swollman	u_quad_t	xt_alignment_hack;
55336079Swollman};
55436079Swollman#endif
55536079Swollman
55636079Swollman/*
5576247Swollman * Names for TCP sysctl objects
5586247Swollman */
5596247Swollman#define	TCPCTL_DO_RFC1323	1	/* use RFC-1323 extensions */
5606247Swollman#define	TCPCTL_MSSDFLT		3	/* MSS default */
5616472Swollman#define TCPCTL_STATS		4	/* statistics (read-only) */
5626472Swollman#define	TCPCTL_RTTDFLT		5	/* default RTT estimate */
5636472Swollman#define	TCPCTL_KEEPIDLE		6	/* keepalive idle timer */
5646472Swollman#define	TCPCTL_KEEPINTVL	7	/* interval to send keepalives */
56518281Spst#define	TCPCTL_SENDSPACE	8	/* send buffer space */
56618281Spst#define	TCPCTL_RECVSPACE	9	/* receive buffer space */
56763431Ssheldonh#define	TCPCTL_KEEPINIT		10	/* timeout for establishing syn */
56836079Swollman#define	TCPCTL_PCBLIST		11	/* list of all outstanding PCBs */
56950673Sjlemon#define	TCPCTL_DELACKTIME	12	/* time before sending delayed ACK */
57052904Sshin#define	TCPCTL_V6MSSDFLT	13	/* MSS default for IPv6 */
571130989Sps#define	TCPCTL_SACK		14	/* Selective Acknowledgement,rfc 2018 */
572141381Smaxim#define	TCPCTL_DROP		15	/* drop tcp connection */
573141381Smaxim#define	TCPCTL_MAXID		16
574167036Smohans#define TCPCTL_FINWAIT2_TIMEOUT        17
5756247Swollman
5766247Swollman#define TCPCTL_NAMES { \
5776247Swollman	{ 0, 0 }, \
5786348Swollman	{ "rfc1323", CTLTYPE_INT }, \
5796247Swollman	{ "mssdflt", CTLTYPE_INT }, \
5806472Swollman	{ "stats", CTLTYPE_STRUCT }, \
5816472Swollman	{ "rttdflt", CTLTYPE_INT }, \
5826472Swollman	{ "keepidle", CTLTYPE_INT }, \
5836472Swollman	{ "keepintvl", CTLTYPE_INT }, \
5846472Swollman	{ "sendspace", CTLTYPE_INT }, \
5856472Swollman	{ "recvspace", CTLTYPE_INT }, \
58618281Spst	{ "keepinit", CTLTYPE_INT }, \
58736079Swollman	{ "pcblist", CTLTYPE_STRUCT }, \
58850673Sjlemon	{ "delacktime", CTLTYPE_INT }, \
58952904Sshin	{ "v6mssdflt", CTLTYPE_INT }, \
590122922Sandre	{ "maxid", CTLTYPE_INT }, \
5916247Swollman}
5926247Swollman
59344078Sdfr
59455205Speter#ifdef _KERNEL
59544078Sdfr#ifdef SYSCTL_DECL
59644078SdfrSYSCTL_DECL(_net_inet_tcp);
597136151SpsSYSCTL_DECL(_net_inet_tcp_sack);
598169683SandreMALLOC_DECLARE(M_TCPLOG);
59944078Sdfr#endif
60044078Sdfr
601195699SrwatsonVNET_DECLARE(struct inpcbhead, tcb);		/* queue of active tcpcb's */
602195699SrwatsonVNET_DECLARE(struct inpcbinfo, tcbinfo);
603195699SrwatsonVNET_DECLARE(struct tcpstat, tcpstat);		/* tcp statistics */
604207369Sbzextern	int tcp_log_in_vain;
605195699SrwatsonVNET_DECLARE(int, tcp_mssdflt);	/* XXX */
606195699SrwatsonVNET_DECLARE(int, tcp_minmss);
607195699SrwatsonVNET_DECLARE(int, tcp_delack_enabled);
608211464SandreVNET_DECLARE(int, tcp_do_rfc3390);
609195699SrwatsonVNET_DECLARE(int, path_mtu_discovery);
610195699SrwatsonVNET_DECLARE(int, ss_fltsz);
611195699SrwatsonVNET_DECLARE(int, ss_fltsz_local);
612215166SlstewartVNET_DECLARE(int, tcp_do_rfc3465);
613215166SlstewartVNET_DECLARE(int, tcp_abc_l_var);
614195727Srwatson#define	V_tcb			VNET(tcb)
615195727Srwatson#define	V_tcbinfo		VNET(tcbinfo)
616195727Srwatson#define	V_tcpstat		VNET(tcpstat)
617195727Srwatson#define	V_tcp_mssdflt		VNET(tcp_mssdflt)
618195727Srwatson#define	V_tcp_minmss		VNET(tcp_minmss)
619195727Srwatson#define	V_tcp_delack_enabled	VNET(tcp_delack_enabled)
620211464Sandre#define	V_tcp_do_rfc3390	VNET(tcp_do_rfc3390)
621195727Srwatson#define	V_path_mtu_discovery	VNET(path_mtu_discovery)
622195727Srwatson#define	V_ss_fltsz		VNET(ss_fltsz)
623195727Srwatson#define	V_ss_fltsz_local	VNET(ss_fltsz_local)
624215166Slstewart#define	V_tcp_do_rfc3465	VNET(tcp_do_rfc3465)
625215166Slstewart#define	V_tcp_abc_l_var		VNET(tcp_abc_l_var)
626185088Szec
627195699SrwatsonVNET_DECLARE(int, tcp_do_sack);			/* SACK enabled/disabled */
628195699SrwatsonVNET_DECLARE(int, tcp_sc_rst_sock_fail);	/* RST on sock alloc failure */
629207369Sbz#define	V_tcp_do_sack		VNET(tcp_do_sack)
630207369Sbz#define	V_tcp_sc_rst_sock_fail	VNET(tcp_sc_rst_sock_fail)
631207369Sbz
632195699SrwatsonVNET_DECLARE(int, tcp_do_ecn);			/* TCP ECN enabled/disabled */
633195699SrwatsonVNET_DECLARE(int, tcp_ecn_maxretries);
634195727Srwatson#define	V_tcp_do_ecn		VNET(tcp_do_ecn)
635195727Srwatson#define	V_tcp_ecn_maxretries	VNET(tcp_ecn_maxretries)
636195699Srwatson
637217252SlstewartVNET_DECLARE(struct hhook_head *, tcp_hhh[HHOOK_TCP_LAST + 1]);
638216758Slstewart#define	V_tcp_hhh		VNET(tcp_hhh)
639216758Slstewart
640167606Sandreint	 tcp_addoptions(struct tcpopt *, u_char *);
641215392Slstewartint	 tcp_ccalgounload(struct cc_algo *unload_algo);
6421541Srgrimesstruct tcpcb *
64392723Salfred	 tcp_close(struct tcpcb *);
644157376Srwatsonvoid	 tcp_discardcb(struct tcpcb *);
645111145Sjlemonvoid	 tcp_twstart(struct tcpcb *);
646162064Sglebius#if 0
647121850Ssilbyint	 tcp_twrecycleable(struct tcptw *tw);
648162064Sglebius#endif
649157376Srwatsonvoid	 tcp_twclose(struct tcptw *_tw, int _reuse);
65092723Salfredvoid	 tcp_ctlinput(int, struct sockaddr *, void *);
65192723Salfredint	 tcp_ctloutput(struct socket *, struct sockopt *);
6521541Srgrimesstruct tcpcb *
65392723Salfred	 tcp_drop(struct tcpcb *, int);
65492723Salfredvoid	 tcp_drain(void);
65592723Salfredvoid	 tcp_init(void);
656193731Szec#ifdef VIMAGE
657193731Szecvoid	 tcp_destroy(void);
658193731Szec#endif
659128452Ssilbyvoid	 tcp_fini(void *);
660217126Sjhbchar	*tcp_log_addrs(struct in_conninfo *, struct tcphdr *, void *,
661171229Speter	    const void *);
662211462Sandrechar	*tcp_log_vain(struct in_conninfo *, struct tcphdr *, void *,
663211462Sandre	    const void *);
664169541Sandreint	 tcp_reass(struct tcpcb *, struct tcphdr *, int *, struct mbuf *);
665126193Sandrevoid	 tcp_reass_init(void);
666213158Slstewartvoid	 tcp_reass_flush(struct tcpcb *);
667204838Sbz#ifdef VIMAGE
668204838Sbzvoid	 tcp_reass_destroy(void);
669204838Sbz#endif
67092723Salfredvoid	 tcp_input(struct mbuf *, int);
671162084Sandreu_long	 tcp_maxmtu(struct in_conninfo *, int *);
672162084Sandreu_long	 tcp_maxmtu6(struct in_conninfo *, int *);
673184722Sbzvoid	 tcp_mss_update(struct tcpcb *, int, struct hc_metrics_lite *, int *);
67492723Salfredvoid	 tcp_mss(struct tcpcb *, int);
675122922Sandreint	 tcp_mssopt(struct in_conninfo *);
676133874Srwatsonstruct inpcb *
67798211Shsu	 tcp_drop_syn_sent(struct inpcb *, int);
67898211Shsustruct inpcb *
67998211Shsu	 tcp_mtudisc(struct inpcb *, int);
6801541Srgrimesstruct tcpcb *
68192723Salfred	 tcp_newtcpcb(struct inpcb *);
68292723Salfredint	 tcp_output(struct tcpcb *);
68392723Salfredvoid	 tcp_respond(struct tcpcb *, void *,
68492723Salfred	    struct tcphdr *, struct mbuf *, tcp_seq, tcp_seq, int);
685169541Sandrevoid	 tcp_tw_init(void);
686193731Szec#ifdef VIMAGE
687193731Szecvoid	 tcp_tw_destroy(void);
688193731Szec#endif
689169541Sandrevoid	 tcp_tw_zone_change(void);
690169608Sandreint	 tcp_twcheck(struct inpcb *, struct tcpopt *, struct tcphdr *,
691169608Sandre	    struct mbuf *, int);
692126351Srwatsonint	 tcp_twrespond(struct tcptw *, int);
69392723Salfredvoid	 tcp_setpersist(struct tcpcb *);
694125783Sbms#ifdef TCP_SIGNATURE
695125783Sbmsint	 tcp_signature_compute(struct mbuf *, int, int, int, u_char *, u_int);
696221023Sattilioint	 tcp_signature_verify(struct mbuf *, int, int, int, struct tcpopt *,
697221023Sattilio	    struct tcphdr *, u_int);
698125783Sbms#endif
69992723Salfredvoid	 tcp_slowtimo(void);
70055679Sshinstruct tcptemp *
701111144Sjlemon	 tcpip_maketemplate(struct inpcb *);
702111144Sjlemonvoid	 tcpip_fillheaders(struct inpcb *, void *, void *);
703168615Sandrevoid	 tcp_timer_activate(struct tcpcb *, int, u_int);
704168615Sandreint	 tcp_timer_active(struct tcpcb *, int);
705169272Srwatsonvoid	 tcp_trace(short, short, struct tcpcb *, void *, struct tcphdr *, int);
706122922Sandre/*
707122922Sandre * All tcp_hc_* functions are IPv4 and IPv6 (via in_conninfo)
708122922Sandre */
709122922Sandrevoid	 tcp_hc_init(void);
710193731Szec#ifdef VIMAGE
711193731Szecvoid	 tcp_hc_destroy(void);
712193731Szec#endif
713122922Sandrevoid	 tcp_hc_get(struct in_conninfo *, struct hc_metrics_lite *);
714122922Sandreu_long	 tcp_hc_getmtu(struct in_conninfo *);
715122922Sandrevoid	 tcp_hc_updatemtu(struct in_conninfo *, u_long);
716122922Sandrevoid	 tcp_hc_update(struct in_conninfo *, struct hc_metrics_lite *);
7179470Swollman
71817096Swollmanextern	struct pr_usrreqs tcp_usrreqs;
7199470Swollmanextern	u_long tcp_sendspace;
7209470Swollmanextern	u_long tcp_recvspace;
72192723Salfredtcp_seq tcp_new_isn(struct tcpcb *);
7229470Swollman
723147637Spsvoid	 tcp_sack_doack(struct tcpcb *, struct tcpopt *, tcp_seq);
724142031Spsvoid	 tcp_update_sack_list(struct tcpcb *tp, tcp_seq rcv_laststart, tcp_seq rcv_lastend);
725130989Spsvoid	 tcp_clean_sackreport(struct tcpcb *tp);
726130989Spsvoid	 tcp_sack_adjust(struct tcpcb *tp);
727136151Spsstruct sackhole *tcp_sack_output(struct tcpcb *tp, int *sack_bytes_rexmt);
728130989Spsvoid	 tcp_sack_partialack(struct tcpcb *, struct tcphdr *);
729130989Spsvoid	 tcp_free_sackholes(struct tcpcb *tp);
730130989Spsint	 tcp_newreno(struct tcpcb *, struct tcphdr *);
731130989Spsu_long	 tcp_seq_subtract(u_long, u_long );
732130989Sps
733215166Slstewartvoid	cc_cong_signal(struct tcpcb *tp, struct tcphdr *th, uint32_t type);
734215166Slstewart
73555205Speter#endif /* _KERNEL */
7362169Spaul
7376348Swollman#endif /* _NETINET_TCP_VAR_H_ */
738