Search in sources :

Example 1 with Capability

use of org.eclipse.kura.net.wifi.WifiInterface.Capability in project kura by eclipse.

the class NetworkConfiguration method populateNetInterfaceConfiguration.

private void populateNetInterfaceConfiguration(AbstractNetInterface<? extends NetInterfaceAddressConfig> netInterfaceConfig, Map<String, Object> props) throws UnknownHostException, KuraException {
    String interfaceName = netInterfaceConfig.getName();
    StringBuffer keyBuffer = new StringBuffer();
    keyBuffer.append("net.interface.").append(interfaceName).append(".type");
    NetInterfaceType interfaceType = NetInterfaceType.valueOf((String) props.get(keyBuffer.toString()));
    s_logger.trace("Populating interface: {} of type {}", interfaceName, interfaceType);
    // build the prefixes for all the properties associated with this interface
    StringBuilder sbPrefix = new StringBuilder();
    sbPrefix.append("net.interface.").append(interfaceName).append(".");
    String netIfReadOnlyPrefix = sbPrefix.toString();
    String netIfPrefix = sbPrefix.append("config.").toString();
    String netIfConfigPrefix = sbPrefix.toString();
    // [RO] State
    String stateConfig = netIfReadOnlyPrefix + "state";
    if (props.containsKey(stateConfig)) {
        try {
            NetInterfaceState state = (NetInterfaceState) props.get(stateConfig);
            s_logger.trace("got state: {}", state);
            netInterfaceConfig.setState(state);
        } catch (Exception e) {
            s_logger.error("Could not process State configuration. Retaining current value.", e);
        }
    }
    // Auto connect
    boolean autoConnect = false;
    String autoConnectKey = netIfPrefix + "autoconnect";
    if (props.containsKey(autoConnectKey)) {
        autoConnect = (Boolean) props.get(autoConnectKey);
        s_logger.trace("got autoConnect: {}", autoConnect);
        netInterfaceConfig.setAutoConnect(autoConnect);
    }
    // MTU
    String mtuConfig = netIfPrefix + "mtu";
    if (props.containsKey(mtuConfig)) {
        int mtu = (Integer) props.get(mtuConfig);
        s_logger.trace("got MTU: {}", mtu);
        netInterfaceConfig.setMTU(mtu);
    }
    // Driver
    String driverKey = netIfReadOnlyPrefix + "driver";
    if (props.containsKey(driverKey)) {
        String driver = (String) props.get(driverKey);
        s_logger.trace("got Driver: {}", driver);
        netInterfaceConfig.setDriver(driver);
    }
    // Driver Version
    String driverVersionKey = netIfReadOnlyPrefix + "driver.version";
    if (props.containsKey(driverVersionKey)) {
        String driverVersion = (String) props.get(driverVersionKey);
        s_logger.trace("got Driver Version: {}", driverVersion);
        netInterfaceConfig.setDriverVersion(driverVersion);
    }
    // Firmware Version
    String firmwardVersionKey = netIfReadOnlyPrefix + "firmware.version";
    if (props.containsKey(firmwardVersionKey)) {
        String firmwareVersion = (String) props.get(firmwardVersionKey);
        s_logger.trace("got Firmware Version: {}", firmwareVersion);
        netInterfaceConfig.setFirmwareVersion(firmwareVersion);
    }
    // Mac Address
    String macAddressKey = netIfReadOnlyPrefix + "mac";
    if (props.containsKey(macAddressKey)) {
        String macAddress = (String) props.get(macAddressKey);
        s_logger.trace("got Mac Address: {}", macAddress);
        netInterfaceConfig.setHardwareAddress(NetUtil.hardwareAddressToBytes(macAddress));
    }
    // Is Loopback
    String loopbackKey = netIfReadOnlyPrefix + "loopback";
    if (props.containsKey(loopbackKey)) {
        Boolean isLoopback = (Boolean) props.get(loopbackKey);
        s_logger.trace("got Is Loopback: {}", isLoopback);
        netInterfaceConfig.setLoopback(isLoopback);
    }
    // Is Point to Point
    String ptpKey = netIfReadOnlyPrefix + "ptp";
    if (props.containsKey(ptpKey)) {
        Boolean isPtp = (Boolean) props.get(ptpKey);
        s_logger.trace("got Is PtP: {}", isPtp);
        netInterfaceConfig.setPointToPoint(isPtp);
    }
    // Is Up
    String upKey = netIfReadOnlyPrefix + "up";
    if (props.containsKey(upKey)) {
        Boolean isUp = (Boolean) props.get(upKey);
        s_logger.trace("got Is Up: {}", isUp);
        netInterfaceConfig.setUp(isUp);
        if (isUp) {
            netInterfaceConfig.setState(NetInterfaceState.ACTIVATED);
        } else {
            netInterfaceConfig.setState(NetInterfaceState.DISCONNECTED);
        }
    } else {
        s_logger.trace("Setting state to");
        netInterfaceConfig.setState(NetInterfaceState.DISCONNECTED);
    }
    // Is Virtual
    String virtualKey = netIfReadOnlyPrefix + "virtual";
    if (props.containsKey(virtualKey)) {
        Boolean isVirtual = (Boolean) props.get(virtualKey);
        s_logger.trace("got Is Virtual: {}", isVirtual);
        netInterfaceConfig.setVirtual(isVirtual);
    }
    // USB
    String vendorId = (String) props.get(netIfReadOnlyPrefix + "usb.vendor.id");
    String vendorName = (String) props.get(netIfReadOnlyPrefix + "usb.vendor.name");
    String productId = (String) props.get(netIfReadOnlyPrefix + "usb.product.id");
    String productName = (String) props.get(netIfReadOnlyPrefix + "usb.product.name");
    String usbBusNumber = (String) props.get(netIfReadOnlyPrefix + "usb.busNumber");
    String usbDevicePath = (String) props.get(netIfReadOnlyPrefix + "usb.devicePath");
    if (vendorId != null && productId != null) {
        UsbDevice usbDevice = new UsbNetDevice(vendorId, productId, vendorName, productName, usbBusNumber, usbDevicePath, interfaceName);
        s_logger.trace("adding usbDevice: {}, port: {}", usbDevice, usbDevice.getUsbPort());
        netInterfaceConfig.setUsbDevice(usbDevice);
    }
    if (netInterfaceConfig instanceof EthernetInterfaceConfigImpl) {
        // Is Up
        String linkUpKey = netIfReadOnlyPrefix + "eth.link.up";
        if (props.containsKey(linkUpKey)) {
            Boolean linkUp = (Boolean) props.get(linkUpKey);
            s_logger.trace("got Is Link Up: {}", linkUp);
            ((EthernetInterfaceConfigImpl) netInterfaceConfig).setLinkUp(linkUp);
        }
    } else if (netInterfaceConfig instanceof WifiInterfaceConfigImpl) {
        // Wifi Capabilities
        String capabilitiesKey = netIfReadOnlyPrefix + "wifi.capabilities";
        if (props.containsKey(capabilitiesKey)) {
            String capabilitiesString = (String) props.get(capabilitiesKey);
            if (capabilitiesString != null) {
                String[] capabilities = capabilitiesString.split(" ");
                if (capabilities != null && capabilities.length > 0) {
                    EnumSet<Capability> capabilitiesEnum = EnumSet.noneOf(Capability.class);
                    for (String capability : capabilities) {
                        if (capability != null && !capability.isEmpty()) {
                            capabilitiesEnum.add(Capability.valueOf(capability));
                        }
                    }
                    ((WifiInterfaceConfigImpl) netInterfaceConfig).setCapabilities(capabilitiesEnum);
                }
            }
        }
    } else if (netInterfaceConfig instanceof ModemInterfaceConfigImpl) {
        ModemInterfaceConfigImpl modemInterfaceConfig = (ModemInterfaceConfigImpl) netInterfaceConfig;
        String key;
        // manufacturer
        key = netIfReadOnlyPrefix + "manufacturer";
        if (props.containsKey(key)) {
            modemInterfaceConfig.setManufacturer((String) props.get(key));
        }
        // manufacturer
        key = netIfReadOnlyPrefix + "model";
        if (props.containsKey(key)) {
            modemInterfaceConfig.setModel((String) props.get(key));
        }
        // revision id
        key = netIfReadOnlyPrefix + "revisionId";
        if (props.containsKey(key)) {
            String revisionIdString = (String) props.get(key);
            modemInterfaceConfig.setRevisionId(revisionIdString.split(","));
        }
        // serial number
        key = netIfReadOnlyPrefix + "serialNum";
        if (props.containsKey(key)) {
            modemInterfaceConfig.setSerialNumber((String) props.get(key));
        }
        // technology types
        key = netIfReadOnlyPrefix + "technologyTypes";
        if (props.containsKey(key)) {
            ArrayList<ModemTechnologyType> technologyTypes = new ArrayList<ModemTechnologyType>();
            String techTypesString = (String) props.get(netIfReadOnlyPrefix + "technologyTypes");
            if (techTypesString != null && !techTypesString.isEmpty()) {
                for (String techTypeString : techTypesString.split(",")) {
                    if (techTypeString != null && !techTypeString.isEmpty()) {
                        try {
                            ModemTechnologyType modemTechType = ModemTechnologyType.valueOf(techTypeString);
                            technologyTypes.add(modemTechType);
                        } catch (IllegalArgumentException e) {
                            s_logger.error("Could not parse type " + techTypeString);
                        }
                    }
                }
                modemInterfaceConfig.setTechnologyTypes(technologyTypes);
            }
        }
        // modem identifier
        key = netIfConfigPrefix + "identifier";
        if (props.containsKey(key)) {
            modemInterfaceConfig.setModemIdentifier((String) props.get(key));
        }
        // power mode
        key = netIfConfigPrefix + "powerMode";
        if (props.containsKey(key)) {
            ModemPowerMode powerMode = ModemPowerMode.UNKNOWN;
            String modemPowerModeString = (String) props.get(netIfConfigPrefix + "powerMode");
            if (modemPowerModeString != null) {
                powerMode = ModemPowerMode.valueOf(modemPowerModeString);
                modemInterfaceConfig.setPowerMode(powerMode);
            }
        }
        // ppp number
        key = netIfConfigPrefix + "pppNum";
        if (props.containsKey(key)) {
            if (props.get(key) != null) {
                modemInterfaceConfig.setPppNum((Integer) props.get(key));
            }
        }
        // powered on
        key = netIfConfigPrefix + "poweredOn";
        if (props.containsKey(key)) {
            if (props.get(key) != null) {
                modemInterfaceConfig.setPoweredOn((Boolean) props.get(key));
            }
        }
    }
    // Status
    String configStatus4 = null;
    String configStatus4Key = "net.interface." + interfaceName + ".config.ip4.status";
    if (props.containsKey(configStatus4Key)) {
        configStatus4 = (String) props.get(configStatus4Key);
    }
    if (configStatus4 == null) {
        configStatus4 = NetInterfaceStatus.netIPv4StatusDisabled.name();
    }
    s_logger.trace("Status Ipv4? {}", configStatus4);
    String configStatus6 = null;
    String configStatus6Key = "net.interface." + interfaceName + ".config.ip6.status";
    if (props.containsKey(configStatus6Key)) {
        configStatus6 = (String) props.get(configStatus6Key);
    }
    if (configStatus6 == null) {
        configStatus6 = NetInterfaceStatus.netIPv6StatusDisabled.name();
    }
    // POPULATE NetInterfaceAddresses
    for (NetInterfaceAddressConfig netInterfaceAddress : netInterfaceConfig.getNetInterfaceAddresses()) {
        List<NetConfig> netConfigs = new ArrayList<NetConfig>();
        if (netInterfaceAddress instanceof NetInterfaceAddressConfigImpl) {
            ((NetInterfaceAddressConfigImpl) netInterfaceAddress).setNetConfigs(netConfigs);
        } else if (netInterfaceAddress instanceof WifiInterfaceAddressConfigImpl) {
            ((WifiInterfaceAddressConfigImpl) netInterfaceAddress).setNetConfigs(netConfigs);
        } else if (netInterfaceAddress instanceof ModemInterfaceAddressConfigImpl) {
            ((ModemInterfaceAddressConfigImpl) netInterfaceAddress).setNetConfigs(netConfigs);
        }
        // Common NetInterfaceAddress
        if (netInterfaceAddress instanceof NetInterfaceAddressImpl) {
            s_logger.trace("netInterfaceAddress is instanceof NetInterfaceAddressImpl");
            NetInterfaceAddressImpl netInterfaceAddressImpl = (NetInterfaceAddressImpl) netInterfaceAddress;
            // TODO: determine dynamically
            String addressType = ".ip4";
            // populate current address status
            String key = "net.interface." + interfaceName + addressType + ".address";
            if (props.containsKey(key)) {
                IPAddress address = IPAddress.parseHostAddress((String) props.get(key));
                s_logger.trace("got {}: {}", key, address);
                netInterfaceAddressImpl.setAddress(address);
            }
            key = "net.interface." + interfaceName + addressType + ".broadcast";
            if (props.containsKey(key)) {
                IPAddress broadcast = IPAddress.parseHostAddress((String) props.get(key));
                s_logger.trace("got {}: {}", key, broadcast);
                netInterfaceAddressImpl.setBroadcast(broadcast);
            }
            key = "net.interface." + interfaceName + addressType + ".dnsServers";
            if (props.containsKey(key)) {
                List<IPAddress> dnsServers = new ArrayList<IPAddress>();
                String dnsServersString = (String) props.get(key);
                s_logger.trace("got {}: {}", key, dnsServersString);
                for (String dnsServer : dnsServersString.split(",")) {
                    dnsServers.add(IPAddress.parseHostAddress(dnsServer));
                }
                netInterfaceAddressImpl.setDnsServers(dnsServers);
            }
            key = "net.interface." + interfaceName + addressType + ".gateway";
            if (props.containsKey(key)) {
                if (props.get(key) != null && !((String) props.get(key)).trim().equals("")) {
                    IPAddress gateway = IPAddress.parseHostAddress((String) props.get(key));
                    s_logger.trace("got {}: {}", key, gateway);
                    netInterfaceAddressImpl.setGateway(gateway);
                } else {
                    s_logger.trace("got {}: null", key);
                    netInterfaceAddressImpl.setGateway(null);
                }
            }
            key = "net.interface." + interfaceName + addressType + ".netmask";
            if (props.containsKey(key)) {
                IPAddress netmask = IPAddress.parseHostAddress((String) props.get(key));
                s_logger.trace("got {}: {}", key, netmask);
                netInterfaceAddressImpl.setBroadcast(netmask);
            }
            key = "net.interface." + interfaceName + addressType + ".prefix";
            if (props.containsKey(key)) {
                Short prefix = (Short) props.get(key);
                s_logger.trace("got {}: {}", key, prefix);
                netInterfaceAddressImpl.setNetworkPrefixLength(prefix);
            }
        }
        // WifiInterfaceAddress
        if (netInterfaceAddress instanceof WifiInterfaceAddressImpl) {
            s_logger.trace("netInterfaceAddress is instanceof WifiInterfaceAddressImpl");
            WifiInterfaceAddressImpl wifiInterfaceAddressImpl = (WifiInterfaceAddressImpl) netInterfaceAddress;
            // wifi mode
            String configWifiMode = netIfPrefix + "wifi.mode";
            if (props.containsKey(configWifiMode)) {
                // FIXME: INFRA for now while debugging - probably want this as
                WifiMode mode = WifiMode.INFRA;
                // UNKNOWN
                if (props.get(configWifiMode) != null) {
                    mode = WifiMode.valueOf((String) props.get(configWifiMode));
                }
                s_logger.trace("Adding wifiMode: {}", mode);
                wifiInterfaceAddressImpl.setMode(mode);
            }
        }
        // ModemInterfaceAddress
        if (netInterfaceAddress instanceof ModemInterfaceAddressConfigImpl) {
            s_logger.trace("netInterfaceAddress is instanceof ModemInterfaceAddressConfigImpl");
            ModemInterfaceAddressConfigImpl modemInterfaceAddressImpl = (ModemInterfaceAddressConfigImpl) netInterfaceAddress;
            // connection type
            String configConnType = netIfPrefix + "connection.type";
            if (props.containsKey(configConnType)) {
                ModemConnectionType connType = ModemConnectionType.PPP;
                String connTypeStr = (String) props.get(configConnType);
                if (connTypeStr != null && !connTypeStr.isEmpty()) {
                    connType = ModemConnectionType.valueOf(connTypeStr);
                }
                s_logger.trace("Adding modem connection type: {}", connType);
                modemInterfaceAddressImpl.setConnectionType(connType);
            }
            // connection type
            String configConnStatus = netIfPrefix + "connection.status";
            if (props.containsKey(configConnStatus)) {
                ModemConnectionStatus connStatus = ModemConnectionStatus.UNKNOWN;
                String connStatusStr = (String) props.get(configConnStatus);
                if (connStatusStr != null && !connStatusStr.isEmpty()) {
                    connStatus = ModemConnectionStatus.valueOf(connStatusStr);
                }
                s_logger.trace("Adding modem connection status: {}", connStatus);
                modemInterfaceAddressImpl.setConnectionStatus(connStatus);
            }
        }
        // POPULATE NetConfigs
        // dhcp4
        String configDhcp4 = "net.interface." + interfaceName + ".config.dhcpClient4.enabled";
        NetConfigIP4 netConfigIP4 = null;
        boolean dhcpEnabled = false;
        if (props.containsKey(configDhcp4)) {
            dhcpEnabled = (Boolean) props.get(configDhcp4);
            s_logger.trace("DHCP 4 enabled? {}", dhcpEnabled);
        }
        netConfigIP4 = new NetConfigIP4(NetInterfaceStatus.valueOf(configStatus4), autoConnect, dhcpEnabled);
        netConfigs.add(netConfigIP4);
        if (!dhcpEnabled) {
            // NetConfigIP4
            String configIp4 = "net.interface." + interfaceName + ".config.ip4.address";
            if (props.containsKey(configIp4)) {
                s_logger.trace("got {}: {}", configIp4, props.get(configIp4));
                // address
                String addressIp4 = (String) props.get(configIp4);
                s_logger.trace("IPv4 address: {}", addressIp4);
                if (addressIp4 != null && !addressIp4.isEmpty()) {
                    IP4Address ip4Address = (IP4Address) IPAddress.parseHostAddress(addressIp4);
                    netConfigIP4.setAddress(ip4Address);
                }
                // prefix
                String configIp4Prefix = "net.interface." + interfaceName + ".config.ip4.prefix";
                short networkPrefixLength = -1;
                if (props.containsKey(configIp4Prefix)) {
                    if (props.get(configIp4Prefix) instanceof Short) {
                        networkPrefixLength = (Short) props.get(configIp4Prefix);
                    } else if (props.get(configIp4Prefix) instanceof String) {
                        networkPrefixLength = Short.parseShort((String) props.get(configIp4Prefix));
                    }
                    try {
                        netConfigIP4.setNetworkPrefixLength(networkPrefixLength);
                    } catch (KuraException e) {
                        s_logger.error("Exception while setting Network Prefix length!", e);
                    }
                /*
                         * s_logger.trace("IPv4 prefix: " + networkPrefixLength);
                         * netInterfaceAddress.setNetworkPrefixLength(networkPrefixLength);
                         * //FIXME - hack for now
                         * netInterfaceAddress.setBroadcast((IP4Address) IPAddress.parseHostAddress("192.168.1.255"));
                         * ip4Config.setNetworkPrefixLength(networkPrefixLength);
                         */
                }
                // gateway
                String configIp4Gateway = "net.interface." + interfaceName + ".config.ip4.gateway";
                if (props.containsKey(configIp4Gateway)) {
                    String gatewayIp4 = (String) props.get(configIp4Gateway);
                    s_logger.trace("IPv4 gateway: {}", gatewayIp4);
                    if (gatewayIp4 != null && !gatewayIp4.isEmpty()) {
                        IP4Address ip4Gateway = (IP4Address) IPAddress.parseHostAddress(gatewayIp4);
                        netConfigIP4.setGateway(ip4Gateway);
                    }
                }
            }
        }
        // dns servers
        String configDNSs = "net.interface." + interfaceName + ".config.ip4.dnsServers";
        if (props.containsKey(configDNSs)) {
            List<IP4Address> dnsIPs = new ArrayList<IP4Address>();
            String dnsAll = (String) props.get(configDNSs);
            String[] dnss = dnsAll.split(",");
            for (String dns : dnss) {
                if (dns != null && dns.length() > 0) {
                    s_logger.trace("IPv4 DNS: {}", dns);
                    IP4Address dnsIp4 = (IP4Address) IPAddress.parseHostAddress(dns);
                    dnsIPs.add(dnsIp4);
                }
            }
            netConfigIP4.setDnsServers(dnsIPs);
        }
        // win servers
        String configWINSs = "net.interface." + interfaceName + ".config.ip4.winsServers";
        if (props.containsKey(configWINSs)) {
            List<IP4Address> winsIPs = new ArrayList<IP4Address>();
            String winsAll = (String) props.get(configWINSs);
            String[] winss = winsAll.split(",");
            for (String wins : winss) {
                s_logger.trace("WINS: {}", wins);
                IP4Address winsIp4 = (IP4Address) IPAddress.parseHostAddress(wins);
                winsIPs.add(winsIp4);
            }
            netConfigIP4.setWinsServers(winsIPs);
        }
        // domains
        String configDomains = "net.interface." + interfaceName + ".config.ip4.domains";
        if (props.containsKey(configDomains)) {
            List<String> domainNames = new ArrayList<String>();
            String domainsAll = (String) props.get(configDomains);
            String[] domains = domainsAll.split(",");
            for (String domain : domains) {
                s_logger.trace("IPv4 Domain: {}", domain);
                domainNames.add(domain);
            }
            netConfigIP4.setDomains(domainNames);
        }
        // FirewallNatConfig - see if NAT is enabled
        String configNatEnabled = "net.interface." + interfaceName + ".config.nat.enabled";
        if (props.containsKey(configNatEnabled)) {
            boolean natEnabled = (Boolean) props.get(configNatEnabled);
            s_logger.trace("NAT enabled? {}", natEnabled);
            if (natEnabled) {
                FirewallAutoNatConfig natConfig = new FirewallAutoNatConfig(interfaceName, "unknown", true);
                netConfigs.add(natConfig);
            }
        }
        // DhcpServerConfigIP4 - see if there is a DHCP 4 Server
        String configDhcpServerEnabled = "net.interface." + interfaceName + ".config.dhcpServer4.enabled";
        if (props.containsKey(configDhcpServerEnabled)) {
            boolean dhcpServerEnabled = (Boolean) props.get(configDhcpServerEnabled);
            s_logger.trace("DHCP Server 4 enabled? {}", dhcpServerEnabled);
            IP4Address subnet = null;
            IP4Address routerAddress = dhcpEnabled ? (IP4Address) netInterfaceAddress.getAddress() : netConfigIP4.getAddress();
            IP4Address subnetMask = null;
            int defaultLeaseTime = -1;
            int maximumLeaseTime = -1;
            short prefix = -1;
            IP4Address rangeStart = null;
            IP4Address rangeEnd = null;
            boolean passDns = false;
            List<IP4Address> dnServers = new ArrayList<IP4Address>();
            // prefix
            String configDhcpServerPrefix = "net.interface." + interfaceName + ".config.dhcpServer4.prefix";
            if (props.containsKey(configDhcpServerPrefix)) {
                if (props.get(configDhcpServerPrefix) instanceof Short) {
                    prefix = (Short) props.get(configDhcpServerPrefix);
                } else if (props.get(configDhcpServerPrefix) instanceof String) {
                    prefix = Short.parseShort((String) props.get(configDhcpServerPrefix));
                }
                s_logger.trace("DHCP Server prefix: {}", prefix);
            }
            // rangeStart
            String configDhcpServerRangeStart = "net.interface." + interfaceName + ".config.dhcpServer4.rangeStart";
            if (props.containsKey(configDhcpServerRangeStart)) {
                String dhcpServerRangeStart = (String) props.get(configDhcpServerRangeStart);
                s_logger.trace("DHCP Server Range Start: {}", dhcpServerRangeStart);
                if (dhcpServerRangeStart != null && !dhcpServerRangeStart.isEmpty()) {
                    rangeStart = (IP4Address) IPAddress.parseHostAddress(dhcpServerRangeStart);
                }
            }
            // rangeEnd
            String configDhcpServerRangeEnd = "net.interface." + interfaceName + ".config.dhcpServer4.rangeEnd";
            if (props.containsKey(configDhcpServerRangeEnd)) {
                String dhcpServerRangeEnd = (String) props.get(configDhcpServerRangeEnd);
                s_logger.trace("DHCP Server Range End: {}", dhcpServerRangeEnd);
                if (dhcpServerRangeEnd != null && !dhcpServerRangeEnd.isEmpty()) {
                    rangeEnd = (IP4Address) IPAddress.parseHostAddress(dhcpServerRangeEnd);
                }
            }
            // default lease time
            String configDhcpServerDefaultLeaseTime = "net.interface." + interfaceName + ".config.dhcpServer4.defaultLeaseTime";
            if (props.containsKey(configDhcpServerDefaultLeaseTime)) {
                if (props.get(configDhcpServerDefaultLeaseTime) instanceof Integer) {
                    defaultLeaseTime = (Integer) props.get(configDhcpServerDefaultLeaseTime);
                } else if (props.get(configDhcpServerDefaultLeaseTime) instanceof String) {
                    defaultLeaseTime = Integer.parseInt((String) props.get(configDhcpServerDefaultLeaseTime));
                }
                s_logger.trace("DHCP Server Default Lease Time: {}", defaultLeaseTime);
            }
            // max lease time
            String configDhcpServerMaxLeaseTime = "net.interface." + interfaceName + ".config.dhcpServer4.maxLeaseTime";
            if (props.containsKey(configDhcpServerMaxLeaseTime)) {
                if (props.get(configDhcpServerMaxLeaseTime) instanceof Integer) {
                    maximumLeaseTime = (Integer) props.get(configDhcpServerMaxLeaseTime);
                } else if (props.get(configDhcpServerMaxLeaseTime) instanceof String) {
                    maximumLeaseTime = Integer.parseInt((String) props.get(configDhcpServerMaxLeaseTime));
                }
                s_logger.trace("DHCP Server Maximum Lease Time: {}", maximumLeaseTime);
            }
            // passDns
            String configDhcpServerPassDns = "net.interface." + interfaceName + ".config.dhcpServer4.passDns";
            if (props.containsKey(configDhcpServerPassDns)) {
                if (props.get(configDhcpServerPassDns) instanceof Boolean) {
                    passDns = (Boolean) props.get(configDhcpServerPassDns);
                } else if (props.get(configDhcpServerPassDns) instanceof String) {
                    passDns = Boolean.parseBoolean((String) props.get(configDhcpServerPassDns));
                }
                s_logger.trace("DHCP Server Pass DNS?: {}", passDns);
            }
            if (routerAddress != null && rangeStart != null && rangeEnd != null) {
                // get the netmask and subnet
                int prefixInt = prefix;
                int mask = ~((1 << 32 - prefixInt) - 1);
                String subnetMaskString = NetworkUtil.dottedQuad(mask);
                String subnetString = NetworkUtil.calculateNetwork(routerAddress.getHostAddress(), subnetMaskString);
                subnet = (IP4Address) IPAddress.parseHostAddress(subnetString);
                subnetMask = (IP4Address) IPAddress.parseHostAddress(subnetMaskString);
                dnServers.add(routerAddress);
                DhcpServerConfigIP4 dhcpServerConfig = new DhcpServerConfigIP4(interfaceName, dhcpServerEnabled, subnet, routerAddress, subnetMask, defaultLeaseTime, maximumLeaseTime, prefix, rangeStart, rangeEnd, passDns, dnServers);
                netConfigs.add(dhcpServerConfig);
            } else {
                s_logger.trace("Not including DhcpServerConfig - router: " + routerAddress + ", range start: " + rangeStart + ", range end: " + rangeEnd);
            }
        }
        // dhcp6
        String configDhcp6 = "net.interface." + interfaceName + ".config.dhcpClient6.enabled";
        NetConfigIP6 netConfigIP6 = null;
        boolean dhcp6Enabled = false;
        if (props.containsKey(configDhcp6)) {
            dhcp6Enabled = (Boolean) props.get(configDhcp6);
            s_logger.trace("DHCP 6 enabled? {}", dhcp6Enabled);
        }
        if (!dhcp6Enabled) {
            // ip6
            String configIp6 = "net.interface." + interfaceName + ".config.ip6.address";
            if (props.containsKey(configIp6)) {
                // address
                String addressIp6 = (String) props.get(configIp6);
                s_logger.trace("IPv6 address: {}", addressIp6);
                if (addressIp6 != null && !addressIp6.isEmpty()) {
                    IP6Address ip6Address = (IP6Address) IPAddress.parseHostAddress(addressIp6);
                    netConfigIP6.setAddress(ip6Address);
                }
                // dns servers
                String configDNSs6 = "net.interface." + interfaceName + ".config.ip6.dnsServers";
                if (props.containsKey(configDNSs6)) {
                    List<IP6Address> dnsIPs = new ArrayList<IP6Address>();
                    String dnsAll = (String) props.get(configDNSs6);
                    String[] dnss = dnsAll.split(",");
                    for (String dns : dnss) {
                        s_logger.trace("IPv6 DNS: {}", dns);
                        IP6Address dnsIp6 = (IP6Address) IPAddress.parseHostAddress(dns);
                        dnsIPs.add(dnsIp6);
                    }
                    netConfigIP6.setDnsServers(dnsIPs);
                }
                // domains
                String configDomains6 = "net.interface." + interfaceName + ".config.ip6.domains";
                if (props.containsKey(configDomains6)) {
                    List<String> domainNames = new ArrayList<String>();
                    String domainsAll = (String) props.get(configDomains6);
                    String[] domains = domainsAll.split(",");
                    for (String domain : domains) {
                        s_logger.trace("IPv6 Domain: {}", domain);
                        domainNames.add(domain);
                    }
                    netConfigIP6.setDomains(domainNames);
                }
            }
        }
        if (interfaceType == NetInterfaceType.WIFI) {
            s_logger.trace("Adding wifi netconfig");
            // Wifi access point config
            WifiConfig apConfig = getWifiConfig(netIfConfigPrefix, WifiMode.MASTER, props);
            if (apConfig != null) {
                s_logger.trace("Adding AP wifi config");
                netConfigs.add(apConfig);
            } else {
                s_logger.warn("no AP wifi config specified");
            }
            // Wifi client/adhoc config
            // WifiConfig adhocConfig = getWifiConfig(netIfConfigPrefix, WifiMode.ADHOC, props);
            WifiConfig infraConfig = getWifiConfig(netIfConfigPrefix, WifiMode.INFRA, props);
            /*
                 * if(adhocConfig != null && infraConfig != null) {
                 * s_logger.warn("Two conflicting client wifi configs specified");
                 * }
                 */
            if (infraConfig != null) {
                s_logger.trace("Adding client INFRA wifi config");
                netConfigs.add(infraConfig);
            } else {
                s_logger.warn("no INFRA wifi config specified");
            }
        /*
                 * if(adhocConfig != null){
                 * s_logger.trace("Adding client ADHOC wifi config");
                 * netConfigs.add(adhocConfig);
                 * }
                 */
        }
        if (interfaceType == NetInterfaceType.MODEM) {
            s_logger.trace("Adding modem netconfig");
            netConfigs.add(getModemConfig(netIfConfigPrefix, props));
        }
    }
}
Also used : ModemInterfaceAddressConfigImpl(org.eclipse.kura.core.net.modem.ModemInterfaceAddressConfigImpl) FirewallAutoNatConfig(org.eclipse.kura.net.firewall.FirewallAutoNatConfig) WifiConfig(org.eclipse.kura.net.wifi.WifiConfig) UsbDevice(org.eclipse.kura.usb.UsbDevice) ArrayList(java.util.ArrayList) KuraException(org.eclipse.kura.KuraException) WifiMode(org.eclipse.kura.net.wifi.WifiMode) ModemTechnologyType(org.eclipse.kura.net.modem.ModemTechnologyType) NetInterfaceAddressConfig(org.eclipse.kura.net.NetInterfaceAddressConfig) Capability(org.eclipse.kura.net.wifi.WifiInterface.Capability) IP4Address(org.eclipse.kura.net.IP4Address) IP6Address(org.eclipse.kura.net.IP6Address) ModemConnectionStatus(org.eclipse.kura.net.modem.ModemConnectionStatus) ModemConnectionType(org.eclipse.kura.net.modem.ModemConnectionType) NetConfig(org.eclipse.kura.net.NetConfig) DhcpServerConfigIP4(org.eclipse.kura.net.dhcp.DhcpServerConfigIP4) NetInterfaceState(org.eclipse.kura.net.NetInterfaceState) NetConfigIP4(org.eclipse.kura.net.NetConfigIP4) NetConfigIP6(org.eclipse.kura.net.NetConfigIP6) UsbNetDevice(org.eclipse.kura.usb.UsbNetDevice) EnumSet(java.util.EnumSet) ModemPowerMode(org.eclipse.kura.net.modem.ModemPowerMode) KuraException(org.eclipse.kura.KuraException) UnknownHostException(java.net.UnknownHostException) WifiAccessPoint(org.eclipse.kura.net.wifi.WifiAccessPoint) NetInterfaceType(org.eclipse.kura.net.NetInterfaceType) ModemInterfaceConfigImpl(org.eclipse.kura.core.net.modem.ModemInterfaceConfigImpl) IPAddress(org.eclipse.kura.net.IPAddress)

