Sponge
CS144's user-space TCP library
|
A router that has multiple network interfaces and performs longest-prefix-match routing between them. More...
#include <router.hh>
Public Member Functions | |
size_t | add_interface (AsyncNetworkInterface &&interface) |
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) More... | |
AsyncNetworkInterface & | interface (const size_t N) |
Access an interface by index. More... | |
void | route () |
Route packets between the interfaces. More... | |
Private Member Functions | |
void | route_one_datagram (InternetDatagram &dgram) |
Private Attributes | |
std::vector< AsyncNetworkInterface > | _interfaces {} |
The router's collection of network interfaces. More... | |
A router that has multiple network interfaces and performs longest-prefix-match routing between them.
|
inline |
void Router::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)
[in] | route_prefix | The "up-to-32-bit" IPv4 address prefix to match the datagram's destination address against |
[in] | prefix_length | For this route to be applicable, how many high-order (most-significant) bits of the route_prefix will need to match the corresponding bits of the datagram's destination address? |
[in] | next_hop | The IP address of the next hop. Will be empty if the network is directly attached to the router (in which case, the next hop address should be the datagram's final destination). |
[in] | interface_num | The index of the interface to send the datagram out on. |
|
inline |
void Router::route | ( | ) |
|
private |
|
private |