|
SatCat5
|
MAC-address cache plugin for the software-defined Ethernet switch.
All Ethernet switches maintain a cache of recently used MAC addresses, noting the port associated with each address so that packets can be directed accordingly. The switch cannot operate without this function, using this plugin or a near-equivalent.
This class defines a SwitchCore plugin with a simple implementation of such a cache, with an LRU replacement policy. Configuration methods mimic eth::SwitchConfig.
Definition at line 25 of file eth_sw_cache.h.
#include <eth_sw_cache.h>
Classes | |
| struct | CacheEntry |
| Data structure for the internal cache. More... | |
Public Member Functions | |
| void | query (satcat5::eth::PluginPacket &pkt) override |
| Implement the required SwitchPlugin API. | |
| void | set_miss_bcast (unsigned port_idx, bool enable) |
| Enable or disable "miss-as-broadcast" flag for a specific port. More... | |
| void | set_miss_mask (SATCAT5_PMASK_TYPE mask) |
| Enable or disable "miss-as-broadcast" flag for all ports. More... | |
| SATCAT5_PMASK_TYPE | get_miss_mask () const |
| Identify which ports are currently in "miss-as-broadcast" mode. More... | |
| unsigned | mactbl_size () const |
| Read or manipulate the contents of the MAC-address table. More... | |
| bool | mactbl_read (unsigned tbl_idx, unsigned &port_idx, satcat5::eth::MacAddr &mac_addr) |
| Read or manipulate the contents of the MAC-address table. More... | |
| bool | mactbl_write (unsigned port_idx, const satcat5::eth::MacAddr &mac_addr) |
| Read or manipulate the contents of the MAC-address table. More... | |
| bool | mactbl_clear () |
| Read or manipulate the contents of the MAC-address table. More... | |
| bool | mactbl_learn (bool enable) |
| Read or manipulate the contents of the MAC-address table. More... | |
| bool | mactbl_learn () const |
| Read or manipulate the contents of the MAC-address table. More... | |
Protected Member Functions | |
| SwitchCacheInner (satcat5::eth::SwitchCore *sw, CacheEntry *array, unsigned size) | |
| Constructor accepts a child-allocated array for the cache. | |
| SATCAT5_PMASK_TYPE | destination_mask (const PluginPacket &pkt) |
| Destination MAC-address lookup. | |
Protected Attributes | |
| bool | m_learn |
| SATCAT5_PMASK_TYPE | m_miss_mask |
| CacheEntry *const | m_array |
| const unsigned | m_size |
| satcat5::util::LruCache< CacheEntry > | m_cache |
Private Attributes | |
| satcat5::eth::SwitchCore *const | m_switch |
| Pointer to the associated SwitchCore object. | |
| satcat5::eth::PluginCore * | m_next |
|
inline |
Identify which ports are currently in "miss-as-broadcast" mode.
For format description,
Definition at line 45 of file eth_sw_cache.h.
|
inline |
Read or manipulate the contents of the MAC-address table.
All functions return true if successful, false otherwise. (These mimic the API provided by satcat5::eth::SwitchConfig)
Definition at line 61 of file eth_sw_cache.h.
|
inline |
Read or manipulate the contents of the MAC-address table.
All functions return true if successful, false otherwise. (These mimic the API provided by satcat5::eth::SwitchConfig)
Definition at line 65 of file eth_sw_cache.h.
|
inline |
Read or manipulate the contents of the MAC-address table.
All functions return true if successful, false otherwise. (These mimic the API provided by satcat5::eth::SwitchConfig)
Definition at line 63 of file eth_sw_cache.h.
| bool SwitchCacheInner::mactbl_read | ( | unsigned | tbl_idx, |
| unsigned & | port_idx, | ||
| satcat5::eth::MacAddr & | mac_addr | ||
| ) |
Read or manipulate the contents of the MAC-address table.
All functions return true if successful, false otherwise. (These mimic the API provided by satcat5::eth::SwitchConfig)
Definition at line 60 of file eth_sw_cache.cc.
|
inline |
Read or manipulate the contents of the MAC-address table.
All functions return true if successful, false otherwise. (These mimic the API provided by satcat5::eth::SwitchConfig)
Definition at line 52 of file eth_sw_cache.h.
| bool SwitchCacheInner::mactbl_write | ( | unsigned | port_idx, |
| const satcat5::eth::MacAddr & | mac_addr | ||
| ) |
Read or manipulate the contents of the MAC-address table.
All functions return true if successful, false otherwise. (These mimic the API provided by satcat5::eth::SwitchConfig)
Definition at line 67 of file eth_sw_cache.cc.
| void SwitchCacheInner::set_miss_bcast | ( | unsigned | port_idx, |
| bool | enable | ||
| ) |
Enable or disable "miss-as-broadcast" flag for a specific port.
Frames with an unknown destination (i.e., destination MAC not found in cache) are sent to every port with this flag. This method sets the configuration for the specified port index.
Definition at line 55 of file eth_sw_cache.cc.
|
inline |
Enable or disable "miss-as-broadcast" flag for all ports.
Frames with an unknown destination (i.e., destination MAC not found in cache) are sent to every port with this flag. This method sets all ports in a single call.
Definition at line 40 of file eth_sw_cache.h.