1 /*
2  * Copyright (c) 1997-1998 by Sun Microsystems, Inc.
3  * All rights reserved.
4  */
5 
6 /*
7  * Copyright (c) 1982, 1986 Regents of the University of California.
8  * All rights reserved.  The Berkeley software License Agreement
9  * specifies the terms and conditions for redistribution.
10  */
11 
12 /*
13  * Kernel variables for tcp.
14  */
15 
16 #ifndef	_NETINET_TCP_VAR_H
17 #define	_NETINET_TCP_VAR_H
18 
19 /* tcp_var.h 1.11 88/08/19 SMI; from UCB 7.3 6/30/87	*/
20 
21 #ifdef	__cplusplus
22 extern "C" {
23 #endif
24 
25 /*
26  * Tcp control block, one per tcp; fields:
27  */
28 struct tcpcb {
29 	struct	tcpiphdr *seg_next;	/* sequencing queue */
30 	struct	tcpiphdr *seg_prev;
31 	short	t_state;		/* state of this connection */
32 	short	t_timer[TCPT_NTIMERS];	/* tcp timers */
33 	short	t_rxtshift;		/* log(2) of rexmt exp. backoff */
34 	short	t_rxtcur;		/* current retransmit value */
35 	short	t_dupacks;		/* consecutive dup acks recd */
36 	ushort_t t_maxseg;		/* maximum segment size */
37 	char	t_force;		/* 1 if forcing out a byte */
38 	uchar_t	t_flags;
39 #define	TF_ACKNOW	0x01		/* ack peer immediately */
40 #define	TF_DELACK	0x02		/* ack, but try to delay it */
41 #define	TF_NODELAY	0x04		/* don't delay packets to coalesce */
42 #define	TF_NOOPT	0x08		/* don't use tcp options */
43 #define	TF_SENTFIN	0x10		/* have sent FIN */
44 	struct	tcpiphdr *t_template;	/* skeletal packet for transmit */
45 	struct	inpcb *t_inpcb;		/* back pointer to internet pcb */
46 /*
47  * The following fields are used as in the protocol specification.
48  * See RFC783, Dec. 1981, page 21.
49  */
50 /* send sequence variables */
51 	tcp_seq	snd_una;		/* send unacknowledged */
52 	tcp_seq	snd_nxt;		/* send next */
53 	tcp_seq	snd_up;			/* send urgent pointer */
54 	tcp_seq	snd_wl1;		/* window update seg seq number */
55 	tcp_seq	snd_wl2;		/* window update seg ack number */
56 	tcp_seq	iss;			/* initial send sequence number */
57 	ushort_t snd_wnd;		/* send window */
58 /* receive sequence variables */
59 	ushort_t rcv_wnd;		/* receive window */
60 	tcp_seq	rcv_nxt;		/* receive next */
61 	tcp_seq	rcv_up;			/* receive urgent pointer */
62 	tcp_seq	irs;			/* initial receive sequence number */
63 /*
64  * Additional variables for this implementation.
65  */
66 /* receive variables */
67 	tcp_seq	rcv_adv;		/* advertised window */
68 /* retransmit variables */
69 	tcp_seq	snd_max;		/* highest sequence number sent */
70 					/* used to recognize retransmits */
71 
72 /* congestion control (for slow start, source quench, retransmit after loss) */
73 	ushort_t snd_cwnd;		/* congestion-controlled window */
74 	ushort_t snd_ssthresh;		/* snd_cwnd size threshhold for */
75 					/* for slow start exponential to */
76 /*
77  * transmit timing stuff.
78  * srtt and rttvar are stored as fixed point; for convenience in smoothing,
79  * srtt has 3 bits to the right of the binary point, rttvar has 2.
80  * "Variance" is actually smoothed difference.
81  */
82 	short	t_idle;			/* inactivity time */
83 	short	t_rtt;			/* round trip time */
84 	tcp_seq	t_rtseq;		/* sequence number being timed */
85 	short	t_srtt;			/* smoothed round-trip time */
86 	short	t_rttvar;		/* variance in round-trip time */
87 	ushort_t max_rcvd;		/* most peer has sent into window */
88 	ushort_t max_sndwnd;		/* largest window peer has offered */
89 /* out-of-band data */
90 	char	t_oobflags;		/* have some */
91 	char	t_iobc;			/* input character */
92 #define	TCPOOB_HAVEDATA	0x01
93 #define	TCPOOB_HADDATA	0x02
94 };
95 
96 #define	intotcpcb(ip)	((struct tcpcb *)(ip)->inp_ppcb)
97 #define	sototcpcb(so)	(intotcpcb(sotoinpcb(so)))
98 
99 /*
100  * TCP statistics.
101  * Many of these should be kept per connection,
102  * but that's inconvenient at the moment.
103  */
104 struct	tcpstat {
105 	uint_t	tcps_connattempt;	/* connections initiated */
106 	uint_t	tcps_accepts;		/* connections accepted */
107 	uint_t	tcps_connects;		/* connections established */
108 	uint_t	tcps_drops;		/* connections dropped */
109 	uint_t	tcps_conndrops;		/* embryonic connections dropped */
110 	uint_t	tcps_closed;		/* conn. closed (includes drops) */
111 	uint_t	tcps_segstimed;		/* segs where we tried to get rtt */
112 	uint_t	tcps_rttupdated;	/* times we succeeded */
113 	uint_t	tcps_delack;		/* delayed acks sent */
114 	uint_t	tcps_timeoutdrop;	/* conn. dropped in rxmt timeout */
115 	uint_t	tcps_rexmttimeo;	/* retransmit timeouts */
116 	uint_t	tcps_persisttimeo;	/* persist timeouts */
117 	uint_t	tcps_keeptimeo;		/* keepalive timeouts */
118 	uint_t	tcps_keepprobe;		/* keepalive probes sent */
119 	uint_t	tcps_keepdrops;		/* connections dropped in keepalive */
120 
121 	uint_t	tcps_sndtotal;		/* total packets sent */
122 	uint_t	tcps_sndpack;		/* data packets sent */
123 	uint_t	tcps_sndbyte;		/* data bytes sent */
124 	uint_t	tcps_sndrexmitpack;	/* data packets retransmitted */
125 	uint_t	tcps_sndrexmitbyte;	/* data bytes retransmitted */
126 	uint_t	tcps_sndacks;		/* ack-only packets sent */
127 	uint_t	tcps_sndprobe;		/* window probes sent */
128 	uint_t	tcps_sndurg;		/* packets sent with URG only */
129 	uint_t	tcps_sndwinup;		/* window update-only packets sent */
130 	uint_t	tcps_sndctrl;		/* control (SYN|FIN|RST) packets sent */
131 
132 	uint_t	tcps_rcvtotal;		/* total packets received */
133 	uint_t	tcps_rcvpack;		/* packets received in sequence */
134 	uint_t	tcps_rcvbyte;		/* bytes received in sequence */
135 	uint_t	tcps_rcvbadsum;		/* packets received with ccksum errs */
136 	uint_t	tcps_rcvbadoff;		/* packets received with bad offset */
137 	uint_t	tcps_rcvshort;		/* packets received too short */
138 	uint_t	tcps_rcvduppack;	/* duplicate-only packets received */
139 	uint_t	tcps_rcvdupbyte;	/* duplicate-only bytes received */
140 	uint_t	tcps_rcvpartduppack;	/* packets with some duplicate data */
141 	uint_t	tcps_rcvpartdupbyte;	/* dup. bytes in part-dup. packets */
142 	uint_t	tcps_rcvoopack;		/* out-of-order packets received */
143 	uint_t	tcps_rcvoobyte;		/* out-of-order bytes received */
144 	uint_t	tcps_rcvpackafterwin;	/* packets with data after window */
145 	uint_t	tcps_rcvbyteafterwin;	/* bytes rcvd after window */
146 	uint_t	tcps_rcvafterclose;	/* packets rcvd after "close" */
147 	uint_t	tcps_rcvwinprobe;	/* rcvd window probe packets */
148 	uint_t	tcps_rcvdupack;		/* rcvd duplicate acks */
149 	uint_t	tcps_rcvacktoomuch;	/* rcvd acks for unsent data */
150 	uint_t	tcps_rcvackpack;	/* rcvd ack packets */
151 	uint_t	tcps_rcvackbyte;	/* bytes acked by rcvd acks */
152 	uint_t	tcps_rcvwinupd;		/* rcvd window update packets */
153 };
154 
155 #define	TCP_COMPAT_42
156 
157 #ifdef	__cplusplus
158 }
159 #endif
160 
161 #endif	/* _NETINET_TCP_VAR_H */
162