|
SatCat5
|
Basic Network Address Translation (NAT) for the IPv4 router.
This block implements "Basic NAT" as defined in IETF RFC-3022: https://www.rfc-editor.org/rfc/rfc3022 Acting as a plugin, the BasicNat block attaches to a router port and translates applicable IP addresses in the ARP and IPv4 headers. It requires that the internal and external address ranges are equal in size, allowing trivial one-to-one mapping of subnet addresses. This is the software analogue of the "router2_basic_nat" VHDL block.
Definition at line 22 of file router2_basic_nat.h.
#include <router2_basic_nat.h>
Public Member Functions | |
| BasicNat (satcat5::eth::SwitchPort *port) | |
| Attach this object to the designated router port. More... | |
| bool | config (const satcat5::ip::Subnet &ip_ext, const satcat5::ip::Subnet &ip_int) |
| Change the NAT configuration. More... | |
Protected Member Functions | |
| void | ingress (satcat5::eth::PluginPacket &pkt) override |
| Packet-received callback. More... | |
| void | egress (satcat5::eth::PluginPacket &pkt) override |
| Packet-transmit callback. More... | |
Protected Attributes | |
| satcat5::ip::Subnet | m_ext |
| satcat5::ip::Subnet | m_int |
| satcat5::eth::SwitchPort *const | m_port |
| Pointer to the associated SwitchPort object. | |
Private Attributes | |
| satcat5::eth::PluginPort * | m_next |
|
explicit |
Attach this object to the designated router port.
Default mode is simple passthrough of all addresses.
Definition at line 13 of file router2_basic_nat.cc.
| bool BasicNat::config | ( | const satcat5::ip::Subnet & | ip_ext, |
| const satcat5::ip::Subnet & | ip_int | ||
| ) |
Change the NAT configuration.
| ip_ext | External/egress subnet. |
| ip_int | Internal/ingress subnet. |
Definition at line 21 of file router2_basic_nat.cc.
|
overrideprotectedvirtual |
Packet-transmit callback.
The egress method is called as each packet is queued for transmission by the eth::SwitchPort. Plugins that alter header fields MUST set FLAG_HEADER_CHANGE. Unlike other contexts, the egress callback may change header length. Override the default implementation to process this event.
Reimplemented from satcat5::eth::PluginPort.
Definition at line 88 of file router2_basic_nat.cc.
|
overrideprotectedvirtual |
Packet-received callback.
The ingress method is called as each packet enters the associated eth::SwitchPort, immediately before processing by eth::SwitchCore and calls to eth::PluginCore::query. Plugins that alter header fields MUST set FLAG_HEADER_CHANGE and MUST NOT make any change that affects header length. Override the default implementation to process this event.
Reimplemented from satcat5::eth::PluginPort.
Definition at line 84 of file router2_basic_nat.cc.