17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * Copyright (c) 1997-1998 by Sun Microsystems, Inc.
37c478bdstevel@tonic-gate * All rights reserved.
47c478bdstevel@tonic-gate */
57c478bdstevel@tonic-gate
67c478bdstevel@tonic-gate/*
77c478bdstevel@tonic-gate * Copyright (c) 1982, 1986 Regents of the University of California.
87c478bdstevel@tonic-gate * All rights reserved.  The Berkeley software License Agreement
97c478bdstevel@tonic-gate * specifies the terms and conditions for redistribution.
107c478bdstevel@tonic-gate */
117c478bdstevel@tonic-gate
127c478bdstevel@tonic-gate/*
137c478bdstevel@tonic-gate * Kernel variables for tcp.
147c478bdstevel@tonic-gate */
157c478bdstevel@tonic-gate
167c478bdstevel@tonic-gate#ifndef	_NETINET_TCP_VAR_H
177c478bdstevel@tonic-gate#define	_NETINET_TCP_VAR_H
187c478bdstevel@tonic-gate
197c478bdstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
207c478bdstevel@tonic-gate/* tcp_var.h 1.11 88/08/19 SMI; from UCB 7.3 6/30/87	*/
217c478bdstevel@tonic-gate
227c478bdstevel@tonic-gate#ifdef	__cplusplus
237c478bdstevel@tonic-gateextern "C" {
247c478bdstevel@tonic-gate#endif
257c478bdstevel@tonic-gate
267c478bdstevel@tonic-gate/*
277c478bdstevel@tonic-gate * Tcp control block, one per tcp; fields:
287c478bdstevel@tonic-gate */
297c478bdstevel@tonic-gatestruct tcpcb {
307c478bdstevel@tonic-gate	struct	tcpiphdr *seg_next;	/* sequencing queue */
317c478bdstevel@tonic-gate	struct	tcpiphdr *seg_prev;
327c478bdstevel@tonic-gate	short	t_state;		/* state of this connection */
337c478bdstevel@tonic-gate	short	t_timer[TCPT_NTIMERS];	/* tcp timers */
347c478bdstevel@tonic-gate	short	t_rxtshift;		/* log(2) of rexmt exp. backoff */
357c478bdstevel@tonic-gate	short	t_rxtcur;		/* current retransmit value */
367c478bdstevel@tonic-gate	short	t_dupacks;		/* consecutive dup acks recd */
377c478bdstevel@tonic-gate	ushort_t t_maxseg;		/* maximum segment size */
387c478bdstevel@tonic-gate	char	t_force;		/* 1 if forcing out a byte */
397c478bdstevel@tonic-gate	uchar_t	t_flags;
407c478bdstevel@tonic-gate#define	TF_ACKNOW	0x01		/* ack peer immediately */
417c478bdstevel@tonic-gate#define	TF_DELACK	0x02		/* ack, but try to delay it */
427c478bdstevel@tonic-gate#define	TF_NODELAY	0x04		/* don't delay packets to coalesce */
437c478bdstevel@tonic-gate#define	TF_NOOPT	0x08		/* don't use tcp options */
447c478bdstevel@tonic-gate#define	TF_SENTFIN	0x10		/* have sent FIN */
457c478bdstevel@tonic-gate	struct	tcpiphdr *t_template;	/* skeletal packet for transmit */
467c478bdstevel@tonic-gate	struct	inpcb *t_inpcb;		/* back pointer to internet pcb */
477c478bdstevel@tonic-gate/*
487c478bdstevel@tonic-gate * The following fields are used as in the protocol specification.
497c478bdstevel@tonic-gate * See RFC783, Dec. 1981, page 21.
507c478bdstevel@tonic-gate */
517c478bdstevel@tonic-gate/* send sequence variables */
527c478bdstevel@tonic-gate	tcp_seq	snd_una;		/* send unacknowledged */
537c478bdstevel@tonic-gate	tcp_seq	snd_nxt;		/* send next */
547c478bdstevel@tonic-gate	tcp_seq	snd_up;			/* send urgent pointer */
557c478bdstevel@tonic-gate	tcp_seq	snd_wl1;		/* window update seg seq number */
567c478bdstevel@tonic-gate	tcp_seq	snd_wl2;		/* window update seg ack number */
577c478bdstevel@tonic-gate	tcp_seq	iss;			/* initial send sequence number */
587c478bdstevel@tonic-gate	ushort_t snd_wnd;		/* send window */
597c478bdstevel@tonic-gate/* receive sequence variables */
607c478bdstevel@tonic-gate	ushort_t rcv_wnd;		/* receive window */
617c478bdstevel@tonic-gate	tcp_seq	rcv_nxt;		/* receive next */
627c478bdstevel@tonic-gate	tcp_seq	rcv_up;			/* receive urgent pointer */
637c478bdstevel@tonic-gate	tcp_seq	irs;			/* initial receive sequence number */
647c478bdstevel@tonic-gate/*
657c478bdstevel@tonic-gate * Additional variables for this implementation.
667c478bdstevel@tonic-gate */
677c478bdstevel@tonic-gate/* receive variables */
687c478bdstevel@tonic-gate	tcp_seq	rcv_adv;		/* advertised window */
697c478bdstevel@tonic-gate/* retransmit variables */
707c478bdstevel@tonic-gate	tcp_seq	snd_max;		/* highest sequence number sent */
717c478bdstevel@tonic-gate					/* used to recognize retransmits */
727c478bdstevel@tonic-gate
737c478bdstevel@tonic-gate/* congestion control (for slow start, source quench, retransmit after loss) */
747c478bdstevel@tonic-gate	ushort_t snd_cwnd;		/* congestion-controlled window */
757c478bdstevel@tonic-gate	ushort_t snd_ssthresh;		/* snd_cwnd size threshhold for */
767c478bdstevel@tonic-gate					/* for slow start exponential to */
777c478bdstevel@tonic-gate/*
787c478bdstevel@tonic-gate * transmit timing stuff.
797c478bdstevel@tonic-gate * srtt and rttvar are stored as fixed point; for convenience in smoothing,
807c478bdstevel@tonic-gate * srtt has 3 bits to the right of the binary point, rttvar has 2.
817c478bdstevel@tonic-gate * "Variance" is actually smoothed difference.
827c478bdstevel@tonic-gate */
837c478bdstevel@tonic-gate	short	t_idle;			/* inactivity time */
847c478bdstevel@tonic-gate	short	t_rtt;			/* round trip time */
857c478bdstevel@tonic-gate	tcp_seq	t_rtseq;		/* sequence number being timed */
867c478bdstevel@tonic-gate	short	t_srtt;			/* smoothed round-trip time */
877c478bdstevel@tonic-gate	short	t_rttvar;		/* variance in round-trip time */
887c478bdstevel@tonic-gate	ushort_t max_rcvd;		/* most peer has sent into window */
897c478bdstevel@tonic-gate	ushort_t max_sndwnd;		/* largest window peer has offered */
907c478bdstevel@tonic-gate/* out-of-band data */
917c478bdstevel@tonic-gate	char	t_oobflags;		/* have some */
927c478bdstevel@tonic-gate	char	t_iobc;			/* input character */
937c478bdstevel@tonic-gate#define	TCPOOB_HAVEDATA	0x01
947c478bdstevel@tonic-gate#define	TCPOOB_HADDATA	0x02
957c478bdstevel@tonic-gate};
967c478bdstevel@tonic-gate
977c478bdstevel@tonic-gate#define	intotcpcb(ip)	((struct tcpcb *)(ip)->inp_ppcb)
987c478bdstevel@tonic-gate#define	sototcpcb(so)	(intotcpcb(sotoinpcb(so)))
997c478bdstevel@tonic-gate
1007c478bdstevel@tonic-gate/*
1017c478bdstevel@tonic-gate * TCP statistics.
1027c478bdstevel@tonic-gate * Many of these should be kept per connection,
1037c478bdstevel@tonic-gate * but that's inconvenient at the moment.
1047c478bdstevel@tonic-gate */
1057c478bdstevel@tonic-gatestruct	tcpstat {
1067c478bdstevel@tonic-gate	uint_t	tcps_connattempt;	/* connections initiated */
1077c478bdstevel@tonic-gate	uint_t	tcps_accepts;		/* connections accepted */
1087c478bdstevel@tonic-gate	uint_t	tcps_connects;		/* connections established */
1097c478bdstevel@tonic-gate	uint_t	tcps_drops;		/* connections dropped */
1107c478bdstevel@tonic-gate	uint_t	tcps_conndrops;		/* embryonic connections dropped */
1117c478bdstevel@tonic-gate	uint_t	tcps_closed;		/* conn. closed (includes drops) */
1127c478bdstevel@tonic-gate	uint_t	tcps_segstimed;		/* segs where we tried to get rtt */
1137c478bdstevel@tonic-gate	uint_t	tcps_rttupdated;	/* times we succeeded */
1147c478bdstevel@tonic-gate	uint_t	tcps_delack;		/* delayed acks sent */
1157c478bdstevel@tonic-gate	uint_t	tcps_timeoutdrop;	/* conn. dropped in rxmt timeout */
1167c478bdstevel@tonic-gate	uint_t	tcps_rexmttimeo;	/* retransmit timeouts */
1177c478bdstevel@tonic-gate	uint_t	tcps_persisttimeo;	/* persist timeouts */
1187c478bdstevel@tonic-gate	uint_t	tcps_keeptimeo;		/* keepalive timeouts */
1197c478bdstevel@tonic-gate	uint_t	tcps_keepprobe;		/* keepalive probes sent */
1207c478bdstevel@tonic-gate	uint_t	tcps_keepdrops;		/* connections dropped in keepalive */
1217c478bdstevel@tonic-gate
1227c478bdstevel@tonic-gate	uint_t	tcps_sndtotal;		/* total packets sent */
1237c478bdstevel@tonic-gate	uint_t	tcps_sndpack;		/* data packets sent */
1247c478bdstevel@tonic-gate	uint_t	tcps_sndbyte;		/* data bytes sent */
1257c478bdstevel@tonic-gate	uint_t	tcps_sndrexmitpack;	/* data packets retransmitted */
1267c478bdstevel@tonic-gate	uint_t	tcps_sndrexmitbyte;	/* data bytes retransmitted */
1277c478bdstevel@tonic-gate	uint_t	tcps_sndacks;		/* ack-only packets sent */
1287c478bdstevel@tonic-gate	uint_t	tcps_sndprobe;		/* window probes sent */
1297c478bdstevel@tonic-gate	uint_t	tcps_sndurg;		/* packets sent with URG only */
1307c478bdstevel@tonic-gate	uint_t	tcps_sndwinup;		/* window update-only packets sent */
1317c478bdstevel@tonic-gate	uint_t	tcps_sndctrl;		/* control (SYN|FIN|RST) packets sent */
1327c478bdstevel@tonic-gate
1337c478bdstevel@tonic-gate	uint_t	tcps_rcvtotal;		/* total packets received */
1347c478bdstevel@tonic-gate	uint_t	tcps_rcvpack;		/* packets received in sequence */
1357c478bdstevel@tonic-gate	uint_t	tcps_rcvbyte;		/* bytes received in sequence */
1367c478bdstevel@tonic-gate	uint_t	tcps_rcvbadsum;		/* packets received with ccksum errs */
1377c478bdstevel@tonic-gate	uint_t	tcps_rcvbadoff;		/* packets received with bad offset */
1387c478bdstevel@tonic-gate	uint_t	tcps_rcvshort;		/* packets received too short */
1397c478bdstevel@tonic-gate	uint_t	tcps_rcvduppack;	/* duplicate-only packets received */
1407c478bdstevel@tonic-gate	uint_t	tcps_rcvdupbyte;	/* duplicate-only bytes received */
1417c478bdstevel@tonic-gate	uint_t	tcps_rcvpartduppack;	/* packets with some duplicate data */
1427c478bdstevel@tonic-gate	uint_t	tcps_rcvpartdupbyte;	/* dup. bytes in part-dup. packets */
1437c478bdstevel@tonic-gate	uint_t	tcps_rcvoopack;		/* out-of-order packets received */
1447c478bdstevel@tonic-gate	uint_t	tcps_rcvoobyte;		/* out-of-order bytes received */
1457c478bdstevel@tonic-gate	uint_t	tcps_rcvpackafterwin;	/* packets with data after window */
1467c478bdstevel@tonic-gate	uint_t	tcps_rcvbyteafterwin;	/* bytes rcvd after window */
1477c478bdstevel@tonic-gate	uint_t	tcps_rcvafterclose;	/* packets rcvd after "close" */
1487c478bdstevel@tonic-gate	uint_t	tcps_rcvwinprobe;	/* rcvd window probe packets */
1497c478bdstevel@tonic-gate	uint_t	tcps_rcvdupack;		/* rcvd duplicate acks */
1507c478bdstevel@tonic-gate	uint_t	tcps_rcvacktoomuch;	/* rcvd acks for unsent data */
1517c478bdstevel@tonic-gate	uint_t	tcps_rcvackpack;	/* rcvd ack packets */
1527c478bdstevel@tonic-gate	uint_t	tcps_rcvackbyte;	/* bytes acked by rcvd acks */
1537c478bdstevel@tonic-gate	uint_t	tcps_rcvwinupd;		/* rcvd window update packets */
1547c478bdstevel@tonic-gate};
1557c478bdstevel@tonic-gate
1567c478bdstevel@tonic-gate#define	TCP_COMPAT_42
1577c478bdstevel@tonic-gate
1587c478bdstevel@tonic-gate#ifdef	__cplusplus
1597c478bdstevel@tonic-gate}
1607c478bdstevel@tonic-gate#endif
1617c478bdstevel@tonic-gate
1627c478bdstevel@tonic-gate#endif	/* _NETINET_TCP_VAR_H */
163