Commit | Line | Data |
---|---|---|
a6503abf | 1 | /* tcp_var.h 4.8 81/11/25 */ |
ad6d0022 BJ |
2 | |
3 | /* | |
4 | * Kernel variables for tcp. | |
5 | */ | |
6 | ||
eb44bfb2 BJ |
7 | /* |
8 | * Tcp+ip header, after ip options removed. | |
9 | */ | |
10 | struct tcpiphdr { | |
11 | struct ipovly ti_i; /* overlaid ip structure */ | |
12 | struct tcphdr ti_t; /* tcp header */ | |
13 | }; | |
14 | #define ti_next ti_i.ih_next | |
15 | #define ti_prev ti_i.ih_prev | |
16 | #define ti_x1 ti_i.ih_x1 | |
17 | #define ti_pr ti_i.ih_pr | |
18 | #define ti_len ti_i.ih_len | |
19 | #define ti_src ti_i.ih_src | |
20 | #define ti_dst ti_i.ih_dst | |
21 | #define ti_sport ti_t.th_sport | |
22 | #define ti_dport ti_t.th_dport | |
23 | #define ti_seq ti_t.th_seq | |
24 | #define ti_ackno ti_t.th_ackno | |
25 | #define ti_x2 ti_t.th_x2 | |
26 | #define ti_off ti_t.th_off | |
27 | #define ti_flags ti_t.th_flags | |
28 | #define ti_win ti_t.th_win | |
29 | #define ti_sum ti_t.th_sum | |
30 | #define ti_urp ti_t.th_urp | |
31 | ||
2ff61f9d BJ |
32 | /* |
33 | * TCP sequence numbers are 32 bit integers operated | |
34 | * on with modular arithmetic. These macros can be | |
35 | * used to compare such integers. | |
36 | */ | |
37 | #define SEQ_LT(a,b) ((int)((a)-(b)) < 0) | |
38 | #define SEQ_LEQ(a,b) ((int)((a)-(b)) <= 0) | |
39 | #define SEQ_GT(a,b) ((int)((a)-(b)) > 0) | |
40 | #define SEQ_GEQ(a,b) ((int)((a)-(b)) >= 0) | |
41 | ||
42 | /* | |
43 | * Definitions of the TCP timers. These timers are counted | |
44 | * down PR_SLOWHZ times a second. | |
45 | */ | |
a6503abf | 46 | #define TCPT_NTIMERS 4 |
2ff61f9d | 47 | |
a6503abf BJ |
48 | #define TCPT_REXMT 0 /* retransmit */ |
49 | #define TCPT_2MSL 1 /* 2*msl quiet time timer */ | |
50 | #define TCPT_PERSIST 2 /* retransmit persistance */ | |
2ff61f9d | 51 | #define TCPT_KEEP 3 /* keep alive */ |
2ff61f9d | 52 | |
ad6d0022 BJ |
53 | /* |
54 | * Tcp control block. | |
55 | */ | |
53a5409e | 56 | struct tcpcb { |
a6503abf BJ |
57 | struct tcpiphdr *seg_next; /* sequencing queue */ |
58 | struct tcpiphdr *seg_prev; | |
59 | int t_state; /* state of this connection */ | |
60 | int seqcnt; /* count of chars in seq queue */ | |
2ff61f9d | 61 | short t_timers[TCPT_NTIMERS]; /* tcp timers */ |
a6503abf | 62 | short t_options; /* connection options: */ |
2ff61f9d BJ |
63 | #define TO_PUSH 0x01 /* push mode */ |
64 | #define TO_URG 0x02 /* urgent mode */ | |
65 | #define TO_KEEP 0x04 /* use keep-alives */ | |
66 | u_char t_flags; | |
67 | #define TF_OWEACK 0x01 /* owe ack to peer */ | |
a6503abf | 68 | #define TF_DELACK 0x02 /* delaying ack to peer */ |
2ff61f9d BJ |
69 | struct tcpiphdr *t_template; /* skeletal packet for transmit */ |
70 | struct inpcb *t_inpcb; /* back pointer to internet pcb */ | |
ad6d0022 | 71 | /* |
2ff61f9d BJ |
72 | * The following fields are used as in the protocol specification. |
73 | * See RFC783, Dec. 1981, page 21. | |
ad6d0022 | 74 | */ |
2ff61f9d BJ |
75 | /* send sequence variables */ |
76 | tcp_seq snd_una; /* send unacknowledged */ | |
77 | tcp_seq snd_nxt; /* send next */ | |
78 | u_short snd_wnd; /* send window */ | |
79 | tcp_seq snd_up; /* send urgent pointer */ | |
80 | tcp_seq snd_wl1; /* window update seg seq number */ | |
81 | tcp_seq snd_wl2; /* window update seg ack number */ | |
82 | tcp_seq iss; /* initial send sequence number */ | |
83 | /* receive sequence variables */ | |
84 | tcp_seq rcv_nxt; /* receive next */ | |
85 | u_short rcv_wnd; /* receive window */ | |
86 | tcp_seq rcv_up; /* receive urgent pointer */ | |
87 | tcp_seq irs; /* initial receive sequence number */ | |
ad6d0022 | 88 | /* |
2ff61f9d | 89 | * Additional variables for this implementation. |
ad6d0022 | 90 | */ |
2ff61f9d | 91 | /* receive variables */ |
a6503abf BJ |
92 | tcp_seq rcv_adv; /* advertised window */ |
93 | /* retransmit variables */ | |
94 | tcp_seq snd_max; /* highest sequence number sent */ | |
95 | used to recognize retransmits */ | |
2ff61f9d | 96 | }; |
ad6d0022 | 97 | |
2ff61f9d BJ |
98 | #define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb) |
99 | #define sototcpcb(so) (intotcpcb(sotoinpcb(so))) | |
ad6d0022 BJ |
100 | |
101 | #define ISSINCR 128 /* increment for iss each second */ | |
ad6d0022 | 102 | |
a6503abf | 103 | #define TCP_TTL 60 /* time to live for TCP segs */ |
ad6d0022 | 104 | /* |
2ff61f9d | 105 | * TCPSC constants give various timeouts in ``slow-clock'' ticks. |
ad6d0022 | 106 | */ |
a6503abf BJ |
107 | #define TCPSC_MSL (120*PR_SLOWHZ) /* max seg lifetime */ |
108 | #define TCPSC_REXMT ( 1*PR_SLOWHZ) /* base retransmit time */ | |
109 | #define TCPSC_KEEP (240*PR_SLOWHZ) /* keep alive */ | |
110 | #define TCPSC_PERSIST ( 5*PR_SLOWHZ) /* retransmit persistance */ | |
111 | ||
112 | #define TCPSC_KEEPTTL ( 4*TCPSC_KEEP) /* keep alive too long */ | |
113 | #define TCPSC_2MSL ( 2*TCPSC_MSL) /* 2*msl quiet time timer */ | |
2ff61f9d | 114 | |
a6503abf | 115 | #define TCPSC_TOOLONG (480*PR_SLOWHZ) |
ad6d0022 | 116 | |
2b4b57cd BJ |
117 | struct tcpstat { |
118 | int tcps_badsum; | |
119 | int tcps_badoff; | |
120 | int tcps_hdrops; | |
121 | int tcps_badsegs; | |
122 | int tcps_unack; | |
123 | }; | |
124 | ||
ad6d0022 | 125 | #ifdef KERNEL |
2ff61f9d BJ |
126 | tcp_seq tcp_iss; /* tcp initial send seq # */ |
127 | struct inpcb tcb; /* head of queue of active tcpcb's */ | |
128 | struct tcpstat tcpstat; /* tcp statistics */ | |
cdad2eb1 | 129 | #endif |
53a5409e | 130 | struct tcpiphdr *tcp_template(); |
ad6d0022 BJ |
131 | #endif |
132 | ||
2ff61f9d BJ |
133 | #ifdef TCPTIMERS |
134 | char *tcptimers[] = | |
135 | { "INIT", "REXMT", "REXMTTL", "KEEP", "KEEPTTL", "PERSIST", "2MSL" }; | |
136 | #endif |