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