GUPnPIgd.SimpleIgd

g GObject.Object GObject.Object GUPnPIgd.SimpleIgd GUPnPIgd.SimpleIgd GObject.Object->GUPnPIgd.SimpleIgd

Subclasses:

GUPnPIgd.SimpleIgdThread

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

error_quark ()

class

new ()

add_port (protocol, external_port, local_ip, local_port, lease_duration, description)

delete_all_mappings ()

remove_port (protocol, external_port)

remove_port_local (protocol, local_ip, local_port)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

main-context

int

r

This GLib.MainContext will be used for all async activities

Signals

Inherited:

GObject.Object (1)

Name

Short Description

context-available

This is to allow the application to control which #GUPnPContext this client should use.

error-mapping-port

This means that mapping a port on a specific IGD has failed (it may still succeed on other IGDs on the network).

mapped-external-port

This signal means that an IGD has been found that that adding a port mapping has succeeded.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class GUPnPIgd.SimpleIgd(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

GUPnPIgd.SimpleIgdClass

All members are private, access them using methods and properties

classmethod error_quark()
Return type:

int

classmethod new()
Returns:

a new GUPnPIgd.SimpleIgd

Return type:

GUPnPIgd.SimpleIgd

main context) This creates a new #GUPnpSimpleIgd object using the special GLib.MainContext

add_port(protocol, external_port, local_ip, local_port, lease_duration, description)
Parameters:
  • protocol (str) – the protocol “UDP” or “TCP”

  • external_port (int) – The port to try to open on the external device, 0 means to try a random port if the same port as the local port is already taken

  • local_ip (str) – The IP address to forward packets to (most likely the local ip address)

  • local_port (int) – The local port to forward packets to

  • lease_duration (int) – The duration of the lease (it will be auto-renewed before it expires). This is in seconds.

  • description (str) – The description that will appear in the router’s table

This adds a port to the router’s forwarding table. The mapping will be automatically refreshed by this object until it is either removed with GUPnPIgd.SimpleIgd.remove_port(), GUPnPIgd.SimpleIgd.remove_port_local() or the object disapears.

If there is a problem, the GUPnPIgd.SimpleIgd ::error-mapping-port signal will be emitted. If a router is found and a port is mapped correctly, GUPnPIgd.SimpleIgd ::mapped-external-port will be emitted. These signals may be emitted multiple times if there are multiple routers present.

delete_all_mappings()
Returns:

True if the object can be disposed, False otherwise

Return type:

bool

Removes all mappings and prevents other from being formed Should only be called by the dispose function of subclasses

remove_port(protocol, external_port)
Parameters:

This tries to remove a port entry from the routers that was previously added with GUPnPIgd.SimpleIgd.add_port(). There is no indicated of success or failure it is a best effort mechanism. If it fails, the bindings will disapears after the lease duration set when the port where added.

remove_port_local(protocol, local_ip, local_port)
Parameters:

This tries to remove a port entry from the routers that was previously added with GUPnPIgd.SimpleIgd.add_port(). There is no indicated of success or failure it is a best effort mechanism. If it fails, the bindings will disapears after the lease duration set when the port where added.

Signal Details

GUPnPIgd.SimpleIgd.signals.context_available(simple_igd, context)
Signal Name:

context-available

Flags:

RUN_LAST

Parameters:
Returns:

False if the context should be used or True if it should be ignored

Return type:

bool

This is to allow the application to control which #GUPnPContext this client should use. If the application connects to this signal, it controls if a context will be used by changing the return value of the signal handler.

GUPnPIgd.SimpleIgd.signals.error_mapping_port(simple_igd, error, proto, external_port, local_ip, local_port, description)
Signal Name:

error-mapping-port

Flags:

RUN_LAST, DETAILED

Parameters:

This means that mapping a port on a specific IGD has failed (it may still succeed on other IGDs on the network).

GUPnPIgd.SimpleIgd.signals.mapped_external_port(simple_igd, proto, external_ip, replaces_external_ip, external_port, local_ip, local_port, description)
Signal Name:

mapped-external-port

Flags:

RUN_LAST

Parameters:
  • simple_igd (GUPnPIgd.SimpleIgd) – The object which received the signal

  • proto (str) – the requested protocol (“UDP” or “TCP”)

  • external_ip (str) – the external IP

  • replaces_external_ip (str) – if this mapping replaces another mapping, this is the old external IP

  • external_port (int) – the external port that was allocated

  • local_ip (str) – IP address that the router should forward the packets to. It could be the address of another machine on the local network

  • local_port (int) – the local port

  • description (str) – the user’s selected description

This signal means that an IGD has been found that that adding a port mapping has succeeded.

Property Details

GUPnPIgd.SimpleIgd.props.main_context
Name:

main-context

Type:

int

Default Value:

None

Flags:

READABLE

This GLib.MainContext will be used for all async activities