Sponge
CS144's user-space TCP library
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TCPOverIPv4OverEthernetAdapter Class Reference

A FD adapter for IPv4 datagrams read from and written to a TAP device. More...

#include <tuntap_adapter.hh>

Inheritance diagram for TCPOverIPv4OverEthernetAdapter:
Inheritance graph
[legend]

Public Member Functions

 TCPOverIPv4OverEthernetAdapter (TapFD &&tap, const EthernetAddress &eth_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< TCPSegmentread ()
 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< TCPSegmentunwrap_tcp_in_ip (const InternetDatagram &ip_dgram)
 
InternetDatagram wrap_tcp_in_ip (TCPSegment &seg)
 
- Public Member Functions inherited from FdAdapterBase
const FdAdapterConfigconfig () const
 Get the current configuration. More...
 
FdAdapterConfigconfig_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
FdAdapterConfigconfig_mutable ()
 

Detailed Description

A FD adapter for IPv4 datagrams read from and written to a TAP device.

Definition at line 44 of file tuntap_adapter.hh.

Constructor & Destructor Documentation

◆ TCPOverIPv4OverEthernetAdapter()

TCPOverIPv4OverEthernetAdapter::TCPOverIPv4OverEthernetAdapter ( TapFD &&  tap,
const EthernetAddress eth_address,
const Address ip_address,
const Address next_hop 
)
explicit

Construct from a TapFD.

Parameters
[in]tapRaw network device that will be owned by the adapter
[in]eth_addressEthernet address (local address) of the adapter
[in]ip_addressIP address (local address) of the adapter
[in]next_hopIP address of the next hop (typically a router or default gateway)

Definition at line 9 of file tuntap_adapter.cc.

Member Function Documentation

◆ operator const TapFD &()

TCPOverIPv4OverEthernetAdapter::operator const TapFD & ( ) const
inline

Access the underlying raw Ethernet connection.

Definition at line 73 of file tuntap_adapter.hh.

◆ operator TapFD &()

TCPOverIPv4OverEthernetAdapter::operator TapFD & ( )
inline

Access the underlying raw Ethernet connection.

Definition at line 70 of file tuntap_adapter.hh.

◆ read()

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.

◆ send_pending()

void TCPOverIPv4OverEthernetAdapter::send_pending ( )
private

Sends any pending Ethernet frames.

Definition at line 51 of file tuntap_adapter.cc.

◆ tick()

void TCPOverIPv4OverEthernetAdapter::tick ( const size_t  ms_since_last_tick)

Called periodically when time elapses.

Parameters
[in]ms_since_last_tickthe number of milliseconds since the last call to this method

Definition at line 40 of file tuntap_adapter.cc.

◆ write()

void TCPOverIPv4OverEthernetAdapter::write ( TCPSegment seg)

Sends a TCP segment (in an IPv4 datagram, in an Ethernet frame).

Parameters
[in]segthe TCPSegment to send

Definition at line 46 of file tuntap_adapter.cc.

Member Data Documentation

◆ _interface

NetworkInterface TCPOverIPv4OverEthernetAdapter::_interface
private

NIC abstraction.

Definition at line 48 of file tuntap_adapter.hh.

◆ _next_hop

Address TCPOverIPv4OverEthernetAdapter::_next_hop
private

IP address of the next hop.

Definition at line 50 of file tuntap_adapter.hh.

◆ _tap

TapFD TCPOverIPv4OverEthernetAdapter::_tap
private

Raw Ethernet connection.

Definition at line 46 of file tuntap_adapter.hh.


The documentation for this class was generated from the following files: