Home | History | Annotate | Line # | Download | only in netinet
tcp_rndiss.h revision 1.1.1.1
      1  1.1.1.1  martti /*	$OpenBSD: tcp_var.h,v 1.83 2007/06/25 12:17:43 markus Exp $	*/
      2  1.1.1.1  martti /*	$NetBSD: tcp_rndiss.h,v 1.1.1.1 2009/12/01 07:03:10 martti Exp $	*/
      3  1.1.1.1  martti 
      4  1.1.1.1  martti /*
      5  1.1.1.1  martti  * Copyright (c) 1982, 1986, 1993, 1994
      6  1.1.1.1  martti  *	The Regents of the University of California.  All rights reserved.
      7  1.1.1.1  martti  *
      8  1.1.1.1  martti  * Redistribution and use in source and binary forms, with or without
      9  1.1.1.1  martti  * modification, are permitted provided that the following conditions
     10  1.1.1.1  martti  * are met:
     11  1.1.1.1  martti  * 1. Redistributions of source code must retain the above copyright
     12  1.1.1.1  martti  *    notice, this list of conditions and the following disclaimer.
     13  1.1.1.1  martti  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.1.1.1  martti  *    notice, this list of conditions and the following disclaimer in the
     15  1.1.1.1  martti  *    documentation and/or other materials provided with the distribution.
     16  1.1.1.1  martti  * 3. Neither the name of the University nor the names of its contributors
     17  1.1.1.1  martti  *    may be used to endorse or promote products derived from this software
     18  1.1.1.1  martti  *    without specific prior written permission.
     19  1.1.1.1  martti  *
     20  1.1.1.1  martti  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     21  1.1.1.1  martti  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     22  1.1.1.1  martti  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23  1.1.1.1  martti  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     24  1.1.1.1  martti  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     25  1.1.1.1  martti  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     26  1.1.1.1  martti  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     27  1.1.1.1  martti  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     28  1.1.1.1  martti  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29  1.1.1.1  martti  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30  1.1.1.1  martti  * SUCH DAMAGE.
     31  1.1.1.1  martti  *
     32  1.1.1.1  martti  *	@(#)tcp_var.h	8.3 (Berkeley) 4/10/94
     33  1.1.1.1  martti  */
     34  1.1.1.1  martti 
     35  1.1.1.1  martti #ifndef _NETINET_TCP_VAR_H_
     36  1.1.1.1  martti #define _NETINET_TCP_VAR_H_
     37  1.1.1.1  martti 
     38  1.1.1.1  martti /*
     39  1.1.1.1  martti  * Kernel variables for tcp.
     40  1.1.1.1  martti  */
     41  1.1.1.1  martti 
     42  1.1.1.1  martti struct sackblk {
     43  1.1.1.1  martti 	tcp_seq start;		/* start seq no. of sack block */
     44  1.1.1.1  martti 	tcp_seq end; 		/* end seq no. */
     45  1.1.1.1  martti };
     46  1.1.1.1  martti 
     47  1.1.1.1  martti struct sackhole {
     48  1.1.1.1  martti 	tcp_seq start;		/* start seq no. of hole */
     49  1.1.1.1  martti 	tcp_seq end;		/* end seq no. */
     50  1.1.1.1  martti 	int	dups;		/* number of dup(s)acks for this hole */
     51  1.1.1.1  martti 	tcp_seq rxmit;		/* next seq. no in hole to be retransmitted */
     52  1.1.1.1  martti 	struct sackhole *next;	/* next in list */
     53  1.1.1.1  martti };
     54  1.1.1.1  martti 
     55  1.1.1.1  martti /*
     56  1.1.1.1  martti  * TCP sequence queue structures.
     57  1.1.1.1  martti  */
     58  1.1.1.1  martti TAILQ_HEAD(tcpqehead, tcpqent);
     59  1.1.1.1  martti struct tcpqent {
     60  1.1.1.1  martti 	TAILQ_ENTRY(tcpqent) tcpqe_q;
     61  1.1.1.1  martti 	struct tcphdr	*tcpqe_tcp;
     62  1.1.1.1  martti 	struct mbuf	*tcpqe_m;	/* mbuf contains packet */
     63  1.1.1.1  martti };
     64  1.1.1.1  martti 
     65  1.1.1.1  martti /*
     66  1.1.1.1  martti  * Tcp control block, one per tcp; fields:
     67  1.1.1.1  martti  */
     68  1.1.1.1  martti struct tcpcb {
     69  1.1.1.1  martti 	struct tcpqehead t_segq;		/* sequencing queue */
     70  1.1.1.1  martti 	struct timeout t_timer[TCPT_NTIMERS];	/* tcp timers */
     71  1.1.1.1  martti 	short	t_state;		/* state of this connection */
     72  1.1.1.1  martti 	short	t_rxtshift;		/* log(2) of rexmt exp. backoff */
     73  1.1.1.1  martti 	short	t_rxtcur;		/* current retransmit value */
     74  1.1.1.1  martti 	short	t_dupacks;		/* consecutive dup acks recd */
     75  1.1.1.1  martti 	u_short	t_maxseg;		/* maximum segment size */
     76  1.1.1.1  martti 	char	t_force;		/* 1 if forcing out a byte */
     77  1.1.1.1  martti 	u_int	t_flags;
     78  1.1.1.1  martti #define	TF_ACKNOW	0x0001		/* ack peer immediately */
     79  1.1.1.1  martti #define	TF_DELACK	0x0002		/* ack, but try to delay it */
     80  1.1.1.1  martti #define	TF_NODELAY	0x0004		/* don't delay packets to coalesce */
     81  1.1.1.1  martti #define	TF_NOOPT	0x0008		/* don't use tcp options */
     82  1.1.1.1  martti #define	TF_SENTFIN	0x0010		/* have sent FIN */
     83  1.1.1.1  martti #define	TF_REQ_SCALE	0x0020		/* have/will request window scaling */
     84  1.1.1.1  martti #define	TF_RCVD_SCALE	0x0040		/* other side has requested scaling */
     85  1.1.1.1  martti #define	TF_REQ_TSTMP	0x0080		/* have/will request timestamps */
     86  1.1.1.1  martti #define	TF_RCVD_TSTMP	0x0100		/* a timestamp was received in SYN */
     87  1.1.1.1  martti #define	TF_SACK_PERMIT	0x0200		/* other side said I could SACK */
     88  1.1.1.1  martti #define	TF_SIGNATURE	0x0400		/* require TCP MD5 signature */
     89  1.1.1.1  martti #ifdef TCP_ECN
     90  1.1.1.1  martti #define TF_ECN_PERMIT	0x00008000	/* other side said I could ECN */
     91  1.1.1.1  martti #define TF_RCVD_CE	0x00010000	/* send ECE in subsequent segs */
     92  1.1.1.1  martti #define TF_SEND_CWR	0x00020000	/* send CWR in next seg */
     93  1.1.1.1  martti #define TF_DISABLE_ECN	0x00040000	/* disable ECN for this connection */
     94  1.1.1.1  martti #endif
     95  1.1.1.1  martti #define TF_REASSLOCK	0x00080000	/* reassembling or draining */
     96  1.1.1.1  martti #define TF_LASTIDLE	0x00100000	/* no outstanding ACK on last send */
     97  1.1.1.1  martti #define TF_DEAD		0x00200000	/* dead and to-be-released */
     98  1.1.1.1  martti #define TF_PMTUD_PEND	0x00400000	/* Path MTU Discovery pending */
     99  1.1.1.1  martti 
    100  1.1.1.1  martti 	struct	mbuf *t_template;	/* skeletal packet for transmit */
    101  1.1.1.1  martti 	struct	inpcb *t_inpcb;		/* back pointer to internet pcb */
    102  1.1.1.1  martti 	struct	timeout t_delack_to;	/* delayed ACK callback */
    103  1.1.1.1  martti /*
    104  1.1.1.1  martti  * The following fields are used as in the protocol specification.
    105  1.1.1.1  martti  * See RFC793, Dec. 1981, page 21.
    106  1.1.1.1  martti  */
    107  1.1.1.1  martti /* send sequence variables */
    108  1.1.1.1  martti 	tcp_seq	snd_una;		/* send unacknowledged */
    109  1.1.1.1  martti 	tcp_seq	snd_nxt;		/* send next */
    110  1.1.1.1  martti 	tcp_seq	snd_up;			/* send urgent pointer */
    111  1.1.1.1  martti 	tcp_seq	snd_wl1;		/* window update seg seq number */
    112  1.1.1.1  martti 	tcp_seq	snd_wl2;		/* window update seg ack number */
    113  1.1.1.1  martti 	tcp_seq	iss;			/* initial send sequence number */
    114  1.1.1.1  martti 	u_long	snd_wnd;		/* send window */
    115  1.1.1.1  martti #if 1 /*def TCP_SACK*/
    116  1.1.1.1  martti 	int	sack_enable;		/* enable SACK for this connection */
    117  1.1.1.1  martti 	int	snd_numholes;		/* number of holes seen by sender */
    118  1.1.1.1  martti 	struct sackhole *snd_holes;	/* linked list of holes (sorted) */
    119  1.1.1.1  martti #if 1 /*defined(TCP_SACK) && defined(TCP_FACK)*/
    120  1.1.1.1  martti 	tcp_seq snd_fack;		/* for FACK congestion control */
    121  1.1.1.1  martti 	u_long	snd_awnd;		/* snd_nxt - snd_fack + */
    122  1.1.1.1  martti 					/* retransmitted data */
    123  1.1.1.1  martti 	int retran_data;		/* amount of outstanding retx. data  */
    124  1.1.1.1  martti #endif /* TCP_FACK */
    125  1.1.1.1  martti #endif /* TCP_SACK */
    126  1.1.1.1  martti #if 1 /*defined(TCP_SACK) || defined(TCP_ECN)*/
    127  1.1.1.1  martti 	tcp_seq snd_last;		/* for use in fast recovery */
    128  1.1.1.1  martti #endif
    129  1.1.1.1  martti /* receive sequence variables */
    130  1.1.1.1  martti 	u_long	rcv_wnd;		/* receive window */
    131  1.1.1.1  martti 	tcp_seq	rcv_nxt;		/* receive next */
    132  1.1.1.1  martti 	tcp_seq	rcv_up;			/* receive urgent pointer */
    133  1.1.1.1  martti 	tcp_seq	irs;			/* initial receive sequence number */
    134  1.1.1.1  martti #if 1 /*def TCP_SACK*/
    135  1.1.1.1  martti 	tcp_seq rcv_lastsack;		/* last seq number(+1) sack'd by rcv'r*/
    136  1.1.1.1  martti 	int	rcv_numsacks;		/* # distinct sack blks present */
    137  1.1.1.1  martti 	struct sackblk sackblks[MAX_SACK_BLKS]; /* seq nos. of sack blocks */
    138  1.1.1.1  martti #endif
    139  1.1.1.1  martti 
    140  1.1.1.1  martti /*
    141  1.1.1.1  martti  * Additional variables for this implementation.
    142  1.1.1.1  martti  */
    143  1.1.1.1  martti /* receive variables */
    144  1.1.1.1  martti 	tcp_seq	rcv_adv;		/* advertised window */
    145  1.1.1.1  martti /* retransmit variables */
    146  1.1.1.1  martti 	tcp_seq	snd_max;		/* highest sequence number sent;
    147  1.1.1.1  martti 					 * used to recognize retransmits
    148  1.1.1.1  martti 					 */
    149  1.1.1.1  martti /* congestion control (for slow start, source quench, retransmit after loss) */
    150  1.1.1.1  martti 	u_long	snd_cwnd;		/* congestion-controlled window */
    151  1.1.1.1  martti 	u_long	snd_ssthresh;		/* snd_cwnd size threshold for
    152  1.1.1.1  martti 					 * for slow start exponential to
    153  1.1.1.1  martti 					 * linear switch
    154  1.1.1.1  martti 					 */
    155  1.1.1.1  martti 	u_short	t_maxopd;		/* mss plus options */
    156  1.1.1.1  martti 	u_short	t_peermss;		/* peer's maximum segment size */
    157  1.1.1.1  martti 
    158  1.1.1.1  martti /*
    159  1.1.1.1  martti  * transmit timing stuff.  See below for scale of srtt and rttvar.
    160  1.1.1.1  martti  * "Variance" is actually smoothed difference.
    161  1.1.1.1  martti  */
    162  1.1.1.1  martti 	uint32_t t_rcvtime;		/* time last segment received */
    163  1.1.1.1  martti 	uint32_t t_rtttime;		/* time we started measuring rtt */
    164  1.1.1.1  martti 	tcp_seq	t_rtseq;		/* sequence number being timed */
    165  1.1.1.1  martti 	short	t_srtt;			/* smoothed round-trip time */
    166  1.1.1.1  martti 	short	t_rttvar;		/* variance in round-trip time */
    167  1.1.1.1  martti 	u_short	t_rttmin;		/* minimum rtt allowed */
    168  1.1.1.1  martti 	u_long	max_sndwnd;		/* largest window peer has offered */
    169  1.1.1.1  martti 
    170  1.1.1.1  martti /* out-of-band data */
    171  1.1.1.1  martti 	char	t_oobflags;		/* have some */
    172  1.1.1.1  martti 	char	t_iobc;			/* input character */
    173  1.1.1.1  martti #define	TCPOOB_HAVEDATA	0x01
    174  1.1.1.1  martti #define	TCPOOB_HADDATA	0x02
    175  1.1.1.1  martti 	short	t_softerror;		/* possible error not yet reported */
    176  1.1.1.1  martti 
    177  1.1.1.1  martti /* RFC 1323 variables */
    178  1.1.1.1  martti 	u_char	snd_scale;		/* window scaling for send window */
    179  1.1.1.1  martti 	u_char	rcv_scale;		/* window scaling for recv window */
    180  1.1.1.1  martti 	u_char	request_r_scale;	/* pending window scaling */
    181  1.1.1.1  martti 	u_char	requested_s_scale;
    182  1.1.1.1  martti 	u_int32_t ts_recent;		/* timestamp echo data */
    183  1.1.1.1  martti 	u_int32_t ts_modulate;		/* modulation on timestamp */
    184  1.1.1.1  martti 	u_int32_t ts_recent_age;		/* when last updated */
    185  1.1.1.1  martti 	tcp_seq	last_ack_sent;
    186  1.1.1.1  martti 
    187  1.1.1.1  martti /* pointer for syn cache entries*/
    188  1.1.1.1  martti 	LIST_HEAD(, syn_cache) t_sc;	/* list of entries by this tcb */
    189  1.1.1.1  martti 
    190  1.1.1.1  martti /* Path-MTU Discovery Information */
    191  1.1.1.1  martti 	u_int	t_pmtud_mss_acked;	/* MSS acked, lower bound for MTU */
    192  1.1.1.1  martti 	u_int	t_pmtud_mtu_sent;	/* MTU used, upper bound for MTU */
    193  1.1.1.1  martti 	tcp_seq	t_pmtud_th_seq;		/* TCP SEQ from ICMP payload */
    194  1.1.1.1  martti 	u_int	t_pmtud_nextmtu;	/* Advertised Next-Hop MTU from ICMP */
    195  1.1.1.1  martti 	u_short	t_pmtud_ip_len;		/* IP length from ICMP payload */
    196  1.1.1.1  martti 	u_short	t_pmtud_ip_hl;		/* IP header length from ICMP payload */
    197  1.1.1.1  martti 
    198  1.1.1.1  martti 	int pf;
    199  1.1.1.1  martti 
    200  1.1.1.1  martti 	struct	timeout t_reap_to;	/* delayed cleanup timeout */
    201  1.1.1.1  martti };
    202  1.1.1.1  martti 
    203  1.1.1.1  martti #define	intotcpcb(ip)	((struct tcpcb *)(ip)->inp_ppcb)
    204  1.1.1.1  martti #define	sototcpcb(so)	(intotcpcb(sotoinpcb(so)))
    205  1.1.1.1  martti 
    206  1.1.1.1  martti #ifdef _KERNEL
    207  1.1.1.1  martti extern int tcp_delack_ticks;
    208  1.1.1.1  martti void	tcp_delack(void *);
    209  1.1.1.1  martti 
    210  1.1.1.1  martti #define TCP_INIT_DELACK(tp)						\
    211  1.1.1.1  martti 	timeout_set(&(tp)->t_delack_to, tcp_delack, tp)
    212  1.1.1.1  martti 
    213  1.1.1.1  martti #define TCP_RESTART_DELACK(tp)						\
    214  1.1.1.1  martti 	timeout_add(&(tp)->t_delack_to, tcp_delack_ticks)
    215  1.1.1.1  martti 
    216  1.1.1.1  martti #define	TCP_SET_DELACK(tp)						\
    217  1.1.1.1  martti do {									\
    218  1.1.1.1  martti 	if (((tp)->t_flags & TF_DELACK) == 0) {				\
    219  1.1.1.1  martti 		(tp)->t_flags |= TF_DELACK;				\
    220  1.1.1.1  martti 		TCP_RESTART_DELACK(tp);					\
    221  1.1.1.1  martti 	}								\
    222  1.1.1.1  martti } while (/*CONSTCOND*/0)
    223  1.1.1.1  martti 
    224  1.1.1.1  martti #define	TCP_CLEAR_DELACK(tp)						\
    225  1.1.1.1  martti do {									\
    226  1.1.1.1  martti 	if ((tp)->t_flags & TF_DELACK) {				\
    227  1.1.1.1  martti 		(tp)->t_flags &= ~TF_DELACK;				\
    228  1.1.1.1  martti 		timeout_del(&(tp)->t_delack_to);			\
    229  1.1.1.1  martti 	}								\
    230  1.1.1.1  martti } while (/*CONSTCOND*/0)
    231  1.1.1.1  martti 
    232  1.1.1.1  martti /*
    233  1.1.1.1  martti  * Handy way of passing around TCP option info.
    234  1.1.1.1  martti  */
    235  1.1.1.1  martti struct tcp_opt_info {
    236  1.1.1.1  martti 	int		ts_present;
    237  1.1.1.1  martti 	u_int32_t	ts_val;
    238  1.1.1.1  martti 	u_int32_t	ts_ecr;
    239  1.1.1.1  martti 	u_int16_t	maxseg;
    240  1.1.1.1  martti };
    241  1.1.1.1  martti 
    242  1.1.1.1  martti /*
    243  1.1.1.1  martti  * Data for the TCP compressed state engine.
    244  1.1.1.1  martti  */
    245  1.1.1.1  martti union syn_cache_sa {
    246  1.1.1.1  martti 	struct sockaddr sa;
    247  1.1.1.1  martti 	struct sockaddr_in sin;
    248  1.1.1.1  martti #if 1 /*def INET6*/
    249  1.1.1.1  martti 	struct sockaddr_in6 sin6;
    250  1.1.1.1  martti #endif
    251  1.1.1.1  martti };
    252  1.1.1.1  martti 
    253  1.1.1.1  martti struct syn_cache {
    254  1.1.1.1  martti 	TAILQ_ENTRY(syn_cache) sc_bucketq;	/* link on bucket list */
    255  1.1.1.1  martti 	struct timeout sc_timer;		/* rexmt timer */
    256  1.1.1.1  martti 	union {					/* cached route */
    257  1.1.1.1  martti 		struct route route4;
    258  1.1.1.1  martti #ifdef INET6
    259  1.1.1.1  martti 		struct route_in6 route6;
    260  1.1.1.1  martti #endif
    261  1.1.1.1  martti 	} sc_route_u;
    262  1.1.1.1  martti #define sc_route4	sc_route_u.route4
    263  1.1.1.1  martti #ifdef INET6
    264  1.1.1.1  martti #define sc_route6	sc_route_u.route6
    265  1.1.1.1  martti #endif
    266  1.1.1.1  martti 	long sc_win;				/* advertised window */
    267  1.1.1.1  martti 	int sc_bucketidx;			/* our bucket index */
    268  1.1.1.1  martti 	u_int32_t sc_hash;
    269  1.1.1.1  martti 	u_int32_t sc_timestamp;			/* timestamp from SYN */
    270  1.1.1.1  martti 	u_int32_t sc_modulate;			/* our timestamp modulator */
    271  1.1.1.1  martti #if 0
    272  1.1.1.1  martti 	u_int32_t sc_timebase;			/* our local timebase */
    273  1.1.1.1  martti #endif
    274  1.1.1.1  martti 	union syn_cache_sa sc_src;
    275  1.1.1.1  martti 	union syn_cache_sa sc_dst;
    276  1.1.1.1  martti 	tcp_seq sc_irs;
    277  1.1.1.1  martti 	tcp_seq sc_iss;
    278  1.1.1.1  martti 	u_int sc_rxtcur;			/* current rxt timeout */
    279  1.1.1.1  martti 	u_int sc_rxttot;			/* total time spend on queues */
    280  1.1.1.1  martti 	u_short sc_rxtshift;			/* for computing backoff */
    281  1.1.1.1  martti 	u_short sc_flags;
    282  1.1.1.1  martti 
    283  1.1.1.1  martti #define	SCF_UNREACH		0x0001		/* we've had an unreach error */
    284  1.1.1.1  martti #define	SCF_TIMESTAMP		0x0002		/* peer will do timestamps */
    285  1.1.1.1  martti #define	SCF_DEAD		0x0004		/* this entry to be released */
    286  1.1.1.1  martti #define	SCF_SACK_PERMIT		0x0008		/* permit sack */
    287  1.1.1.1  martti #define	SCF_ECN_PERMIT		0x0010		/* permit ecn */
    288  1.1.1.1  martti #define	SCF_SIGNATURE		0x0020		/* enforce tcp signatures */
    289  1.1.1.1  martti 
    290  1.1.1.1  martti 	struct mbuf *sc_ipopts;			/* IP options */
    291  1.1.1.1  martti 	u_int16_t sc_peermaxseg;
    292  1.1.1.1  martti 	u_int16_t sc_ourmaxseg;
    293  1.1.1.1  martti 	u_int     sc_request_r_scale	: 4,
    294  1.1.1.1  martti 		  sc_requested_s_scale	: 4;
    295  1.1.1.1  martti 
    296  1.1.1.1  martti 	struct tcpcb *sc_tp;			/* tcb for listening socket */
    297  1.1.1.1  martti 	LIST_ENTRY(syn_cache) sc_tpq;		/* list of entries by same tp */
    298  1.1.1.1  martti };
    299  1.1.1.1  martti 
    300  1.1.1.1  martti struct syn_cache_head {
    301  1.1.1.1  martti 	TAILQ_HEAD(, syn_cache) sch_bucket;	/* bucket entries */
    302  1.1.1.1  martti 	u_short sch_length;			/* # entries in bucket */
    303  1.1.1.1  martti };
    304  1.1.1.1  martti 
    305  1.1.1.1  martti static __inline int tcp_reass_lock_try(struct tcpcb *);
    306  1.1.1.1  martti static __inline void tcp_reass_unlock(struct tcpcb *);
    307  1.1.1.1  martti #define tcp_reass_lock(tp) tcp_reass_lock_try(tp)
    308  1.1.1.1  martti 
    309  1.1.1.1  martti static __inline int
    310  1.1.1.1  martti tcp_reass_lock_try(struct tcpcb *tp)
    311  1.1.1.1  martti {
    312  1.1.1.1  martti 	int s;
    313  1.1.1.1  martti 
    314  1.1.1.1  martti 	/* Use splvm() due to mbuf allocation. */
    315  1.1.1.1  martti 	s = splvm();
    316  1.1.1.1  martti 	if (tp->t_flags & TF_REASSLOCK) {
    317  1.1.1.1  martti 		splx(s);
    318  1.1.1.1  martti 		return (0);
    319  1.1.1.1  martti 	}
    320  1.1.1.1  martti 	tp->t_flags |= TF_REASSLOCK;
    321  1.1.1.1  martti 	splx(s);
    322  1.1.1.1  martti 	return (1);
    323  1.1.1.1  martti }
    324  1.1.1.1  martti 
    325  1.1.1.1  martti static __inline void
    326  1.1.1.1  martti tcp_reass_unlock(struct tcpcb *tp)
    327  1.1.1.1  martti {
    328  1.1.1.1  martti 	int s;
    329  1.1.1.1  martti 
    330  1.1.1.1  martti 	s = splvm();
    331  1.1.1.1  martti 	tp->t_flags &= ~TF_REASSLOCK;
    332  1.1.1.1  martti 	splx(s);
    333  1.1.1.1  martti }
    334  1.1.1.1  martti #endif /* _KERNEL */
    335  1.1.1.1  martti 
    336  1.1.1.1  martti /*
    337  1.1.1.1  martti  * The smoothed round-trip time and estimated variance
    338  1.1.1.1  martti  * are stored as fixed point numbers scaled by the values below.
    339  1.1.1.1  martti  * For convenience, these scales are also used in smoothing the average
    340  1.1.1.1  martti  * (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed).
    341  1.1.1.1  martti  * With these scales, srtt has 5 bits to the right of the binary point,
    342  1.1.1.1  martti  * and thus an "ALPHA" of 0.875.  rttvar has 4 bits to the right of the
    343  1.1.1.1  martti  * binary point, and is smoothed with an ALPHA of 0.75.
    344  1.1.1.1  martti  */
    345  1.1.1.1  martti #define	TCP_RTT_SHIFT		3	/* shift for srtt; 5 bits frac. */
    346  1.1.1.1  martti #define	TCP_RTTVAR_SHIFT	2	/* shift for rttvar; 4 bits */
    347  1.1.1.1  martti #define	TCP_RTT_BASE_SHIFT	2	/* remaining 2 bit shift */
    348  1.1.1.1  martti #define	TCP_RTT_MAX		(1<<9)	/* maximum rtt */
    349  1.1.1.1  martti 
    350  1.1.1.1  martti /*
    351  1.1.1.1  martti  * The initial retransmission should happen at rtt + 4 * rttvar.
    352  1.1.1.1  martti  * Because of the way we do the smoothing, srtt and rttvar
    353  1.1.1.1  martti  * will each average +1/2 tick of bias.  When we compute
    354  1.1.1.1  martti  * the retransmit timer, we want 1/2 tick of rounding and
    355  1.1.1.1  martti  * 1 extra tick because of +-1/2 tick uncertainty in the
    356  1.1.1.1  martti  * firing of the timer.  The bias will give us exactly the
    357  1.1.1.1  martti  * 1.5 tick we need.  But, because the bias is
    358  1.1.1.1  martti  * statistical, we have to test that we don't drop below
    359  1.1.1.1  martti  * the minimum feasible timer (which is 2 ticks).
    360  1.1.1.1  martti  * This macro assumes that the value of (1 << TCP_RTTVAR_SHIFT)
    361  1.1.1.1  martti  * is the same as the multiplier for rttvar.
    362  1.1.1.1  martti  */
    363  1.1.1.1  martti #define	TCP_REXMTVAL(tp) \
    364  1.1.1.1  martti 	((((tp)->t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar) >> TCP_RTT_BASE_SHIFT)
    365  1.1.1.1  martti 
    366  1.1.1.1  martti /*
    367  1.1.1.1  martti  * TCP statistics.
    368  1.1.1.1  martti  * Many of these should be kept per connection,
    369  1.1.1.1  martti  * but that's inconvenient at the moment.
    370  1.1.1.1  martti  */
    371  1.1.1.1  martti struct	tcpstat {
    372  1.1.1.1  martti 	u_int32_t tcps_connattempt;	/* connections initiated */
    373  1.1.1.1  martti 	u_int32_t tcps_accepts;		/* connections accepted */
    374  1.1.1.1  martti 	u_int32_t tcps_connects;	/* connections established */
    375  1.1.1.1  martti 	u_int32_t tcps_drops;		/* connections dropped */
    376  1.1.1.1  martti 	u_int32_t tcps_conndrops;	/* embryonic connections dropped */
    377  1.1.1.1  martti 	u_int32_t tcps_closed;		/* conn. closed (includes drops) */
    378  1.1.1.1  martti 	u_int32_t tcps_segstimed;	/* segs where we tried to get rtt */
    379  1.1.1.1  martti 	u_int32_t tcps_rttupdated;	/* times we succeeded */
    380  1.1.1.1  martti 	u_int32_t tcps_delack;		/* delayed acks sent */
    381  1.1.1.1  martti 	u_int32_t tcps_timeoutdrop;	/* conn. dropped in rxmt timeout */
    382  1.1.1.1  martti 	u_int32_t tcps_rexmttimeo;	/* retransmit timeouts */
    383  1.1.1.1  martti 	u_int32_t tcps_persisttimeo;	/* persist timeouts */
    384  1.1.1.1  martti 	u_int32_t tcps_persistdrop;	/* connections dropped in persist */
    385  1.1.1.1  martti 	u_int32_t tcps_keeptimeo;	/* keepalive timeouts */
    386  1.1.1.1  martti 	u_int32_t tcps_keepprobe;	/* keepalive probes sent */
    387  1.1.1.1  martti 	u_int32_t tcps_keepdrops;	/* connections dropped in keepalive */
    388  1.1.1.1  martti 
    389  1.1.1.1  martti 	u_int32_t tcps_sndtotal;		/* total packets sent */
    390  1.1.1.1  martti 	u_int32_t tcps_sndpack;		/* data packets sent */
    391  1.1.1.1  martti 	u_int64_t tcps_sndbyte;		/* data bytes sent */
    392  1.1.1.1  martti 	u_int32_t tcps_sndrexmitpack;	/* data packets retransmitted */
    393  1.1.1.1  martti 	u_int64_t tcps_sndrexmitbyte;	/* data bytes retransmitted */
    394  1.1.1.1  martti 	u_int64_t tcps_sndrexmitfast;	/* Fast retransmits */
    395  1.1.1.1  martti 	u_int32_t tcps_sndacks;		/* ack-only packets sent */
    396  1.1.1.1  martti 	u_int32_t tcps_sndprobe;	/* window probes sent */
    397  1.1.1.1  martti 	u_int32_t tcps_sndurg;		/* packets sent with URG only */
    398  1.1.1.1  martti 	u_int32_t tcps_sndwinup;	/* window update-only packets sent */
    399  1.1.1.1  martti 	u_int32_t tcps_sndctrl;		/* control (SYN|FIN|RST) packets sent */
    400  1.1.1.1  martti 
    401  1.1.1.1  martti 	u_int32_t tcps_rcvtotal;	/* total packets received */
    402  1.1.1.1  martti 	u_int32_t tcps_rcvpack;		/* packets received in sequence */
    403  1.1.1.1  martti 	u_int64_t tcps_rcvbyte;		/* bytes received in sequence */
    404  1.1.1.1  martti 	u_int32_t tcps_rcvbadsum;	/* packets received with ccksum errs */
    405  1.1.1.1  martti 	u_int32_t tcps_rcvbadoff;	/* packets received with bad offset */
    406  1.1.1.1  martti 	u_int32_t tcps_rcvmemdrop;	/* packets dropped for lack of memory */
    407  1.1.1.1  martti 	u_int32_t tcps_rcvnosec;	/* packets dropped for lack of ipsec */
    408  1.1.1.1  martti 	u_int32_t tcps_rcvshort;	/* packets received too short */
    409  1.1.1.1  martti 	u_int32_t tcps_rcvduppack;	/* duplicate-only packets received */
    410  1.1.1.1  martti 	u_int64_t tcps_rcvdupbyte;	/* duplicate-only bytes received */
    411  1.1.1.1  martti 	u_int32_t tcps_rcvpartduppack;	/* packets with some duplicate data */
    412  1.1.1.1  martti 	u_int64_t tcps_rcvpartdupbyte;	/* dup. bytes in part-dup. packets */
    413  1.1.1.1  martti 	u_int32_t tcps_rcvoopack;	/* out-of-order packets received */
    414  1.1.1.1  martti 	u_int64_t tcps_rcvoobyte;	/* out-of-order bytes received */
    415  1.1.1.1  martti 	u_int32_t tcps_rcvpackafterwin;	/* packets with data after window */
    416  1.1.1.1  martti 	u_int64_t tcps_rcvbyteafterwin;	/* bytes rcvd after window */
    417  1.1.1.1  martti 	u_int32_t tcps_rcvafterclose;	/* packets rcvd after "close" */
    418  1.1.1.1  martti 	u_int32_t tcps_rcvwinprobe;	/* rcvd window probe packets */
    419  1.1.1.1  martti 	u_int32_t tcps_rcvdupack;	/* rcvd duplicate acks */
    420  1.1.1.1  martti 	u_int32_t tcps_rcvacktoomuch;	/* rcvd acks for unsent data */
    421  1.1.1.1  martti 	u_int32_t tcps_rcvacktooold;	/* rcvd acks for old data */
    422  1.1.1.1  martti 	u_int32_t tcps_rcvackpack;	/* rcvd ack packets */
    423  1.1.1.1  martti 	u_int64_t tcps_rcvackbyte;	/* bytes acked by rcvd acks */
    424  1.1.1.1  martti 	u_int32_t tcps_rcvwinupd;	/* rcvd window update packets */
    425  1.1.1.1  martti 	u_int32_t tcps_pawsdrop;	/* segments dropped due to PAWS */
    426  1.1.1.1  martti 	u_int32_t tcps_predack;		/* times hdr predict ok for acks */
    427  1.1.1.1  martti 	u_int32_t tcps_preddat;		/* times hdr predict ok for data pkts */
    428  1.1.1.1  martti 
    429  1.1.1.1  martti 	u_int32_t tcps_pcbhashmiss;	/* input packets missing pcb hash */
    430  1.1.1.1  martti 	u_int32_t tcps_noport;		/* no socket on port */
    431  1.1.1.1  martti 	u_int32_t tcps_badsyn;		/* SYN packet with src==dst rcv'ed */
    432  1.1.1.1  martti 
    433  1.1.1.1  martti 	u_int32_t tcps_rcvbadsig;	/* rcvd bad/missing TCP signatures */
    434  1.1.1.1  martti 	u_int64_t tcps_rcvgoodsig;	/* rcvd good TCP signatures */
    435  1.1.1.1  martti 	u_int32_t tcps_inhwcsum;	/* input hardware-checksummed packets */
    436  1.1.1.1  martti 	u_int32_t tcps_outhwcsum;	/* output hardware-checksummed packets */
    437  1.1.1.1  martti 
    438  1.1.1.1  martti 	/* ECN stats */
    439  1.1.1.1  martti 	u_int32_t tcps_ecn_accepts;	/* ecn connections accepted */
    440  1.1.1.1  martti 	u_int32_t tcps_ecn_rcvece;	/* # of rcvd ece */
    441  1.1.1.1  martti 	u_int32_t tcps_ecn_rcvcwr;	/* # of rcvd cwr */
    442  1.1.1.1  martti 	u_int32_t tcps_ecn_rcvce;	/* # of rcvd ce in ip header */
    443  1.1.1.1  martti 	u_int32_t tcps_ecn_sndect;	/* # of cwr sent */
    444  1.1.1.1  martti 	u_int32_t tcps_ecn_sndece;	/* # of ece sent */
    445  1.1.1.1  martti 	u_int32_t tcps_ecn_sndcwr;	/* # of cwr sent */
    446  1.1.1.1  martti 	u_int32_t tcps_cwr_ecn;		/* # of cwnd reduced by ecn */
    447  1.1.1.1  martti 	u_int32_t tcps_cwr_frecovery;	/* # of cwnd reduced by fastrecovery */
    448  1.1.1.1  martti 	u_int32_t tcps_cwr_timeout;	/* # of cwnd reduced by timeout */
    449  1.1.1.1  martti 
    450  1.1.1.1  martti 	/* These statistics deal with the SYN cache. */
    451  1.1.1.1  martti 	u_int64_t tcps_sc_added;	/* # of entries added */
    452  1.1.1.1  martti 	u_int64_t tcps_sc_completed;	/* # of connections completed */
    453  1.1.1.1  martti 	u_int64_t tcps_sc_timed_out;	/* # of entries timed out */
    454  1.1.1.1  martti 	u_int64_t tcps_sc_overflowed;	/* # dropped due to overflow */
    455  1.1.1.1  martti 	u_int64_t tcps_sc_reset;	/* # dropped due to RST */
    456  1.1.1.1  martti 	u_int64_t tcps_sc_unreach;	/* # dropped due to ICMP unreach */
    457  1.1.1.1  martti 	u_int64_t tcps_sc_bucketoverflow;/* # dropped due to bucket overflow */
    458  1.1.1.1  martti 	u_int64_t tcps_sc_aborted;	/* # of entries aborted (no mem) */
    459  1.1.1.1  martti 	u_int64_t tcps_sc_dupesyn;	/* # of duplicate SYNs received */
    460  1.1.1.1  martti 	u_int64_t tcps_sc_dropped;	/* # of SYNs dropped (no route/mem) */
    461  1.1.1.1  martti 	u_int64_t tcps_sc_collisions;	/* # of hash collisions */
    462  1.1.1.1  martti 	u_int64_t tcps_sc_retransmitted;/* # of retransmissions */
    463  1.1.1.1  martti 
    464  1.1.1.1  martti 	u_int64_t tcps_conndrained;	/* # of connections drained */
    465  1.1.1.1  martti 
    466  1.1.1.1  martti 	u_int64_t tcps_sack_recovery_episode;	/* SACK recovery episodes */
    467  1.1.1.1  martti 	u_int64_t tcps_sack_rexmits;		/* SACK rexmit segments */
    468  1.1.1.1  martti 	u_int64_t tcps_sack_rexmit_bytes;	/* SACK rexmit bytes */
    469  1.1.1.1  martti 	u_int64_t tcps_sack_rcv_opts;		/* SACK options received */
    470  1.1.1.1  martti 	u_int64_t tcps_sack_snd_opts;		/* SACK options sent */
    471  1.1.1.1  martti };
    472  1.1.1.1  martti 
    473  1.1.1.1  martti /*
    474  1.1.1.1  martti  * Names for TCP sysctl objects.
    475  1.1.1.1  martti  */
    476  1.1.1.1  martti 
    477  1.1.1.1  martti #define	TCPCTL_RFC1323		1 /* enable/disable RFC1323 timestamps/scaling */
    478  1.1.1.1  martti #define	TCPCTL_KEEPINITTIME	2 /* TCPT_KEEP value */
    479  1.1.1.1  martti #define TCPCTL_KEEPIDLE		3 /* allow tcp_keepidle to be changed */
    480  1.1.1.1  martti #define TCPCTL_KEEPINTVL	4 /* allow tcp_keepintvl to be changed */
    481  1.1.1.1  martti #define TCPCTL_SLOWHZ		5 /* return kernel idea of PR_SLOWHZ */
    482  1.1.1.1  martti #define TCPCTL_BADDYNAMIC	6 /* return bad dynamic port bitmap */
    483  1.1.1.1  martti #define	TCPCTL_RECVSPACE	7 /* receive buffer space */
    484  1.1.1.1  martti #define	TCPCTL_SENDSPACE	8 /* send buffer space */
    485  1.1.1.1  martti #define	TCPCTL_IDENT		9 /* get connection owner */
    486  1.1.1.1  martti #define	TCPCTL_SACK	       10 /* selective acknowledgement, rfc 2018 */
    487  1.1.1.1  martti #define TCPCTL_MSSDFLT	       11 /* Default maximum segment size */
    488  1.1.1.1  martti #define	TCPCTL_RSTPPSLIMIT     12 /* RST pps limit */
    489  1.1.1.1  martti #define	TCPCTL_ACK_ON_PUSH     13 /* ACK immediately on PUSH */
    490  1.1.1.1  martti #define	TCPCTL_ECN	       14 /* RFC3168 ECN */
    491  1.1.1.1  martti #define	TCPCTL_SYN_CACHE_LIMIT 15 /* max size of comp. state engine */
    492  1.1.1.1  martti #define	TCPCTL_SYN_BUCKET_LIMIT	16 /* max size of hash bucket */
    493  1.1.1.1  martti #define	TCPCTL_RFC3390	       17 /* enable/disable RFC3390 increased cwnd */
    494  1.1.1.1  martti #define	TCPCTL_REASS_LIMIT     18 /* max entries for tcp reass queues */
    495  1.1.1.1  martti #define	TCPCTL_DROP	       19 /* drop tcp connection */
    496  1.1.1.1  martti #define	TCPCTL_SACKHOLE_LIMIT  20 /* max entries for tcp sack queues */
    497  1.1.1.1  martti #define	TCPCTL_MAXID	       21
    498  1.1.1.1  martti 
    499  1.1.1.1  martti #define	TCPCTL_NAMES { \
    500  1.1.1.1  martti 	{ 0, 0 }, \
    501  1.1.1.1  martti 	{ "rfc1323",	CTLTYPE_INT }, \
    502  1.1.1.1  martti 	{ "keepinittime",	CTLTYPE_INT }, \
    503  1.1.1.1  martti 	{ "keepidle",	CTLTYPE_INT }, \
    504  1.1.1.1  martti 	{ "keepintvl",	CTLTYPE_INT }, \
    505  1.1.1.1  martti 	{ "slowhz",	CTLTYPE_INT }, \
    506  1.1.1.1  martti 	{ "baddynamic", CTLTYPE_STRUCT }, \
    507  1.1.1.1  martti 	{ "recvspace",	CTLTYPE_INT }, \
    508  1.1.1.1  martti 	{ "sendspace",	CTLTYPE_INT }, \
    509  1.1.1.1  martti 	{ "ident", 	CTLTYPE_STRUCT }, \
    510  1.1.1.1  martti 	{ "sack",	CTLTYPE_INT }, \
    511  1.1.1.1  martti 	{ "mssdflt",	CTLTYPE_INT }, \
    512  1.1.1.1  martti 	{ "rstppslimit",	CTLTYPE_INT }, \
    513  1.1.1.1  martti 	{ "ackonpush",	CTLTYPE_INT }, \
    514  1.1.1.1  martti 	{ "ecn", 	CTLTYPE_INT }, \
    515  1.1.1.1  martti 	{ "syncachelimit", 	CTLTYPE_INT }, \
    516  1.1.1.1  martti 	{ "synbucketlimit", 	CTLTYPE_INT }, \
    517  1.1.1.1  martti 	{ "rfc3390", 	CTLTYPE_INT }, \
    518  1.1.1.1  martti 	{ "reasslimit", 	CTLTYPE_INT }, \
    519  1.1.1.1  martti 	{ "drop", 	CTLTYPE_STRUCT }, \
    520  1.1.1.1  martti 	{ "sackholelimit", 	CTLTYPE_INT }, \
    521  1.1.1.1  martti }
    522  1.1.1.1  martti 
    523  1.1.1.1  martti #define	TCPCTL_VARS { \
    524  1.1.1.1  martti 	NULL, \
    525  1.1.1.1  martti 	&tcp_do_rfc1323, \
    526  1.1.1.1  martti 	&tcptv_keep_init, \
    527  1.1.1.1  martti 	&tcp_keepidle, \
    528  1.1.1.1  martti 	&tcp_keepintvl, \
    529  1.1.1.1  martti 	NULL, \
    530  1.1.1.1  martti 	NULL, \
    531  1.1.1.1  martti 	&tcp_recvspace, \
    532  1.1.1.1  martti 	&tcp_sendspace, \
    533  1.1.1.1  martti 	NULL, \
    534  1.1.1.1  martti 	NULL, \
    535  1.1.1.1  martti 	&tcp_mssdflt, \
    536  1.1.1.1  martti 	&tcp_rst_ppslim, \
    537  1.1.1.1  martti 	&tcp_ack_on_push, \
    538  1.1.1.1  martti 	NULL, \
    539  1.1.1.1  martti 	&tcp_syn_cache_limit, \
    540  1.1.1.1  martti 	&tcp_syn_bucket_limit, \
    541  1.1.1.1  martti 	&tcp_do_rfc3390, \
    542  1.1.1.1  martti 	NULL, \
    543  1.1.1.1  martti 	NULL, \
    544  1.1.1.1  martti 	NULL \
    545  1.1.1.1  martti }
    546  1.1.1.1  martti 
    547  1.1.1.1  martti struct tcp_ident_mapping {
    548  1.1.1.1  martti 	struct sockaddr_storage faddr, laddr;
    549  1.1.1.1  martti 	int euid, ruid;
    550  1.1.1.1  martti };
    551  1.1.1.1  martti 
    552  1.1.1.1  martti #ifdef _KERNEL
    553  1.1.1.1  martti extern	struct inpcbtable tcbtable;	/* head of queue of active tcpcb's */
    554  1.1.1.1  martti extern	struct tcpstat tcpstat;	/* tcp statistics */
    555  1.1.1.1  martti extern	u_int32_t tcp_now;		/* for RFC 1323 timestamps */
    556  1.1.1.1  martti extern	int tcp_do_rfc1323;	/* enabled/disabled? */
    557  1.1.1.1  martti extern	int tcp_mssdflt;	/* default maximum segment size */
    558  1.1.1.1  martti extern	int tcp_ack_on_push;	/* ACK immediately on PUSH */
    559  1.1.1.1  martti #ifdef TCP_SACK
    560  1.1.1.1  martti extern	int tcp_do_sack;	/* SACK enabled/disabled */
    561  1.1.1.1  martti extern	struct pool sackhl_pool;
    562  1.1.1.1  martti extern	int tcp_sackhole_limit;	/* max entries for tcp sack queues */
    563  1.1.1.1  martti #endif
    564  1.1.1.1  martti extern	int tcp_do_ecn;		/* RFC3168 ECN enabled/disabled? */
    565  1.1.1.1  martti extern	int tcp_do_rfc3390;	/* RFC3390 Increasing TCP's Initial Window */
    566  1.1.1.1  martti 
    567  1.1.1.1  martti extern	struct pool tcpqe_pool;
    568  1.1.1.1  martti extern	int tcp_reass_limit;	/* max entries for tcp reass queues */
    569  1.1.1.1  martti 
    570  1.1.1.1  martti extern	int tcp_syn_cache_limit; /* max entries for compressed state engine */
    571  1.1.1.1  martti extern	int tcp_syn_bucket_limit;/* max entries per hash bucket */
    572  1.1.1.1  martti 
    573  1.1.1.1  martti extern	int tcp_syn_cache_size;
    574  1.1.1.1  martti extern	struct syn_cache_head tcp_syn_cache[];
    575  1.1.1.1  martti extern	u_long syn_cache_count;
    576  1.1.1.1  martti 
    577  1.1.1.1  martti int	 tcp_attach(struct socket *);
    578  1.1.1.1  martti void	 tcp_canceltimers(struct tcpcb *);
    579  1.1.1.1  martti struct tcpcb *
    580  1.1.1.1  martti 	 tcp_close(struct tcpcb *);
    581  1.1.1.1  martti void	 tcp_reaper(void *);
    582  1.1.1.1  martti int	 tcp_freeq(struct tcpcb *);
    583  1.1.1.1  martti #if defined(INET6) && !defined(TCP6)
    584  1.1.1.1  martti void	 tcp6_ctlinput(int, struct sockaddr *, void *);
    585  1.1.1.1  martti #endif
    586  1.1.1.1  martti void	 *tcp_ctlinput(int, struct sockaddr *, void *);
    587  1.1.1.1  martti int	 tcp_ctloutput(int, struct socket *, int, int, struct mbuf **);
    588  1.1.1.1  martti struct tcpcb *
    589  1.1.1.1  martti 	 tcp_disconnect(struct tcpcb *);
    590  1.1.1.1  martti struct tcpcb *
    591  1.1.1.1  martti 	 tcp_drop(struct tcpcb *, int);
    592  1.1.1.1  martti int	 tcp_dooptions(struct tcpcb *, u_char *, int, struct tcphdr *,
    593  1.1.1.1  martti 		struct mbuf *, int, struct tcp_opt_info *);
    594  1.1.1.1  martti void	 tcp_drain(void);
    595  1.1.1.1  martti void	 tcp_init(void);
    596  1.1.1.1  martti #if defined(INET6) && !defined(TCP6)
    597  1.1.1.1  martti int	 tcp6_input(struct mbuf **, int *, int);
    598  1.1.1.1  martti #endif
    599  1.1.1.1  martti void	 tcp_input(struct mbuf *, ...);
    600  1.1.1.1  martti int	 tcp_mss(struct tcpcb *, int);
    601  1.1.1.1  martti void	 tcp_mss_update(struct tcpcb *);
    602  1.1.1.1  martti u_int	 tcp_hdrsz(struct tcpcb *);
    603  1.1.1.1  martti void	 tcp_mtudisc(struct inpcb *, int);
    604  1.1.1.1  martti void	 tcp_mtudisc_increase(struct inpcb *, int);
    605  1.1.1.1  martti #ifdef INET6
    606  1.1.1.1  martti void	tcp6_mtudisc(struct inpcb *, int);
    607  1.1.1.1  martti void	tcp6_mtudisc_callback(struct in6_addr *);
    608  1.1.1.1  martti #endif
    609  1.1.1.1  martti struct tcpcb *
    610  1.1.1.1  martti 	 tcp_newtcpcb(struct inpcb *);
    611  1.1.1.1  martti void	 tcp_notify(struct inpcb *, int);
    612  1.1.1.1  martti int	 tcp_output(struct tcpcb *);
    613  1.1.1.1  martti void	 tcp_pulloutofband(struct socket *, u_int, struct mbuf *, int);
    614  1.1.1.1  martti int	 tcp_reass(struct tcpcb *, struct tcphdr *, struct mbuf *, int *);
    615  1.1.1.1  martti void	 tcp_rscale(struct tcpcb *, u_long);
    616  1.1.1.1  martti void	 tcp_respond(struct tcpcb *, caddr_t, struct mbuf *, tcp_seq,
    617  1.1.1.1  martti 		tcp_seq, int);
    618  1.1.1.1  martti void	 tcp_setpersist(struct tcpcb *);
    619  1.1.1.1  martti void	 tcp_slowtimo(void);
    620  1.1.1.1  martti struct mbuf *
    621  1.1.1.1  martti 	 tcp_template(struct tcpcb *);
    622  1.1.1.1  martti void	 tcp_trace(short, short, struct tcpcb *, caddr_t, int, int);
    623  1.1.1.1  martti struct tcpcb *
    624  1.1.1.1  martti 	 tcp_usrclosed(struct tcpcb *);
    625  1.1.1.1  martti int	 tcp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
    626  1.1.1.1  martti #if defined(INET6) && !defined(TCP6)
    627  1.1.1.1  martti int	 tcp6_usrreq(struct socket *,
    628  1.1.1.1  martti 	    int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
    629  1.1.1.1  martti #endif
    630  1.1.1.1  martti int	 tcp_usrreq(struct socket *,
    631  1.1.1.1  martti 	    int, struct mbuf *, struct mbuf *, struct mbuf *);
    632  1.1.1.1  martti void	 tcp_xmit_timer(struct tcpcb *, int);
    633  1.1.1.1  martti void	 tcpdropoldhalfopen(struct tcpcb *, u_int16_t);
    634  1.1.1.1  martti #ifdef TCP_SACK
    635  1.1.1.1  martti void	 tcp_sack_option(struct tcpcb *,struct tcphdr *,u_char *,int);
    636  1.1.1.1  martti void	 tcp_update_sack_list(struct tcpcb *tp, tcp_seq, tcp_seq);
    637  1.1.1.1  martti void	 tcp_del_sackholes(struct tcpcb *, struct tcphdr *);
    638  1.1.1.1  martti void	 tcp_clean_sackreport(struct tcpcb *tp);
    639  1.1.1.1  martti void	 tcp_sack_adjust(struct tcpcb *tp);
    640  1.1.1.1  martti struct sackhole *
    641  1.1.1.1  martti 	 tcp_sack_output(struct tcpcb *tp);
    642  1.1.1.1  martti int	 tcp_sack_partialack(struct tcpcb *, struct tcphdr *);
    643  1.1.1.1  martti #ifdef DEBUG
    644  1.1.1.1  martti void	 tcp_print_holes(struct tcpcb *tp);
    645  1.1.1.1  martti #endif
    646  1.1.1.1  martti #endif /* TCP_SACK */
    647  1.1.1.1  martti #if defined(TCP_SACK)
    648  1.1.1.1  martti int	 tcp_newreno(struct tcpcb *, struct tcphdr *);
    649  1.1.1.1  martti u_long	 tcp_seq_subtract(u_long, u_long );
    650  1.1.1.1  martti #endif /* TCP_SACK */
    651  1.1.1.1  martti #ifdef TCP_SIGNATURE
    652  1.1.1.1  martti int	tcp_signature_apply(caddr_t, caddr_t, unsigned int);
    653  1.1.1.1  martti int	tcp_signature(struct tdb *, int, struct mbuf *, struct tcphdr *,
    654  1.1.1.1  martti 	    int, int, char *);
    655  1.1.1.1  martti #endif /* TCP_SIGNATURE */
    656  1.1.1.1  martti void	tcp_rndiss_init(void);
    657  1.1.1.1  martti tcp_seq	tcp_rndiss_next(void);
    658  1.1.1.1  martti u_int16_t
    659  1.1.1.1  martti 	tcp_rndiss_encrypt(u_int16_t);
    660  1.1.1.1  martti void     tcp_set_iss_tsm(struct tcpcb *);
    661  1.1.1.1  martti 
    662  1.1.1.1  martti int	 syn_cache_add(struct sockaddr *, struct sockaddr *,
    663  1.1.1.1  martti 		struct tcphdr *, unsigned int, struct socket *,
    664  1.1.1.1  martti 		struct mbuf *, u_char *, int, struct tcp_opt_info *, tcp_seq *);
    665  1.1.1.1  martti void	 syn_cache_unreach(struct sockaddr *, struct sockaddr *,
    666  1.1.1.1  martti 	   struct tcphdr *);
    667  1.1.1.1  martti struct socket *syn_cache_get(struct sockaddr *, struct sockaddr *,
    668  1.1.1.1  martti 		struct tcphdr *, unsigned int, unsigned int,
    669  1.1.1.1  martti 		struct socket *so, struct mbuf *);
    670  1.1.1.1  martti void	 syn_cache_init(void);
    671  1.1.1.1  martti void	 syn_cache_insert(struct syn_cache *, struct tcpcb *);
    672  1.1.1.1  martti struct syn_cache *syn_cache_lookup(struct sockaddr *, struct sockaddr *,
    673  1.1.1.1  martti 		struct syn_cache_head **);
    674  1.1.1.1  martti void	 syn_cache_reset(struct sockaddr *, struct sockaddr *,
    675  1.1.1.1  martti 		struct tcphdr *);
    676  1.1.1.1  martti int	 syn_cache_respond(struct syn_cache *, struct mbuf *);
    677  1.1.1.1  martti void	 syn_cache_timer(void *);
    678  1.1.1.1  martti void	 syn_cache_cleanup(struct tcpcb *);
    679  1.1.1.1  martti void	 syn_cache_reaper(void *);
    680  1.1.1.1  martti 
    681  1.1.1.1  martti #endif /* _KERNEL */
    682  1.1.1.1  martti #endif /* _NETINET_TCP_VAR_H_ */
    683