SatCat5
satcat5::ip::Table Class Reference

Detailed Description

IPv4 forwarding table.

SatCat5 routing-table concepts. This class implements a static routing table, also known as a forarding information base (FIB). This class is used directly by ip::Stack, and as the parent for the router2::Table class used in router::StackGateware.

Definition at line 144 of file ip_table.h.

#include <ip_table.h>

Inheritance diagram for satcat5::ip::Table:
[legend]
Collaboration diagram for satcat5::ip::Table:
[legend]

Public Member Functions

 Table ()
 Construct an empty table with a local default route. More...
 
void log_to (satcat5::log::LogBuffer &wr) const
 Create a log entry with the full contents of this table. More...
 
void route_clear (bool lockdown=true)
 Clear all routes, including the default. More...
 
void route_flush ()
 Flush cached MAC-addresses. More...
 
bool route_default (const satcat5::ip::Addr &gateway, const satcat5::eth::MacAddr &dstmac=satcat5::eth::MACADDR_NONE, u8 port=0, u8 flags=0)
 Set the default behavior when no other routes match.
 
bool route_simple (const satcat5::ip::Addr &gateway, const satcat5::ip::Mask &subnet=satcat5::ip::MASK_24)
 Simplified one-step setup for a typical home network. More...
 
bool route_static (const satcat5::ip::Subnet &subnet, const satcat5::ip::Addr &gateway, const satcat5::eth::MacAddr &dstmac=satcat5::eth::MACADDR_NONE, u8 port=0, u8 flags=0)
 Create or update a single static route. More...
 
bool route_local (const satcat5::ip::Subnet &subnet, u8 port=0, u8 flags=0)
 Create or update a local static route. More...
 
bool route_cache (const satcat5::ip::Addr &gateway, const satcat5::eth::MacAddr &dstmac)
 Update matching MAC address cache entries. More...
 
bool route_remove (const satcat5::ip::Subnet &subnet)
 Remove a single static route. More...
 
bool route_remove (const satcat5::ip::Addr &addr)
 
satcat5::ip::Route route_lookup (const satcat5::ip::Addr &dstaddr) const
 Next-hop routing lookup for the given destination address.
 

Protected Member Functions

const satcat5::ip::Routeroute_rddef () const
 Internal methods used to access "m_route_default". More...
 
virtual bool route_wrdef (const satcat5::ip::Route &route)
 Internal methods used to access "m_route_default". More...
 
const satcat5::ip::Routeroute_read (unsigned idx) const
 Internal methods used to access "m_route_table". More...
 
virtual bool route_write (unsigned idx, const satcat5::ip::Route &route)
 Internal methods used to access "m_route_table". More...
 

Protected Attributes

unsigned m_wridx_static
 
unsigned m_wridx_ephemeral
 

Private Attributes

satcat5::ip::Route m_route_default
 
satcat5::ip::Route m_route_table [SATCAT5_ROUTING_TABLE]
 

Constructor & Destructor Documentation

◆ Table()

Table::Table ( )

Construct an empty table with a local default route.

Note this is NOT the same as route_clear().

Definition at line 52 of file ip_table.cc.

Member Function Documentation

◆ log_to()

void Table::log_to ( satcat5::log::LogBuffer wr) const

Create a log entry with the full contents of this table.

Internally, this calls Route::log_to for each ip::Route in the table. Note: Large tables may be truncated if they exceed the maximum log buffer size.

Definition at line 59 of file ip_table.cc.

◆ route_cache()

bool Table::route_cache ( const satcat5::ip::Addr gateway,
const satcat5::eth::MacAddr dstmac 
)

Update matching MAC address cache entries.

If a new cache entry is created, port number is copied from the best matching route.

See also
route_lookup. Returns true if any records are updated.

Definition at line 138 of file ip_table.cc.

◆ route_clear()

void Table::route_clear ( bool  lockdown = true)

Clear all routes, including the default.

After calling this method, all destination addresses are unreachable until new routes are loaded.

Definition at line 73 of file ip_table.cc.

◆ route_flush()

void Table::route_flush ( )

Flush cached MAC-addresses.

This method deletes all cached next-hop MAC addresses, i.e., those set by ARP messages using the route_cache method.

  • Static routes with a fixed MAC address are unaffected.
  • Static routes with a dynamic MAC address clear that MAC.
  • Ephemeral routes are completely deleted.

Definition at line 81 of file ip_table.cc.

◆ route_local()

bool satcat5::ip::Table::route_local ( const satcat5::ip::Subnet subnet,
u8  port = 0,
u8  flags = 0 
)
inline

Create or update a local static route.

Returns true if successful, false if table is full.

Definition at line 192 of file ip_table.h.

◆ route_rddef()

const satcat5::ip::Route& satcat5::ip::RouteArray::route_rddef ( ) const
inlineprotectedinherited

Internal methods used to access "m_route_default".

Child classes may override this to implement mirroring.

Definition at line 119 of file ip_table.h.

◆ route_read()

const satcat5::ip::Route& satcat5::ip::RouteArray::route_read ( unsigned  idx) const
inlineprotectedinherited

Internal methods used to access "m_route_table".

Child classes may override route_write() to implement mirroring.

Definition at line 127 of file ip_table.h.

◆ route_remove()

bool Table::route_remove ( const satcat5::ip::Subnet subnet)

Remove a single static route.

Returns true if successful, false if no match is found.

Definition at line 178 of file ip_table.cc.

◆ route_simple()

bool Table::route_simple ( const satcat5::ip::Addr gateway,
const satcat5::ip::Mask subnet = satcat5::ip::MASK_24 
)

Simplified one-step setup for a typical home network.

This method loads the single-gateway, single-subnet route typical for a small-office or home-office (SOHO) LAN.

Definition at line 105 of file ip_table.cc.

◆ route_static()

bool Table::route_static ( const satcat5::ip::Subnet subnet,
const satcat5::ip::Addr gateway,
const satcat5::eth::MacAddr dstmac = satcat5::eth::MACADDR_NONE,
u8  port = 0,
u8  flags = 0 
)

Create or update a single static route.

Returns true if successful, false if table is full.

Definition at line 111 of file ip_table.cc.

◆ route_wrdef()

bool RouteArray::route_wrdef ( const satcat5::ip::Route route)
protectedvirtualinherited

Internal methods used to access "m_route_default".

Child classes may override this to implement mirroring.

Reimplemented in satcat5::router2::Table.

Definition at line 229 of file ip_table.cc.

◆ route_write()

bool RouteArray::route_write ( unsigned  idx,
const satcat5::ip::Route route 
)
protectedvirtualinherited

Internal methods used to access "m_route_table".

Child classes may override route_write() to implement mirroring.

Reimplemented in satcat5::router2::Table.

Definition at line 234 of file ip_table.cc.


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