try {
ipNL = (IPv4NetworkLayer) NetUtils.getNLM().getNetworkLayer(EthernetConstants.ETH_P_IP);
} catch (NoSuchProtocolException ex) {
throw new NetworkException("Cannot find IPv4 network layer", ex);
}
final IPv4RoutingTable rt = ipNL.getRoutingTable();
for (IPv4Route route : rt.entries()) {
if (!route.getDestination().equals(target)) {
continue;
}
if (gateway != null) {
if (!gateway.equals(route.getGateway())) {
continue;
}
}
if (device != null) {
if (device != route.getDevice()) {
continue;
}
}
rt.remove(route);
return;
}
}