org.fourthline.cling.support.model.PortMapping Java Examples

The following examples show how to use org.fourthline.cling.support.model.PortMapping. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PortMappingAdd.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
protected PortMappingAdd(Service service, ControlPoint controlPoint, PortMapping portMapping) {
    super(new ActionInvocation(service.getAction("AddPortMapping")), controlPoint);

    this.portMapping = portMapping;

    getActionInvocation().setInput("NewExternalPort", portMapping.getExternalPort());
    getActionInvocation().setInput("NewProtocol", portMapping.getProtocol());
    getActionInvocation().setInput("NewInternalClient", portMapping.getInternalClient());
    getActionInvocation().setInput("NewInternalPort", portMapping.getInternalPort());
    getActionInvocation().setInput("NewLeaseDuration", portMapping.getLeaseDurationSeconds());
    getActionInvocation().setInput("NewEnabled", portMapping.isEnabled());
    if (portMapping.hasRemoteHost())
        getActionInvocation().setInput("NewRemoteHost", portMapping.getRemoteHost());
    if (portMapping.hasDescription())
        getActionInvocation().setInput("NewPortMappingDescription", portMapping.getDescription());

}
 
Example #2
Source File: PortMappingAdd.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
protected PortMappingAdd(Service service, ControlPoint controlPoint, PortMapping portMapping) {
    super(new ActionInvocation(service.getAction("AddPortMapping")), controlPoint);

    this.portMapping = portMapping;

    getActionInvocation().setInput("NewExternalPort", portMapping.getExternalPort());
    getActionInvocation().setInput("NewProtocol", portMapping.getProtocol());
    getActionInvocation().setInput("NewInternalClient", portMapping.getInternalClient());
    getActionInvocation().setInput("NewInternalPort", portMapping.getInternalPort());
    getActionInvocation().setInput("NewLeaseDuration", portMapping.getLeaseDurationSeconds());
    getActionInvocation().setInput("NewEnabled", portMapping.isEnabled());
    if (portMapping.hasRemoteHost())
        getActionInvocation().setInput("NewRemoteHost", portMapping.getRemoteHost());
    if (portMapping.hasDescription())
        getActionInvocation().setInput("NewPortMappingDescription", portMapping.getDescription());

}
 
Example #3
Source File: UpnpPortMapper.java    From bt with Apache License 2.0 5 votes vote down vote up
@Override
public void mapPort(final int port, final String address, final PortMapProtocol protocol, final String mappingDescription) {
    LOG.debug("Mapping port: [{}] for address: [{}] with description: [{}].", port, address, mappingDescription);
    final Protocol resolvedProtocol = resolveProtocol(protocol);
    final PortMapping portMapping = new PortMapping(port, address, resolvedProtocol, mappingDescription);
    mappingServicesRegistrar.registerPortMapping(portMapping);
    LOG.debug("Port: [{}] for address: [{}] with description: [{}] has been mapped.", port, address, mappingDescription);
}
 
Example #4
Source File: PortMappingDelete.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected PortMappingDelete(Service service, ControlPoint controlPoint, PortMapping portMapping) {
    super(new ActionInvocation(service.getAction("DeletePortMapping")), controlPoint);

    this.portMapping = portMapping;

    getActionInvocation().setInput("NewExternalPort", portMapping.getExternalPort());
    getActionInvocation().setInput("NewProtocol", portMapping.getProtocol());
    if (portMapping.hasRemoteHost())
        getActionInvocation().setInput("NewRemoteHost", portMapping.getRemoteHost());

}
 
Example #5
Source File: PortMappingListener.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
synchronized public void deviceRemoved(Registry registry, Device device) {
    for (Service service : device.findServices()) {
        Iterator<Map.Entry<Service, List<PortMapping>>> it = activePortMappings.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry<Service, List<PortMapping>> activeEntry = it.next();
            if (!activeEntry.getKey().equals(service)) continue;

            if (activeEntry.getValue().size() > 0)
                handleFailureMessage("Device disappeared, couldn't delete port mappings: " + activeEntry.getValue().size());

            it.remove();
        }
    }
}
 
Example #6
Source File: PortMappingDelete.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected PortMappingDelete(Service service, ControlPoint controlPoint, PortMapping portMapping) {
    super(new ActionInvocation(service.getAction("DeletePortMapping")), controlPoint);

    this.portMapping = portMapping;

    getActionInvocation().setInput("NewExternalPort", portMapping.getExternalPort());
    getActionInvocation().setInput("NewProtocol", portMapping.getProtocol());
    if (portMapping.hasRemoteHost())
        getActionInvocation().setInput("NewRemoteHost", portMapping.getRemoteHost());

}
 
Example #7
Source File: PortMappingListener.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
@Override
synchronized public void deviceRemoved(Registry registry, Device device) {
    for (Service service : device.findServices()) {
        Iterator<Map.Entry<Service, List<PortMapping>>> it = activePortMappings.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry<Service, List<PortMapping>> activeEntry = it.next();
            if (!activeEntry.getKey().equals(service)) continue;

            if (activeEntry.getValue().size() > 0)
                handleFailureMessage("Device disappeared, couldn't delete port mappings: " + activeEntry.getValue().size());

            it.remove();
        }
    }
}
 
Example #8
Source File: PortMappingAdd.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public PortMappingAdd(Service service, PortMapping portMapping) {
    this(service, null, portMapping);
}
 
Example #9
Source File: UpnpPortMappingServicesRegistrar.java    From bt with Apache License 2.0 4 votes vote down vote up
/**
 * Creates corresponding UPNP serive for port mapping.
 *
 * @param portMapping desired port mapping;
 */
public void registerPortMapping(PortMapping portMapping) {
    final UpnpService service = new UpnpServiceImpl(upnpServiceConfiguration, new PortMappingListener(portMapping));
    service.getControlPoint().search();
    bindShutdownHook(service);
}
 
Example #10
Source File: PortMappingListener.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public PortMappingListener(PortMapping portMapping) {
    this(new PortMapping[]{portMapping});
}
 
Example #11
Source File: ClingRouter.java    From subsonic with GNU General Public License v3.0 4 votes vote down vote up
private PortMapping createPortMapping(int port) throws UnknownHostException {
    String localIp = InetAddress.getLocalHost().getHostAddress();
    return new PortMapping(port, localIp, PortMapping.Protocol.TCP, "Subsonic");
}
 
Example #12
Source File: PortMappingListener.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public PortMappingListener(PortMapping portMapping) {
    this(new PortMapping[]{portMapping});
}
 
Example #13
Source File: PortMappingListener.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public PortMappingListener(PortMapping[] portMappings) {
    this.portMappings = portMappings;
}
 
Example #14
Source File: PortMappingDelete.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public PortMappingDelete(Service service, PortMapping portMapping) {
    this(service, null, portMapping);
}
 
Example #15
Source File: PortMappingDelete.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public PortMappingDelete(Service service, PortMapping portMapping) {
    this(service, null, portMapping);
}
 
Example #16
Source File: PortMappingAdd.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public PortMappingAdd(Service service, PortMapping portMapping) {
    this(service, null, portMapping);
}
 
Example #17
Source File: PortMappingListener.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public PortMappingListener(PortMapping[] portMappings) {
    this.portMappings = portMappings;
}