The subintf module manages subinterfaces.
Subinterfaces are multiple logical routed interfaces under an Ethernet or LAG routed interface (also referred to as the parent interface). Each subinterface is assigned a VLAN tag that is unique to the subinterface (among all its sibling subinterfaces under the same parent interface). The VLAN tag is used for mux/demux of data traffic from/to all subinterfaces under the parent interface.
This module provides APIs to provision subinterfaces. APIs include subinterface creation, deletion, retrieval and getter/setter for the subinterface VLAN tag. An iterator is also provided to iterate through all the subinterfaces that are configured in the system.
The subinterface APIs can be used with the ones in “intf” module, as shown in the sample code below. For example, the eos::intf_handler‘s on_intf_create() API can be used to react to the creation of new subinterfaces.
#include <eos/agent.h> #include <eos/subintf.h> #include <eos/panic.h> #include <eos/sdk.h> static eos::subintf_mgr *subintf_mgr; class ApplicationAgent : public eos::agent_handler, eos::intf_handler { public: explicit ApplicationAgent(eos::sdk & sdk) : eos::agent_handler(sdk.get_agent_mgr()), eos::intf_handler(sdk.get_intf_mgr()) { watch_intf(eos::intf_id_t("Ethernet1.1"), true); } // Called when all agents are initialized void on_initialized() { // Creates subinterface subintf_mgr->subintf_is(eos::intf_id_t("Ethernet1.1")); } // Handler for subinterface creation void on_intf_create(eos::intf_id_t i) { if (i == eos::intf_id_t("Ethernet1.1")) { // Ethernet1.1 is now usable. // Other application logic goes here, such as creating more subinterfaces } return; } } int main(int argc, char **argv) { eos::sdk sdk; subintf_mgr = sdk.get_subintf_mgr(); ApplicationAgent agent(sdk); sdk.main_loop(argc, argv); }
An iterator over all subinterfaces in the system.
Private Functions
Friends
The manager for subinterfaces. This is the main entry point for applications to use EosSdk subintf APIs.
Public Functions
Returns an iterator for iterating over the subinterfaces in the system. The iterator yields an intf_id_t for each configured subinterface.
Returns whether the given subinterface exists.
If exists returns true, then this intf_id_t can be successfully passed into every method of the subintf_mgr. If not, then methods of the subintf_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, and subintf_mgr for subinterfaces) are all guaranteed to return the same result.
Creates a subinterface when given the subinterface ID. No action will be taken if the subinterface exists already. The subinterface will be created even if its parent interface does not exist. But the subinterface will become operationally up on only after its parent interface becomes operationally up and is in routed mode.
Creates a subinterface and sets its VLAN tag. If the subinterface already exists, its VLAN tag will be updated.
Returns the subinterface with the given ID. Will return an empty subintf_t if the subinterface does not exist.
Deletes a subinterface. It will simply return if the given subinterface does not exist.
Returns the configured VLAN tag of a given subinterface. Returns zero if the subinterface does not exist or if no VLAN tag is configured for the subinterface.
Configures the VLAN tag of a given subinterface. Throws invalid_argument_error exception if the subinterface does not exist.
Protected Functions
Private Members
This data structure defines a subinterface.
Public Functions
Getter for ‘intf_id’: the interface ID of this subinterface.
Getter for ‘vlan_id’: the VLAN tag of this subinterface.
Setter for ‘vlan_id’.
The hash function for type subintf_t.
Returns a string representation of the current object’s values.
Friends
A utility stream operator that adds a string representation of subintf_t to the ostream.