|
INET Framework for OMNeT++/OMNEST
|
This class provides an IArp implementation whithout exchanging packets.
More...
#include <GlobalArp.h>
This class provides an IArp implementation whithout exchanging packets.
◆ ArpCache
◆ GlobalArp()
| inet::GlobalArp::GlobalArp |
( |
| ) |
|
36 throw cRuntimeError(
"Global ARP cache not empty, model error in previous run?");
◆ ~GlobalArp()
| inet::GlobalArp::~GlobalArp |
( |
| ) |
|
|
virtual |
45 if (it->second->owner ==
this) {
◆ ensureCacheEntry()
324 ArpCacheEntry *entry =
new ArpCacheEntry();
326 entry->networkInterface = networkInterface;
328 ASSERT(where->second == entry);
Referenced by initialize().
◆ getL3AddressFor()
Returns the Layer 3 address for the given MAC address.
If it is not available (not in the cache, pending resolution, or already expired), UNSPECIFIED_ADDRESS is returned.
Implements inet::IArp.
197 #ifdef INET_WITH_IPv4
199 if (macAddress.isUnspecified())
202 if (it->second->networkInterface->getMacAddress() == macAddress && it->first.getType() ==
L3Address::IPv4)
207 #ifdef INET_WITH_IPv6
209 if (macAddress.isUnspecified())
212 if (it->second->networkInterface->getMacAddress() == macAddress && it->first.getType() ==
L3Address::IPv6)
218 return L3Address(macAddress);
220 if (macAddress.isUnspecified())
221 return ModuleIdAddress();
223 if (it->second->networkInterface->getMacAddress() == macAddress && it->first.getType() ==
L3Address::MODULEID)
225 return ModuleIdAddress();
228 if (macAddress.isUnspecified())
229 return ModulePathAddress();
231 if (it->second->networkInterface->getMacAddress() == macAddress && it->first.getType() ==
L3Address::MODULEPATH)
233 return ModulePathAddress();
236 throw cRuntimeError(
"Unknown address type");
◆ handleCrashOperation()
◆ handleMessageWhenUp()
| void inet::GlobalArp::handleMessageWhenUp |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
◆ handlePacket()
| void inet::GlobalArp::handlePacket |
( |
Packet * |
packet | ) |
|
|
protectedvirtual |
◆ handleSelfMessage()
| void inet::GlobalArp::handleSelfMessage |
( |
cMessage * |
msg | ) |
|
|
protectedvirtual |
◆ handleStartOperation()
◆ handleStopOperation()
◆ initialize()
| void inet::GlobalArp::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
Reimplemented from inet::OperationalMixin< cSimpleModule >.
60 const char *addressTypeString = par(
"addressType");
61 if (!strcmp(addressTypeString,
"ipv4"))
63 else if (!strcmp(addressTypeString,
"ipv6"))
65 else if (!strcmp(addressTypeString,
"mac"))
67 else if (!strcmp(addressTypeString,
"modulepath"))
69 else if (!strcmp(addressTypeString,
"moduleid"))
72 throw cRuntimeError(
"Unknown address type");
79 NetworkInterface *networkInterface =
interfaceTable->getInterface(i);
80 if (!networkInterface->isLoopback()) {
82 if (
auto ipv4Data = networkInterface->findProtocolData<Ipv4InterfaceData>()) {
83 Ipv4Address ipv4Address = ipv4Data->getIPAddress();
84 if (!ipv4Address.isUnspecified())
89 if (
auto ipv6Data = networkInterface->findProtocolData<Ipv6InterfaceData>()) {
90 Ipv6Address ipv6Address = ipv6Data->getLinkLocalAddress();
91 if (!ipv6Address.isUnspecified())
95 #ifdef INET_WITH_NEXTHOP
96 if (
auto genericData = networkInterface->findProtocolData<NextHopInterfaceData>()) {
97 L3Address address = genericData->getAddress();
98 if (!address.isUnspecified())
105 if (node !=
nullptr) {
◆ isInitializeStage()
| virtual bool inet::GlobalArp::isInitializeStage |
( |
int |
stage | ) |
const |
|
inlineoverrideprotectedvirtual |
◆ isModuleStartStage()
| virtual bool inet::GlobalArp::isModuleStartStage |
( |
int |
stage | ) |
const |
|
inlineoverrideprotectedvirtual |
◆ isModuleStopStage()
| virtual bool inet::GlobalArp::isModuleStopStage |
( |
int |
stage | ) |
const |
|
inlineoverrideprotectedvirtual |
◆ mapUnicastAddress()
157 switch (address.getType()) {
158 #ifdef INET_WITH_IPv4
160 Ipv4Address ipv4Address = address.toIpv4();
163 return it->second->networkInterface->getMacAddress();
164 throw cRuntimeError(
"GlobalArp does not support dynamic address resolution");
168 #ifdef INET_WITH_IPv6
170 Ipv6Address ipv6Address = address.toIpv6();
173 return it->second->networkInterface->getMacAddress();
174 throw cRuntimeError(
"GlobalArp does not support dynamic address resolution");
179 return address.toMac();
181 auto networkInterface = check_and_cast<NetworkInterface *>(getSimulation()->getModule(address.toModuleId().getId()));
182 return networkInterface->getMacAddress();
185 auto networkInterface = check_and_cast<NetworkInterface *>(getSimulation()->getModule(address.toModulePath().getId()));
186 return networkInterface->getMacAddress();
189 throw cRuntimeError(
"Unknown address type");
Referenced by resolveL3Address().
◆ numInitStages()
| virtual int inet::GlobalArp::numInitStages |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ receiveSignal()
| void inet::GlobalArp::receiveSignal |
( |
cComponent * |
source, |
|
|
simsignal_t |
signalID, |
|
|
cObject * |
obj, |
|
|
cObject * |
details |
|
) |
| |
|
overridevirtual |
242 Enter_Method(
"%s", cComponent::getSignalName(signalID));
246 const NetworkInterfaceChangeDetails *iecd = check_and_cast<const NetworkInterfaceChangeDetails *>(obj);
247 NetworkInterface *networkInterface = iecd->getNetworkInterface();
248 if (networkInterface->isLoopback())
251 ArpCacheEntry *entry =
nullptr;
252 #ifdef INET_WITH_IPv4
255 if (it->second->networkInterface == networkInterface && it->first.getType() ==
L3Address::IPv4)
259 auto ipv4Data = networkInterface->findProtocolData<Ipv4InterfaceData>();
260 if (!ipv4Data || ipv4Data->getIPAddress().isUnspecified())
262 entry =
new ArpCacheEntry();
264 entry->networkInterface = networkInterface;
269 ASSERT(entry->owner ==
this);
271 auto ipv4Data = networkInterface->findProtocolData<Ipv4InterfaceData>();
272 if (!ipv4Data || ipv4Data->getIPAddress().isUnspecified()) {
277 Ipv4Address ipv4Address = networkInterface->getProtocolData<Ipv4InterfaceData>()->getIPAddress();
279 ASSERT(where->second == entry);
283 #ifdef INET_WITH_IPv6
286 if (it->second->networkInterface == networkInterface && it->first.getType() ==
L3Address::IPv6)
290 auto ipv6Data = networkInterface->findProtocolData<Ipv6InterfaceData>();
291 if (ipv6Data ==
nullptr || ipv6Data->getLinkLocalAddress().isUnspecified())
293 entry =
new ArpCacheEntry();
295 entry->networkInterface = networkInterface;
300 ASSERT(entry->owner ==
this);
302 auto ipv6Data = networkInterface->findProtocolData<Ipv6InterfaceData>();
303 if (ipv6Data ==
nullptr || ipv6Data->getLinkLocalAddress().isUnspecified()) {
308 Ipv6Address ipv6Address = networkInterface->getProtocolData<Ipv6InterfaceData>()->getLinkLocalAddress();
310 ASSERT(where->second == entry);
317 throw cRuntimeError(
"Unknown signal");
◆ resolveL3Address()
Tries to resolve the given network address to a MAC address.
If the MAC address is not yet resolved it returns an unspecified address and starts an address resolution procedure. A signal is emitted when the address resolution procedure terminates.
Implements inet::IArp.
146 if (address.isUnicast())
148 else if (address.isMulticast())
149 return address.mapToMulticastMacAddress();
150 else if (address.isBroadcast())
152 throw cRuntimeError(
"Address must be one of unicast, multicast, or broadcast");
◆ toMulticastMacAddress() [1/2]
◆ toMulticastMacAddress() [2/2]
◆ addressType
◆ globalArpCache
◆ globalArpCacheRefCnt
| int inet::GlobalArp::globalArpCacheRefCnt = 0 |
|
staticprotected |
◆ interfaceTable
The documentation for this class was generated from the following files:
cModule * findContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:31
@ MODULEID
Definition: L3Address.h:40
MacAddress mapUnicastAddress(L3Address address)
Definition: GlobalArp.cc:155
@ STAGE_NETWORK_LAYER
Definition: ModuleOperations.h:53
virtual void initialize(int stage) override
Definition: OperationalMixinImpl.h:26
@ STAGE_NETWORK_LAYER
Definition: ModuleOperations.h:29
INET_API InitStage INITSTAGE_NETWORK_LAYER
Initialization of network layer protocols.
@ IPv4
Definition: L3Address.h:35
@ MODULEPATH
Definition: L3Address.h:39
L3Address::AddressType addressType
Definition: GlobalArp.h:43
virtual void handlePacket(Packet *packet)
Definition: GlobalArp.cc:125
static const Ipv6Address UNSPECIFIED_ADDRESS
The unspecified address.
Definition: Ipv6Address.h:54
void ensureCacheEntry(const L3Address &address, const NetworkInterface *networkInterface)
Definition: GlobalArp.cc:320
static int globalArpCacheRefCnt
Definition: GlobalArp.h:46
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
virtual void handleSelfMessage(cMessage *msg)
Definition: GlobalArp.cc:120
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
static ArpCache globalArpCache
Definition: GlobalArp.h:45
@ IPv6
Definition: L3Address.h:36
ModuleRefByPar< IInterfaceTable > interfaceTable
Definition: GlobalArp.h:42
static const Ipv4Address UNSPECIFIED_ADDRESS
0.0.0.0
Definition: Ipv4Address.h:91
#define Enter_Method(...)
Definition: SelfDoc.h:71
@ MAC
Definition: L3Address.h:38
simsignal_t interfaceIpv4ConfigChangedSignal
Definition: Simsignals.cc:35
static const MacAddress BROADCAST_ADDRESS
The broadcast MAC address, ff:ff:ff:ff:ff:ff.
Definition: MacAddress.h:34
static const MacAddress UNSPECIFIED_ADDRESS
The unspecified MAC address, 00:00:00:00:00:00.
Definition: MacAddress.h:31
simsignal_t interfaceIpv6ConfigChangedSignal
Definition: Simsignals.cc:36