Open.Nat
Represents a NAT device and provides access to the operation set that allows
open (forward) ports, close ports and get the externa (visible) IP address.
Creates the port map asynchronous.
The Mapping entry.
device.CreatePortMapAsync(new Mapping(Protocol.Tcp, 1700, 1600));
MappingException
Deletes a mapped port asynchronous.
The Mapping entry.
device.DeletePortMapAsync(new Mapping(Protocol.Tcp, 1700, 1600));
MappingException-class
Gets all mappings asynchronous.
The list of all forwarded ports
var mappings = await device.GetAllMappingsAsync();
foreach(var mapping in mappings)
{
Console.WriteLine(mapping)
}
MappingException
Gets the external (visible) IP address asynchronous. This is the NAT device IP address
The public IP addrees
Console.WriteLine("My public IP is: {0}", await device.GetExternalIPAsync());
MappingException
Gets the specified mapping asynchronous.
The protocol.
The port.
The matching mapping
Protocol to allow/disallow
Transport Control Protocol
Datagram Protocol
Represents a port forwarding entry in the NAT translation table.
Gets the mapping's description. It is the value stored in the NewPortMappingDescription parameter.
The NewPortMappingDescription parameter is a human readable string that describes the connection.
It is used in sorme web interfaces of routers so the user can see which program is using what port.
Gets the private ip.
Gets the protocol.
The PrivatePort parameter specifies the port on a client machine to which all traffic
coming in on PublicPort for the protocol specified by
Protocol should be forwarded to.
Protocol enum
Gets the public ip.
Gets the external (visible) port number.
It is the value stored in the NewExternalPort parameter .
The NewExternalPort parameter is used to specify the TCP or UDP port on the WAN side of the router which should be forwarded.
Gets the lifetime. The Lifetime parameter tells the router how long the portmapping should be active.
Since most programs don't know this in advance, it is often set to 0, which means 'unlimited' or 'permanent'.
All portmappings are release automatically as part of the shutdown process when NatUtility.ReleaseOnShutdown is true.
Permanent portmappings will not be released if the process ends anormally.
Since most programs don't know the lifetime in advance, Open.NAT renew all the portmappings (except the permanents) before they expires. So, developers have to close explicitly those portmappings
they don't want to remain open for the session.
Gets the expiration. The property value is calculated using Lifetime property.
Initializes a new instance of the class.
The protocol.
The private ip.
The private port.
The public port.
The lifetime.
The description.
Initializes a new instance of the class.
The protocol.
The private port.
The public port.
This constructor initializes a Permanent mapping. The description by deafult is "Open.NAT"
Initializes a new instance of the class.
The protocol.
The private port.
The public port.
The description.
This constructor initializes a Permanent mapping.
Initializes a new instance of the class.
The protocol.
The private port.
The public port.
The lifetime.
The description.
Determines whether this instance is expired.
Permanent mappings never expires.
Returns a that represents this instance.
A that represents this instance.
The TraceSource instance
used for debugging and Troubleshooting
NatUtility.TraceSource.Switch.Level = SourceLevels.Verbose;
NatUtility.TraceSource.Listeners.Add(new ConsoleListener());
At least one trace listener has to be added to the Listeners collection if a trace is required; if no listener is added
there will no be tracing to analyse.
Open.NAT only supports SourceLevels.Verbose, SourceLevels.Error, SourceLevels.Warning and SourceLevels.Information.
Discovers and returns an UPnp or Pmp NAT device; otherwise a NatDeviceNotFoundException
exception is thrown after 3 seconds.
A NAT device
when no NAT found before 3 seconds.
Discovers and returns a NAT device for the specified type; otherwise a NatDeviceNotFoundException
exception is thrown when it is cancelled.
It allows to specify the NAT type to discover as well as the cancellation token in order.
Port mapper protocol; Upnp, Pmp or both
Cancellation token source for cancelling the discovery process
A NAT device
when no NAT found before cancellation
Discovers and returns all NAT devices for the specified type. If no NAT device is found it returns an empty enumerable
Port mapper protocol; Upnp, Pmp or both
Cancellation token source for cancelling the discovery process
All found NAT devices
Release all ports opened by Open.NAT.
If ReleaseOnShutdown value is true, it release all the mappings created through the library.
Protocol that should be used for searching a NAT device.
Use only Port Mapping Protocol
Use only Universal Plug and Play
The message sent to discover all uPnP devices on the network