|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.tomp2p.upnp.InternetGatewayDevice
public class InternetGatewayDevice
This class can be used to access some functionalities on the InternetGatewayDevice on your network without having to know anything about the required input/output parameters. All device functions are not provided.
Method Summary | |
---|---|
boolean |
addPortMapping(String description,
String protocol,
String internalHost,
int externalPort,
int internalPort)
|
boolean |
addPortMapping(String description,
String protocol,
String remoteHost,
int externalPort,
String internalClient,
int internalPort,
int leaseDuration)
Configures a nat entry on the UPNP device. |
boolean |
deletePortMapping(String remoteHost,
int externalPort,
String protocol)
Deletes a port mapping on the IDG device |
static Collection<InternetGatewayDevice> |
getDevices(int timeout)
Lookup all the IGD (IP or PPP) devices on the network. |
static Collection<InternetGatewayDevice> |
getDevices(int timeout,
int ttl,
int mx,
NetworkInterface ni)
Lookup all the IGD (IP urn:schemas-upnp-org:service:WANIPConnection:1, or PPP urn:schemas-upnp-org:service:WANPPPConnection:1) devices for a given network interface. |
String |
getExternalIPAddress()
Retrieves the external IP address |
ActionResponse |
getGenericPortMappingEntry(int newPortMappingIndex)
Retrieves a generic port mapping entry. |
RootDevice |
getIGDRootDevice()
Retrieves the IDG UNPNRootDevice object |
Integer |
getNatMappingsCount()
Retrieves the current number of mapping in the NAT table |
ActionResponse |
getSpecificPortMappingEntry(String remoteHost,
int externalPort,
String protocol)
Retrieves information about a specific port mapping |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public RootDevice getIGDRootDevice()
public static Collection<InternetGatewayDevice> getDevices(int timeout) throws IOException
timeout
- the timeout in ms to listen for devices response, -1 for default value
IOException
- if some IO Exception occurs during discoverypublic static Collection<InternetGatewayDevice> getDevices(int timeout, int ttl, int mx, NetworkInterface ni) throws IOException
timeout
- the timeout in ms to listen for devices response, -1 for default valuettl
- the discovery ttl such as Discovery.DEFAULT_TTL
mx
- the discovery mx such as Discovery.DEFAULT_MX
ni
- the network interface where to lookup IGD devices
IOException
- if some IO Exception occurs during discoverypublic String getExternalIPAddress() throws UPNPResponseException, IOException
UPNPResponseException
- if the devices returns an error code
IOException
- if some error occurs during communication with the devicepublic ActionResponse getGenericPortMappingEntry(int newPortMappingIndex) throws IOException, UPNPResponseException
newPortMappingIndex
- the index to lookup in the nat table of the upnp device
IOException
- if some error occurs during communication with the device
UPNPResponseException
- if some unexpected error occurs on the UPNP devicepublic ActionResponse getSpecificPortMappingEntry(String remoteHost, int externalPort, String protocol) throws IOException, UPNPResponseException
remoteHost
- the remote host ip to check, null if wildcardexternalPort
- the port to checkprotocol
- the protocol for the mapping, either TCP or UDP
IOException
- if some error occurs during communication with the device
UPNPResponseException
- if some unexpected error occurs on the UPNP devicepublic boolean addPortMapping(String description, String protocol, String internalHost, int externalPort, int internalPort) throws IOException, UPNPResponseException
IOException
UPNPResponseException
public boolean addPortMapping(String description, String protocol, String remoteHost, int externalPort, String internalClient, int internalPort, int leaseDuration) throws IOException, UPNPResponseException
description
- the mapping description, null for no descriptionprotocol
- the protocol, either TCP or UDPremoteHost
- the remote host ip for this entry, null for a wildcard valueexternalPort
- the external port to open on the UPNP device an map on the internal client, 0 for a wildcard
valueinternalClient
- the internal client ip where data should be redirectedinternalPort
- the internal client port where data should be redirectedleaseDuration
- the lease duration in seconds 0 for an infinite time
IOException
- if some error occurs during communication with the device
UPNPResponseException
- if the device does not accept some settings :public boolean deletePortMapping(String remoteHost, int externalPort, String protocol) throws IOException, UPNPResponseException
remoteHost
- the host ip for which the mapping was done, null value for a wildcard valueexternalPort
- the port to closeprotocol
- the protocol for the mapping, TCP or UDP
IOException
- if some error occurs during communication with the device
UPNPResponseException
- if the devices returns an error messagepublic Integer getNatMappingsCount() throws IOException, UPNPResponseException
IOException
- if some error occurs during communication with the device
UPNPResponseException
- if the devices returns an error message with error code other than 404
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |