// Find the device ourselves
final DeviceManager dm;
try {
dm = InitialNaming.lookup(DeviceManager.NAME);
} catch (NameNotFoundException ex) {
throw new NetworkException("Cannot find DeviceManager", ex);
}
device = findDevice(dm, target, target.getDefaultSubnetmask());
}
final IPv4NetworkLayer ipNL;
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();
rt.add(new IPv4Route(target, null, gateway, device));
}