UPNPDevice
Inherits: RefCounted < Object
Description
Section titled “Description”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.
Properties
Section titled “Properties”| Type | Name | Default |
|---|---|---|
| String | description_url |
"" |
| String | igd_control_url |
"" |
| String | igd_our_addr |
"" |
| String | igd_service_type |
"" |
| IGDStatus | igd_status |
9 |
| String | service_type |
"" |
Methods
Section titled “Methods”| Returns | Method |
|---|---|
| int | add_port_mapping(port: int, port_internal: int = 0, desc: String = "", proto: String = "UDP", duration: int = 0) const |
| int | delete_port_mapping(port: int, proto: String = "UDP") const |
| bool | is_valid_gateway() const |
| String | query_external_address() const |
Enumerations
Section titled “Enumerations”IGDStatus
enum IGDStatus
IGD_STATUS_OK = 0
OK.
IGD_STATUS_HTTP_ERROR = 1
HTTP error.
IGD_STATUS_HTTP_EMPTY = 2
Empty HTTP response.
IGD_STATUS_NO_IGD = 3
Not a valid IGD.
IGD_STATUS_DISCONNECTED = 4
Disconnected.
IGD_STATUS_UNKNOWN_DEVICE = 5
Unknown device.
IGD_STATUS_INVALID_CONTROL = 6
Invalid control.
IGD_STATUS_UNKNOWN_ERROR = 7
Unknown error.
Property descriptions
Section titled “Property descriptions”description_url
String description_url = ""
URL to the device description.
igd_control_url
String igd_control_url = ""
IDG control URL.
igd_our_addr
String igd_our_addr = ""
Address of the local machine in the network connecting it to this UPNPDevice.
igd_service_type
String igd_service_type = ""
IGD service type.
igd_status
IGDStatus igd_status = 9
IGD status.
service_type
String service_type = ""
Service type.
Method descriptions
Section titled “Method descriptions”add_port_mapping
int add_port_mapping(port: int, port_internal: int = 0, desc: String = "", proto: String = "UDP", duration: int = 0) const
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().
delete_port_mapping
int delete_port_mapping(port: int, proto: String = "UDP") const
Deletes the port mapping identified by the given port and protocol combination on this device. See UPNP.delete_port_mapping().
is_valid_gateway
bool is_valid_gateway() const
Returns true if this is a valid IGD (InternetGatewayDevice) which potentially supports port forwarding.
query_external_address
String query_external_address() const
Returns the external IP address of this UPNPDevice or an empty string.
