Sponge
CS144's user-space TCP library
|
A converter from TCP segments to serialized IPv4 datagrams. More...
#include <tcp_over_ip.hh>
Public Member Functions | |
std::optional< TCPSegment > | unwrap_tcp_in_ip (const InternetDatagram &ip_dgram) |
InternetDatagram | wrap_tcp_in_ip (TCPSegment &seg) |
Public Member Functions inherited from FdAdapterBase | |
const FdAdapterConfig & | config () const |
Get the current configuration. More... | |
FdAdapterConfig & | config_mut () |
Get the current configuration (mutable) More... | |
bool | listening () const |
Get the listening flag. More... | |
void | set_listening (const bool l) |
Set the listening flag. More... | |
void | tick (const size_t) |
Called periodically when time elapses. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from FdAdapterBase | |
FdAdapterConfig & | config_mutable () |
A converter from TCP segments to serialized IPv4 datagrams.
Definition at line 12 of file tcp_over_ip.hh.
optional< TCPSegment > TCPOverIPv4Adapter::unwrap_tcp_in_ip | ( | const InternetDatagram & | ip_dgram | ) |
This function attempts to parse a TCP segment from the IP datagram's payload.
If this succeeds, it then checks that the received segment is related to the current connection. When a TCP connection has been established, this means checking that the source and destination ports in the TCP header are correct.
If the TCP connection is listening (i.e., TCPOverIPv4OverTunFdAdapter::_listen is true
) and the TCP segment read from the wire includes a SYN, this function clears the _listen
flag and records the source and destination addresses and port numbers from the TCP header; it uses this information to filter future reads.
Definition at line 26 of file tcp_over_ip.cc.
InternetDatagram TCPOverIPv4Adapter::wrap_tcp_in_ip | ( | TCPSegment & | seg | ) |
Takes a TCP segment, sets port numbers as necessary, and wraps it in an IPv4 datagram
[in] | seg | is the TCP segment to convert |
Definition at line 75 of file tcp_over_ip.cc.