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 32767 /* Never offer a window over 32767 without using 28 window scaling (not yet supported). Some poor 29 stacks do signed 16bit maths! */ 30 #defineMIN_WINDOW 2048
31 #define MAX_ACK_BACKLOG 2
32 #defineMIN_WRITE_SPACE 2048
33 #defineTCP_WINDOW_DIFF 2048
34
35 /* urg_data states */ 36 #defineURG_VALID 0x0100
37 #defineURG_NOTYET 0x0200
38 #defineURG_READ 0x0400
39
40 #defineTCP_RETR1 7 /* 41 * This is how many retries it does before it 42 * tries to figure out if the gateway is 43 * down. 44 */ 45
46 #defineTCP_RETR2 15 /* 47 * This should take at least 48 * 90 minutes to time out. 49 */ 50
51 #defineTCP_TIMEOUT_LEN (15*60*HZ) /* should be about 15 mins */ 52 #defineTCP_TIMEWAIT_LEN (60*HZ) /* how long to wait to successfully 53 * close the socket, about 60 seconds */ 54 #defineTCP_FIN_TIMEOUT (3*60*HZ) /* BSD style FIN_WAIT2 deadlock breaker */ 55 #defineTCP_ACK_TIME (3*HZ) /* time to delay before sending an ACK */ 56 #defineTCP_DONE_TIME 250 /* maximum time to wait before actually 57 * destroying a socket */ 58 #define TCP_WRITE_TIME 3000 /* initial time to wait for an ACK, 59 * after last transmit */ 60 #defineTCP_TIMEOUT_INIT (3*HZ) /* RFC 1122 initial timeout value */ 61 #defineTCP_SYN_RETRIES 10 /* number of times to retry opening a 62 * connection (TCP_RETR2-....) */ 63 #define TCP_PROBEWAIT_LEN 100 /* time to wait between probes when 64 * I've got something to write and 65 * there is no window */ 66
67 #defineTCP_NO_CHECK 0 /* turn to one if you want the default 68 * to be no checksum */ 69
70
71 /* 72 * TCP option 73 */ 74
75 #defineTCPOPT_NOP 1 /* Padding */ 76 #defineTCPOPT_EOL 0 /* End of options */ 77 #defineTCPOPT_MSS 2 /* Segment size negotiating */ 78 /* 79 * We don't use these yet, but they are for PAWS and big windows 80 */ 81 #define TCPOPT_WINDOW 3 /* Window scaling */ 82 #define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */ 83
84
85 /* 86 * The next routines deal with comparing 32 bit unsigned ints 87 * and worry about wraparound (automatic with unsigned arithmetic). 88 */ 89
90 extern__inlineintbefore(__u32seq1, __u32seq2)
/* */ 91 { 92 return (__s32)(seq1-seq2) < 0;
93 } 94
95 extern__inlineintafter(__u32seq1, __u32seq2)
/* */ 96 { 97 return (__s32)(seq1-seq2) > 0;
98 } 99
100
101 /* is s2<=s1<=s3 ? */ 102 extern__inlineint between(__u32seq1, __u32seq2, __u32seq3)
/* */ 103 { 104 return (after(seq1+1, seq2) && before(seq1, seq3+1));
105 } 106
107
108 /* 109 * List all states of a TCP socket that can be viewed as a "connected" 110 * state. This now includes TCP_SYN_RECV, although I am not yet fully 111 * convinced that this is the solution for the 'getpeername(2)' 112 * problem. Thanks to Stephen A. Wood <saw@cebaf.gov> -FvK 113 */ 114 extern__inlineconstint 115 tcp_connected(constintstate)
/* */ 116 { 117 return(state == TCP_ESTABLISHED || state == TCP_CLOSE_WAIT ||
118 state == TCP_FIN_WAIT1 || state == TCP_FIN_WAIT2 ||
119 state == TCP_SYN_RECV);
120 } 121
122
123 externstructprototcp_prot;
124
125
126 externvoidtcp_err(interr, unsignedchar *header, unsignedlongdaddr,
127 unsignedlongsaddr, structinet_protocol *protocol);
128 externvoidtcp_shutdown (structsock *sk, inthow);
129 externinttcp_rcv(structsk_buff *skb, structdevice *dev,
130 structoptions *opt, unsignedlongdaddr,
131 unsignedshortlen, unsignedlongsaddr, intredo,
132 structinet_protocol *protocol);
133
134 externinttcp_ioctl(structsock *sk, intcmd, unsignedlongarg);
135
136 externinttcp_select_window(structsock *sk);
137 externvoidtcp_send_check(structtcphdr *th, unsignedlongsaddr,
138 unsignedlongdaddr, intlen, structsock *sk);
139 externvoidtcp_send_probe0(structsock *sk);
140 externvoidtcp_enqueue_partial(structsk_buff *, structsock *);
141 externstructsk_buff * tcp_dequeue_partial(structsock *);
142 externvoidtcp_cache_zap(void);
143
144 #endif/* _TCP_H */