Search in sources :

Example 1 with ModemInterfaceConfigImpl

use of org.eclipse.kura.core.net.modem.ModemInterfaceConfigImpl 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 ModemInterfaceConfigImpl

use of org.eclipse.kura.core.net.modem.ModemInterfaceConfigImpl in project kura by eclipse.

the class PppConfigReader method getConfig.

private void getConfig(NetInterfaceConfig<? extends NetInterfaceAddressConfig> netInterfaceConfig) throws KuraException {
    String interfaceName = netInterfaceConfig.getName();
    s_logger.debug("Getting ppp config for {}", interfaceName);
    if (netInterfaceConfig instanceof ModemInterfaceConfigImpl) {
        StringBuilder key = new StringBuilder("net.interface." + netInterfaceConfig.getName() + ".modem.identifier");
        String modemId = KuranetConfig.getProperty(key.toString());
        s_logger.debug("Getting modem identifier using key " + key + ": " + modemId);
        if (modemId != null) {
            ((ModemInterfaceConfigImpl) netInterfaceConfig).setModemIdentifier(modemId);
        }
    }
    List<? extends NetInterfaceAddressConfig> netInterfaceAddressConfigs = netInterfaceConfig.getNetInterfaceAddresses();
    for (NetInterfaceAddressConfig netInterfaceAddressConfig : netInterfaceAddressConfigs) {
        if (netInterfaceAddressConfig instanceof ModemInterfaceAddressConfigImpl) {
            List<NetConfig> netConfigs = netInterfaceAddressConfig.getConfigs();
            if (netConfigs == null) {
                netConfigs = new ArrayList<NetConfig>();
                ((ModemInterfaceAddressConfigImpl) netInterfaceAddressConfig).setNetConfigs(netConfigs);
            }
            // Create a ModemConfig
            ModemConfig modemConfig = getModemConfig(interfaceName, netInterfaceConfig.getUsbDevice());
            if (modemConfig != null) {
                netConfigs.add(modemConfig);
            }
            // Create a NetConfigIP4
            netConfigs.add(getNetConfigIP4(interfaceName));
            // Populate with DNS provided by PPP (displayed as read-only in Denali)
            if (LinuxNetworkUtil.hasAddress("ppp" + modemConfig.getPppNumber())) {
                List<? extends IPAddress> pppDnsServers = LinuxDns.getInstance().getPppDnServers();
                if (pppDnsServers != null) {
                    ((ModemInterfaceAddressConfigImpl) netInterfaceAddressConfig).setDnsServers(pppDnsServers);
                }
            }
        }
    }
}
Also used : ModemInterfaceAddressConfigImpl(org.eclipse.kura.core.net.modem.ModemInterfaceAddressConfigImpl) ModemConfig(org.eclipse.kura.net.modem.ModemConfig) ModemInterfaceConfigImpl(org.eclipse.kura.core.net.modem.ModemInterfaceConfigImpl) NetConfig(org.eclipse.kura.net.NetConfig) NetInterfaceAddressConfig(org.eclipse.kura.net.NetInterfaceAddressConfig)

Example 3 with ModemInterfaceConfigImpl

use of org.eclipse.kura.core.net.modem.ModemInterfaceConfigImpl in project kura by eclipse.

the class GenericNetworkInterface method getCurrentConfig.

