00001
00002
00003
00004
00005 #ifndef _TCP_H
00006 #define _TCP_H
00007
00008 #include "tcpproxy.h"
00009
00010 #define TCP_PROTO 6
00011 #define IP_VERSION 4
00012 #define IP_START_TTL 254
00013 #define TCP_LINK_MSS 1402
00014 #define TCP_TWO_MSL 60000
00015 #define TCP_WIN_CLAMP_SIZE 12618
00016
00017 typedef struct tcp_cid
00018 {
00019
00020 __u32 saddr;
00021 __u32 daddr;
00022 __u16 sport;
00023 __u16 dport;
00024 } Ttcp_cid;
00025
00026
00027 typedef enum tcp_state
00028 {
00029 TCPS_FREE = 0,
00030 TCPS_NEW,
00031 TCPS_SYN_SENT,
00032 TCPS_SYN_RECV,
00033 TCPS_ESTABLISHED,
00034 TCPS_FIN_WAIT1,
00035 TCPS_FIN_WAIT2,
00036 TCPS_TIME_WAIT,
00037 TCPS_CLOSED,
00038 TCPS_CLOSE_WAIT,
00039 TCPS_LAST_ACK,
00040 TCPS_CLOSING,
00041 TCPS_MAX_STATES
00042 } Ttcp_state;
00043
00044 enum {
00045 TCP_INIT_MH_SEQ = 1,
00046 TCP_INIT_MH_ACK = 2,
00047 TCP_INIT_FH_SEQ = 4,
00048 TCP_INIT_FH_ACK = 8
00049 };
00050
00051 typedef struct tcp_cb
00052 {
00053
00054
00055
00056 struct tcp_cid cid;
00057 enum tcp_state state;
00058 unsigned init;
00059 unsigned mh_seq;
00060 unsigned mh_ack;
00061 unsigned fh_seq;
00062 unsigned fh_ack;
00063 int out_queue;
00064 pthread_mutex_t mut;
00065 } Ttcp_cb;
00066
00067
00068 void init_tcp();
00069 void cleanup_tcp();
00070 inline int seq_cmp(unsigned a, unsigned b);
00071 inline int tcp_data_size(Tpacket_data *pd);
00072 void tcp_timeout(void *ptr);
00073 int handle_tcp(Tpacket_data *pd);
00074
00075 #endif