throw new NetworkException("The destination address must have been set");
}
stat.opackets.inc();
// The device we will use to transmit the packet
final Device dev;
final NetDeviceAPI api;
// The hardware address we will be sending to
final HardwareAddress hwDstAddr;
// Has the destination device been given?
if (skbuf.getDevice() == null) {
// The device has not been send, figure out the route ourselves.
// First lets try to find a route
final IPv4Route route;
route = findRoute(hdr, skbuf);
route.incUseCount();
// Get the device
dev = route.getDevice();
api = route.getDeviceAPI();
// Get my source address if not already set
if (hdr.getSource() == null) {
hdr.setSource(getSourceAddress(route, hdr, skbuf));
}
// Get the hardware address for this device
hwDstAddr = findDstHWAddress(route, hdr, skbuf);
} else {
// The device has been given, use it
dev = skbuf.getDevice();
try {
api = dev.getAPI(NetDeviceAPI.class);
} catch (ApiNotFoundException ex) {
throw new NetworkException("Device is not a network device", ex);
}
// The source address must have been set, check it
if (hdr.getSource() == null) {