inet-3.6.4/src/inet/networklayer/ipv4/IPv4RoutingTable.cc
// The 'routes' vector stores the routes in this order.
// The best matching route should precede the other matching routes,
// so the method should return true if a is better the b.
The 'routes' vector stores the routes in this order.
The best matching route should precede the other matching routes,
so the method should return true if a is better the b.
The ' routes ' vector stores the routes in this order . The best matching route should precede the other matching routes so the method should return true if a is better the b .
bool IPv4RoutingTable::routeLessThan(const IPv4Route *a, const IPv4Route *b) const
{
    if (a->getNetmask() != b->getNetmask())
        return a->getNetmask() > b->getNetmask();
    if (a->getDestination() != b->getDestination())
        return a->getDestination() < b->getDestination();
    if (useAdminDist && (a->getAdminDist() != b->getAdminDist()))
        return a->getAdminDist() < b->getAdminDist();
    return a->getMetric() < b->getMetric();
}
bool IPv4RoutingTable :: routeLessThan ( const IPv4Route * a , const IPv4Route * b ) const { if ( a -> getNetmask ( ) != b -> getNetmask ( ) ) return a -> getNetmask ( ) > b -> getNetmask ( ) ; if ( a -> getDestination ( ) != b -> getDestination ( ) ) return a -> getDestination ( ) < b -> getDestination ( ) ; if ( useAdminDist && ( a -> getAdminDist ( ) != b -> getAdminDist ( ) ) ) return a -> getAdminDist ( ) < b -> getAdminDist ( ) ; return a -> getMetric ( ) < b -> getMetric ( ) ; }
The 'routes' vector stores the routes in this order.
The ' routes ' vector stores the routes in this order .
// longer prefixes are better, because they are more specific // for the same destination/netmask: // smaller administration distance is better (if useAdminDist) // smaller metric is better