|
Sponge
CS144's user-space TCP library
|
Go to the documentation of this file. 1 #ifndef SPONGE_LIBSPONGE_ROUTER_HH
2 #define SPONGE_LIBSPONGE_ROUTER_HH
32 if (optional_dgram.has_value()) {
65 void add_route(
const uint32_t route_prefix,
66 const uint8_t prefix_length,
67 const std::optional<Address> next_hop,
68 const size_t interface_num);
74 #endif // SPONGE_LIBSPONGE_ROUTER_HH
std::optional< InternetDatagram > recv_frame(const EthernetFrame &frame)
Receives an Ethernet frame and responds appropriately.
void recv_frame(const EthernetFrame &frame)
Receives and Ethernet frame and responds appropriately.
void add_route(const uint32_t route_prefix, const uint8_t prefix_length, const std::optional< Address > next_hop, const size_t interface_num)
Add a route (a forwarding rule)
A router that has multiple network interfaces and performs longest-prefix-match routing between them.
std::queue< InternetDatagram > & datagrams_out()
Access queue of Internet datagrams that have been received.
A "network interface" that connects IP (the internet layer, or network layer) with Ethernet (the netw...
void route_one_datagram(InternetDatagram &dgram)
std::vector< AsyncNetworkInterface > _interfaces
The router's collection of network interfaces.
size_t add_interface(AsyncNetworkInterface &&interface)
std::queue< InternetDatagram > _datagrams_out
A wrapper for NetworkInterface that makes the host-side interface asynchronous: instead of returning ...
AsyncNetworkInterface & interface(const size_t N)
Access an interface by index.
AsyncNetworkInterface(NetworkInterface &&interface)
Construct from a NetworkInterface.
NetworkInterface(const EthernetAddress ðernet_address, const Address &ip_address)
Construct a network interface with given Ethernet (network-access-layer) and IP (internet-layer) addr...
void route()
Route packets between the interfaces.