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