protected void addService(UPnPWANConnection wan_service) throws UPnPException { wan_service.addListener(this); mapping_manager.serviceFound(wan_service); try { this_mon.enter(); log.log( " Found " + (wan_service.getGenericService().getServiceType().indexOf("PPP") == -1 ? "WANIPConnection" : "WANPPPConnection")); UPnPWANConnectionPortMapping[] ports; String usn = wan_service.getGenericService().getDevice().getRootDevice().getUSN(); if (getDeviceStats(usn, STATS_READ_OK) == 0 && getDeviceStats(usn, STATS_READ_BAD) > 2) { ports = new UPnPWANConnectionPortMapping[0]; wan_service.periodicallyRecheckMappings(false); log.log(" Not reading port mappings from device due to previous failures"); } else { ports = wan_service.getPortMappings(); } for (int j = 0; j < ports.length; j++) { log.log( " mapping [" + j + "] " + ports[j].getExternalPort() + "/" + (ports[j].isTCP() ? "TCP" : "UDP") + " [" + ports[j].getDescription() + "] -> " + ports[j].getInternalHost()); } services.add( new UPnPPluginService( wan_service, ports, alert_success_param, grab_ports_param, alert_other_port_param, release_mappings_param)); if (services.size() > 1) { // check this isn't a single device with multiple services String new_usn = wan_service.getGenericService().getDevice().getRootDevice().getUSN(); boolean multiple_found = false; for (int i = 0; i < services.size() - 1; i++) { UPnPPluginService service = (UPnPPluginService) services.get(i); String existing_usn = service.getService().getGenericService().getDevice().getRootDevice().getUSN(); if (!new_usn.equals(existing_usn)) { multiple_found = true; break; } } if (multiple_found) { PluginConfig pc = plugin_interface.getPluginconfig(); if (!pc.getPluginBooleanParameter("upnp.device.multipledevices.warned", false)) { pc.setPluginParameter("upnp.device.multipledevices.warned", true); String text = MessageText.getString("upnp.alert.multipledevice.warning"); log.logAlertRepeatable(LoggerChannel.LT_WARNING, text); } } } checkState(); } finally { this_mon.exit(); } }