Sponge
CS144's user-space TCP library
|
A FD adapter for IPv4 datagrams read from and written to a TAP device. More...
#include <tuntap_adapter.hh>
Public Member Functions | |
TCPOverIPv4OverEthernetAdapter (TapFD &&tap, const EthernetAddress ð_address, const Address &ip_address, const Address &next_hop) | |
Construct from a TapFD. More... | |
operator const TapFD & () const | |
Access the underlying raw Ethernet connection. More... | |
operator TapFD & () | |
Access the underlying raw Ethernet connection. More... | |
std::optional< TCPSegment > | read () |
Attempts to read and parse an Ethernet frame containing an IPv4 datagram that contains a TCP segment. More... | |
void | tick (const size_t ms_since_last_tick) |
Called periodically when time elapses. More... | |
void | write (TCPSegment &seg) |
Sends a TCP segment (in an IPv4 datagram, in an Ethernet frame). More... | |
Public Member Functions inherited from TCPOverIPv4Adapter | |
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... | |
Private Member Functions | |
void | send_pending () |
Sends any pending Ethernet frames. More... | |
Private Attributes | |
NetworkInterface | _interface |
NIC abstraction. More... | |
Address | _next_hop |
IP address of the next hop. More... | |
TapFD | _tap |
Raw Ethernet connection. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from FdAdapterBase | |
FdAdapterConfig & | config_mutable () |
A FD adapter for IPv4 datagrams read from and written to a TAP device.
Definition at line 44 of file tuntap_adapter.hh.
|
explicit |
Construct from a TapFD.
[in] | tap | Raw network device that will be owned by the adapter |
[in] | eth_address | Ethernet address (local address) of the adapter |
[in] | ip_address | IP address (local address) of the adapter |
[in] | next_hop | IP address of the next hop (typically a router or default gateway) |
Definition at line 9 of file tuntap_adapter.cc.
|
inline |
Access the underlying raw Ethernet connection.
Definition at line 73 of file tuntap_adapter.hh.
|
inline |
Access the underlying raw Ethernet connection.
Definition at line 70 of file tuntap_adapter.hh.
optional< TCPSegment > TCPOverIPv4OverEthernetAdapter::read | ( | ) |
Attempts to read and parse an Ethernet frame containing an IPv4 datagram that contains a TCP segment.
Definition at line 19 of file tuntap_adapter.cc.
|
private |
Sends any pending Ethernet frames.
Definition at line 51 of file tuntap_adapter.cc.
void TCPOverIPv4OverEthernetAdapter::tick | ( | const size_t | ms_since_last_tick | ) |
Called periodically when time elapses.
[in] | ms_since_last_tick | the number of milliseconds since the last call to this method |
Definition at line 40 of file tuntap_adapter.cc.
void TCPOverIPv4OverEthernetAdapter::write | ( | TCPSegment & | seg | ) |
Sends a TCP segment (in an IPv4 datagram, in an Ethernet frame).
[in] | seg | the TCPSegment to send |
Definition at line 46 of file tuntap_adapter.cc.
|
private |
NIC abstraction.
Definition at line 48 of file tuntap_adapter.hh.
|
private |
IP address of the next hop.
Definition at line 50 of file tuntap_adapter.hh.
|
private |
Raw Ethernet connection.
Definition at line 46 of file tuntap_adapter.hh.