use of org.eclipse.kura.usb.UsbNetDevice 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));
}
}
}
use of org.eclipse.kura.usb.UsbNetDevice in project kura by eclipse.
the class LinuxUdevNative method callback.
/*
* WARNING
*
* The callback does not fire for devices open by a process
* when the device is unplugged from the USB.
* Note that `udevadm monitor' correctly reports removal of these devices so there
* must be something wrong with our native code using libudev.
*
* On top of that information for detached (UdevEventType.DETACHED) devices is completely unreliable:
* missing manufacturer and product names, wrong VID&PID (often the one of the
* USB hub the device was attached to), wrong USB path (often the path of the USB hub
* the device was attached to).
* The only reliable information seems to be the device node name, e.g. ttyACM0.
*
* Information for devices being attached (UdevEventType.ATTACHED) seems to work more reliably.
* The callback might still fire with wrong/incomplete information but EVENTUALLY
* we get all the devices with the right information.
*
*/
private void callback(String type, UsbDevice usbDevice) {
s_logger.debug("TYPE: {}", usbDevice.getClass());
s_logger.debug("\tmanfufacturer name: {}", usbDevice.getManufacturerName());
s_logger.debug("\tproduct name: {}", usbDevice.getProductName());
s_logger.debug("\tvendor ID: {}", usbDevice.getVendorId());
s_logger.debug("\tproduct ID: {}", usbDevice.getProductId());
s_logger.debug("\tUSB Bus Number: {}", usbDevice.getUsbBusNumber());
if (usbDevice instanceof UsbBlockDevice) {
String name = ((UsbBlockDevice) usbDevice).getDeviceNode();
if (name != null) {
if (type.compareTo(UdevEventType.ATTACHED.name()) == 0) {
/*
* FIXME: does an already existing device, with the same name,
* need to be removed first?
*/
m_blockDevices.put(name, (UsbBlockDevice) usbDevice);
this.m_linuxUdevListener.attached(usbDevice);
} else if (type.compareTo(UdevEventType.DETACHED.name()) == 0) {
/*
* Due to the above limitations,
* the best we can do is to remove the device from the
* map of already known devices by its name.
*/
UsbBlockDevice removedDevice = m_blockDevices.remove(name);
if (removedDevice != null) {
this.m_linuxUdevListener.detached(removedDevice);
}
} else {
s_logger.debug("Unknown udev event: {}", type);
}
}
} else if (usbDevice instanceof UsbNetDevice) {
String name = ((UsbNetDevice) usbDevice).getInterfaceName();
if (name != null) {
if (type.compareTo(UdevEventType.ATTACHED.name()) == 0) {
m_netDevices.put(name, (UsbNetDevice) usbDevice);
this.m_linuxUdevListener.attached(usbDevice);
} else if (type.compareTo(UdevEventType.DETACHED.name()) == 0) {
UsbNetDevice removedDevice = m_netDevices.remove(name);
if (removedDevice != null) {
this.m_linuxUdevListener.detached(removedDevice);
}
} else {
s_logger.debug("Unknown udev event: {}", type);
}
}
} else if (usbDevice instanceof UsbTtyDevice) {
String name = ((UsbTtyDevice) usbDevice).getDeviceNode();
if (name != null) {
if (type.compareTo(UdevEventType.ATTACHED.name()) == 0) {
m_ttyDevices.put(name, (UsbTtyDevice) usbDevice);
this.m_linuxUdevListener.attached(usbDevice);
} else if (type.compareTo(UdevEventType.DETACHED.name()) == 0) {
UsbTtyDevice removedDevice = m_ttyDevices.remove(name);
if (removedDevice != null) {
this.m_linuxUdevListener.detached(removedDevice);
}
} else {
s_logger.debug("Unknown udev event: {}", type);
}
}
}
}
use of org.eclipse.kura.usb.UsbNetDevice in project kura by eclipse.
the class UsbServiceImpl method attached.
@Override
public synchronized void attached(UsbDevice device) {
s_logger.debug("firing UsbDeviceAddedEvent for: {}", device);
Map<String, String> map = new HashMap<String, String>();
map.put(UsbDeviceEvent.USB_EVENT_USB_PORT_PROPERTY, device.getUsbPort());
map.put(UsbDeviceEvent.USB_EVENT_VENDOR_ID_PROPERTY, device.getVendorId());
map.put(UsbDeviceEvent.USB_EVENT_PRODUCT_ID_PROPERTY, device.getProductId());
map.put(UsbDeviceEvent.USB_EVENT_MANUFACTURER_NAME_PROPERTY, device.getManufacturerName());
map.put(UsbDeviceEvent.USB_EVENT_PRODUCT_NAME_PROPERTY, device.getProductName());
map.put(UsbDeviceEvent.USB_EVENT_BUS_NUMBER_PROPERTY, device.getUsbBusNumber());
map.put(UsbDeviceEvent.USB_EVENT_DEVICE_PATH_PROPERTY, device.getUsbDevicePath());
if (device instanceof UsbBlockDevice) {
map.put(UsbDeviceEvent.USB_EVENT_RESOURCE_PROPERTY, ((UsbBlockDevice) device).getDeviceNode());
} else if (device instanceof UsbNetDevice) {
map.put(UsbDeviceEvent.USB_EVENT_RESOURCE_PROPERTY, ((UsbNetDevice) device).getInterfaceName());
} else if (device instanceof UsbTtyDevice) {
map.put(UsbDeviceEvent.USB_EVENT_RESOURCE_PROPERTY, ((UsbTtyDevice) device).getDeviceNode());
}
this.m_eventAdmin.postEvent(new UsbDeviceAddedEvent(map));
}
use of org.eclipse.kura.usb.UsbNetDevice in project kura by eclipse.
the class NetworkConfigurationServiceImpl method getDefinition.
private Tocd getDefinition() throws KuraException {
ObjectFactory objectFactory = new ObjectFactory();
Tocd tocd = objectFactory.createTocd();
tocd.setName("NetworkConfigurationService");
tocd.setId("org.eclipse.kura.net.admin.NetworkConfigurationService");
tocd.setDescription("Network Configuration Service");
// get the USB network interfaces (if any)
List<UsbNetDevice> usbNetDevices = this.m_usbService.getUsbNetDevices();
Tad tad = objectFactory.createTad();
tad.setId("net.interfaces");
tad.setName("net.interfaces");
tad.setType(Tscalar.STRING);
tad.setCardinality(10000);
tad.setRequired(true);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.PLATFORM_INTERFACES));
tocd.addAD(tad);
// Get the network interfaces on the platform
try {
List<String> networkInterfaceNames = LinuxNetworkUtil.getAllInterfaceNames();
for (String ifaceName : networkInterfaceNames) {
// get the current configuration for this interface
NetInterfaceType type = LinuxNetworkUtil.getType(ifaceName);
String prefix = "net.interface.";
if (type == NetInterfaceType.LOOPBACK) {
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.mtu").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.mtu").toString());
tad.setType(Tscalar.INTEGER);
tad.setCardinality(0);
tad.setRequired(true);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_MTU));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.autoconnect").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.autoconnect").toString());
tad.setType(Tscalar.BOOLEAN);
tad.setCardinality(0);
tad.setRequired(true);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_AUTOCONNECT));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.driver").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.driver").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_DRIVER));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.address").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.address").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_ADDRESS));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.prefix").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.prefix").toString());
tad.setType(Tscalar.SHORT);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_PREFIX));
tocd.addAD(tad);
} else if (type == NetInterfaceType.ETHERNET || type == NetInterfaceType.WIFI) {
if (usbNetDevices != null) {
for (UsbNetDevice usbNetDevice : usbNetDevices) {
if (usbNetDevice.getInterfaceName().equals(ifaceName)) {
// found a match - add the read only fields?
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".usb.port").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".usb.port").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.USB_PORT));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".usb.manufacturer").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".usb.manfacturer").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.USB_MANUFACTURER));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".usb.product").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".usb.product").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.USB_PRODUCT));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".usb.manufacturer.id").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".usb.manfacturer.id").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.USB_MANUFACTURER_ID));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".usb.product.id").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".usb.product.id").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.USB_PRODUCT_ID));
tocd.addAD(tad);
// no need to continue
break;
}
}
}
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.mtu").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.mtu").toString());
tad.setType(Tscalar.INTEGER);
tad.setCardinality(0);
tad.setRequired(true);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_MTU));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.autoconnect").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.autoconnect").toString());
tad.setType(Tscalar.BOOLEAN);
tad.setCardinality(0);
tad.setRequired(true);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_AUTOCONNECT));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpClient4.enabled").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpClient4.enabled").toString());
tad.setType(Tscalar.BOOLEAN);
tad.setCardinality(0);
tad.setRequired(true);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_DHCP_CLIENT_ENABLED));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.address").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.address").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_ADDRESS));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.prefix").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.prefix").toString());
tad.setType(Tscalar.SHORT);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_PREFIX));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.gateway").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.gateway").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_GATEWAY));
tocd.addAD(tad);
// DNS and WINS
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.dnsServers").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.dnsServers").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(10000);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_DNS_SERVERS));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.winsServers").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.winsServers").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(10000);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WINS_SERVERS));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.enabled").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.enabled").toString());
tad.setType(Tscalar.BOOLEAN);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_DHCP_SERVER_ENABLED));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.defaultLeaseTime").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.defaultLeaseTime").toString());
tad.setType(Tscalar.INTEGER);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_DHCP_SERVER_DEFAULT_LEASE_TIME));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.maxLeaseTime").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.maxLeaseTime").toString());
tad.setType(Tscalar.INTEGER);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_DHCP_SERVER_MAX_LEASE_TIME));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.prefix").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.prefix").toString());
tad.setType(Tscalar.SHORT);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_DHCP_SERVER_PREFIX));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.rangeStart").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.rangeStart").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_DHCP_SERVER_RANGE_START));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.rangeEnd").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.rangeEnd").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_DHCP_SERVER_RANGE_END));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.passDns").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.passDns").toString());
tad.setType(Tscalar.BOOLEAN);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_DHCP_SERVER_PASS_DNS));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.nat.enabled").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.nat.enabled").toString());
tad.setType(Tscalar.BOOLEAN);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_DHCP_SERVER_NAT_ENABLED));
tocd.addAD(tad);
if (type == NetInterfaceType.WIFI) {
// Common
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".wifi.capabilities").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".wifi.capabilities").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.WIFI_CAPABILITIES));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.mode").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.mode").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_MODE));
tocd.addAD(tad);
// INFRA
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.ssid").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.ssid").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_INFRA_SSID));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.hardwareMode").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.hardwareMode").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_INFRA_HARDWARE_MODE));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.radioMode").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.radioMode").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_INFRA_HARDWARE_MODE));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.securityType").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.securityType").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_INFRA_SECURITY_TYPE));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.passphrase").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.passphrase").toString());
tad.setType(Tscalar.PASSWORD);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_INFRA_PASSPHRASE));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.pairwiseCiphers").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.pairwiseCiphers").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_INFRA_PAIRWISE_CIPHERS));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.groupCiphers").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.groupCiphers").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_INFRA_GROUP_CIPHERS));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.channel").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.channel").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_INFRA_CHANNEL));
tocd.addAD(tad);
// MASTER
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.ssid").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.ssid").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_MASTER_SSID));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.broadcast").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.broadcast").toString());
tad.setType(Tscalar.BOOLEAN);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_MASTER_BROADCAST_ENABLED));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.hardwareMode").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.hardwareMode").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_MASTER_HARDWARE_MODE));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.radioMode").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.radioMode").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_MASTER_HARDWARE_MODE));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.securityType").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.securityType").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_MASTER_SECURITY_TYPE));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.passphrase").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.passphrase").toString());
tad.setType(Tscalar.PASSWORD);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_MASTER_PASSPHRASE));
tocd.addAD(tad);
tad = objectFactory.createTad();
tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.channel").toString());
tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.channel").toString());
tad.setType(Tscalar.STRING);
tad.setCardinality(0);
tad.setRequired(false);
tad.setDefault("");
tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_MASTER_CHANNEL));
tocd.addAD(tad);
/*
* // ADHOC
* tad = objectFactory.createTad();
* tad.setId((new
* StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.ssid")).toString()
* );
* tad.setName((new
* StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.ssid")).toString()
* );
* tad.setType(Tscalar.STRING);
* tad.setCardinality(0);
* tad.setRequired(false);
* tad.setDefault("");
* tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.
* CONFIG_WIFI_ADHOC_SSID));
* tocd.addAD(tad);
*
* tad = objectFactory.createTad();
* tad.setId((new
* StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.hardwareMode")).
* toString());
* tad.setName((new
* StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.hardwareMode")).
* toString());
* tad.setType(Tscalar.STRING);
* tad.setCardinality(0);
* tad.setRequired(false);
* tad.setDefault("");
* tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.
* CONFIG_WIFI_ADHOC_HARDWARE_MODE));
* tocd.addAD(tad);
*
* tad = objectFactory.createTad();
* tad.setId((new
* StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.radioMode")).
* toString());
* tad.setName((new
* StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.radioMode")).
* toString());
* tad.setType(Tscalar.STRING);
* tad.setCardinality(0);
* tad.setRequired(false);
* tad.setDefault("");
* tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.
* CONFIG_WIFI_ADHOC_HARDWARE_MODE));
* tocd.addAD(tad);
*
* tad = objectFactory.createTad();
* tad.setId((new
* StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.securityType")).
* toString());
* tad.setName((new
* StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.securityType")).
* toString());
* tad.setType(Tscalar.STRING);
* tad.setCardinality(0);
* tad.setRequired(false);
* tad.setDefault("");
* tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.
* CONFIG_WIFI_ADHOC_SECURITY_TYPE));
* tocd.addAD(tad);
*
* tad = objectFactory.createTad();
* tad.setId((new
* StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.passphrase")).
* toString());
* tad.setName((new
* StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.passphrase")).
* toString());
* tad.setType(Tscalar.STRING);
* tad.setCardinality(0);
* tad.setRequired(false);
* tad.setDefault("");
* tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.
* CONFIG_WIFI_ADHOC_PASSPHRASE));
* tocd.addAD(tad);
*
* tad = objectFactory.createTad();
* tad.setId((new
* StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.channel")).
* toString());
* tad.setName((new
* StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.channel")).
* toString());
* tad.setType(Tscalar.STRING);
* tad.setCardinality(0);
* tad.setRequired(false);
* tad.setDefault("");
* tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.
* CONFIG_WIFI_ADHOC_CHANNEL));
* tocd.addAD(tad);
*/
}
// TODO - deal with USB devices (READ ONLY)
}
}
} catch (Exception e) {
throw new KuraException(KuraErrorCode.CONFIGURATION_ERROR, e);
}
return tocd;
}
use of org.eclipse.kura.usb.UsbNetDevice in project kura by eclipse.
the class UsbServiceImpl method detached.
@Override
public synchronized void detached(UsbDevice device) {
s_logger.debug("firing UsbDeviceRemovedEvent for: {}", device);
Map<String, String> map = new HashMap<String, String>();
map.put(UsbDeviceEvent.USB_EVENT_USB_PORT_PROPERTY, device.getUsbPort());
map.put(UsbDeviceEvent.USB_EVENT_VENDOR_ID_PROPERTY, device.getVendorId());
map.put(UsbDeviceEvent.USB_EVENT_PRODUCT_ID_PROPERTY, device.getProductId());
map.put(UsbDeviceEvent.USB_EVENT_MANUFACTURER_NAME_PROPERTY, device.getManufacturerName());
map.put(UsbDeviceEvent.USB_EVENT_PRODUCT_NAME_PROPERTY, device.getProductName());
map.put(UsbDeviceEvent.USB_EVENT_BUS_NUMBER_PROPERTY, device.getUsbBusNumber());
map.put(UsbDeviceEvent.USB_EVENT_DEVICE_PATH_PROPERTY, device.getUsbDevicePath());
if (device instanceof UsbBlockDevice) {
map.put(UsbDeviceEvent.USB_EVENT_RESOURCE_PROPERTY, ((UsbBlockDevice) device).getDeviceNode());
} else if (device instanceof UsbNetDevice) {
map.put(UsbDeviceEvent.USB_EVENT_RESOURCE_PROPERTY, ((UsbNetDevice) device).getInterfaceName());
} else if (device instanceof UsbTtyDevice) {
map.put(UsbDeviceEvent.USB_EVENT_RESOURCE_PROPERTY, ((UsbTtyDevice) device).getDeviceNode());
}
this.m_eventAdmin.postEvent(new UsbDeviceRemovedEvent(map));
}
Aggregations