Main Page | Class List | File List | Class Members | File Members

tcp.h

Go to the documentation of this file.
00001 /* TCP handling code.
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   /* TTL for spoofed packets from proxy, e.g. TCP RST. */
00013 #define TCP_LINK_MSS       1402  /* MSS of the GPRS link in bytes. */
00014 #define TCP_TWO_MSL        60000 /* Twice maximum segment lifetime, in milliseconds.  */
00015 #define TCP_WIN_CLAMP_SIZE 12618 /* TCP window size to clamp to (9 * MSS). */
00016 
00017 typedef struct tcp_cid
00018 {
00019     /* Values stored in network byte order. */
00020     __u32 saddr;
00021     __u32 daddr;            
00022     __u16 sport;
00023     __u16 dport;                
00024 } Ttcp_cid;
00025 
00026 /* NB: Remember to modify tcp_switch in tcp.c if tcp_state is modified. */
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     /* Value of cid must be such that saddr is that of the host on proxied link 
00054      * (e.g. the mobile host).
00055      */
00056     struct tcp_cid cid;
00057     enum tcp_state state;  /* State is that of the mobile host's TCP.        */
00058     unsigned init;         /* Bits to indicate initialised parts of state.   */
00059     unsigned mh_seq;       /* Current sequence number from MH (seq+segsize). */
00060     unsigned mh_ack;       /* Highest ack received from MH.                  */
00061     unsigned fh_seq;       /* Current sequence number from FH (seq+segsize). */
00062     unsigned fh_ack;       /* Highest ack received from FG.                  */
00063     int out_queue;         /* Number of tcp output queue.                    */
00064     pthread_mutex_t mut;   /* Mutex for synchronisation.                     */
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 /* _TCP_H */

Generated on Sun May 14 13:36:52 2006 by  doxygen 1.4.2