struct TcpConn {
int state;
unsigned int local_ip;
unsigned int remote_ip;
unsigned short local_port;
unsigned short remote_port;
unsigned int snd_nxt;
unsigned int snd_una;
unsigned int rcv_nxt;
unsigned int rcv_wnd;
unsigned char rx_buf[TCP_RX_BUF];
unsigned long rx_len;
unsigned char tx_buf[TCP_TX_BUF];
unsigned long tx_len;
}Fields
next sequence number to send
oldest unacknowledged sequence number
next expected receive sequence number
receive window advertised
Methods
Feed a received packet (starting at TCP header offset in pkt). Returns 1 if state changed, 0 otherwise.
Enqueue payload data to send. Returns bytes accepted (0 if full).
§
int build_segment(
&PacketBuf pkt,
const unsigned char eth_src[NET_MAC_LEN],
const unsigned char eth_dst[NET_MAC_LEN],
)source · definitionBuild next outgoing segment into pkt; returns 1 if segment produced.
Is there received data ready?
Consume up to out.len bytes from rx_buf into out; returns bytes copied.
§
void connect(
unsigned int remote_ip,
unsigned short remote_port,
unsigned int local_ip,
unsigned short local_port,
unsigned int isn,
)source · definitionInitiate active open (send SYN).
Passive open: wait in LISTEN for a SYN to local_port. The peer's address/port are taken from that SYN; the next build_segment() then produces the SYN+ACK (with sequence number 'isn').
Close connection (send FIN).
= drop()