inet-3.6.4/src/inet/networklayer/ipv4/IPv4RoutingTable.cc
// JcM add: check if the dest addr is local network broadcast
JcM add: check if the dest addr is local network broadcast
JcM add : check if the dest addr is local network broadcast
bool IPv4RoutingTable::isLocalBroadcastAddress(const IPv4Address& dest) const
{
    Enter_Method("isLocalBroadcastAddress(%u.%u.%u.%u)", dest.getDByte(0), dest.getDByte(1), dest.getDByte(2), dest.getDByte(3));    
    if (localBroadcastAddresses.empty()) {
        for (int i = 0; i < ift->getNumInterfaces(); i++) {
            InterfaceEntry *ie = ift->getInterface(i);
            if (!ie->isBroadcast())
                continue;
            IPv4Address interfaceAddr = ie->ipv4Data()->getIPAddress();
            IPv4Address broadcastAddr = interfaceAddr.makeBroadcastAddress(ie->ipv4Data()->getNetmask());
            if (!broadcastAddr.isUnspecified()) {
                localBroadcastAddresses.insert(broadcastAddr);
            }
        }
    }
    auto it = localBroadcastAddresses.find(dest);
    return it != localBroadcastAddresses.end();
}
bool IPv4RoutingTable :: isLocalBroadcastAddress ( const IPv4Address & dest ) const { Enter_Method ( " " , dest . getDByte ( 0 ) , dest . getDByte ( 1 ) , dest . getDByte ( 2 ) , dest . getDByte ( 3 ) ) ; if ( localBroadcastAddresses . empty ( ) ) { for ( int i = 0 ; i < ift -> getNumInterfaces ( ) ; i ++ ) { InterfaceEntry * ie = ift -> getInterface ( i ) ; if ( ! ie -> isBroadcast ( ) ) continue ; IPv4Address interfaceAddr = ie -> ipv4Data ( ) -> getIPAddress ( ) ; IPv4Address broadcastAddr = interfaceAddr . makeBroadcastAddress ( ie -> ipv4Data ( ) -> getNetmask ( ) ) ; if ( ! broadcastAddr . isUnspecified ( ) ) { localBroadcastAddresses . insert ( broadcastAddr ) ; } } } auto it = localBroadcastAddresses . find ( dest ) ; return it != localBroadcastAddresses . end ( ) ; }
JcM add: check if the dest addr is local network broadcast
JcM add : check if the dest addr is local network broadcast
// note: str().c_str() too slow here // collect interface addresses if not yet done