1 /* 2 * INET An implementation of the TCP/IP protocol suite for the LINUX 3 * operating system. INET is implemented using the BSD Socket 4 * interface as the means of communication with the user level. 5 * 6 * Definitions for the TCP module. 7 * 8 * Version: @(#)tcp.h 1.0.5 05/23/93 9 * 10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 12 * 13 * This program is free software; you can redistribute it and/or 14 * modify it under the terms of the GNU General Public License 15 * as published by the Free Software Foundation; either version 16 * 2 of the License, or (at your option) any later version. 17 */ 18 #ifndef_TCP_H 19 #define_TCP_H 20
21 #include <linux/tcp.h>
22
23 #defineMAX_SYN_SIZE 44 + MAX_HEADER + 15
24 #define MAX_FIN_SIZE 40 + MAX_HEADER + 15
25 #defineMAX_ACK_SIZE 40 + MAX_HEADER + 15
26 #defineMAX_RESET_SIZE 40 + MAX_HEADER + 15
27 #defineMAX_WINDOW 16384
28 #defineMIN_WINDOW 2048
29 #define MAX_ACK_BACKLOG 2
30 #defineMIN_WRITE_SPACE 2048
31 #defineTCP_WINDOW_DIFF 2048
32
33 /* urg_data states */ 34 #defineURG_VALID 0x0100
35 #defineURG_NOTYET 0x0200
36 #defineURG_READ 0x0400
37
38 #defineTCP_RETR1 7 /* 39 * This is how many retries it does before it 40 * tries to figure out if the gateway is 41 * down. 42 */ 43
44 #defineTCP_RETR2 15 /* 45 * This should take at least 46 * 90 minutes to time out. 47 */ 48
49 #defineTCP_TIMEOUT_LEN (15*60*HZ) /* should be about 15 mins */ 50 #defineTCP_TIMEWAIT_LEN (60*HZ) /* how long to wait to successfully 51 * close the socket, about 60 seconds */ 52 #defineTCP_FIN_TIMEOUT (3*60*HZ) /* BSD style FIN_WAIT2 deadlock breaker */ 53 #defineTCP_ACK_TIME (3*HZ) /* time to delay before sending an ACK */ 54 #defineTCP_DONE_TIME 250 /* maximum time to wait before actually 55 * destroying a socket */ 56 #define TCP_WRITE_TIME 3000 /* initial time to wait for an ACK, 57 * after last transmit */ 58 #defineTCP_TIMEOUT_INIT (3*HZ) /* RFC 1122 initial timeout value */ 59 #defineTCP_SYN_RETRIES 10 /* number of times to retry opening a 60 * connection (TCP_RETR2-....) */ 61 #define TCP_PROBEWAIT_LEN 100 /* time to wait between probes when 62 * I've got something to write and 63 * there is no window */ 64
65 #defineTCP_NO_CHECK 0 /* turn to one if you want the default 66 * to be no checksum */ 67
68
69 /* 70 * TCP option 71 */ 72
73 #defineTCPOPT_NOP 1 /* Padding */ 74 #defineTCPOPT_EOL 0 /* End of options */ 75 #defineTCPOPT_MSS 2 /* Segment size negotiating */ 76 /* 77 * We don't use these yet, but they are for PAWS and big windows 78 */ 79 #define TCPOPT_WINDOW 3 /* Window scaling */ 80 #define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */ 81
82
83 /* 84 * The next routines deal with comparing 32 bit unsigned ints 85 * and worry about wraparound (automatic with unsigned arithmetic). 86 */ 87
88 extern__inlineintbefore(__u32seq1, __u32seq2)
/* */ 89 { 90 return (__s32)(seq1-seq2) < 0;
91 } 92
93 extern__inlineintafter(__u32seq1, __u32seq2)
/* */ 94 { 95 return (__s32)(seq1-seq2) > 0;
96 } 97
98
99 /* is s2<=s1<=s3 ? */ 100 extern__inlineint between(__u32seq1, __u32seq2, __u32seq3)
/* */ 101 { 102 return (after(seq1+1, seq2) && before(seq1, seq3+1));
103 } 104
105
106 /* 107 * List all states of a TCP socket that can be viewed as a "connected" 108 * state. This now includes TCP_SYN_RECV, although I am not yet fully 109 * convinced that this is the solution for the 'getpeername(2)' 110 * problem. Thanks to Stephen A. Wood <saw@cebaf.gov> -FvK 111 */ 112 extern__inlineconstint 113 tcp_connected(constintstate)
/* */ 114 { 115 return(state == TCP_ESTABLISHED || state == TCP_CLOSE_WAIT ||
116 state == TCP_FIN_WAIT1 || state == TCP_FIN_WAIT2 ||
117 state == TCP_SYN_RECV);
118 } 119
120
121 externstructprototcp_prot;
122
123
124 externvoidtcp_err(interr, unsignedchar *header, unsignedlongdaddr,
125 unsignedlongsaddr, structinet_protocol *protocol);
126 externvoidtcp_shutdown (structsock *sk, inthow);
127 externinttcp_rcv(structsk_buff *skb, structdevice *dev,
128 structoptions *opt, unsignedlongdaddr,
129 unsignedshortlen, unsignedlongsaddr, intredo,
130 structinet_protocol *protocol);
131
132 externinttcp_ioctl(structsock *sk, intcmd, unsignedlongarg);
133
134 externinttcp_select_window(structsock *sk);
135 externvoidtcp_send_check(structtcphdr *th, unsignedlongsaddr,
136 unsignedlongdaddr, intlen, structsock *sk);
137 externvoidtcp_send_probe0(structsock *sk);
138 externvoidtcp_enqueue_partial(structsk_buff *, structsock *);
139 externstructsk_buff * tcp_dequeue_partial(structsock *);
140 externvoidtcp_cache_zap(void);
141
142 #endif/* _TCP_H */