protected static NetInterfaceConfig<?> getCurrentConfig(String interfaceName, NetInterfaceType type, NetInterfaceStatus status, boolean dhcpServerEnabled, boolean passDns, Properties kuraProps) throws KuraException {
    try {
        NetInterfaceConfig<?> netInterfaceConfig = null;
        boolean autoConnect = false;
        int mtu = -1;
        boolean dhcp = false;
        IP4Address address = null;
        String ipAddress = null;
        String prefixString = null;
        String netmask = null;
        String gateway = null;
        boolean interfaceEnabled = false;
        if (kuraProps != null) {
            String onBoot = kuraProps.getProperty("ONBOOT");
            if ("yes".equals(onBoot)) {
                autoConnect = true;
                // we are enabled - just not sure if for LAN or WAN
                if (status == NetInterfaceStatus.netIPv4StatusUnknown) {
                    interfaceEnabled = true;
                }
            } else {
                autoConnect = false;
            }
            // override MTU with what is in config if it is present
            String stringMtu = kuraProps.getProperty("MTU");
            if (stringMtu == null) {
                try {
                    mtu = LinuxNetworkUtil.getCurrentMtu(interfaceName);
                } catch (KuraException e) {
                    // just assume ???
                    if (interfaceName.equals("lo")) {
                        mtu = 16436;
                    } else {
                        mtu = 1500;
                    }
                }
            } else {
                mtu = Short.parseShort(stringMtu);
            }
            // get the bootproto
            String bootproto = kuraProps.getProperty("BOOTPROTO");
            if (bootproto == null) {
                bootproto = "static";
            }
            // get the defroute
            String defroute = kuraProps.getProperty("DEFROUTE");
            if (defroute == null) {
                defroute = "no";
            }
            if (interfaceEnabled) {
                if (defroute.equals("yes")) {
                    status = NetInterfaceStatus.netIPv4StatusEnabledWAN;
                } else {
                    status = NetInterfaceStatus.netIPv4StatusEnabledLAN;
                }
            }
            // check for dhcp or static configuration
            try {
                ipAddress = kuraProps.getProperty("IPADDR");
                prefixString = kuraProps.getProperty("PREFIX");
                netmask = kuraProps.getProperty("NETMASK");
                kuraProps.getProperty("BROADCAST");
                try {
                    gateway = kuraProps.getProperty("GATEWAY");
                    s_logger.debug("got gateway for {}: {}", interfaceName, gateway);
                } catch (Exception e) {
                    s_logger.warn("missing gateway stanza for " + interfaceName);
                }
                if (bootproto.equals("dhcp")) {
                    s_logger.debug("currently set for DHCP");
                    dhcp = true;
                    ipAddress = null;
                    netmask = null;
                } else {
                    s_logger.debug("currently set for static address");
                    dhcp = false;
                }
            } catch (Exception e) {
                e.printStackTrace();
                throw new KuraException(KuraErrorCode.INTERNAL_ERROR, "malformatted config file: " + NET_CONFIGURATION_DIRECTORY + "ifcfg-" + interfaceName);
            }
            if (ipAddress != null && !ipAddress.isEmpty()) {
                address = (IP4Address) IPAddress.parseHostAddress(ipAddress);
            }
            // make sure at least prefix or netmask is present if static
            if (!dhcp && prefixString == null && netmask == null) {
                throw new KuraException(KuraErrorCode.INTERNAL_ERROR, "malformatted config file: " + NET_CONFIGURATION_DIRECTORY + "ifcfg-" + interfaceName + " must contain NETMASK and/or PREFIX");
            }
        }
        ConnectionInfo conInfo = new ConnectionInfoImpl(interfaceName);
        LinuxDns dnsService = LinuxDns.getInstance();
        // note - we only add the fields we need/care about from a configuration standpoint
        if (type == NetInterfaceType.LOOPBACK) {
            s_logger.debug("Adding a Loopback interface");
            netInterfaceConfig = new LoopbackInterfaceConfigImpl(interfaceName);
            ((LoopbackInterfaceImpl<?>) netInterfaceConfig).setMTU(mtu);
            // loopback autoConnect
            ((LoopbackInterfaceImpl<?>) netInterfaceConfig).setAutoConnect(true);
            // should always be true?
            ((LoopbackInterfaceImpl<?>) netInterfaceConfig).setLoopback(true);
            List<NetInterfaceAddressConfig> netInterfaceAddressConfigs = new ArrayList<NetInterfaceAddressConfig>();
            List<NetInterfaceAddress> netInterfaceAddresses = new ArrayList<NetInterfaceAddress>();
            NetInterfaceAddressConfigImpl netInterfaceAddressConfig = new NetInterfaceAddressConfigImpl();
            netInterfaceAddressConfigs.add(netInterfaceAddressConfig);
            netInterfaceAddresses.add(netInterfaceAddressConfig);
            LinuxIfconfig ifconfig = LinuxNetworkUtil.getInterfaceConfiguration(interfaceName);
            if (ifconfig != null && ifconfig.isUp()) {
                netInterfaceAddressConfig.setAddress(IPAddress.parseHostAddress(ifconfig.getInetAddress()));
                netInterfaceAddressConfig.setBroadcast(IPAddress.parseHostAddress(ifconfig.getInetBcast()));
                netInterfaceAddressConfig.setNetmask(IPAddress.parseHostAddress(ifconfig.getInetMask()));
                netInterfaceAddressConfig.setNetworkPrefixLength(NetworkUtil.getNetmaskShortForm(ifconfig.getInetMask()));
                netInterfaceAddressConfig.setGateway(conInfo.getGateway());
                if (dhcp) {
                    netInterfaceAddressConfig.setDnsServers(dnsService.getDhcpDnsServers(interfaceName, netInterfaceAddressConfig.getAddress()));
                } else {
                    netInterfaceAddressConfig.setDnsServers(conInfo.getDnsServers());
                }
            }
            ((LoopbackInterfaceConfigImpl) netInterfaceConfig).setNetInterfaceAddresses(netInterfaceAddressConfigs);
            List<NetConfig> netConfigs = new ArrayList<NetConfig>();
            netInterfaceAddressConfig.setNetConfigs(netConfigs);
            // FIXME - hardcoded
            NetConfig netConfig = new NetConfigIP4(NetInterfaceStatus.netIPv4StatusEnabledLAN, true);
            ((NetConfigIP4) netConfig).setAddress(address);
            ((NetConfigIP4) netConfig).setDhcp(dhcp);
            ((NetConfigIP4) netConfig).setDnsServers(null);
            ((NetConfigIP4) netConfig).setDomains(null);
            ((NetConfigIP4) netConfig).setGateway(null);
            ((NetConfigIP4) netConfig).setNetworkPrefixLength((short) 8);
            ((NetConfigIP4) netConfig).setSubnetMask((IP4Address) IPAddress.parseHostAddress("255.0.0.0"));
            ((NetConfigIP4) netConfig).setWinsServers(null);
            netConfigs.add(netConfig);
        } else if (type == NetInterfaceType.ETHERNET) {
            s_logger.debug("Adding an Ethernet interface - {}", interfaceName);
            netInterfaceConfig = new EthernetInterfaceConfigImpl(interfaceName);
            ((EthernetInterfaceImpl<?>) netInterfaceConfig).setMTU(mtu);
            ((EthernetInterfaceImpl<?>) netInterfaceConfig).setAutoConnect(autoConnect);
            ((EthernetInterfaceImpl<?>) netInterfaceConfig).setLoopback(false);
            List<NetInterfaceAddressConfig> netInterfaceAddressConfigs = new ArrayList<NetInterfaceAddressConfig>();
            List<NetInterfaceAddress> netInterfaceAddresses = new ArrayList<NetInterfaceAddress>();
            NetInterfaceAddressConfigImpl netInterfaceAddressConfig = new NetInterfaceAddressConfigImpl();
            netInterfaceAddressConfigs.add(netInterfaceAddressConfig);
            netInterfaceAddresses.add(netInterfaceAddressConfig);
            LinuxIfconfig ifconfig = LinuxNetworkUtil.getInterfaceConfiguration(interfaceName);
            if (ifconfig != null) {
                ((EthernetInterfaceImpl<?>) netInterfaceConfig).setHardwareAddress(ifconfig.getMacAddressBytes());
                if (ifconfig.isUp()) {
                    try {
                        netInterfaceAddressConfig.setAddress(IPAddress.parseHostAddress(ifconfig.getInetAddress()));
                        netInterfaceAddressConfig.setBroadcast(IPAddress.parseHostAddress(ifconfig.getInetBcast()));
                        netInterfaceAddressConfig.setNetmask(IPAddress.parseHostAddress(ifconfig.getInetMask()));
                        netInterfaceAddressConfig.setNetworkPrefixLength(NetworkUtil.getNetmaskShortForm(ifconfig.getInetMask()));
                        netInterfaceAddressConfig.setGateway(conInfo.getGateway());
                        if (dhcp) {
                            netInterfaceAddressConfig.setDnsServers(dnsService.getDhcpDnsServers(interfaceName, netInterfaceAddressConfig.getAddress()));
                        } else {
                            netInterfaceAddressConfig.setDnsServers(conInfo.getDnsServers());
                        }
                    } catch (KuraException e) {
                        s_logger.warn("The interface went down " + interfaceName + " not including current state in status because it is not up");
                        netInterfaceAddressConfig.setAddress(null);
                        netInterfaceAddressConfig.setBroadcast(null);
                        netInterfaceAddressConfig.setNetmask(null);
                        netInterfaceAddressConfig.setNetworkPrefixLength((short) -1);
                        netInterfaceAddressConfig.setGateway(null);
                        netInterfaceAddressConfig.setDnsServers(null);
                    }
                }
            }
            ((EthernetInterfaceConfigImpl) netInterfaceConfig).setNetInterfaceAddresses(netInterfaceAddressConfigs);
            // add the config
            List<NetConfig> netConfigs = new ArrayList<NetConfig>();
            netInterfaceAddressConfig.setNetConfigs(netConfigs);
            NetConfigIP4 netConfig = new NetConfigIP4(NetInterfaceStatus.netIPv4StatusDisabled, autoConnect);
            setNetConfigIP4(netConfig, status, autoConnect, dhcp, address, gateway, prefixString, netmask, kuraProps);
            netConfigs.add(netConfig);
            if (dhcpServerEnabled) {
                // add DHCP server configuration to the list
                DhcpServerImpl dhcpServer = DhcpServerFactory.getInstance(interfaceName, dhcpServerEnabled, passDns);
                DhcpServerConfig4 dhcpServerConfig = dhcpServer.getDhcpServerConfig(dhcpServerEnabled, passDns);
                if (dhcpServerConfig != null) {
                    netConfigs.add(dhcpServerConfig);
                }
            }
        } else if (type == NetInterfaceType.WIFI) {
            s_logger.debug("Adding a Wireless interface - {}", interfaceName);
            WifiInterfaceConfigImpl wifiInterfaceConfig = new WifiInterfaceConfigImpl(interfaceName);
            netInterfaceConfig = wifiInterfaceConfig;
            wifiInterfaceConfig.setMTU(mtu);
            wifiInterfaceConfig.setAutoConnect(autoConnect);
            wifiInterfaceConfig.setLoopback(false);
            List<WifiInterfaceAddressConfig> wifiInterfaceAddressConfigs = new ArrayList<WifiInterfaceAddressConfig>();
            List<WifiInterfaceAddress> wifiInterfaceAddresses = new ArrayList<WifiInterfaceAddress>();
            WifiInterfaceAddressConfigImpl wifiInterfaceAddressConfig = new WifiInterfaceAddressConfigImpl();
            wifiInterfaceAddressConfigs.add(wifiInterfaceAddressConfig);
            wifiInterfaceAddresses.add(wifiInterfaceAddressConfig);
            String currentSSID = LinuxNetworkUtil.getSSID(interfaceName);
            LinuxIfconfig ifconfig = LinuxNetworkUtil.getInterfaceConfiguration(interfaceName);
            if (ifconfig != null) {
                wifiInterfaceConfig.setHardwareAddress(ifconfig.getMacAddressBytes());
                if (ifconfig.isUp()) {
                    wifiInterfaceAddressConfig.setAddress(IPAddress.parseHostAddress(ifconfig.getInetAddress()));
                    wifiInterfaceAddressConfig.setBroadcast(IPAddress.parseHostAddress(ifconfig.getInetBcast()));
                    String currentNetmask = ifconfig.getInetMask();
                    if (currentNetmask != null) {
                        wifiInterfaceAddressConfig.setNetmask(IPAddress.parseHostAddress(currentNetmask));
                        wifiInterfaceAddressConfig.setNetworkPrefixLength(NetworkUtil.getNetmaskShortForm(currentNetmask));
                    }
                    wifiInterfaceAddressConfig.setBitrate(LinuxNetworkUtil.getWifiBitrate(interfaceName));
                    wifiInterfaceAddressConfig.setGateway(conInfo.getGateway());
                    if (dhcp) {
                        wifiInterfaceAddressConfig.setDnsServers(dnsService.getDhcpDnsServers(interfaceName, wifiInterfaceAddressConfig.getAddress()));
                    } else {
                        wifiInterfaceAddressConfig.setDnsServers(conInfo.getDnsServers());
                    }
                    WifiAccessPointImpl ap = null;
                    if (currentSSID != null) {
                        s_logger.debug("Adding access point SSID: {}", currentSSID);
                        ap = new WifiAccessPointImpl(currentSSID);
                        // TODO: fill in other info
                        ap.setMode(WifiMode.INFRA);
                        List<Long> bitrate = new ArrayList<Long>();
                        bitrate.add(54000000L);
                        ap.setBitrate(bitrate);
                        ap.setFrequency(12345);
                        ap.setHardwareAddress("20AA4B8A6442".getBytes());
                        ap.setRsnSecurity(EnumSet.allOf(WifiSecurity.class));
                        ap.setStrength(1234);
                        ap.setWpaSecurity(EnumSet.allOf(WifiSecurity.class));
                    }
                    wifiInterfaceAddressConfig.setWifiAccessPoint(ap);
                }
            }
            // mode
            WifiMode wifiMode = WifiMode.UNKNOWN;
            s_logger.debug("Get WifiMode...");
            try {
                // get from config file
                String mode = kuraProps.getProperty("MODE");
                if (mode != null) {
                    s_logger.debug("Getting wifi mode from {}", kuraFile.getAbsolutePath());
                    if (mode.equalsIgnoreCase("Managed")) {
                        wifiMode = WifiMode.INFRA;
                    } else if (mode.equalsIgnoreCase("Master")) {
                        wifiMode = WifiMode.MASTER;
                    } else if (mode.equalsIgnoreCase("Ad-Hoc")) {
                        wifiMode = WifiMode.ADHOC;
                    } else {
                        wifiMode = WifiMode.valueOf(mode);
                    }
                } else {
                    // get current setting using iwconfig
                    s_logger.debug("Getting wifi mode from iwconfig");
                    wifiMode = LinuxNetworkUtil.getWifiMode(interfaceName);
                }
            } catch (Exception e) {
            // leave as unknown
            }
            s_logger.debug("Current WifiMode: {}", wifiMode);
            wifiInterfaceAddressConfig.setMode(wifiMode);
            wifiInterfaceConfig.setNetInterfaceAddresses(wifiInterfaceAddressConfigs);
            // TODO: fix
            wifiInterfaceConfig.setCapabilities(EnumSet.allOf(Capability.class));
            // add the configs - one for client (managed) mode, one for access point (master) mode
            List<NetConfig> netConfigs = new ArrayList<NetConfig>();
            wifiInterfaceAddressConfig.setNetConfigs(netConfigs);
            // get the NetConfig
            NetConfigIP4 netConfig = new NetConfigIP4(NetInterfaceStatus.netIPv4StatusDisabled, autoConnect);
            setNetConfigIP4(netConfig, status, autoConnect, dhcp, address, gateway, prefixString, netmask, kuraProps);
            netConfigs.add(netConfig);
            // get the wpa_supplicant configuration
            WifiConfig wifiClientConfig = new WifiConfig();
            setWifiClientConfig(interfaceName, wifiClientConfig, wifiMode);
            // get the hostapd configuration
            WifiConfig wifiAPConfig = new WifiConfig();
            setWifiAccessPointConfig(wifiAPConfig);
            // add WiFi configurations to the list
            netConfigs.add(wifiClientConfig);
            netConfigs.add(wifiAPConfig);
            if (dhcpServerEnabled) {
                // add DHCP server configuration to the list
                DhcpServerImpl dhcpServer = DhcpServerFactory.getInstance(interfaceName, dhcpServerEnabled, passDns);
                DhcpServerConfig4 dhcpServerConfig = dhcpServer.getDhcpServerConfig(dhcpServerEnabled, passDns);
                if (dhcpServerConfig != null) {
                    netConfigs.add(dhcpServerConfig);
                }
            }
        } else if (type == NetInterfaceType.MODEM) {
            s_logger.debug("Adding a Modem interface");
            netInterfaceConfig = new ModemInterfaceConfigImpl(interfaceName);
            ((ModemInterfaceConfigImpl) netInterfaceConfig).setMTU(mtu);
            ((ModemInterfaceConfigImpl) netInterfaceConfig).setAutoConnect(autoConnect);
            ((ModemInterfaceConfigImpl) netInterfaceConfig).setLoopback(false);
            ((ModemInterfaceConfigImpl) netInterfaceConfig).setPointToPoint(true);
            List<ModemInterfaceAddressConfig> modemInterfaceAddressConfigs = new ArrayList<ModemInterfaceAddressConfig>();
            List<ModemInterfaceAddress> netInterfaceAddresses = new ArrayList<ModemInterfaceAddress>();
            ModemInterfaceAddressConfigImpl netInterfaceAddressConfig = new ModemInterfaceAddressConfigImpl();
            modemInterfaceAddressConfigs.add(netInterfaceAddressConfig);
            netInterfaceAddresses.add(netInterfaceAddressConfig);
            LinuxIfconfig ifconfig = LinuxNetworkUtil.getInterfaceConfiguration(interfaceName);
            if (ifconfig != null) {
                ((ModemInterfaceConfigImpl) netInterfaceConfig).setHardwareAddress(ifconfig.getMacAddressBytes());
                if (ifconfig.isUp()) {
                    netInterfaceAddressConfig.setAddress(IPAddress.parseHostAddress(ifconfig.getInetAddress()));
                    netInterfaceAddressConfig.setBroadcast(IPAddress.parseHostAddress(ifconfig.getInetBcast()));
                    netInterfaceAddressConfig.setNetmask(IPAddress.parseHostAddress(ifconfig.getInetMask()));
                    netInterfaceAddressConfig.setNetworkPrefixLength(NetworkUtil.getNetmaskShortForm(ifconfig.getInetMask()));
                    netInterfaceAddressConfig.setGateway(conInfo.getGateway());
                    netInterfaceAddressConfig.setDnsServers(conInfo.getDnsServers());
                }
            }
            ((ModemInterfaceConfigImpl) netInterfaceConfig).setNetInterfaceAddresses(modemInterfaceAddressConfigs);
            // add the config
            List<NetConfig> netConfigs = new ArrayList<NetConfig>();
            netInterfaceAddressConfig.setNetConfigs(netConfigs);
            NetConfigIP4 netConfig = new NetConfigIP4(NetInterfaceStatus.netIPv4StatusDisabled, autoConnect);
            setNetConfigIP4(netConfig, status, autoConnect, dhcp, address, gateway, prefixString, netmask, kuraProps);
            netConfigs.add(netConfig);
        } else {
            s_logger.warn("Unsupported Type: " + type);
        }
        return netInterfaceConfig;
    } catch (UnknownHostException e) {
        throw new KuraException(KuraErrorCode.INTERNAL_ERROR, e);
    }
}
Also used : ModemInterfaceAddressConfigImpl(org.eclipse.kura.core.net.modem.ModemInterfaceAddressConfigImpl) WifiConfig(org.eclipse.kura.net.wifi.WifiConfig) ArrayList(java.util.ArrayList) WifiInterfaceAddressConfig(org.eclipse.kura.net.wifi.WifiInterfaceAddressConfig) LinuxDns(org.eclipse.kura.linux.net.dns.LinuxDns) KuraException(org.eclipse.kura.KuraException) WifiMode(org.eclipse.kura.net.wifi.WifiMode) ModemInterfaceAddressConfig(org.eclipse.kura.net.modem.ModemInterfaceAddressConfig) ArrayList(java.util.ArrayList) List(java.util.List) NetInterfaceAddressConfig(org.eclipse.kura.net.NetInterfaceAddressConfig) WifiInterfaceAddressConfigImpl(org.eclipse.kura.core.net.WifiInterfaceAddressConfigImpl) Capability(org.eclipse.kura.net.wifi.WifiInterface.Capability) IP4Address(org.eclipse.kura.net.IP4Address) DhcpServerImpl(org.eclipse.kura.linux.net.dhcp.DhcpServerImpl) EthernetInterfaceConfigImpl(org.eclipse.kura.core.net.EthernetInterfaceConfigImpl) WifiAccessPointImpl(org.eclipse.kura.core.net.WifiAccessPointImpl) NetInterfaceAddress(org.eclipse.kura.net.NetInterfaceAddress) NetConfig(org.eclipse.kura.net.NetConfig) ConnectionInfo(org.eclipse.kura.net.ConnectionInfo) WifiInterfaceAddress(org.eclipse.kura.net.wifi.WifiInterfaceAddress) NetInterfaceAddressConfigImpl(org.eclipse.kura.core.net.NetInterfaceAddressConfigImpl) NetConfigIP4(org.eclipse.kura.net.NetConfigIP4) LoopbackInterfaceConfigImpl(org.eclipse.kura.core.net.LoopbackInterfaceConfigImpl) UnknownHostException(java.net.UnknownHostException) DhcpServerConfig4(org.eclipse.kura.net.dhcp.DhcpServerConfig4) KuraException(org.eclipse.kura.KuraException) UnknownHostException(java.net.UnknownHostException) WifiInterfaceConfigImpl(org.eclipse.kura.core.net.WifiInterfaceConfigImpl) LoopbackInterfaceImpl(org.eclipse.kura.core.net.LoopbackInterfaceImpl) ModemInterfaceConfigImpl(org.eclipse.kura.core.net.modem.ModemInterfaceConfigImpl) WifiSecurity(org.eclipse.kura.net.wifi.WifiSecurity) ModemInterfaceAddress(org.eclipse.kura.net.modem.ModemInterfaceAddress) ConnectionInfoImpl(org.eclipse.kura.linux.net.ConnectionInfoImpl)

