UPNPDevice

继承: RefCounted < Object

Universal Plug and Play (UPnP) device.

描述

Universal Plug and Play (UPnP) device. See UPNP for UPnP discovery and utility functions. Provides low-level access to UPNP control commands. Allows to manage port mappings (port forwarding) and to query network information of the device (like local and external IP address and status). Note that methods on this class are synchronous and block the calling thread.

属性

方法

intadd_port_mapping ( port: int, port_internal: int = 0, desc: String = "", proto: String = "UDP", duration: int = 0 ) const1
intdelete_port_mapping ( port: int, proto: String = "UDP" ) const1
boolis_valid_gateway ( ) const1
Stringquery_external_address ( ) const1

枚举

enum IGDStatus:

IGDStatus IGD_STATUS_OK = 0

OK.

IGDStatus IGD_STATUS_HTTP_ERROR = 1

HTTP error.

IGDStatus IGD_STATUS_HTTP_EMPTY = 2

Empty HTTP response.

IGDStatus IGD_STATUS_NO_URLS = 3

已弃用: This value is no longer used.

Returned response contained no URLs.

IGDStatus IGD_STATUS_NO_IGD = 4

Not a valid IGD.

IGDStatus IGD_STATUS_DISCONNECTED = 5

Disconnected.

IGDStatus IGD_STATUS_UNKNOWN_DEVICE = 6

Unknown device.

IGDStatus IGD_STATUS_INVALID_CONTROL = 7

Invalid control.

IGDStatus IGD_STATUS_MALLOC_ERROR = 8

已弃用: This value is no longer used.

Memory allocation error.

IGDStatus IGD_STATUS_UNKNOWN_ERROR = 9

Unknown error.


属性说明

String description_url = ""

  • void set_description_url ( value: String )
  • String get_description_url ( )

URL to the device description.


String igd_control_url = ""

  • void set_igd_control_url ( value: String )
  • String get_igd_control_url ( )

IDG control URL.


String igd_our_addr = ""

  • void set_igd_our_addr ( value: String )
  • String get_igd_our_addr ( )

Address of the local machine in the network connecting it to this UPNPDevice.


String igd_service_type = ""

  • void set_igd_service_type ( value: String )
  • String get_igd_service_type ( )

IGD service type.


IGDStatus igd_status = 9

IGD status. See IGDStatus.


String service_type = ""

  • void set_service_type ( value: String )
  • String get_service_type ( )

Service type.


方法说明

int add_port_mapping ( port: int, port_internal: int = 0, desc: String = "", proto: String = "UDP", duration: int = 0 ) const1

Adds a port mapping to forward the given external port on this UPNPDevice for the given protocol to the local machine. See UPNP.add_port_mapping.


int delete_port_mapping ( port: int, proto: String = "UDP" ) const1

Deletes the port mapping identified by the given port and protocol combination on this device. See UPNP.delete_port_mapping.


bool is_valid_gateway ( ) const1

Returns true if this is a valid IGD (InternetGatewayDevice) which potentially supports port forwarding.


String query_external_address ( ) const1

Returns the external IP address of this UPNPDevice or an empty string.

2

本方法通常需要用户覆盖才能生效。

1

本方法无副作用,不会修改该实例的任何成员变量。

3

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

4

本方法用于构造某个类型。

5

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。