Enumerationmigueldeicaza.swiftgodot 0.45.0SwiftGodot
UPNPResult
UPNP.swift:36enum UPNPResult
Cases
case success
UPNP command or discovery was successful.
case notAuthorized
Not authorized to use the command on the
UPNPDevice
. May be returned when the user disabled UPNP on their router.case portMappingNotFound
No port mapping was found for the given port, protocol combination on the given
UPNPDevice
.case inconsistentParameters
Inconsistent parameters.
case noSuchEntryInArray
No such entry in array. May be returned if a given port, protocol combination is not found on an
UPNPDevice
.case actionFailed
The action failed.
case srcIpWildcardNotPermitted
The
UPNPDevice
does not allow wildcard values for the source IP address.case extPortWildcardNotPermitted
The
UPNPDevice
does not allow wildcard values for the external port.case intPortWildcardNotPermitted
The
UPNPDevice
does not allow wildcard values for the internal port.case remoteHostMustBeWildcard
The remote host value must be a wildcard.
case extPortMustBeWildcard
The external port value must be a wildcard.
case noPortMapsAvailable
No port maps are available. May also be returned if port mapping functionality is not available.
case conflictWithOtherMechanism
Conflict with other mechanism. May be returned instead of .conflictWithOtherMapping if a port mapping conflicts with an existing one.
case conflictWithOtherMapping
Conflict with an existing port mapping.
case samePortValuesRequired
External and internal port values must be the same.
case onlyPermanentLeaseSupported
Only permanent leases are supported. Do not use the
duration
parameter when adding port mappings.case invalidGateway
Invalid gateway.
case invalidPort
Invalid port.
case invalidProtocol
Invalid protocol.
case invalidDuration
Invalid duration.
case invalidArgs
Invalid arguments.
case invalidResponse
Invalid response.
case invalidParam
Invalid parameter.
case httpError
HTTP error.
case socketError
Socket error.
case memAllocError
Error allocating memory.
case noGateway
No gateway available. You may need to call
discover(timeout:ttl:deviceFilter:)
first, or discovery didn’t detect any valid IGDs (InternetGatewayDevices).case noDevices
No devices available. You may need to call
discover(timeout:ttl:deviceFilter:)
first, or discovery didn’t detect any validUPNPDevice
s.case unknownError
Unknown error.
Other members in extension
View members
Hide members
This section is hidden by default because it contains too many (15) members.
Type members
Instance members
var discoverIpv6: Bool
If
true
, IPv6 is used forUPNPDevice
discovery.var discoverLocalPort: Int32
If
0
, the local port to use for discovery is chosen automatically by the system. If1
, discovery will be done from the source port 1900 (same as destination port). Otherwise, the value will be used as the port.var discoverMulticastIf: String
Multicast interface to use for discovery. Uses the default multicast interface if empty.
func addDevice(UPNPDevice?
) Adds the given
UPNPDevice
to the list of discovered devices.func addPortMapping(port: Int32, portInternal: Int32, desc: String, proto: String, duration: Int32
) -> Int32 Adds a mapping to forward the external
port
(between 1 and 65535, although recommended to use port 1024 or above) on the default gateway (seegetGateway
) to theportInternal
on the local machine for the given protocolproto
(either"TCP"
or"UDP"
, with UDP being the default). If a port mapping for the given port and protocol combination already exists on that gateway device, this method tries to overwrite it. If that is not desired, you can retrieve the gateway manually withgetGateway
and calladdPortMapping(port:portInternal:desc:proto:duration:)
on it, if any. Note that forwarding a well-known port (below 1024) with UPnP may fail depending on the device.func clearDevices(
) Clears the list of discovered devices.
func deletePortMapping(port: Int32, proto: String
) -> Int32 Deletes the port mapping for the given port and protocol combination on the default gateway (see
getGateway
) if one exists.port
must be a valid port between 1 and 65535,proto
can be either"TCP"
or"UDP"
. May be refused for mappings pointing to addresses other than this one, for well-known ports (below 1024), or for mappings not added via UPnP. SeeUPNPResult
for possible return values.func discover(timeout: Int32, ttl: Int32, deviceFilter: String
) -> Int32 Discovers local
UPNPDevice
s. Clears the list of previously discovered devices.func getDevice(index: Int32
) -> UPNPDevice? Returns the
UPNPDevice
at the givenindex
.func getDeviceCount(
) -> Int32 Returns the number of discovered
UPNPDevice
s.func getGateway(
) -> UPNPDevice? Returns the default gateway. That is the first discovered
UPNPDevice
that is also a valid IGD (InternetGatewayDevice).func queryExternalAddress(
) -> String Returns the external
IP
address of the default gateway (seegetGateway
) as string. Returns an empty string on error.func removeDevice(index: Int32
) Removes the device at
index
from the list of discovered devices.func setDevice(index: Int32, device: UPNPDevice?
) Sets the device at
index
from the list of discovered devices todevice
.
Citizens in SwiftGodot
Conformances
protocol CaseIterable
A type that provides a collection of all of its values.
protocol CustomDebugStringConvertible
A type with a customized textual representation suitable for debugging purposes.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol RawRepresentable<RawValue>
A type that can be converted to and from an associated raw value.
Type members
Instance members
var debugDescription: String
A textual representation of this instance, suitable for debugging
Type features
static func != (lhs: Self, rhs: Self
) -> Bool Returns a Boolean value indicating whether two values are not equal.