Watt-32 tcp/ip  2.2 dev-rel.10
Data Structures | Typedefs | Functions | Variables
tcp_fsm.c File Reference

Go to the source code of this file.

Data Structures

struct  tcp_reasm
 

Typedefs

typedef int(* tcp_StateProc )(_tcp_Socket **, const in_Header *, tcp_Header *, int)
 

Functions

static int tcp_listen_state (_tcp_Socket **, const in_Header *, tcp_Header *, int)
 
static int tcp_resolve_state (_tcp_Socket **, const in_Header *, tcp_Header *, int)
 
static int tcp_synsent_state (_tcp_Socket **, const in_Header *, tcp_Header *, int)
 
static int tcp_synrec_state (_tcp_Socket **, const in_Header *, tcp_Header *, int)
 
static int tcp_estab_state (_tcp_Socket **, const in_Header *, tcp_Header *, int)
 
static int tcp_estcl_state (_tcp_Socket **, const in_Header *, tcp_Header *, int)
 
static int tcp_finwt1_state (_tcp_Socket **, const in_Header *, tcp_Header *, int)
 
static int tcp_finwt2_state (_tcp_Socket **, const in_Header *, tcp_Header *, int)
 
static int tcp_closewt_state (_tcp_Socket **, const in_Header *, tcp_Header *, int)
 
static int tcp_closing_state (_tcp_Socket **, const in_Header *, tcp_Header *, int)
 
static int tcp_lastack_state (_tcp_Socket **, const in_Header *, tcp_Header *, int)
 
static int tcp_timewt_state (_tcp_Socket **, const in_Header *, tcp_Header *, int)
 
static int tcp_process_data (_tcp_Socket *s, const tcp_Header *tcp, int len, int *flags)
 Process the data in an incoming segment. More...
 
static void tcp_set_window (_tcp_Socket *s, const tcp_Header *tcp)
 Allocate a Tx-buffer based on peer's advertised window. More...
 
static int tcp_process_ACK (_tcp_Socket *s, long *unack)
 
static int tcp_reassemble (_tcp_Socket *s, const tcp_Header *tcp, UINT len, int flags)
 
int _tcp_fsm (_tcp_Socket **sp, const in_Header *ip)
 
static void tcp_process_options (_tcp_Socket *s, const tcp_Header *tcp, const BYTE *tcp_data, int flags)
 Process TCP options in segment.
 
static void copy_in_order (_tcp_Socket *s, const BYTE *data, unsigned len)
 
static void data_in_order (_tcp_Socket *s, const BYTE *data, unsigned len, unsigned diff)
 
static void prepend_out_of_order (_tcp_Socket *s, const BYTE *data, unsigned len)
 
static void append_out_of_order (_tcp_Socket *s, const BYTE *data, unsigned len)
 
static void data_out_of_order (_tcp_Socket *s, const BYTE *data, unsigned len, unsigned diff)
 
static int tcp_reassemble (_tcp_Socket *s, const tcp_Header *tcp, const BYTE *data, UINT len, int *flags)
 

Variables

static tcp_StateProc tcp_state_tab []
 
static BOOL is_ip4
 
static DWORD acknum
 
static DWORD seqnum
 

Detailed Description

State machine for TCP processing. Previously this was in pctcp.c and tcp_handler().

Definition in file tcp_fsm.c.

Function Documentation

static int tcp_process_data ( _tcp_Socket s,
const tcp_Header tcp,
int  len,
int *  flags 
)
static

Process the data in an incoming segment.

Called from all states where incoming data can be received: SYNSENT, ESTAB, ESTCL, CLOSWT, FIN-WAIT-1 and FIN-WAIT-2.

Todo:
Handle Out-of-Order urgent data. Raise SIGURG.

Definition at line 993 of file tcp_fsm.c.

References tcp_Socket::adv_win, tcp_Socket::recv_next, tcp_process_options(), tcp_set_window(), tcp_Socket::tx_datalen, and tcp_Socket::unhappy.

static int tcp_reassemble ( _tcp_Socket s,
const tcp_Header tcp,
const BYTE *  data,
UINT  len,
int *  flags 
)
static
Todo:
Create a better TCP reassembler some day. Current logic only handles 1 missed segment. We should handle at least 2.

Definition at line 1201 of file tcp_fsm.c.

References tcp_Socket::adv_win, and tcp_Socket::recv_next.

static void tcp_set_window ( _tcp_Socket s,
const tcp_Header tcp 
)
static

Allocate a Tx-buffer based on peer's advertised window.

Note: our advertised window (s->adv_win) is controlled by sock_setbuf().

Definition at line 1155 of file tcp_fsm.c.

References _eth_ndis3pkt, tcp_Socket::max_tx_data, tcp_Socket::tx_buf, tcp_Socket::tx_data, tcp_Socket::tx_datalen, and tcp_Socket::window.

static int tcp_synsent_state ( _tcp_Socket **  sp,
const in_Header ip,
tcp_Header tcp,
int  flags 
)
static

Variable Documentation

tcp_StateProc tcp_state_tab[]
static
Initial value:
= {
tcp_listen_state,
tcp_resolve_state,
tcp_synrec_state,
tcp_estab_state,
tcp_estcl_state,
tcp_finwt1_state,
tcp_finwt2_state,
tcp_closewt_state,
tcp_closing_state,
tcp_lastack_state,
tcp_timewt_state,
}
static int tcp_synsent_state(_tcp_Socket **, const in_Header *, tcp_Header *, int)
Definition: tcp_fsm.c:219

Definition at line 66 of file tcp_fsm.c.