INET Framework for OMNeT++/OMNEST
|
Represents the interface table. More...
#include <InterfaceTable.h>
Public Member Functions | |
InterfaceTable () | |
virtual | ~InterfaceTable () |
virtual std::string | getFullPath () const override |
Module path name. More... | |
virtual void | receiveSignal (cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override |
Called by the signal handler whenever a change of a category occurs to which this client has subscribed. More... | |
virtual cModule * | getHostModule () const override |
Returns the host or router this interface table lives in. More... | |
virtual bool | isLocalAddress (const L3Address &address) const override |
Checks if the address is a local one, i.e. More... | |
virtual bool | isNeighborAddress (const L3Address &address) const override |
Checks if the address is on the network of one of the interfaces, but not local. More... | |
virtual InterfaceEntry * | findInterfaceByAddress (const L3Address &address) const override |
Returns an interface given by its address. More... | |
virtual void | addInterface (InterfaceEntry *entry) override |
Adds an interface. More... | |
virtual void | deleteInterface (InterfaceEntry *entry) override |
Deletes the given interface from the table. More... | |
virtual int | getNumInterfaces () const override |
Returns the number of interfaces. More... | |
virtual InterfaceEntry * | getInterface (int pos) const override |
Returns the InterfaceEntry specified by an index 0..numInterfaces-1. More... | |
virtual InterfaceEntry * | getInterfaceById (int id) const override |
Returns an interface by its Id. More... | |
virtual int | getBiggestInterfaceId () const override |
Returns the biggest interface Id. More... | |
virtual InterfaceEntry * | getInterfaceByNodeOutputGateId (int id) const override |
Returns an interface given by its getNodeOutputGateId(). More... | |
virtual InterfaceEntry * | getInterfaceByNodeInputGateId (int id) const override |
Returns an interface given by its getNodeInputGateId(). More... | |
virtual InterfaceEntry * | getInterfaceByNetworkLayerGateIndex (int index) override |
Returns an interface given by its getNetworkLayerGateIndex(). More... | |
virtual InterfaceEntry * | getInterfaceByInterfaceModule (cModule *ifmod) const override |
Returns an interface by one of its component module (e.g. More... | |
virtual InterfaceEntry * | getInterfaceByName (const char *name) const override |
Returns an interface given by its name. More... | |
virtual InterfaceEntry * | getFirstLoopbackInterface () const override |
Returns the first interface with the isLoopback flag set. More... | |
virtual InterfaceEntry * | getFirstMulticastInterface () const override |
Returns the first multicast capable interface. More... | |
virtual bool | handleOperationStage (LifecycleOperation *operation, int stage, IDoneCallback *doneCallback) override |
ILifecycle method. More... | |
virtual MulticastGroupList | collectMulticastGroups () const override |
Returns all multicast group address, with it's interfaceId. More... | |
Public Member Functions inherited from inet::IInterfaceTable | |
virtual | ~IInterfaceTable () |
Public Member Functions inherited from inet::ILifecycle | |
virtual | ~ILifecycle () |
Protected Types | |
typedef std::vector< InterfaceEntry * > | InterfaceVector |
Protected Member Functions | |
virtual void | refreshDisplay () const override |
virtual void | updateLinkDisplayString (InterfaceEntry *entry) const |
virtual void | discoverConnectingGates (InterfaceEntry *entry) |
virtual void | interfaceChanged (simsignal_t signalID, const InterfaceEntryChangeDetails *details) override |
virtual void | invalidateTmpInterfaceList () |
virtual void | resetInterfaces () |
virtual int | numInitStages () const override |
virtual void | initialize (int stage) override |
virtual void | handleMessage (cMessage *) override |
Raises an error. More... | |
Protected Attributes | |
cModule * | host |
InterfaceVector | idToInterface |
int | tmpNumInterfaces |
InterfaceEntry ** | tmpInterfaceList |
Represents the interface table.
This object has one instance per host or router. It has methods to manage the interface table, so one can access functionality similar to the "ifconfig" command.
See the NED documentation for general overview.
This is a simple module without gates, it requires function calls to it (message handling does nothing). Methods are provided for reading and updating the interface table.
Interfaces are dynamically registered: at the start of the simulation, every L2 module adds its own InterfaceEntry to the table; after that, IPv4's IIPv4RoutingTable and IPv6's IPv6RoutingTable (an possibly, further L3 protocols) add protocol-specific data on each InterfaceEntry (see IPv4InterfaceData, IPv6InterfaceData, and InterfaceEntry::setIPv4Data(), InterfaceEntry::setIPv6Data())
Interfaces are represented by InterfaceEntry objects.
When interfaces need to be reliably and efficiently identified from other modules, interfaceIds should be used. They are better suited than pointers because when an interface gets removed (see deleteInterface()), it is often impossible/impractical to invalidate all pointers to it, and also because pointers are not necessarily unique (a new InterfaceEntry may get allocated exactly at the address of a previously deleted one). Interface Ids are unique (Ids of removed interfaces are not issued again), stale Ids can be detected, and they are also invariant to insertion/deletion.
Clients can get notified about interface changes by subscribing to the following signals on host module: NF_INTERFACE_CREATED, NF_INTERFACE_DELETED, NF_INTERFACE_STATE_CHANGED, NF_INTERFACE_CONFIG_CHANGED. State change gets fired for up/down events; all other changes fire as config change.
|
protected |
inet::InterfaceTable::InterfaceTable | ( | ) |
|
virtual |
|
overridevirtual |
Adds an interface.
The entry->getInterfaceModule() will be used to discover and fill in getNetworkLayerGateIndex(), getNodeOutputGateId(), and getNodeInputGateId() in InterfaceEntry. It should be nullptr if this is a virtual interface (e.g. loopback).
Implements inet::IInterfaceTable.
|
overridevirtual |
Returns all multicast group address, with it's interfaceId.
Implements inet::IInterfaceTable.
|
overridevirtual |
Deletes the given interface from the table.
Indices of existing interfaces (see getInterface(int)) may change. It is an error if the given interface is not in the table.
Implements inet::IInterfaceTable.
|
protectedvirtual |
Referenced by addInterface().
|
overridevirtual |
Returns an interface given by its address.
Returns nullptr if not found.
Implements inet::IInterfaceTable.
Referenced by isLocalAddress().
|
overridevirtual |
|
overridevirtual |
Returns the first interface with the isLoopback flag set.
(If there's no loopback, it returns nullptr – but this should never happen because InterfaceTable itself registers a loopback interface on startup.)
Implements inet::IInterfaceTable.
|
overridevirtual |
Returns the first multicast capable interface.
If there is no such interface, then returns nullptr.
Implements inet::IInterfaceTable.
|
inlineoverridevirtual |
Module path name.
Implements inet::IInterfaceTable.
Referenced by discoverConnectingGates(), and getInterfaceByInterfaceModule().
|
overridevirtual |
|
overridevirtual |
Returns the InterfaceEntry specified by an index 0..numInterfaces-1.
Throws an error if index is out of range.
Note that this index is NOT the same as interfaceId! Indices are not guaranteed to stay the same after interface addition/deletion, so cannot be used to reliably identify the interface. Use interfaceId to refer to interfaces from other modules or from messages/packets.
Implements inet::IInterfaceTable.
Referenced by collectMulticastGroups().
|
overridevirtual |
Returns an interface by its Id.
Ids are guaranteed to be invariant to interface deletions/additions. Returns nullptr if there is no such interface (This allows detecting stale IDs without raising an error.)
Implements inet::IInterfaceTable.
Referenced by deleteInterface().
|
overridevirtual |
Returns an interface by one of its component module (e.g.
PPP). Returns nullptr if not found.
Implements inet::IInterfaceTable.
|
overridevirtual |
Returns an interface given by its name.
Returns nullptr if not found.
Implements inet::IInterfaceTable.
Referenced by addInterface().
|
overridevirtual |
Returns an interface given by its getNetworkLayerGateIndex().
Returns nullptr if not found.
Implements inet::IInterfaceTable.
|
overridevirtual |
Returns an interface given by its getNodeInputGateId().
Returns nullptr if not found.
Implements inet::IInterfaceTable.
Referenced by getInterfaceByInterfaceModule().
|
overridevirtual |
Returns an interface given by its getNodeOutputGateId().
Returns nullptr if not found.
Implements inet::IInterfaceTable.
Referenced by getInterfaceByInterfaceModule().
|
overridevirtual |
Returns the number of interfaces.
Implements inet::IInterfaceTable.
Referenced by collectMulticastGroups(), getInterface(), and refreshDisplay().
|
overrideprotectedvirtual |
|
overridevirtual |
ILifecycle method.
Implements inet::ILifecycle.
|
overrideprotectedvirtual |
|
overrideprotectedvirtual |
Implements inet::IInterfaceTable.
|
protectedvirtual |
Referenced by addInterface(), and deleteInterface().
|
overridevirtual |
Checks if the address is a local one, i.e.
one of the host's.
Implements inet::IInterfaceTable.
|
overridevirtual |
Checks if the address is on the network of one of the interfaces, but not local.
Implements inet::IInterfaceTable.
|
inlineoverrideprotectedvirtual |
|
overridevirtual |
Called by the signal handler whenever a change of a category occurs to which this client has subscribed.
|
overrideprotectedvirtual |
|
protectedvirtual |
Referenced by handleOperationStage().
|
protectedvirtual |
Referenced by refreshDisplay().
|
protected |
|
protected |
Referenced by addInterface(), deleteInterface(), findInterfaceByAddress(), getBiggestInterfaceId(), getFirstLoopbackInterface(), getFirstMulticastInterface(), getInterface(), getInterfaceById(), getInterfaceByName(), getInterfaceByNetworkLayerGateIndex(), getInterfaceByNodeInputGateId(), getInterfaceByNodeOutputGateId(), getNumInterfaces(), initialize(), isNeighborAddress(), refreshDisplay(), resetInterfaces(), and ~InterfaceTable().
|
mutableprotected |
Referenced by getInterface(), InterfaceTable(), invalidateTmpInterfaceList(), and ~InterfaceTable().
|
mutableprotected |
Referenced by getNumInterfaces(), InterfaceTable(), and invalidateTmpInterfaceList().