Example 2 with Capability

use of org.eclipse.kura.net.wifi.WifiInterface.Capability in project kura by eclipse.

the class LinuxNetworkUtil method getWifiCapabilities.

/*
     * Returns an empty capabilities set if the interface is not found or on error
     */
public static EnumSet<Capability> getWifiCapabilities(String ifaceName) throws KuraException {
    EnumSet<Capability> capabilities = EnumSet.noneOf(Capability.class);
    // ignore logical interfaces like "1-1.2"
    if (Character.isDigit(ifaceName.charAt(0))) {
        return capabilities;
    }
    SafeProcess proc = null;
    BufferedReader br = null;
    try {
        // start the process
        proc = ProcessUtil.exec("iwlist " + ifaceName + " auth");
        if (proc.waitFor() != 0) {
            s_logger.warn("error executing command --- iwlist --- exit value = {}", proc.exitValue());
            // FIXME: throw exception
            return capabilities;
        }
        // get the output
        br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
        String line = null;
        while ((line = br.readLine()) != null) {
            // Remove all whitespace
            String cleanLine = line.replaceAll("\\s", "");
            if ("WPA".equals(cleanLine)) {
                capabilities.add(Capability.WPA);
            } else if ("WPA2".equals(cleanLine)) {
                capabilities.add(Capability.RSN);
            } else if ("CIPHER-TKIP".equals(cleanLine)) {
                capabilities.add(Capability.CIPHER_TKIP);
            } else if ("CIPHER-CCMP".equals(cleanLine)) {
                capabilities.add(Capability.CIPHER_CCMP);
            // TODO: WEP options don't always seem to be displayed?
            } else if ("WEP-104".equals(cleanLine)) {
                capabilities.add(Capability.CIPHER_WEP104);
            } else if ("WEP-40".equals(cleanLine)) {
                capabilities.add(Capability.CIPHER_WEP40);
            }
        }
    } catch (IOException e) {
        throw new KuraException(KuraErrorCode.INTERNAL_ERROR, e);
    } catch (InterruptedException e) {
        throw new KuraException(KuraErrorCode.INTERNAL_ERROR, e);
    } finally {
        if (br != null) {
            try {
                br.close();
            } catch (IOException ex) {
                s_logger.error("I/O Exception while closing BufferedReader!");
            }
        }
        if (proc != null) {
            ProcessUtil.destroy(proc);
        }
    }
    return capabilities;
}
Also used : Capability(org.eclipse.kura.net.wifi.WifiInterface.Capability) InputStreamReader(java.io.InputStreamReader) KuraException(org.eclipse.kura.KuraException) SafeProcess(org.eclipse.kura.core.util.SafeProcess) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException)

