mac_table¶
MAC address table management module.
This module offers a MAC address table manager, used to define MAC addresses in system configuration.
This module also offers a handler that provides notifications when a MAC address has been learned (or forgotten).
Please refer to examples/SimpleMac.cpp for an example.
-
namespace
eos
-
class
mac_table_handler
- #include <mac_table.h>
Handler for the MAC table.
This handler provides notifications when MAC addresses are learned on or removed from an interface. Note: This handler currently only provides notifications for unicast MAC addresses.
Public Functions
-
mac_table_handler
(mac_table_mgr * mgr)
-
mac_table_mgr *
get_mac_table_mgr
() const
-
void
watch_all_mac_entries
(bool) Registers this class to receive change updates from the MAC table.
Expects a boolean signifying whether notifications should be propagated to this instance or not.
-
void
watch_mac_entry
(mac_key_t const & key, bool) Registers this class to receive change updates on the given MAC entry.
Expects the key of the corresponding MAC address and a boolean signifying whether notifications should be propagated to this instance or not.
-
virtual void
on_mac_entry_set
(mac_entry_t const & entry) This handler is called when a unicast MAC entry is learned for the first time, or when a unicast MAC entry has moved to a different interface.
-
virtual void
on_mac_entry_del
(mac_key_t const & key) This handler is called when a unicast entry is removed from the MAC address table.
-
-
class
mac_table_iter_t
Private Functions
-
mac_table_iter_t
(mac_table_iter_impl * const)
Friends
-
friend class
mac_table_iter_impl
-
-
class
mac_table_status_iter_t
Private Functions
-
mac_table_status_iter_t
(mac_table_status_iter_impl * const)
Friends
-
friend class
mac_table_status_iter_impl
-
-
class
mac_table_mgr
- #include <mac_table.h>
Manager for the MAC address table.
Public Functions
-
virtual
~mac_table_mgr
()
-
virtual mac_table_iter_t
mac_table_iter
() const = 0 Iterator for all configured MAC addresses.
-
virtual mac_table_status_iter_t
mac_table_status_iter
() const = 0 Iterator for the MAC address table.
-
virtual mac_entry_t
mac_entry
(mac_key_t const & key) const = 0 Retrieves a mac_entry_t given the VLAN and MAC address key from the collection of configured entries.
This entry contains the interface (or, for multicast entries, the interfaces) that the given key was configured on. If the entry has not been configured, an empty mac_entry_t() is returned.
- Parameters
mac_key_t
-The MAC address key object, consisting of a VLAN and a MAC address, which are used to retrieve that unique MAC entry.
-
virtual mac_entry_t
mac_entry
(vlan_id_t vlan, eth_addr_t mac) const = 0 Returns a mac_entry_t given a VLAN and MAC address from the collection of configured entries.
-
virtual mac_entry_t
mac_entry_status
(mac_key_t const & key) const = 0 Retrieves a mac_entry_t given the VLAN and MAC address key from the collection of entries either learned dynamically or explicitly configured.
This entry contains the interface (or, for multicast entries, the interfaces) that the given key has been learned on. If the entry has not been learned, an empty mac_entry_t() is returned. Note: At this time, a multicast MAC entry’s status directly mirrors its configuration and does not reflect whether or not the entry has been programmed into hardware.
- Parameters
mac_key_t
-The MAC address key object, consisting of a VLAN and a MAC address, which are used to retrieve that unique MAC entry.
-
virtual mac_entry_type_t
type
(mac_key_t const & key) const = 0 Returns the type of the programmed MAC entry.
-
virtual uint32_t
moves
(mac_key_t const & key) const = 0 Returns the number of times the MAC entry has moved.
-
virtual seconds_t
last_move_time
(mac_key_t const & key) const = 0 Returns the time at which the MAC entry last moved (since boot).
-
virtual void
mac_entry_set
(mac_entry_t const & entry) = 0 Configure a MAC address statically as “learned” on a given interface (or set of interfaces for multicast MAC entries).
-
virtual void
mac_entry_del
(mac_key_t const & key) = 0 Remove a MAC entry with the given key from the collection of entries that were either learned dynamically or configured explicitly.
Protected Functions
-
mac_table_mgr
()
Private Members
-
mac_table_mgr
Friends
-
friend class
mac_table_handler
-
virtual
-
class
Type definitions in mac_table¶
-
namespace
eos
Enums
- mac_entry_type_t enum
Types of MAC entries.
Values:
MAC_ENTRY_NULL
-MAC_ENTRY_LEARNED_DYNAMIC
-MAC_ENTRY_LEARNED_SECURE
-MAC_ENTRY_CONFIGURED_DYNAMIC
-MAC_ENTRY_CONFIGURED_SECURE
-MAC_ENTRY_CONFIGURED_STATIC
-MAC_ENTRY_PEER_DYNAMIC
-MAC_ENTRY_PEER_STATIC
-MAC_ENTRY_PEER_SECURE
-MAC_ENTRY_LEARNED_REMOTE
-MAC_ENTRY_CONFIGURED_REMOTE
-MAC_ENTRY_RECEIVED_REMOTE
-MAC_ENTRY_PEER_LEARNED_REMOTE
-MAC_ENTRY_PEER_CONFIGURED_REMOTE
-MAC_ENTRY_PEER_RECEIVED_REMOTE
-MAC_ENTRY_EVPN_DYNAMIC_REMOTE
-MAC_ENTRY_EVPN_CONFIGURED_REMOTE
-MAC_ENTRY_PEER_EVPN_REMOTE
-MAC_ENTRY_CONFIGURED_ROUTER
-MAC_ENTRY_PEER_ROUTER
-MAC_ENTRY_EVPN_INTF
-Deprecated.
MAC_ENTRY_EVPN_REMOTE_MAC
-Deprecated.
MAC_ENTRY_PEER_EVPN_REMOTE_MAC
-Deprecated.
MAC_ENTRY_EVPN_INTF_DYNAMIC
-MAC_ENTRY_EVPN_INTF_STATIC
-MAC_ENTRY_AUTHENTICATED
-MAC_ENTRY_PEER_AUTHENTICATED
-MAC_ENTRY_PENDING_SECURE
-MAC_ENTRY_VPLS_DYNAMIC_REMOTE
-
-
class
mac_key_t
- #include <mac_table.h>
The MAC entry key class. Maps a MAC address with a specific VLAN ID to an interface.
Public Functions
-
mac_key_t
() Default constructor.
-
mac_key_t
(vlan_id_t vlan_id, eth_addr_t const & eth_addr)
-
mac_key_t
(const mac_key_t & other)
-
vlan_id_t
vlan_id
() const Getter for ‘vlan_id’: the VLAN subdomain identifier.
-
eth_addr_t
eth_addr
() const Getter for ‘eth_addr’: the Ethernet address of the MAC entry.
-
bool
operator!
() const Non-existent keys are effectively false(so this returns true).
-
bool
operator==
(mac_key_t const & other) const
-
bool
operator!=
(mac_key_t const & other) const
-
bool
operator<
(mac_key_t const & other) const
-
uint32_t
hash
() const The hash function for type mac_key_t.
-
std::string
to_string
() const Returns a string representation of the current object’s values.
Private Members
-
std::shared_ptr< mac_key_impl_t >
pimpl
Friends
-
friend std::ostream &
operator<<
A utility stream operator that adds a string representation of mac_key_t to the ostream.
-
-
class
mac_entry_t
- #include <mac_table.h>
An entry from the MAC address table.
Public Functions
-
mac_entry_t
() Default constructor.
-
mac_entry_t
(mac_key_t const & mac_key) Constructor for basic MAC entry.
-
mac_entry_t
(mac_key_t const & mac_key, intf_id_t intf) Constructor for unicast MAC entry and interface.
-
mac_entry_t
(mac_key_t const & mac_key, std::set< intf_id_t > const & intfs) Constructor for multicast MAC entry and interfaces.
-
mac_entry_t
(vlan_id_t vlan_id, eth_addr_t eth_addr) Deprecated constructor.
-
mac_entry_t
(eth_addr_t eth_addr, intf_id_t intf) Deprecated constructor. Default VLAN identifier is 0. Please use method mac_key_is with a VLAN ID and the eth_addr attribute to set a valid VLAN ID.
-
mac_entry_t
(const mac_entry_t & other)
-
mac_entry_t &
operator=
(mac_entry_t const & other)
-
mac_key_t
mac_key
() const Getter for ‘mac_key’: the key of the MAC entry.
-
void
mac_key_is
(mac_key_t const & mac_key) Setter for ‘mac_key’.
-
std::set< intf_id_t > const &
intfs
() const Getter for ‘intfs’: the set of interfaces that this key forwards to. For unicast MAC entries, this expects a set with either 1 interface or 0 interfaces to signify a drop. If passed a multicast MAC address, ‘intfs’ can contain one or more output interfaces.
-
void
intfs_is
(std::set< intf_id_t > const & intfs) Setter for ‘intfs’.
-
void
intf_set
(intf_id_t const & value) Inserts one intf of ‘value’ to the set.
-
void
intf_del
(intf_id_t const & value) Deletes one intf of ‘value’ from the set.
-
bool
operator!
() const Returns ‘true’ if this key is “empty”, that is if neither the VLAN nor the MAC address is set.
-
vlan_id_t
vlan_id
() const The VLAN subdomain identifier of the MAC entry.
-
eth_addr_t
eth_addr
() const The Ethernet address of the MAC entry.
-
intf_id_t
intf
() const Return the interface of the unicast MAC entry, the first interface of a multicast MAC entry, or an empty object if the entry is a drop entry.
-
void
intf_is
(intf_id_t intf) Setter for ‘intf’: a single interface in a MAC entry.
-
bool
operator==
(mac_entry_t const & other) const
-
bool
operator!=
(mac_entry_t const & other) const
-
uint32_t
hash
() const The hash function for type mac_entry_t.
-
void
mix_me
(hash_mix & h) const The hash mix function for type mac_entry_t.
-
std::string
to_string
() const Returns a string representation of the current object’s values.
Private Members
-
std::shared_ptr< mac_entry_impl_t >
pimpl
Friends
-
friend std::ostream &
operator<<
A utility stream operator that adds a string representation of mac_entry_t to the ostream.
-