• Api Documentation
  • Source Code
Search Results for

    Show / Hide Table of Contents
    • SharpOpenNat
      • Extensions
      • INatDevice
      • INatDiscoverer
      • Mapping
      • MappingException
      • MappingLifetime
      • NatDeviceNotFoundException
      • OpenNat
      • PortMapper
      • Protocol

    Class Mapping

    Represents a port forwarding entry in the NAT translation table.

    Inheritance
    object
    Mapping
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: SharpOpenNat
    Assembly: SharpOpenNat.dll
    Syntax
    public class Mapping

    Constructors

    | Edit this page View Source

    Mapping(Protocol, int, int)

    Initializes a new instance of the Mapping class.

    Declaration
    public Mapping(Protocol protocol, int privatePort, int publicPort)
    Parameters
    Type Name Description
    Protocol protocol

    The protocol.

    int privatePort

    The private port.

    int publicPort

    The public port.

    Remarks

    This constructor initializes a Permanent mapping. The description by default is "SharpOpenNat"

    | Edit this page View Source

    Mapping(Protocol, int, int, int, string)

    Initializes a new instance of the Mapping class.

    Declaration
    public Mapping(Protocol protocol, int privatePort, int publicPort, int lifetime, string description)
    Parameters
    Type Name Description
    Protocol protocol

    The protocol.

    int privatePort

    The private port.

    int publicPort

    The public port.

    int lifetime

    The lifetime in seconds.

    string description

    The description.

    | Edit this page View Source

    Mapping(Protocol, int, int, string)

    Initializes a new instance of the Mapping class.

    Declaration
    public Mapping(Protocol protocol, int privatePort, int publicPort, string description)
    Parameters
    Type Name Description
    Protocol protocol

    The protocol.

    int privatePort

    The private port.

    int publicPort

    The public port.

    string description

    The description.

    Remarks

    This constructor initializes a Permanent mapping.

    | Edit this page View Source

    Mapping(Protocol, IPAddress, int, int, int, string)

    Initializes a new instance of the Mapping class.

    Declaration
    public Mapping(Protocol protocol, IPAddress privateIP, int privatePort, int publicPort, int lifetime, string description)
    Parameters
    Type Name Description
    Protocol protocol

    The protocol.

    IPAddress privateIP

    The private ip.

    int privatePort

    The private port.

    int publicPort

    The public port.

    int lifetime

    The lifetime in seconds.

    string description

    The description.

    Properties

    | Edit this page View Source

    Description

    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.

    Declaration
    public string Description { get; }
    Property Value
    Type Description
    string
    | Edit this page View Source

    Expiration

    Gets the expiration. The property value is calculated using Lifetime property.

    Declaration
    public DateTime Expiration { get; }
    Property Value
    Type Description
    DateTime
    | Edit this page View Source

    Lifetime

    Gets the lifetime in seconds. 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'.

    Declaration
    public int Lifetime { get; }
    Property Value
    Type Description
    int
    Remarks

    All portmappings are release automatically as part of the shutdown process. Permanent portmappings will not be released if the process ends anormally. Since most programs don't know the lifetime in advance, SharpOpenNat 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.

    | Edit this page View Source

    LifetimeType

    Gets the Lifetime of the mapping

    Declaration
    public MappingLifetime LifetimeType { get; }
    Property Value
    Type Description
    MappingLifetime
    | Edit this page View Source

    PrivateIP

    Gets the private ip.

    Declaration
    public IPAddress PrivateIP { get; }
    Property Value
    Type Description
    IPAddress
    | Edit this page View Source

    PrivatePort

    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.

    Declaration
    public int PrivatePort { get; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    Protocol

    Gets the protocol.

    Declaration
    public Protocol Protocol { get; }
    Property Value
    Type Description
    Protocol
    | Edit this page View Source

    PublicIP

    Gets the public ip.

    Declaration
    public IPAddress PublicIP { get; }
    Property Value
    Type Description
    IPAddress
    | Edit this page View Source

    PublicPort

    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.

    Declaration
    public int PublicPort { get; }
    Property Value
    Type Description
    int

    Methods

    | Edit this page View Source

    Equals(object?)

    Determines whether the specified object is equal to the current object.

    Declaration
    public override bool Equals(object? obj)
    Parameters
    Type Name Description
    object obj

    The object to compare with the current object.

    Returns
    Type Description
    bool

    true if the specified object is equal to the current object; otherwise, false.

    Overrides
    object.Equals(object)
    | Edit this page View Source

    GetHashCode()

    Serves as the default hash function.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A hash code for the current object.

    Overrides
    object.GetHashCode()
    | Edit this page View Source

    IsExpired()

    Determines whether this instance is expired.

    Declaration
    public bool IsExpired()
    Returns
    Type Description
    bool
    Remarks

    Permanent mappings never expires.

    | Edit this page View Source

    ToString()

    Returns a string that represents this instance.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    A string that represents this instance.

    Overrides
    object.ToString()
    • Edit this page
    • View Source
    In this article
    Back to top Copyright Alan McGovern, Ben Motmans, Lucas Ontivero, Jérémy Ansel (c) 2006-2024