xref: /csrg-svn/sys/netinet/tcp.h (revision 4499)
1*4499Swnj /* tcp.h 1.1 81/10/14 */
2*4499Swnj struct th {                     /* tcp header (fits over ip header) */
3*4499Swnj 	struct th *t_next;              /* -> next tcp on rcv chain */
4*4499Swnj 	struct th *t_prev;              /* -> prev tcp on rcv chain */
5*4499Swnj 	unsigned char t_x1;             /* (unused) */
6*4499Swnj 	unsigned char t_pr;             /* protocol */
7*4499Swnj 	unsigned short t_len;           /* seg length */
8*4499Swnj 	struct socket t_s;              /* source internet address */
9*4499Swnj 	struct socket t_d;              /* destination internet address */
10*4499Swnj 	unsigned short t_src;           /* source port */
11*4499Swnj 	unsigned short t_dst;           /* destination port */
12*4499Swnj 	sequence t_seq;                 /* sequence number */
13*4499Swnj 	sequence t_ackno;               /* acknowledgement number */
14*4499Swnj #define t_end(x) (x->t_seq + x->t_len - 1)
15*4499Swnj 	unsigned char
16*4499Swnj 		t_x2:4,                 /* (unused) */
17*4499Swnj 		t_off:4;                /* data offset */
18*4499Swnj 	unsigned char
19*4499Swnj 		t_fin:1,                /* fin flag */
20*4499Swnj 		t_syn:1,                /* syn flag */
21*4499Swnj 		t_rst:1,                /* reset flag */
22*4499Swnj 		t_eol:1,                /* eol flag */
23*4499Swnj 		t_ack:1,                /* ack flag */
24*4499Swnj 		t_urg:1,                /* urgent flag */
25*4499Swnj 		t_x3:2;                 /* (unused) */
26*4499Swnj 	unsigned short t_win;           /* window */
27*4499Swnj 	unsigned short t_sum;           /* checksum */
28*4499Swnj 	unsigned short t_urp;           /* urgent pointer */
29*4499Swnj };
30*4499Swnj 
31*4499Swnj struct tcb {                    /* tcp control block */
32*4499Swnj 
33*4499Swnj 	/* various pointers */
34*4499Swnj 
35*4499Swnj 	struct th *t_rcv_next;          /* -> first el on rcv queue */
36*4499Swnj 	struct th *t_rcv_prev;          /* -> last el on rcv queue */
37*4499Swnj 	struct tcb *t_tcb_next;         /* -> next tcb */
38*4499Swnj 	struct tcb *t_tcb_prev;         /* -> prev tcb */
39*4499Swnj 	struct ucb *t_ucb;              /* -> ucb */
40*4499Swnj 	struct mbuf *t_rcv_unack;       /* -> unacked message queue */
41*4499Swnj 
42*4499Swnj 	/* sequence number variables */
43*4499Swnj 
44*4499Swnj 	sequence iss;                   /* initial send seq # */
45*4499Swnj 	sequence irs;                   /* initial recv seq # */
46*4499Swnj 	sequence rcv_urp;               /* rcv urgent pointer */
47*4499Swnj 	sequence rcv_nxt;               /* next seq # to rcv */
48*4499Swnj 	sequence rcv_end;               /* rcv eol pointer */
49*4499Swnj 	sequence snd_off;               /* seq # of first datum in send buf */
50*4499Swnj 	sequence seq_fin;               /* seq # of FIN sent */
51*4499Swnj 	sequence snd_end;               /* send eol pointer */
52*4499Swnj 	sequence snd_urp;               /* snd urgent pointer */
53*4499Swnj 	sequence snd_lst;               /* seq # of last sent datum */
54*4499Swnj 	sequence snd_nxt;               /* seq # of next datum to send */
55*4499Swnj 	sequence snd_una;               /* seq # of first unacked datum */
56*4499Swnj 	sequence snd_wl;                /* seq # of last sent window */
57*4499Swnj 	sequence snd_hi;                /* highest seq # sent */
58*4499Swnj 	sequence snd_wnd;               /* send window max */
59*4499Swnj 	sequence t_rexmt_val;           /* value saved in rexmt timer */
60*4499Swnj 	sequence t_rtl_val;             /* value saved in rexmt too long timer */
61*4499Swnj 	sequence t_xmt_val;             /* seq # sent when xmt timer started */
62*4499Swnj 
63*4499Swnj 	/* various flags and state variables */
64*4499Swnj 
65*4499Swnj 	unsigned short
66*4499Swnj 		ack_due:1,              /* must we send ACK */
67*4499Swnj 		cancelled:1,            /* retransmit timer cancelled */
68*4499Swnj 		dropped_txt:1,          /* dropped incoming data */
69*4499Swnj 		fin_rcvd:1,             /* FIN received */
70*4499Swnj 		force_one:1,            /* force sending of one byte */
71*4499Swnj 		new_window:1,           /* received new window size */
72*4499Swnj 		rexmt:1,                /* this msg is a retransmission */
73*4499Swnj 		snd_fin:1,              /* FIN should be sent */
74*4499Swnj 		snd_rst:1,              /* RST should be sent */
75*4499Swnj 		snd_urg:1,              /* urgent data to send */
76*4499Swnj 		syn_acked:1,            /* SYN has been ACKed */
77*4499Swnj 		syn_rcvd:1,             /* SYN has been received */
78*4499Swnj 		usr_closed:1,           /* user has closed connection */
79*4499Swnj 		waited_2_ml:1,          /* wait time for FIN ACK is up */
80*4499Swnj 		net_keep:1,             /* don't free this net input */
81*4499Swnj 		usr_abort:1;            /* user has closed and does not expect
82*4499Swnj 					   to receive any more data */
83*4499Swnj 
84*4499Swnj 	unsigned short t_flag2;         /* (unused) */
85*4499Swnj 	unsigned short t_lport;         /* local port */
86*4499Swnj 	unsigned short t_fport;         /* foreign port */
87*4499Swnj 	unsigned char t_state;          /* state of this connection */
88*4499Swnj 	unsigned char t_xmtime;         /* current rexmt time */
89*4499Swnj 	unsigned char t_sec;            /* security */
90*4499Swnj 	unsigned char t_prec;           /* precedence */
91*4499Swnj 	unsigned char t_compt;          /* compartment */
92*4499Swnj 
93*4499Swnj 	/* timers */
94*4499Swnj 
95*4499Swnj 	unsigned char t_init;           /* initialization too long */
96*4499Swnj 	unsigned char t_rexmt;          /* retransmission */
97*4499Swnj 	unsigned char t_rexmttl;        /* retransmit too long */
98*4499Swnj 	unsigned char t_persist;        /* retransmit persistance */
99*4499Swnj 	unsigned char t_finack;         /* fin acknowledged */
100*4499Swnj 	unsigned char t_xmt;            /* round trip transmission time */
101*4499Swnj };
102*4499Swnj 
103*4499Swnj #define ISSINCR 128                     /* increment for iss each second */
104*4499Swnj #define TCPROTO 6                       /* TCP-4 protocol number */
105*4499Swnj #define TCPSIZE 20                      /* size of TCP leader (bytes) */
106*4499Swnj #define T_2ML   10                      /* 2*maximum packet lifetime */
107*4499Swnj #define T_PERS  5                       /* persist time */
108*4499Swnj #define T_INIT  30                      /* init too long timeout */
109*4499Swnj #define T_REXMT 1                       /* base for retransmission time */
110*4499Swnj #define T_REXMTTL 30                    /* retransmit too long timeout */
111*4499Swnj #define T_REMAX 30                      /* maximum retransmission time */
112*4499Swnj #define ACTIVE  1                       /* active open */
113*4499Swnj #define PASSIVE 0                       /* passive open */
114*4499Swnj 
115