xref: /csrg-svn/sys/netinet/tcp_var.h (revision 25262)
1 /*
2  * Copyright (c) 1982 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  *
6  *	@(#)tcp_var.h	6.5 (Berkeley) 10/23/85
7  */
8 
9 /*
10  * Kernel variables for tcp.
11  */
12 
13 /*
14  * Tcp control block, one per tcp; fields:
15  */
16 struct tcpcb {
17 	struct	tcpiphdr *seg_next;	/* sequencing queue */
18 	struct	tcpiphdr *seg_prev;
19 	short	t_state;		/* state of this connection */
20 	short	t_timer[TCPT_NTIMERS];	/* tcp timers */
21 	short	t_rxtshift;		/* log(2) of rexmt exp. backoff */
22 	struct	mbuf *t_tcpopt;		/* tcp options */
23 	short	t_maxseg;		/* maximum segment size */
24 	char	t_force;		/* 1 if forcing out a byte */
25 	u_char	t_flags;
26 #define	TF_ACKNOW	0x01			/* ack peer immediately */
27 #define	TF_DELACK	0x02			/* ack, but try to delay it */
28 #define	TF_DONTKEEP	0x04			/* don't use keep-alives */
29 #define	TF_NOOPT	0x08			/* don't use tcp options */
30 	struct	tcpiphdr *t_template;	/* skeletal packet for transmit */
31 	struct	inpcb *t_inpcb;		/* back pointer to internet pcb */
32 /*
33  * The following fields are used as in the protocol specification.
34  * See RFC783, Dec. 1981, page 21.
35  */
36 /* send sequence variables */
37 	tcp_seq	snd_una;		/* send unacknowledged */
38 	tcp_seq	snd_nxt;		/* send next */
39 	tcp_seq	snd_up;			/* send urgent pointer */
40 	tcp_seq	snd_wl1;		/* window update seg seq number */
41 	tcp_seq	snd_wl2;		/* window update seg ack number */
42 	tcp_seq	iss;			/* initial send sequence number */
43 	u_short	snd_wnd;		/* send window */
44 /* receive sequence variables */
45 	short	rcv_wnd;		/* receive window */
46 	tcp_seq	rcv_nxt;		/* receive next */
47 	tcp_seq	rcv_up;			/* receive urgent pointer */
48 	tcp_seq	irs;			/* initial receive sequence number */
49 /*
50  * Additional variables for this implementation.
51  */
52 /* receive variables */
53 	tcp_seq	rcv_adv;		/* advertised window */
54 /* retransmit variables */
55 	tcp_seq	snd_max;		/* highest sequence number sent
56 					 * used to recognize retransmits
57 					 */
58 /* congestion control (for source quench) */
59 	u_short	snd_cwnd;		/* congestion-controlled window */
60 /* transmit timing stuff */
61 	short	t_idle;			/* inactivity time */
62 	short	t_rtt;			/* round trip time */
63 	u_short max_rcvd;		/* most peer has sent into window */
64 	tcp_seq	t_rtseq;		/* sequence number being timed */
65 	float	t_srtt;			/* smoothed round-trip time */
66 	u_short	max_sndwnd;		/* largest window peer has offered */
67 /* out-of-band data */
68 	char	t_oobflags;		/* have some */
69 	char	t_iobc;			/* input character */
70 #define	TCPOOB_HAVEDATA	0x01
71 #define	TCPOOB_HADDATA	0x02
72 };
73 
74 #define	intotcpcb(ip)	((struct tcpcb *)(ip)->inp_ppcb)
75 #define	sototcpcb(so)	(intotcpcb(sotoinpcb(so)))
76 
77 struct	tcpstat {
78 	int	tcps_badsum;
79 	int	tcps_badoff;
80 	int	tcps_hdrops;
81 	int	tcps_badsegs;
82 	int	tcps_unack;
83 };
84 
85 #ifdef KERNEL
86 struct	inpcb tcb;		/* head of queue of active tcpcb's */
87 struct	tcpstat tcpstat;	/* tcp statistics */
88 struct	tcpiphdr *tcp_template();
89 struct	tcpcb *tcp_close(), *tcp_drop();
90 struct	tcpcb *tcp_timers(), *tcp_disconnect(), *tcp_usrclosed();
91 #endif
92