cfg = InitialNaming.lookup(IPv4ConfigurationService.NAME);
} catch (NameNotFoundException ex) {
throw new NetworkException(ex);
}
BOOTPHeader hdr = msg.getHeader();
cfg.configureDeviceStatic(device, new IPv4Address(hdr
.getYourIPAddress()), null, false);
final IPv4Address serverAddr = new IPv4Address(hdr.getServerIPAddress());
final IPv4Address networkAddress = serverAddr.and(serverAddr.getDefaultSubnetmask());
if (hdr.getGatewayIPAddress().isAnyLocalAddress()) {
cfg.addRoute(serverAddr, null, device, false);
cfg.addRoute(networkAddress, null, device, false);
} else {
cfg.addRoute(networkAddress, new IPv4Address(hdr.getGatewayIPAddress()), device, false);
}
byte[] routerValue = msg.getOption(DHCPMessage.ROUTER_OPTION);
if (routerValue != null && routerValue.length >= 4) {
IPv4Address routerIP = new IPv4Address(routerValue, 0);
log.info("Got Router IP address : " + routerIP);
cfg.addRoute(IPv4Address.ANY, routerIP, device, false);
}
// find the dns servers and add to the resolver
final byte[] dnsValue = msg.getOption(DHCPMessage.DNS_OPTION);
if (dnsValue != null) {
for (int i = 0; i < dnsValue.length; i += 4) {
final IPv4Address dnsIP = new IPv4Address(dnsValue, i);
log.info("Got Dns IP address : " + dnsIP);
try {
ResolverImpl.addDnsServer(dnsIP);
} catch (Throwable ex) {