Skip to content

Commit

Permalink
Add ModuleIdAddress and ModulePathAddress to get L3AddressResolver::f…
Browse files Browse the repository at this point in the history
…indHostWithAddress

Replaced the logic to check Ipv6, Ipv4 and Mac L3Address types with a call to
the NetworkInterface::hasNetworkAddress(L3address ) which duplicated the logic.
  • Loading branch information
edlongman committed Apr 26, 2021
1 parent 9a3825d commit 57924dc
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/inet/networklayer/common/L3AddressResolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -531,30 +531,30 @@ cModule *L3AddressResolver::findHostWithAddress(const L3Address& add)
for (int i = 0; i < itable->getNumInterfaces(); i++) {
NetworkInterface *entry = itable->getInterface(i);
switch (add.getType()) {
#ifdef INET_WITH_IPv6
case L3Address::IPv6: {
auto protocolData = entry->findProtocolData<Ipv6InterfaceData>();
if (protocolData != nullptr && protocolData->hasAddress(add.toIpv6()))
#ifdef WITH_IPv6
case L3Address::IPv6:
#endif // ifdef WITH_IPv6
#ifdef WITH_IPv4
case L3Address::IPv4:
#endif // ifdef WITH_IPv4
case L3Address::MAC:
if (entry->hasNetworkAddress(add))
return mod;
break;
}

#endif // ifdef INET_WITH_IPv6
#ifdef INET_WITH_IPv4
case L3Address::IPv4: {
auto protocolData = entry->findProtocolData<Ipv4InterfaceData>();
if (protocolData != nullptr && protocolData->getIPAddress() == add.toIpv4())
case L3Address::MODULEPATH: {
if(entry->getModulePathAddress() == add.toModulePath()){
return mod;
}
break;
}

#endif // ifdef INET_WITH_IPv4
case L3Address::MAC:
if (entry->getMacAddress() == add.toMac())
case L3Address::MODULEID: {
if(entry->getModuleIdAddress() == add.toModuleId()){
return mod;
}
break;
}
default:
(void)entry; // eliminate warning: unused variable 'entry'
(void)entry; // eliminate warning: unused variable 'entry'
throw cRuntimeError("findHostWithAddress() doesn't accept AddressType '%s', yet", L3Address::getTypeName(add.getType()));
break;
}
Expand Down

0 comments on commit 57924dc

Please sign in to comment.