Example 4 with ModemInterfaceConfigImpl

use of org.eclipse.kura.core.net.modem.ModemInterfaceConfigImpl in project kura by eclipse.

the class DnsMonitorServiceImpl method getConfiguredDnsServers.

// Get a list of dns servers for the specified NetInterfaceConfig
private Set<IPAddress> getConfiguredDnsServers(NetInterfaceConfig<? extends NetInterfaceAddressConfig> netInterfaceConfig) throws KuraException {
    String interfaceName = netInterfaceConfig.getName();
    s_logger.trace("Getting dns servers for {}", interfaceName);
    LinuxDns linuxDns = LinuxDns.getInstance();
    LinkedHashSet<IPAddress> serverList = new LinkedHashSet<IPAddress>();
    for (NetInterfaceAddressConfig netInterfaceAddressConfig : netInterfaceConfig.getNetInterfaceAddresses()) {
        for (NetConfig netConfig : netInterfaceAddressConfig.getConfigs()) {
            if (netConfig instanceof NetConfigIP4) {
                NetConfigIP4 netConfigIP4 = (NetConfigIP4) netConfig;
                List<IP4Address> userServers = netConfigIP4.getDnsServers();
                if (netConfigIP4.isDhcp()) {
                    // If DHCP but there are user defined entries, use those instead
                    if (userServers != null && !userServers.isEmpty()) {
                        s_logger.debug("Configured for DHCP with user-defined servers - adding: {}", userServers);
                        serverList.addAll(userServers);
                    } else {
                        if (netInterfaceConfig.getType().equals(NetInterfaceType.MODEM)) {
                            // FIXME - don't like this
                            // cannot use interfaceName here because it one config behind
                            int pppNo = ((ModemInterfaceConfigImpl) netInterfaceConfig).getPppNum();
                            if (LinuxNetworkUtil.hasAddress("ppp" + pppNo)) {
                                List<IPAddress> servers = linuxDns.getPppDnServers();
                                if (servers != null) {
                                    s_logger.debug("Adding PPP dns servers: {}", servers);
                                    serverList.addAll(servers);
                                }
                            }
                        } else {
                            String currentAddress = LinuxNetworkUtil.getCurrentIpAddress(interfaceName);
                            List<IPAddress> servers = linuxDns.getDhcpDnsServers(interfaceName, currentAddress);
                            if (servers != null) {
                                s_logger.debug("Configured for DHCP - adding DHCP servers: {}", servers);
                                serverList.addAll(servers);
                            }
                        }
                    }
                } else {
                    // If static, use the user defined entries
                    s_logger.debug("Configured for static - adding user-defined servers: {}", userServers);
                    serverList.addAll(userServers);
                }
            }
        }
    }
    return serverList;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IP4Address(org.eclipse.kura.net.IP4Address) NetConfigIP4(org.eclipse.kura.net.NetConfigIP4) LinuxDns(org.eclipse.kura.linux.net.dns.LinuxDns) ModemInterfaceConfigImpl(org.eclipse.kura.core.net.modem.ModemInterfaceConfigImpl) NetConfig(org.eclipse.kura.net.NetConfig) IPAddress(org.eclipse.kura.net.IPAddress) NetInterfaceAddressConfig(org.eclipse.kura.net.NetInterfaceAddressConfig)

Example 5 with ModemInterfaceConfigImpl

use of org.eclipse.kura.core.net.modem.ModemInterfaceConfigImpl in project kura by eclipse.

the class NetworkAdminServiceImpl method updateModemInterfaceConfig.

@Override
public void updateModemInterfaceConfig(String interfaceName, String serialNum, String modemId, int pppNumber, boolean autoConnect, int mtu, List<NetConfig> netConfigs) throws KuraException {
    NetConfigIP4 netConfig4 = null;
    NetConfigIP6 netConfig6 = null;
    ModemConfig modemConfig = null;
    boolean hadNetConfig4 = false;
    boolean hadNetConfig6 = false;
    boolean hadModemConfig = false;
    if (netConfigs != null && !netConfigs.isEmpty()) {
        for (NetConfig netConfig : netConfigs) {
            if (!netConfig.isValid()) {
                throw new KuraException(KuraErrorCode.CONFIGURATION_ERROR, "NetConfig Configuration is invalid: " + netConfig.toString());
            }
            if (netConfig instanceof NetConfigIP4) {
                netConfig4 = (NetConfigIP4) netConfig;
            } else if (netConfig instanceof NetConfigIP6) {
                netConfig6 = (NetConfigIP6) netConfig;
            } else if (netConfig instanceof ModemConfig) {
                modemConfig = (ModemConfig) netConfig;
            }
        }
    }
    // validation
    if (netConfig4 == null && netConfig6 == null) {
        throw new KuraException(KuraErrorCode.CONFIGURATION_REQUIRED_ATTRIBUTE_MISSING, "Either IPv4 or IPv6 configuration must be defined");
    }
    if (modemConfig == null) {
        throw new KuraException(KuraErrorCode.CONFIGURATION_REQUIRED_ATTRIBUTE_MISSING, "Modem configuration must be defined");
    }
    List<String> modifiedInterfaceNames = new ArrayList<String>();
    boolean configurationChanged = false;
    ComponentConfiguration originalNetworkComponentConfiguration = ((SelfConfiguringComponent) this.m_networkConfigurationService).getConfiguration();
    if (originalNetworkComponentConfiguration == null) {
        return;
    }
    try {
        NetworkConfiguration newNetworkConfiguration = new NetworkConfiguration(originalNetworkComponentConfiguration.getConfigurationProperties());
        List<NetInterfaceConfig<? extends NetInterfaceAddressConfig>> netInterfaceConfigs = newNetworkConfiguration.getNetInterfaceConfigs();
        for (NetInterfaceConfig<? extends NetInterfaceAddressConfig> netInterfaceConfig : netInterfaceConfigs) {
            if (netInterfaceConfig.getName().equals(interfaceName)) {
                // handle MTU
                if (mtu != netInterfaceConfig.getMTU()) {
                    AbstractNetInterface<?> absNetInterfaceConfig = (AbstractNetInterface<?>) netInterfaceConfig;
                    s_logger.debug("updating MTU for {}", interfaceName);
                    absNetInterfaceConfig.setMTU(mtu);
                    configurationChanged = true;
                    if (!modifiedInterfaceNames.contains(interfaceName)) {
                        modifiedInterfaceNames.add(interfaceName);
                    }
                }
                if (netInterfaceConfig instanceof ModemInterfaceConfigImpl) {
                    ModemInterfaceConfigImpl modemInterfaceConfig = (ModemInterfaceConfigImpl) netInterfaceConfig;
                    if (modemId == null) {
                        modemId = "";
                    }
                    // handle modem id
                    if (!modemId.equals(modemInterfaceConfig.getModemIdentifier())) {
                        s_logger.debug("updating Modem identifier: {}", modemId);
                        modemInterfaceConfig.setModemIdentifier(modemId);
                        configurationChanged = true;
                        if (!modifiedInterfaceNames.contains(interfaceName)) {
                            modifiedInterfaceNames.add(interfaceName);
                        }
                    }
                    // handle ppp num
                    if (pppNumber != modemInterfaceConfig.getPppNum()) {
                        s_logger.debug("updating PPP number: {}", pppNumber);
                        modemInterfaceConfig.setPppNum(pppNumber);
                        configurationChanged = true;
                        if (!modifiedInterfaceNames.contains(interfaceName)) {
                            modifiedInterfaceNames.add(interfaceName);
                        }
                    }
                }
                // replace existing configs
                List<? extends NetInterfaceAddressConfig> netInterfaceAddressConfigs = netInterfaceConfig.getNetInterfaceAddresses();
                if (netInterfaceAddressConfigs != null && !netInterfaceAddressConfigs.isEmpty()) {
                    for (NetInterfaceAddressConfig netInterfaceAddressConfig : netInterfaceAddressConfigs) {
                        List<NetConfig> existingNetConfigs = netInterfaceAddressConfig.getConfigs();
                        List<NetConfig> newNetConfigs = new ArrayList<NetConfig>();
                        for (NetConfig netConfig : existingNetConfigs) {
                            s_logger.debug("looking at existing NetConfig for {} with value: {}", interfaceName, netConfig);
                            if (netConfig instanceof NetConfigIP4) {
                                if (netConfig4 == null) {
                                    s_logger.debug("removing NetConfig4 for {}", interfaceName);
                                } else {
                                    hadNetConfig4 = true;
                                    newNetConfigs.add(netConfig4);
                                    if (!netConfig.equals(netConfig4)) {
                                        s_logger.debug("updating NetConfig4 for {}", interfaceName);
                                        s_logger.debug("Is new State DHCP? {}", netConfig4.isDhcp());
                                        configurationChanged = true;
                                        if (!modifiedInterfaceNames.contains(interfaceName)) {
                                            modifiedInterfaceNames.add(interfaceName);
                                        }
                                    } else {
                                        s_logger.debug("not updating NetConfig4 for {} because it is unchanged", interfaceName);
                                    }
                                }
                            } else if (netConfig instanceof NetConfig6) {
                                if (netConfig6 == null) {
                                    s_logger.debug("removing NetConfig6 for {}", interfaceName);
                                } else {
                                    hadNetConfig6 = true;
                                    newNetConfigs.add(netConfig6);
                                    if (!netConfig.equals(netConfig6)) {
                                        s_logger.debug("updating NetConfig6 for {}", interfaceName);
                                        configurationChanged = true;
                                        if (!modifiedInterfaceNames.contains(interfaceName)) {
                                            modifiedInterfaceNames.add(interfaceName);
                                        }
                                    } else {
                                        s_logger.debug("not updating NetConfig6 for {} because it is unchanged", interfaceName);
                                    }
                                }
                            } else if (netConfig instanceof ModemConfig) {
                                if (modemConfig == null) {
                                    s_logger.debug("removing ModemConfig for {}", interfaceName);
                                } else {
                                    hadModemConfig = true;
                                    newNetConfigs.add(modemConfig);
                                    if (!netConfig.equals(modemConfig)) {
                                        s_logger.debug("updating ModemConfig for {}", interfaceName);
                                        configurationChanged = true;
                                        if (!modifiedInterfaceNames.contains(interfaceName)) {
                                            modifiedInterfaceNames.add(interfaceName);
                                        }
                                    } else {
                                        s_logger.debug("not updating ModemConfig for {} because it is unchanged", interfaceName);
                                    }
                                }
                            } else {
                                s_logger.debug("Found unsupported configuration: {}", netConfig.toString());
                            }
                        }
                        // add configs that did not match any in the current configuration
                        if (netConfigs != null && !netConfigs.isEmpty()) {
                            for (NetConfig netConfig : netConfigs) {
                                if (netConfig instanceof NetConfigIP4 && !hadNetConfig4) {
                                    s_logger.debug("adding new NetConfig4 to existing config for {}", interfaceName);
                                    newNetConfigs.add(netConfig);
                                    configurationChanged = true;
                                    if (!modifiedInterfaceNames.contains(interfaceName)) {
                                        modifiedInterfaceNames.add(interfaceName);
                                    }
                                }
                                if (netConfig instanceof NetConfigIP6 && !hadNetConfig6) {
                                    s_logger.debug("adding new NetConfig6 to existing config for {}", interfaceName);
                                    newNetConfigs.add(netConfig);
                                    configurationChanged = true;
                                    if (!modifiedInterfaceNames.contains(interfaceName)) {
                                        modifiedInterfaceNames.add(interfaceName);
                                    }
                                }
                                if (netConfig instanceof ModemConfig && !hadModemConfig) {
                                    s_logger.debug("adding new ModemConfig to existing config for {}", interfaceName);
                                    newNetConfigs.add(netConfig);
                                    configurationChanged = true;
                                    if (!modifiedInterfaceNames.contains(interfaceName)) {
                                        modifiedInterfaceNames.add(interfaceName);
                                    }
                                }
                            }
                        }
                        for (NetConfig netConfig : newNetConfigs) {
                            s_logger.debug("Current NetConfig: {} :: {}", netConfig.getClass(), netConfig);
                        }
                        // replace with new list
                        ((ModemInterfaceAddressConfigImpl) netInterfaceAddressConfig).setNetConfigs(newNetConfigs);
                    }
                }
            }
            newNetworkConfiguration.addNetInterfaceConfig(netInterfaceConfig);
        }
        if (configurationChanged) {
            submitNetworkConfiguration(modifiedInterfaceNames, newNetworkConfiguration);
        }
    } catch (UnknownHostException e) {
        s_logger.warn("Exception while updating ModemInterfaceConfig", e);
    }
}
Also used : ModemInterfaceAddressConfigImpl(org.eclipse.kura.core.net.modem.ModemInterfaceAddressConfigImpl) NetInterfaceConfig(org.eclipse.kura.net.NetInterfaceConfig) UnknownHostException(java.net.UnknownHostException) NetConfig6(org.eclipse.kura.net.NetConfig6) ArrayList(java.util.ArrayList) AbstractNetInterface(org.eclipse.kura.core.net.AbstractNetInterface) NetConfigIP4(org.eclipse.kura.net.NetConfigIP4) SelfConfiguringComponent(org.eclipse.kura.configuration.SelfConfiguringComponent) ComponentConfiguration(org.eclipse.kura.configuration.ComponentConfiguration) NetConfigIP6(org.eclipse.kura.net.NetConfigIP6) ModemConfig(org.eclipse.kura.net.modem.ModemConfig) ModemInterfaceConfigImpl(org.eclipse.kura.core.net.modem.ModemInterfaceConfigImpl) KuraException(org.eclipse.kura.KuraException) NetConfig(org.eclipse.kura.net.NetConfig) NetworkConfiguration(org.eclipse.kura.core.net.NetworkConfiguration) NetInterfaceAddressConfig(org.eclipse.kura.net.NetInterfaceAddressConfig)

Aggregations

ModemInterfaceConfigImpl (org.eclipse.kura.core.net.modem.ModemInterfaceConfigImpl)8 NetInterfaceAddressConfig (org.eclipse.kura.net.NetInterfaceAddressConfig)7 NetConfig (org.eclipse.kura.net.NetConfig)6 ModemInterfaceAddressConfigImpl (org.eclipse.kura.core.net.modem.ModemInterfaceAddressConfigImpl)5 ArrayList (java.util.ArrayList)4 KuraException (org.eclipse.kura.KuraException)4 NetConfigIP4 (org.eclipse.kura.net.NetConfigIP4)4 UnknownHostException (java.net.UnknownHostException)3 IP4Address (org.eclipse.kura.net.IP4Address)3 EthernetInterfaceConfigImpl (org.eclipse.kura.core.net.EthernetInterfaceConfigImpl)2 LoopbackInterfaceConfigImpl (org.eclipse.kura.core.net.LoopbackInterfaceConfigImpl)2 NetworkConfiguration (org.eclipse.kura.core.net.NetworkConfiguration)2 WifiInterfaceConfigImpl (org.eclipse.kura.core.net.WifiInterfaceConfigImpl)2 LinuxDns (org.eclipse.kura.linux.net.dns.LinuxDns)2 IPAddress (org.eclipse.kura.net.IPAddress)2 NetConfigIP6 (org.eclipse.kura.net.NetConfigIP6)2 NetInterfaceAddress (org.eclipse.kura.net.NetInterfaceAddress)2 ModemInterfaceAddressConfig (org.eclipse.kura.net.modem.ModemInterfaceAddressConfig)2 WifiInterfaceAddressConfig (org.eclipse.kura.net.wifi.WifiInterfaceAddressConfig)2 EnumSet (java.util.EnumSet)1