Package nattraverso :: Package pynupnp :: Module upnp :: Class UPnPDevice
[show private | hide private]
[frames | no frames]

Class UPnPDevice


Represents an UPnP device, with the associated infos, and remote methods.
Method Summary
  __init__(self, soap_proxy, info)
Build the device, with the given SOAP proxy, and the meta-infos.
twisted.internet.defer.Deferred add_port_mapping(self, local_ip, intport, extport, desc, proto, lease)
Add a port mapping in the upnp device.
twisted.internet.defer.Deferred get_external_ip(self)
Triggers an external ip discovery on the upnp device.
twisted.internet.defer.Deferred get_port_mappings(self)
Retreive the existing port mappings
twisted.internet.defer.Deferred remove_port_mapping(self, extport, proto)
Remove an existing port mapping on the device.
twisted.internet.defer.Deferred _get_port_mapping(self, mapping_id, mappings)
Fetch the existing mappings starting at index "mapping_id" from the device.
  _on_external_ip(self, res)
Called when we received the external ip address from the device.
  _on_no_port_mapping_added(self, failure)
Called when the port mapping could not be added.
  _on_no_port_mapping_received(self, failure, mappings)
Called when we have no more port mappings to retreive, or an error occured while retreiving them.
  _on_no_port_mapping_removed(self, failure)
Called when the port mapping could not be removed.
  _on_port_mapping_added(self, response)
The port mapping was successfully added, return None to the deferred.
twisted.internet.defer.Deferred _on_port_mapping_received(self, response, mapping_id, mappings)
Called we we receive a single mapping from the device.
  _on_port_mapping_removed(self, response)
The port mapping was successfully removed, return None to the deferred.

Method Details

__init__(self, soap_proxy, info)
(Constructor)

Build the device, with the given SOAP proxy, and the meta-infos.
Parameters:
soap_proxy - an initialized SoapProxy to the device
info - a dictionnary of various infos concerning the device extracted with UPnPXml

add_port_mapping(self, local_ip, intport, extport, desc, proto, lease=0)

Add a port mapping in the upnp device. Returns a deferred.
Parameters:
local_ip - the LAN ip of this host as "x.x.x.x"
intport - the internal port number
extport - the external port number
desc - the description of this mapping (string)
proto - "UDP" or "TCP"
lease - The duration of the lease in (mili)seconds(??)
Returns:
A deferred called with None when the mapping is done
           (type=twisted.internet.defer.Deferred)

get_external_ip(self)

Triggers an external ip discovery on the upnp device. Returns a deferred called with the external ip of this host.
Returns:
A deferred called with the ip address, as "x.x.x.x"
           (type=twisted.internet.defer.Deferred)

get_port_mappings(self)

Retreive the existing port mappings
Returns:
A deferred called with the dictionnary as defined in the interface portmapper.NATMapper.get_port_mappings
           (type=twisted.internet.defer.Deferred)

See Also: portmapper.NATMapper.get_port_mappings

remove_port_mapping(self, extport, proto)

Remove an existing port mapping on the device. Returns a deferred
Parameters:
extport - the external port number associated to the mapping to be removed
proto - either "UDP" or "TCP"
Returns:
A deferred called with None when the mapping is done
           (type=twisted.internet.defer.Deferred)

_get_port_mapping(self, mapping_id=0, mappings=None)

Fetch the existing mappings starting at index "mapping_id" from the device.

To retreive all the mappings call this without parameters.
Parameters:
mapping_id - The index of the mapping to start fetching from
mappings - the dictionnary of already fetched mappings
Returns:
A deferred called with the existing mappings when all have been retreived, see get_port_mappings
           (type=twisted.internet.defer.Deferred)

_on_external_ip(self, res)

Called when we received the external ip address from the device.
Parameters:
res - the SOAPpy structure of the result
Returns:
the external ip string, as "x.x.x.x"

_on_no_port_mapping_added(self, failure)

Called when the port mapping could not be added. Immediately raise an UPnPError, with the SOAPpy structure inside.
Raises:
UPnPError - When the port mapping could not be added

_on_no_port_mapping_received(self, failure, mappings)

Called when we have no more port mappings to retreive, or an error occured while retreiving them.

Either we have a "SpecifiedArrayIndexInvalid" SOAP error, and that's ok, it just means we have finished. If it returns some other error, then we fail with an UPnPError.
Parameters:
failure - the failure
mappings - the already retreived mappings
Returns:
The existing mappings as defined in get_port_mappings
Raises:
UPnPError - When we got any other error than "SpecifiedArrayIndexInvalid"

_on_no_port_mapping_removed(self, failure)

Called when the port mapping could not be removed. Immediately raise an UPnPError, with the SOAPpy structure inside.
Raises:
UPnPError - When the port mapping could not be deleted

_on_port_mapping_added(self, response)

The port mapping was successfully added, return None to the deferred.

_on_port_mapping_received(self, response, mapping_id, mappings)

Called we we receive a single mapping from the device.
Parameters:
response - a SOAPpy structure, representing the device's answer
mapping_id - The index of the next mapping in the device
mappings - the already fetched mappings, see get_port_mappings
Returns:
A deferred called with the existing mappings when all have been retreived, see get_port_mappings
           (type=twisted.internet.defer.Deferred)

_on_port_mapping_removed(self, response)

The port mapping was successfully removed, return None to the deferred.

Generated by Epydoc 2.1 on Tue Aug 30 14:56:47 2005 http://epydoc.sf.net