use of org.eclipse.kura.net.dhcp.DhcpServerConfig in project kura by eclipse.
the class NetworkConfiguration method toString.
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
Iterator<String> it = this.m_netInterfaceConfigs.keySet().iterator();
while (it.hasNext()) {
NetInterfaceConfig<? extends NetInterfaceAddressConfig> netInterfaceConfig = this.m_netInterfaceConfigs.get(it.next());
sb.append("\nname: " + netInterfaceConfig.getName());
sb.append(" :: Loopback? " + netInterfaceConfig.isLoopback());
sb.append(" :: Point to Point? " + netInterfaceConfig.isPointToPoint());
sb.append(" :: Up? " + netInterfaceConfig.isUp());
sb.append(" :: Virtual? " + netInterfaceConfig.isVirtual());
sb.append(" :: Driver: " + netInterfaceConfig.getDriver());
sb.append(" :: Driver Version: " + netInterfaceConfig.getDriverVersion());
sb.append(" :: Firmware Version: " + netInterfaceConfig.getFirmwareVersion());
sb.append(" :: MTU: " + netInterfaceConfig.getMTU());
if (netInterfaceConfig.getHardwareAddress() != null) {
sb.append(" :: Hardware Address: " + new String(netInterfaceConfig.getHardwareAddress()));
}
sb.append(" :: State: " + netInterfaceConfig.getState());
sb.append(" :: Type: " + netInterfaceConfig.getType());
sb.append(" :: Usb Device: " + netInterfaceConfig.getUsbDevice());
List<? extends NetInterfaceAddress> netInterfaceAddresses = netInterfaceConfig.getNetInterfaceAddresses();
for (NetInterfaceAddress netInterfaceAddress : netInterfaceAddresses) {
if (netInterfaceAddress.getAddress() != null) {
sb.append(" :: Address: " + netInterfaceAddress.getAddress().getHostAddress());
}
sb.append(" :: Prefix: " + netInterfaceAddress.getNetworkPrefixLength());
if (netInterfaceAddress.getNetmask() != null) {
sb.append(" :: Netmask: " + netInterfaceAddress.getNetmask().getHostAddress());
}
if (netInterfaceAddress.getBroadcast() != null) {
sb.append(" :: Broadcast: " + netInterfaceAddress.getBroadcast().getHostAddress());
}
}
List<? extends NetInterfaceAddressConfig> netInterfaceAddressConfigs = netInterfaceConfig.getNetInterfaceAddresses();
if (netInterfaceAddressConfigs != null) {
for (NetInterfaceAddressConfig netInterfaceAddressConfig : netInterfaceAddressConfigs) {
List<NetConfig> netConfigs = netInterfaceAddressConfig.getConfigs();
if (netConfigs != null) {
for (NetConfig netConfig : netConfigs) {
if (netConfig instanceof NetConfigIP4) {
sb.append("\n\tIPv4 ");
if (((NetConfigIP4) netConfig).isDhcp()) {
sb.append(" :: is DHCP client");
Map<String, Object> dhcp4Map = ((NetConfigIP4) netConfig).getProperties();
for (Map.Entry<String, Object> entry : dhcp4Map.entrySet()) {
String dhcpKey = entry.getKey();
sb.append(" :: " + dhcpKey + ": " + entry.getValue());
}
} else if (((NetConfigIP4) netConfig).getAddress() == null) {
sb.append(" :: is not configured for STATIC or DHCP");
} else {
sb.append(" :: is STATIC client");
if (((NetConfigIP4) netConfig).getAddress() != null) {
sb.append(" :: Address: " + ((NetConfigIP4) netConfig).getAddress().getHostAddress());
}
sb.append(" :: Prefix: " + ((NetConfigIP4) netConfig).getNetworkPrefixLength());
if (((NetConfigIP4) netConfig).getGateway() != null) {
sb.append(" :: Gateway: " + ((NetConfigIP4) netConfig).getGateway().getHostAddress());
}
List<IP4Address> dnsServers = ((NetConfigIP4) netConfig).getDnsServers();
List<IP4Address> winsServers = ((NetConfigIP4) netConfig).getWinsServers();
List<String> domains = ((NetConfigIP4) netConfig).getDomains();
if (dnsServers != null) {
for (IP4Address dnsServer : dnsServers) {
sb.append(" :: DNS : " + dnsServer.getHostAddress());
}
}
if (winsServers != null) {
for (IP4Address winsServer : winsServers) {
sb.append(" :: WINS Server : " + winsServer.getHostAddress());
}
}
if (domains != null) {
for (String domain : domains) {
sb.append(" :: Domains : " + domain);
}
}
}
} else if (netConfig instanceof NetConfigIP6) {
sb.append("\n\tIPv6 ");
if (((NetConfigIP6) netConfig).isDhcp()) {
sb.append(" :: is DHCP client");
Map<String, Object> dhcp6Map = ((NetConfigIP6) netConfig).getProperties();
Iterator<String> it2 = dhcp6Map.keySet().iterator();
while (it2.hasNext()) {
String dhcpKey = it2.next();
sb.append(" :: " + dhcpKey + ": " + dhcp6Map.get(dhcpKey));
}
} else {
sb.append(" :: is STATIC client");
if (((NetConfigIP6) netConfig).getAddress() != null) {
sb.append(" :: Address: " + ((NetConfigIP6) netConfig).getAddress().getHostAddress());
}
List<IP6Address> dnsServers = ((NetConfigIP6) netConfig).getDnsServers();
List<String> domains = ((NetConfigIP6) netConfig).getDomains();
for (IP6Address dnsServer : dnsServers) {
sb.append(" :: DNS : " + dnsServer.getHostAddress());
}
for (String domain : domains) {
sb.append(" :: Domains : " + domain);
}
}
} else if (netConfig instanceof WifiConfig) {
sb.append("\n\tWifiConfig ");
sb.append(" :: SSID: " + ((WifiConfig) netConfig).getSSID());
sb.append(" :: BgScan: " + ((WifiConfig) netConfig).getBgscan());
sb.append(" :: Broadcast: " + ((WifiConfig) netConfig).getBroadcast());
int[] channels = ((WifiConfig) netConfig).getChannels();
if (channels != null && channels.length > 0) {
for (int i = 0; i < channels.length; i++) {
sb.append(channels[i]);
if (i + 1 < channels.length) {
sb.append(",");
}
}
}
sb.append(" :: Group Ciphers: " + ((WifiConfig) netConfig).getGroupCiphers());
sb.append(" :: Hardware Mode: " + ((WifiConfig) netConfig).getHardwareMode());
sb.append(" :: Mode: " + ((WifiConfig) netConfig).getMode());
sb.append(" :: Pairwise Ciphers: " + ((WifiConfig) netConfig).getPairwiseCiphers());
sb.append(" :: Passkey: " + ((WifiConfig) netConfig).getPasskey());
sb.append(" :: Security: " + ((WifiConfig) netConfig).getSecurity());
} else if (netConfig instanceof ModemConfig) {
sb.append("\n\tModemConfig ");
sb.append(" :: APN: " + ((ModemConfig) netConfig).getApn());
sb.append(" :: Data Compression: " + ((ModemConfig) netConfig).getDataCompression());
sb.append(" :: Dial String: " + ((ModemConfig) netConfig).getDialString());
sb.append(" :: Header Compression: " + ((ModemConfig) netConfig).getHeaderCompression());
sb.append(" :: Password: " + ((ModemConfig) netConfig).getPassword());
sb.append(" :: PPP number: " + ((ModemConfig) netConfig).getPppNumber());
sb.append(" :: Profile ID: " + ((ModemConfig) netConfig).getProfileID());
sb.append(" :: Username: " + ((ModemConfig) netConfig).getUsername());
sb.append(" :: Auth Type: " + ((ModemConfig) netConfig).getAuthType());
sb.append(" :: IP Address: " + ((ModemConfig) netConfig).getIpAddress());
sb.append(" :: PDP Type: " + ((ModemConfig) netConfig).getPdpType());
} else if (netConfig instanceof DhcpServerConfig) {
sb.append("\n\tDhcpServerConfig ");
// TODO - finish displaying
} else if (netConfig instanceof FirewallAutoNatConfig) {
sb.append("\n\tFirewallAutoNatConfig ");
// TODO - finish displaying
} else {
if (netConfig != null && netConfig.getClass() != null) {
sb.append("\n\tUNKNOWN CONFIG TYPE???: " + netConfig.getClass().getName());
} else {
sb.append("\n\tNULL NETCONFIG PRESENT?!?");
}
}
}
}
}
}
}
return sb.toString();
}
use of org.eclipse.kura.net.dhcp.DhcpServerConfig in project kura by eclipse.
the class DnsMonitorServiceImpl method getAllowedNetworks.
private void getAllowedNetworks(NetInterfaceConfig<? extends NetInterfaceAddressConfig> netInterfaceConfig) throws KuraException {
String interfaceName = netInterfaceConfig.getName();
s_logger.debug("Getting DNS proxy config for {}", interfaceName);
List<? extends NetInterfaceAddressConfig> netInterfaceAddressConfigs = null;
netInterfaceAddressConfigs = netInterfaceConfig.getNetInterfaceAddresses();
if (netInterfaceAddressConfigs != null && netInterfaceAddressConfigs.size() > 0) {
for (NetInterfaceAddressConfig netInterfaceAddressConfig : netInterfaceAddressConfigs) {
List<NetConfig> netConfigs = netInterfaceAddressConfig.getConfigs();
if (netConfigs != null && netConfigs.size() > 0) {
for (int i = 0; i < netConfigs.size(); i++) {
NetConfig netConfig = netConfigs.get(i);
if (netConfig instanceof DhcpServerConfig) {
if (((DhcpServerConfig) netConfig).isPassDns()) {
s_logger.debug("Found an allowed network: " + ((DhcpServerConfig) netConfig).getRouterAddress() + "/" + ((DhcpServerConfig) netConfig).getPrefix());
this.m_enabled = true;
// this is an 'allowed network'
this.m_allowedNetworks.add(new NetworkPair<IP4Address>((IP4Address) ((DhcpServerConfig) netConfig).getRouterAddress(), ((DhcpServerConfig) netConfig).getPrefix()));
}
}
}
}
}
}
}
Aggregations