intf¶
Base interface types.
A base interface contains non-media or interface type specific information. Also included in this module is the interface ID type intf_id_t, used to uniquely identify any interface in the system of any type, as well as common enumerates.
-
namespace
eos
-
class
intf_handler
: public eos::base_handler<intf_mgr, intf_handler>¶ - #include <intf.h>
This class receives changes to base interface attributes.
Public Functions
-
void
watch_all_intfs
(bool)¶ Registers this class to receive change updates on the interface.
Expects a boolean signifying whether notifications should be propagated to this instance or not.
-
void
watch_intf
(intf_id_t, bool)¶ Registers this class to receive change updates on the given interface.
Expects the id of the corresponding interface and a boolean signifying whether notifications should be propagated to this instance or not.
-
virtual void
on_intf_create
(intf_id_t)¶ Handler called when a new interface is created.
After on_intf_create is called, the given intf_id is guaranteed to exist (ie intf_mgr::exists will return true). At that point, the intf_id can be used will all methods of the intf_mgr class.
This also means that the intf_id can be used with all other relevant *intf_mgr classes (ie eth_intf_mgr, eth_phy_intf_mgr, eth_lag_intf_mgr, and subintf_mgr as appropriate based on the intf_type).
-
virtual void
on_intf_delete
(intf_id_t)¶ Handler called when an interface has been removed.
After on_intf_delete is called, the given intf_id is guaranteed to not exist (ie intf_mgr::exists will return false). At that point, the intf_id cannot be used will any methods in the intf_mgr class.
This also means that the intf_id can no longer be used with all other relevant *intf_mgr classes (ie eth_intf_mgr, eth_phy_intf_mgr, eth_lag_intf_mgr, and subintf_mgr as appropriate based on the intf_type).
-
virtual void
on_oper_status
(intf_id_t, oper_status_t)¶ Handler called when the operational status of an interface changes.
Note that for physical interfaces, the on_oper_status handler will get called with INTF_OPER_NULL when the underlying hardware for that physical interface is removed.
-
void
-
class
intf_iter_t
: public eos::iter_base<intf_id_t, intf_iter_impl>¶ - #include <intf.h>
An interface iterator.
Private Functions
-
explicit
intf_iter_t
(intf_iter_impl*const)¶
Friends
- friend class intf_iter_impl
-
explicit
-
class
intf_mgr
: public eos::base_mgr<intf_handler, intf_id_t>¶ - #include <intf.h>
The interface manager. This class inspects and configures base interface attributes.
Public Functions
-
virtual
~intf_mgr
()¶
-
virtual intf_iter_t
intf_iter
() const = 0¶ Iterates over all interfaces currently available in the system.
-
virtual bool
exists
(intf_id_t) const = 0¶ Returns whether the given interface exists.
If exists returns true, then this intf_id_t can be successfully passed into every method of the intf_mgr. If not, then methods of the intf_mgr can throw a no_such_interface_error exception.
The exists method of all *intf_mgr classes that manage a given interface (ie intf_mgr, eth_intf_mgr, eth_phy_intf_mgr, eth_lag_intf_mgr, and/or subintf_mgr) are all guaranteed to return the same result.
-
virtual std::string
kernel_intf_name
(intf_id_t) const = 0¶ Given an intf_id_t, returns the kernel interface name (as a string). Returns an empty string if matching kernel interface is not found.
-
virtual intf_id_t
eos_intf_name
(std::string) const = 0¶ Given a kernel interface name string, return the EOS interface as an intf_id_t. Returns an empty intf_id_t() if matching EOS interface is not found.
-
virtual bool
admin_enabled
(intf_id_t) const = 0¶ Returns true if the given interface is configured to be enabled.
-
virtual std::string
description
(intf_id_t) const = 0¶ Returns the configured description of the given interface.
-
virtual void
description_is
(intf_id_t, char const*) = 0¶ Configure the description of the given interface. Creates a copy of the passed in string description.
-
virtual void
description_is
(intf_id_t, const std::string&) = 0¶ Configure the description of the given interface.
-
virtual oper_status_t
oper_status
(intf_id_t) const = 0¶ Inspects the current operational status of the given interface.
Protected Functions
-
intf_mgr
()¶
Private Members
-
intf_mgr
Friends
- friend class intf_handler
-
virtual
-
class
intf_counter_mgr
¶ - #include <intf.h>
The interface counter manager. This class inspects base interface counters and statistics.
Public Functions
-
virtual
~intf_counter_mgr
()¶
-
virtual intf_counters_t
counters
(intf_id_t) const = 0¶ Get the current counters of the given interface.
-
virtual intf_traffic_rates_t
traffic_rates
(intf_id_t) const = 0¶ Get the current traffic rates of the given interface.
Protected Functions
-
intf_counter_mgr
()¶
Private Members
-
intf_counter_mgr
-
virtual
-
class
Type definitions in intf¶
-
namespace
eos
Enums
-
enum
oper_status_t
¶ The operational status of an interface.
Values:
-
enumerator
INTF_OPER_NULL
¶
-
enumerator
INTF_OPER_UP
¶
-
enumerator
INTF_OPER_DOWN
¶
-
enumerator
-
enum
intf_type_t
¶ The interface’s type.
Values:
-
enumerator
INTF_TYPE_NULL
¶
-
enumerator
INTF_TYPE_OTHER
¶
-
enumerator
INTF_TYPE_ETH
¶
-
enumerator
INTF_TYPE_VLAN
¶
-
enumerator
INTF_TYPE_MANAGEMENT
¶
-
enumerator
INTF_TYPE_LOOPBACK
¶
-
enumerator
INTF_TYPE_LAG
¶
-
enumerator
INTF_TYPE_NULL0
¶
-
enumerator
INTF_TYPE_CPU
¶
-
enumerator
INTF_TYPE_VXLAN
¶
-
enumerator
-
class
intf_id_t
¶ - #include <intf.h>
Unique identifier for an interface.
Public Functions
-
intf_id_t
()¶ Default constructor.
-
explicit
intf_id_t
(char const *name)¶ Constructor based on an interface name, i.e. ‘Ethernet3/1’, or ‘Management1’.
-
explicit
intf_id_t
(std::string const &name)¶ Constructor based on an interface name, i.e. ‘Ethernet3/1’, or ‘Management1’.
-
explicit
intf_id_t
(uint64_t)¶ Constructor based on internal id representation, not part of the public API.
-
bool
is_null0
() const¶ Returns true if the interface is Null0.
-
bool
is_subintf
() const¶ Returns true if the interface is a subinterface.
-
intf_type_t
intf_type
() const¶ Returns the interface’s type.
-
bool
operator!
() const¶ Only the ‘default interface’ provided by the default constructor evaluates to false.
Private Members
-
uint64_t
intfId_
¶
-
-
class
intf_counters_t
¶ - #include <intf.h>
Interface counter class.
All of these attributes have the same meanings as the corresponding objects in the Interface MIB (RFC 2863, ‘IF-MIB’).
Public Functions
-
intf_counters_t
()¶
-
intf_counters_t
(uint64_t out_ucast_pkts, uint64_t out_multicast_pkts, uint64_t out_broadcast_pkts, uint64_t in_ucast_pkts, uint64_t in_multicast_pkts, uint64_t in_broadcast_pkts, uint64_t out_octets, uint64_t in_octets, uint64_t out_discards, uint64_t out_errors, uint64_t in_discards, uint64_t in_errors, seconds_t sample_time)¶
-
intf_counters_t
(const intf_counters_t &other)¶
-
intf_counters_t &
operator=
(intf_counters_t const &other)¶
-
intf_counters_t
(intf_counters_t &&other) noexcept¶
-
intf_counters_t &
operator=
(intf_counters_t &&other) noexcept¶
-
uint64_t
out_ucast_pkts
() const¶ Getter for ‘out_ucast_pkts’: IF-MIB ifOutUcastPkts. Note that IF-MIB specifies that ifOutUcastPkts should include packets that were dropped due to excessive collisions, as if they were successfully transmitted. We count these as out_errors.
-
uint64_t
out_multicast_pkts
() const¶ Getter for ‘out_multicast_pkts’: IF-MIB ifOutMulticastPkts counter.
-
uint64_t
out_broadcast_pkts
() const¶ Getter for ‘out_broadcast_pkts’: IF-MIB ifOutBroadcastPkts counter.
-
uint64_t
in_ucast_pkts
() const¶ Getter for ‘in_ucast_pkts’: IF-MIB ifInUcastPkts.
-
uint64_t
in_multicast_pkts
() const¶ Getter for ‘in_multicast_pkts’: IF-MIB ifInMulticastPkts counter.
-
uint64_t
in_broadcast_pkts
() const¶ Getter for ‘in_broadcast_pkts’: IF-MIB ifInBroadcastPkts counter.
-
uint64_t
out_octets
() const¶ Getter for ‘out_octets’: IF-MIB ifOutOctets counter. Note that for Ethernet interfaces, the octet counters include the MAC header and FCS (but not the preamble or SFD). This is different to the IEEE 802.3 counters (which do not include MAC header and FCS). See RFC 3635.
-
uint64_t
in_octets
() const¶ Getter for ‘in_octets’: IF-MIB ifInOctets counter. Note that for Ethernet interfaces, the octet counters include the MAC header and FCS (but not the preamble or SFD). This is different to the IEEE 802.3 counters (which do not include MAC header and FCS). See RFC 3635.
-
uint64_t
out_discards
() const¶ Getter for ‘out_discards’: IF-MIB ifOutDiscards counter.
-
uint64_t
out_errors
() const¶ Getter for ‘out_errors’: IF-MIB ifOutErrors counter.
-
uint64_t
in_discards
() const¶ Getter for ‘in_discards’: IF-MIB ifInDiscards counter.
-
uint64_t
in_errors
() const¶ Getter for ‘in_errors’: IF-MIB ifInErrors counter. The IF-MIB specifies that CRC errors should not get counted at all!, and that inErrors should include IP header checksum errors. We do not do this. We count CRC errors as inErrors, and IP header checksum errors as good packets at this level (in_ucast_pkts).
-
bool
operator==
(intf_counters_t const &other) const¶
-
bool
operator!=
(intf_counters_t const &other) const¶
-
uint32_t
hash
() const¶ The hash function for type intf_counters_t.
-
void
mix_me
(hash_mix &h) const¶ The hash mix function for type intf_counters_t.
Public Static Functions
-
static void
operator delete
(void*) noexcept¶
Friends
-
friend std::ostream &
operator<<
(std::ostream &os, const intf_counters_t &obj)¶ A utility stream operator that adds a string representation of intf_counters_t to the ostream.
-
-
class
intf_traffic_rates_t
¶ - #include <intf.h>
Interface traffic rates class.
Public Functions
-
intf_traffic_rates_t
()¶
-
intf_traffic_rates_t
(double out_pkts_rate, double in_pkts_rate, double out_bits_rate, double in_bits_rate, seconds_t sample_time)¶
-
intf_traffic_rates_t
(const intf_traffic_rates_t &other)¶
-
intf_traffic_rates_t &
operator=
(intf_traffic_rates_t const &other)¶
-
intf_traffic_rates_t
(intf_traffic_rates_t &&other) noexcept¶
-
intf_traffic_rates_t &
operator=
(intf_traffic_rates_t &&other) noexcept¶
-
double
out_pkts_rate
() const¶ Getter for ‘out_pkts_rate’: output packets per second.
-
double
in_pkts_rate
() const¶ Getter for ‘in_pkts_rate’: input packets per second.
-
double
out_bits_rate
() const¶ Getter for ‘out_bits_rate’: output bits per second.
-
double
in_bits_rate
() const¶ Getter for ‘in_bits_rate’: input bits per second.
-
bool
operator==
(intf_traffic_rates_t const &other) const¶
-
bool
operator!=
(intf_traffic_rates_t const &other) const¶
-
uint32_t
hash
() const¶ The hash function for type intf_traffic_rates_t.
-
void
mix_me
(hash_mix &h) const¶ The hash mix function for type intf_traffic_rates_t.
Public Static Functions
-
static void
operator delete
(void*) noexcept¶
Friends
-
friend std::ostream &
operator<<
(std::ostream &os, const intf_traffic_rates_t &obj)¶ A utility stream operator that adds a string representation of intf_traffic_rates_t to the ostream.
-
-
class
no_such_interface_error
: public eos::error¶ - #include <intf.h>
Non-existent interface error.
Public Functions
-
virtual
~no_such_interface_error
() noexcept¶
-
virtual void
raise
() const¶ Throws this exception.
-
uint32_t
hash
() const¶ The hash function for type no_such_interface_error.
-
void
mix_me
(hash_mix &h) const¶ The hash mix function for type no_such_interface_error.
Friends
-
friend std::ostream &
operator<<
(std::ostream &os, const no_such_interface_error &obj)¶ A utility stream operator that adds a string representation of no_such_interface_error to the ostream.
-
virtual
-
class
not_switchport_eligible_error
: public eos::error¶ - #include <intf.h>
Error of configuring an interface as a routed port that cannot be a routed port.
Public Functions
-
virtual
~not_switchport_eligible_error
() noexcept¶
-
virtual void
raise
() const¶ Throws this exception.
-
uint32_t
hash
() const¶ The hash function for type not_switchport_eligible_error.
-
void
mix_me
(hash_mix &h) const¶ The hash mix function for type not_switchport_eligible_error.
Friends
-
friend std::ostream &
operator<<
(std::ostream &os, const not_switchport_eligible_error &obj)¶ A utility stream operator that adds a string representation of not_switchport_eligible_error to the ostream.
-
virtual
-
enum