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
- #include <intf.h>
This class receives changes to base interface attributes.
Public Functions
-
intf_handler
(intf_mgr *)
-
intf_mgr *
get_intf_mgr
() const
-
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.
-
virtual void
on_admin_enabled
(intf_id_t, bool) Handler called after an interface has been configured to be enabled.
-
virtual void
on_intf_description
(intf_id_t, const std::string &) Handler called when the configured description of an interface changes.
-
-
class
intf_iter_t
- #include <intf.h>
An interface iterator.
Private Functions
-
intf_iter_t
(intf_iter_impl * const)
Friends
-
friend class
intf_iter_impl
-
-
class
intf_mgr
- #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 void
admin_enabled_is
(intf_id_t, bool) = 0 Configures the enabled status of the interface.
-
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
- oper_status_t enum
The operational status of an interface.
Values:
INTF_OPER_NULL
-INTF_OPER_UP
-INTF_OPER_DOWN
-
- intf_type_t enum
The interface’s type.
Values:
INTF_TYPE_NULL
-INTF_TYPE_OTHER
-INTF_TYPE_ETH
-INTF_TYPE_VLAN
-INTF_TYPE_MANAGEMENT
-INTF_TYPE_LOOPBACK
-INTF_TYPE_LAG
-INTF_TYPE_NULL0
-INTF_TYPE_CPU
-INTF_TYPE_VXLAN
-
-
class
intf_id_t
- #include <intf.h>
Unique identifier for an interface.
Public Functions
-
intf_id_t
() Default constructor.
-
intf_id_t
(char const * name) Constructor based on an interface name, i.e. ‘Ethernet3/1’, or ‘Management1’.
-
intf_id_t
(std::string const & name) Constructor based on an interface name, i.e. ‘Ethernet3/1’, or ‘Management1’.
-
intf_id_t
(uint64_t id) 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.
-
std::string
to_string
() const Returns the interface name as a string, e.g., ‘Ethernet3/1’.
-
bool
operator!
() const Only the ‘default interface’ provided by the default constructor evaluates to false.
-
bool
operator==
(intf_id_t const & other) const
-
bool
operator!=
(intf_id_t const & other) const
-
bool
operator<
(intf_id_t const & other) const
-
uint32_t
hash
() const The hash function for type intf_id_t.
Private Members
-
uint64_t
intfId_
Friends
-
friend struct
IntfIdHelper
-
friend std::ostream &
operator<<
A utility stream operator that adds a string representation of intf_id_t to the ostream.
-
-
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)
-
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).
-
seconds_t
sample_time
() const Getter for ‘sample_time’: time when the counters were updated.
-
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.
-
std::string
to_string
() const Returns a string representation of the current object’s values.
Private Members
-
std::shared_ptr< intf_counters_impl_t >
pimpl
Friends
-
friend std::ostream &
operator<<
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)
-
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.
-
seconds_t
sample_time
() const Getter for ‘sample_time’: time when the rates were updated.
-
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.
-
std::string
to_string
() const Returns a string representation of the current object’s values.
Private Members
-
std::shared_ptr< intf_traffic_rates_impl_t >
pimpl
Friends
-
friend std::ostream &
operator<<
A utility stream operator that adds a string representation of intf_traffic_rates_t to the ostream.
-
-
class
no_such_interface_error
- #include <intf.h>
Non-existent interface error.
Public Functions
-
no_such_interface_error
(intf_id_t intf)
-
no_such_interface_error
(std::string const & intfName)
-
virtual
~no_such_interface_error
()
-
intf_id_t
intf
() const
-
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.
-
std::string
to_string
() const Returns a string representation of the current object’s values.
Private Members
-
intf_id_t
intf_
Friends
-
friend std::ostream &
operator<<
A utility stream operator that adds a string representation of no_such_interface_error to the ostream.
-
-
class
not_switchport_eligible_error
- #include <intf.h>
Error of configuring an interface as a routed port that cannot be a routed port.
Public Functions
-
not_switchport_eligible_error
(intf_id_t intf)
-
virtual
~not_switchport_eligible_error
()
-
intf_id_t
intf
() const
-
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.
-
std::string
to_string
() const Returns a string representation of the current object’s values.
Private Members
-
intf_id_t
intf_
Friends
-
friend std::ostream &
operator<<
A utility stream operator that adds a string representation of not_switchport_eligible_error to the ostream.
-