SatCat5
satcat5::router2::BasicNat Class Reference

Detailed Description

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>

Inheritance diagram for satcat5::router2::BasicNat:
[legend]
Collaboration diagram for satcat5::router2::BasicNat:
[legend]

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::PluginPortm_next
 

Constructor & Destructor Documentation

◆ BasicNat()

BasicNat::BasicNat ( satcat5::eth::SwitchPort port)
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.

Member Function Documentation

◆ config()

bool BasicNat::config ( const satcat5::ip::Subnet ip_ext,
const satcat5::ip::Subnet ip_int 
)

Change the NAT configuration.

Parameters
ip_extExternal/egress subnet.
ip_intInternal/ingress subnet.
Returns
True if the new configuration is accepted.

Definition at line 21 of file router2_basic_nat.cc.

◆ egress()

void BasicNat::egress ( satcat5::eth::PluginPacket pkt)
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.

◆ ingress()

void BasicNat::ingress ( satcat5::eth::PluginPacket pkt)
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.


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