Search in sources :

Example 36 with NetInterfaceAddressConfig

use of org.eclipse.kura.net.NetInterfaceAddressConfig in project kura by eclipse.

the class NetworkConfiguration method addNetConfig.

public void addNetConfig(String interfaceName, NetInterfaceType netInterfaceType, NetConfig netConfig) throws KuraException {
    NetInterfaceConfig<? extends NetInterfaceAddressConfig> netInterfaceConfig = this.m_netInterfaceConfigs.get(interfaceName);
    if (netInterfaceConfig == null) {
        switch(netInterfaceType) {
            case LOOPBACK:
                netInterfaceConfig = new LoopbackInterfaceConfigImpl(interfaceName);
                break;
            case ETHERNET:
                netInterfaceConfig = new EthernetInterfaceConfigImpl(interfaceName);
                break;
            case WIFI:
                netInterfaceConfig = new WifiInterfaceConfigImpl(interfaceName);
                break;
            case MODEM:
                netInterfaceConfig = new ModemInterfaceConfigImpl(interfaceName);
            default:
                break;
        }
    }
    List<? extends NetInterfaceAddressConfig> netInterfaceAddressConfigs = netInterfaceConfig.getNetInterfaceAddresses();
    s_logger.trace("Adding a netConfig: {}", netConfig);
    for (NetInterfaceAddressConfig netInterfaceAddressConfig : netInterfaceAddressConfigs) {
        NetInterfaceAddressConfigImpl netInterfaceAddressConfigImpl = (NetInterfaceAddressConfigImpl) netInterfaceAddressConfig;
        List<NetConfig> netConfigs = netInterfaceAddressConfig.getConfigs();
        netConfigs.add(netConfig);
        netInterfaceAddressConfigImpl.setNetConfigs(netConfigs);
    }
    this.m_recomputeProperties = true;
}
Also used : ModemInterfaceConfigImpl(org.eclipse.kura.core.net.modem.ModemInterfaceConfigImpl) NetConfig(org.eclipse.kura.net.NetConfig) NetInterfaceAddressConfig(org.eclipse.kura.net.NetInterfaceAddressConfig)

Aggregations

NetInterfaceAddressConfig (org.eclipse.kura.net.NetInterfaceAddressConfig)36 NetConfig (org.eclipse.kura.net.NetConfig)31 KuraException (org.eclipse.kura.KuraException)21 NetConfigIP4 (org.eclipse.kura.net.NetConfigIP4)20 ArrayList (java.util.ArrayList)11 IOException (java.io.IOException)10 FirewallAutoNatConfig (org.eclipse.kura.net.firewall.FirewallAutoNatConfig)10 WifiMode (org.eclipse.kura.net.wifi.WifiMode)10 UnknownHostException (java.net.UnknownHostException)9 IP4Address (org.eclipse.kura.net.IP4Address)9 WifiConfig (org.eclipse.kura.net.wifi.WifiConfig)9 WifiInterfaceAddressConfig (org.eclipse.kura.net.wifi.WifiInterfaceAddressConfig)9 IPAddress (org.eclipse.kura.net.IPAddress)8 NetInterfaceConfig (org.eclipse.kura.net.NetInterfaceConfig)8 WifiInterfaceAddressConfigImpl (org.eclipse.kura.core.net.WifiInterfaceAddressConfigImpl)7 ModemInterfaceConfigImpl (org.eclipse.kura.core.net.modem.ModemInterfaceConfigImpl)7 NetInterfaceType (org.eclipse.kura.net.NetInterfaceType)7 Properties (java.util.Properties)6 NetConfigIP6 (org.eclipse.kura.net.NetConfigIP6)6 NetInterfaceStatus (org.eclipse.kura.net.NetInterfaceStatus)6