Example 3 with Capability

use of org.eclipse.kura.net.wifi.WifiInterface.Capability in project kura by eclipse.

the class NetworkConfiguration method recomputeNetworkProperties.

// ---------------------------------------------------------------
// 
// Private Methods
// 
// ---------------------------------------------------------------
private void recomputeNetworkProperties() {
    Map<String, Object> properties = new HashMap<String, Object>();
    String netIfPrefix = null;
    String netIfReadOnlyPrefix = null;
    String netIfConfigPrefix = null;
    StringBuilder sbPrefix = null;
    StringBuilder sbInterfaces = new StringBuilder();
    if (this.m_modifiedInterfaceNames != null && !this.m_modifiedInterfaceNames.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        String prefix = "";
        for (String interfaceName : this.m_modifiedInterfaceNames) {
            sb.append(prefix);
            prefix = ",";
            sb.append(interfaceName);
        }
        String result = sb.toString();
        s_logger.debug("Set modified interface names: {}", result);
        properties.put("modified.interface.names", result);
    }
    Iterator<String> it = this.m_netInterfaceConfigs.keySet().iterator();
    while (it.hasNext()) {
        NetInterfaceConfig<? extends NetInterfaceAddressConfig> netInterfaceConfig = this.m_netInterfaceConfigs.get(it.next());
        // add the interface to the list of interface found in the platform
        if (sbInterfaces.length() != 0) {
            sbInterfaces.append(",");
        }
        sbInterfaces.append(netInterfaceConfig.getName());
        // build the prefixes for all the properties associated with this interface
        sbPrefix = new StringBuilder("net.interface.").append(netInterfaceConfig.getName()).append(".");
        netIfReadOnlyPrefix = sbPrefix.toString();
        netIfPrefix = sbPrefix.append("config.").toString();
        netIfConfigPrefix = sbPrefix.toString();
        // add the properties of the interface
        properties.put(netIfReadOnlyPrefix + "type", netInterfaceConfig.getType().toString());
        properties.put(netIfPrefix + "name", netInterfaceConfig.getName());
        if (netInterfaceConfig.getState() != null) {
            properties.put(netIfPrefix + "state", netInterfaceConfig.getState().toString());
        }
        properties.put(netIfPrefix + "autoconnect", netInterfaceConfig.isAutoConnect());
        properties.put(netIfPrefix + "mtu", netInterfaceConfig.getMTU());
        properties.put(netIfReadOnlyPrefix + "driver", netInterfaceConfig.getDriver());
        properties.put(netIfReadOnlyPrefix + "driver.version", netInterfaceConfig.getDriverVersion());
        properties.put(netIfReadOnlyPrefix + "firmware.version", netInterfaceConfig.getFirmwareVersion());
        properties.put(netIfReadOnlyPrefix + "mac", NetUtil.hardwareAddressToString(netInterfaceConfig.getHardwareAddress()));
        properties.put(netIfReadOnlyPrefix + "loopback", netInterfaceConfig.isLoopback());
        properties.put(netIfReadOnlyPrefix + "ptp", netInterfaceConfig.isPointToPoint());
        properties.put(netIfReadOnlyPrefix + "up", netInterfaceConfig.isUp());
        properties.put(netIfReadOnlyPrefix + "virtual", netInterfaceConfig.isVirtual());
        // usb
        if (netInterfaceConfig.getUsbDevice() != null) {
            UsbDevice usbDev = netInterfaceConfig.getUsbDevice();
            properties.put(netIfReadOnlyPrefix + "usb.vendor.id", usbDev.getVendorId());
            properties.put(netIfReadOnlyPrefix + "usb.vendor.name", usbDev.getManufacturerName());
            properties.put(netIfReadOnlyPrefix + "usb.product.id", usbDev.getProductId());
            properties.put(netIfReadOnlyPrefix + "usb.product.name", usbDev.getProductName());
            properties.put(netIfReadOnlyPrefix + "usb.busNumber", usbDev.getUsbBusNumber());
            properties.put(netIfReadOnlyPrefix + "usb.devicePath", usbDev.getUsbDevicePath());
        }
        // custom readonly props for Ethernet and Wifi
        if (netInterfaceConfig instanceof EthernetInterfaceConfigImpl) {
            properties.put(netIfReadOnlyPrefix + "eth.link.up", ((EthernetInterfaceConfigImpl) netInterfaceConfig).isLinkUp());
        } else if (netInterfaceConfig instanceof WifiInterfaceConfigImpl) {
            EnumSet<Capability> capabilities = ((WifiInterfaceConfigImpl) netInterfaceConfig).getCapabilities();
            if (capabilities != null && !capabilities.isEmpty()) {
                StringBuilder sb = new StringBuilder();
                for (Capability capability : capabilities) {
                    sb.append(capability.toString());
                    sb.append(",");
                }
                String capabilitiesString = sb.toString();
                capabilitiesString = capabilitiesString.substring(0, capabilitiesString.length() - 1);
                properties.put(netIfReadOnlyPrefix + "wifi.capabilities", capabilitiesString);
            }
        }
        // add wifi properties
        if (netInterfaceConfig.getType() == NetInterfaceType.WIFI) {
            // capabilities
            StringBuilder sbCapabilities = new StringBuilder();
            EnumSet<Capability> capabilities = ((WifiInterface) netInterfaceConfig).getCapabilities();
            if (capabilities != null) {
                Iterator<Capability> it2 = ((WifiInterface) netInterfaceConfig).getCapabilities().iterator();
                while (it2.hasNext()) {
                    sbCapabilities.append(it2.next().name()).append(" ");
                }
                properties.put(netIfReadOnlyPrefix + "wifi.capabilities", sbCapabilities.toString());
            }
        }
        // add modem properties
        if (netInterfaceConfig.getType() == NetInterfaceType.MODEM) {
            String delim;
            // revision
            StringBuffer revisionIdBuf = new StringBuffer();
            String[] revisionId = ((ModemInterface<?>) netInterfaceConfig).getRevisionId();
            if (revisionId != null) {
                delim = null;
                for (String rev : revisionId) {
                    if (delim != null) {
                        revisionIdBuf.append(delim);
                    }
                    revisionIdBuf.append(rev);
                    delim = ",";
                }
            }
            // technology types
            StringBuffer techTypesBuf = new StringBuffer();
            List<ModemTechnologyType> techTypes = ((ModemInterface<?>) netInterfaceConfig).getTechnologyTypes();
            if (techTypes != null) {
                delim = null;
                for (ModemTechnologyType techType : techTypes) {
                    if (delim != null) {
                        techTypesBuf.append(delim);
                    }
                    techTypesBuf.append(techType.toString());
                    delim = ",";
                }
            }
            ModemPowerMode powerMode = ModemPowerMode.UNKNOWN;
            if (((ModemInterface<?>) netInterfaceConfig).getPowerMode() != null) {
                powerMode = ((ModemInterface<?>) netInterfaceConfig).getPowerMode();
            }
            properties.put(netIfReadOnlyPrefix + "manufacturer", ((ModemInterface<?>) netInterfaceConfig).getManufacturer());
            properties.put(netIfReadOnlyPrefix + "model", ((ModemInterface<?>) netInterfaceConfig).getModel());
            properties.put(netIfReadOnlyPrefix + "revisionId", revisionIdBuf.toString());
            properties.put(netIfReadOnlyPrefix + "serialNum", ((ModemInterface<?>) netInterfaceConfig).getSerialNumber());
            properties.put(netIfReadOnlyPrefix + "technologyTypes", techTypesBuf.toString());
            properties.put(netIfConfigPrefix + "identifier", ((ModemInterface<?>) netInterfaceConfig).getModemIdentifier());
            properties.put(netIfConfigPrefix + "powerMode", powerMode.toString());
            properties.put(netIfConfigPrefix + "pppNum", ((ModemInterface<?>) netInterfaceConfig).getPppNum());
            properties.put(netIfConfigPrefix + "poweredOn", ((ModemInterface<?>) netInterfaceConfig).isPoweredOn());
        }
        for (NetInterfaceAddress nia : netInterfaceConfig.getNetInterfaceAddresses()) {
            String typePrefix = "ip4.";
            if (nia != null) {
                if (nia.getAddress() != null) {
                    properties.put(netIfReadOnlyPrefix + typePrefix + "address", nia.getAddress().getHostAddress());
                }
                if (nia.getBroadcast() != null) {
                    properties.put(netIfReadOnlyPrefix + typePrefix + "broadcast", nia.getBroadcast().getHostAddress());
                }
                if (nia.getGateway() != null) {
                    properties.put(netIfReadOnlyPrefix + typePrefix + "gateway", nia.getGateway().getHostAddress());
                }
                if (nia.getNetmask() != null) {
                    properties.put(netIfReadOnlyPrefix + typePrefix + "netmask", nia.getNetmask().getHostAddress());
                }
                if (nia.getNetmask() != null) {
                    properties.put(netIfReadOnlyPrefix + typePrefix + "prefix", Short.valueOf(nia.getNetworkPrefixLength()));
                }
                if (nia.getDnsServers() != null) {
                    StringBuilder dnsServers = new StringBuilder();
                    for (IPAddress dnsServer : nia.getDnsServers()) {
                        if (dnsServers.length() != 0) {
                            dnsServers.append(",");
                        }
                        dnsServers.append(dnsServer);
                    }
                    properties.put(netIfReadOnlyPrefix + typePrefix + "dnsServers", dnsServers.toString());
                }
                // Wifi interface address
                if (nia instanceof WifiInterfaceAddress) {
                    // access point
                    WifiAccessPoint wap = ((WifiInterfaceAddress) nia).getWifiAccessPoint();
                    if (wap != null) {
                    /*
                             * TODO: need fields to reflect current state?
                             * properties.put(sbNetIfPrefix+"wifi.ssid", wap.getSSID());
                             * properties.put(sbNetIfPrefix+"wifi.mode", wap.getMode());
                             */
                    }
                    long bitrate = ((WifiInterfaceAddress) nia).getBitrate();
                    properties.put(netIfReadOnlyPrefix + "wifi.bitrate", Long.valueOf(bitrate));
                    WifiMode wifiMode;
                    if (((WifiInterfaceAddress) nia).getMode() != null) {
                        wifiMode = ((WifiInterfaceAddress) nia).getMode();
                    } else {
                        wifiMode = WifiMode.UNKNOWN;
                    }
                    properties.put(netIfPrefix + "wifi.mode", wifiMode.toString());
                }
                // Modem interface address
                if (nia instanceof ModemInterfaceAddress) {
                    if (((ModemInterfaceAddress) nia).getConnectionType() != null) {
                        properties.put(netIfConfigPrefix + "connection.type", ((ModemInterfaceAddress) nia).getConnectionType().toString());
                    }
                    if (((ModemInterfaceAddress) nia).getConnectionStatus() != null) {
                        properties.put(netIfConfigPrefix + "connection.status", ((ModemInterfaceAddress) nia).getConnectionStatus().toString());
                    }
                }
            }
        }
        // add the properties of the network configurations associated to the interface
        List<? extends NetInterfaceAddressConfig> netInterfaceAddressConfigs = netInterfaceConfig.getNetInterfaceAddresses();
        s_logger.trace("netInterfaceAddressConfigs.size() for {}: {}", netInterfaceConfig.getName(), netInterfaceAddressConfigs.size());
        for (NetInterfaceAddressConfig netInterfaceAddressConfig : netInterfaceAddressConfigs) {
            List<NetConfig> netConfigs = netInterfaceAddressConfig.getConfigs();
            if (netConfigs != null) {
                s_logger.trace("netConfigs.size(): {}", netConfigs.size());
                for (NetConfig netConfig : netConfigs) {
                    if (netConfig instanceof WifiConfig) {
                        s_logger.trace("adding netconfig WifiConfigIP4 for {}", netInterfaceConfig.getName());
                        addWifiConfigIP4Properties((WifiConfig) netConfig, netIfConfigPrefix, properties);
                    } else if (netConfig instanceof ModemConfig) {
                        s_logger.trace("adding netconfig ModemConfig for {}", netInterfaceConfig.getName());
                        addModemConfigProperties((ModemConfig) netConfig, netIfConfigPrefix, properties);
                    } else if (netConfig instanceof NetConfigIP4) {
                        s_logger.trace("adding netconfig NetConfigIP4 for {}", netInterfaceConfig.getName());
                        addNetConfigIP4Properties((NetConfigIP4) netConfig, netIfConfigPrefix, properties);
                    /*
                             * Iterator<String> it2 = properties.keySet().iterator();
                             * while(it2.hasNext()) {
                             * String key = it2.next();
                             * System.out.println("\t\t\t"+key+"="+properties.get(key));
                             * }
                             */
                    } else if (netConfig instanceof NetConfigIP6) {
                        s_logger.trace("adding netconfig NetConfigIP6 for {}", netInterfaceConfig.getName());
                        addNetConfigIP6Properties((NetConfigIP6) netConfig, netIfConfigPrefix, properties);
                    /*
                             * Iterator<String> it = properties.keySet().iterator();
                             * while(it.hasNext()) {
                             * String key = it.next();
                             * System.out.println("\t\t\t"+key+"="+properties.get(key));
                             * }
                             */
                    } else if (netConfig instanceof DhcpServerConfig4) {
                        s_logger.trace("adding netconfig DhcpServerConfig4 for {}", netInterfaceConfig.getName());
                        addDhcpServerConfig4((DhcpServerConfig4) netConfig, netIfConfigPrefix, properties);
                    } else if (netConfig instanceof FirewallAutoNatConfig) {
                        s_logger.trace("adding netconfig FirewallNatConfig for {}", netInterfaceConfig.getName());
                        addFirewallNatConfig((FirewallAutoNatConfig) netConfig, netIfConfigPrefix, properties);
                    }
                }
            }
        }
    }
    properties.put("net.interfaces", sbInterfaces.toString());
    this.m_properties = properties;
}
Also used : FirewallAutoNatConfig(org.eclipse.kura.net.firewall.FirewallAutoNatConfig) HashMap(java.util.HashMap) WifiConfig(org.eclipse.kura.net.wifi.WifiConfig) UsbDevice(org.eclipse.kura.usb.UsbDevice) WifiInterface(org.eclipse.kura.net.wifi.WifiInterface) NetConfigIP4(org.eclipse.kura.net.NetConfigIP4) NetConfigIP6(org.eclipse.kura.net.NetConfigIP6) WifiMode(org.eclipse.kura.net.wifi.WifiMode) ModemTechnologyType(org.eclipse.kura.net.modem.ModemTechnologyType) NetInterfaceAddressConfig(org.eclipse.kura.net.NetInterfaceAddressConfig) ModemInterface(org.eclipse.kura.net.modem.ModemInterface) Capability(org.eclipse.kura.net.wifi.WifiInterface.Capability) EnumSet(java.util.EnumSet) ModemPowerMode(org.eclipse.kura.net.modem.ModemPowerMode) DhcpServerConfig4(org.eclipse.kura.net.dhcp.DhcpServerConfig4) WifiAccessPoint(org.eclipse.kura.net.wifi.WifiAccessPoint) ModemConfig(org.eclipse.kura.net.modem.ModemConfig) NetInterfaceAddress(org.eclipse.kura.net.NetInterfaceAddress) NetConfig(org.eclipse.kura.net.NetConfig) WifiInterfaceAddress(org.eclipse.kura.net.wifi.WifiInterfaceAddress) IPAddress(org.eclipse.kura.net.IPAddress) ModemInterfaceAddress(org.eclipse.kura.net.modem.ModemInterfaceAddress)

Aggregations

Capability (org.eclipse.kura.net.wifi.WifiInterface.Capability)3 EnumSet (java.util.EnumSet)2 KuraException (org.eclipse.kura.KuraException)2 IPAddress (org.eclipse.kura.net.IPAddress)2 NetConfig (org.eclipse.kura.net.NetConfig)2 NetConfigIP4 (org.eclipse.kura.net.NetConfigIP4)2 NetConfigIP6 (org.eclipse.kura.net.NetConfigIP6)2 NetInterfaceAddressConfig (org.eclipse.kura.net.NetInterfaceAddressConfig)2 FirewallAutoNatConfig (org.eclipse.kura.net.firewall.FirewallAutoNatConfig)2 ModemPowerMode (org.eclipse.kura.net.modem.ModemPowerMode)2 ModemTechnologyType (org.eclipse.kura.net.modem.ModemTechnologyType)2 WifiAccessPoint (org.eclipse.kura.net.wifi.WifiAccessPoint)2 WifiConfig (org.eclipse.kura.net.wifi.WifiConfig)2 WifiMode (org.eclipse.kura.net.wifi.WifiMode)2 UsbDevice (org.eclipse.kura.usb.UsbDevice)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1