Take netmask bits from most specific route.

This commit is contained in:
Adam Ierymenko 2019-02-01 14:05:29 -08:00
parent 34c1023ba7
commit 5b1ef2fb03

View File

@ -1523,8 +1523,11 @@ void EmbeddedNetworkController::_request(
int routedNetmaskBits = -1;
for(unsigned int rk=0;rk<nc->routeCount;++rk) {
if (reinterpret_cast<const InetAddress *>(&(nc->routes[rk].target))->containsAddress(ip))
routedNetmaskBits = reinterpret_cast<const InetAddress *>(&(nc->routes[rk].target))->netmaskBits();
if (reinterpret_cast<const InetAddress *>(&(nc->routes[rk].target))->containsAddress(ip)) {
const int nb = (int)(reinterpret_cast<const InetAddress *>(&(nc->routes[rk].target))->netmaskBits());
if (nb > routedNetmaskBits)
routedNetmaskBits = nb;
}
}
if (routedNetmaskBits >= 0) {