aboutsummaryrefslogtreecommitdiff
path: root/Mono.Nat
diff options
context:
space:
mode:
authorhawken <hawken@thehawken.org>2019-01-07 23:24:34 +0000
committerhawken <hawken@thehawken.org>2019-01-07 23:24:34 +0000
commitba1794f64bb1959b3af0fbbddca57df14a5544a9 (patch)
tree8edc7dec5be3beb793ab00305f222fe15f2a52e7 /Mono.Nat
parent4ab82f7436b80359ef4c5f08027b309d1e1cf3b0 (diff)
Remove tabs and trailing whitespace
Diffstat (limited to 'Mono.Nat')
-rw-r--r--Mono.Nat/AbstractNatDevice.cs35
-rw-r--r--Mono.Nat/Enums/ProtocolType.cs16
-rw-r--r--Mono.Nat/EventArgs/DeviceEventArgs.cs34
-rw-r--r--Mono.Nat/INatDevice.cs18
-rw-r--r--Mono.Nat/Mapping.cs144
-rw-r--r--Mono.Nat/Pmp/PmpConstants.cs52
-rw-r--r--Mono.Nat/Pmp/PmpSearcher.cs10
-rw-r--r--Mono.Nat/Upnp/Searchers/UpnpSearcher.cs20
8 files changed, 163 insertions, 166 deletions
diff --git a/Mono.Nat/AbstractNatDevice.cs b/Mono.Nat/AbstractNatDevice.cs
index 1b4216002..1241170c1 100644
--- a/Mono.Nat/AbstractNatDevice.cs
+++ b/Mono.Nat/AbstractNatDevice.cs
@@ -13,10 +13,10 @@
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
-//
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
-//
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -34,23 +34,22 @@ using System.Threading.Tasks;
namespace Mono.Nat
{
- public abstract class AbstractNatDevice : INatDevice
- {
- private DateTime lastSeen;
-
- protected AbstractNatDevice ()
- {
+ public abstract class AbstractNatDevice : INatDevice
+ {
+ private DateTime lastSeen;
+
+ protected AbstractNatDevice()
+ {
+ }
- }
+ public abstract IPAddress LocalAddress { get; }
- public abstract IPAddress LocalAddress { get; }
-
- public DateTime LastSeen
- {
- get { return lastSeen; }
- set { lastSeen = value; }
- }
+ public DateTime LastSeen
+ {
+ get { return lastSeen; }
+ set { lastSeen = value; }
+ }
- public abstract Task CreatePortMap(Mapping mapping);
- }
+ public abstract Task CreatePortMap(Mapping mapping);
+ }
}
diff --git a/Mono.Nat/Enums/ProtocolType.cs b/Mono.Nat/Enums/ProtocolType.cs
index a1f5cbb0e..54480598d 100644
--- a/Mono.Nat/Enums/ProtocolType.cs
+++ b/Mono.Nat/Enums/ProtocolType.cs
@@ -11,10 +11,10 @@
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
-//
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
-//
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -28,9 +28,9 @@ using System;
namespace Mono.Nat
{
- public enum Protocol
- {
- Tcp,
- Udp
- }
-} \ No newline at end of file
+ public enum Protocol
+ {
+ Tcp,
+ Udp
+ }
+}
diff --git a/Mono.Nat/EventArgs/DeviceEventArgs.cs b/Mono.Nat/EventArgs/DeviceEventArgs.cs
index fbbbf63e3..6358a0c29 100644
--- a/Mono.Nat/EventArgs/DeviceEventArgs.cs
+++ b/Mono.Nat/EventArgs/DeviceEventArgs.cs
@@ -11,10 +11,10 @@
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
-//
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
-//
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -28,18 +28,18 @@ using System;
namespace Mono.Nat
{
- public class DeviceEventArgs : EventArgs
- {
- private INatDevice device;
-
- public DeviceEventArgs(INatDevice device)
- {
- this.device = device;
- }
-
- public INatDevice Device
- {
- get { return this.device; }
- }
- }
-} \ No newline at end of file
+ public class DeviceEventArgs : EventArgs
+ {
+ private INatDevice device;
+
+ public DeviceEventArgs(INatDevice device)
+ {
+ this.device = device;
+ }
+
+ public INatDevice Device
+ {
+ get { return this.device; }
+ }
+ }
+}
diff --git a/Mono.Nat/INatDevice.cs b/Mono.Nat/INatDevice.cs
index b0401627b..6a1509071 100644
--- a/Mono.Nat/INatDevice.cs
+++ b/Mono.Nat/INatDevice.cs
@@ -13,10 +13,10 @@
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
-//
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
-//
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -34,12 +34,12 @@ using System.Threading.Tasks;
namespace Mono.Nat
{
- public interface INatDevice
- {
- Task CreatePortMap (Mapping mapping);
-
- IPAddress LocalAddress { get; }
+ public interface INatDevice
+ {
+ Task CreatePortMap (Mapping mapping);
+
+ IPAddress LocalAddress { get; }
- DateTime LastSeen { get; set; }
- }
+ DateTime LastSeen { get; set; }
+ }
}
diff --git a/Mono.Nat/Mapping.cs b/Mono.Nat/Mapping.cs
index dd49404c6..438068934 100644
--- a/Mono.Nat/Mapping.cs
+++ b/Mono.Nat/Mapping.cs
@@ -13,10 +13,10 @@
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
-//
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
-//
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -30,94 +30,92 @@ using System;
namespace Mono.Nat
{
- public class Mapping
- {
+ public class Mapping
+ {
private string description;
private DateTime expiration;
private int lifetime;
private int privatePort;
- private Protocol protocol;
- private int publicPort;
-
+ private Protocol protocol;
+ private int publicPort;
+ public Mapping(Protocol protocol, int privatePort, int publicPort)
+ : this (protocol, privatePort, publicPort, 0)
+ {
+ }
- public Mapping (Protocol protocol, int privatePort, int publicPort)
- : this (protocol, privatePort, publicPort, 0)
- {
- }
-
- public Mapping (Protocol protocol, int privatePort, int publicPort, int lifetime)
- {
- this.protocol = protocol;
- this.privatePort = privatePort;
- this.publicPort = publicPort;
- this.lifetime = lifetime;
+ public Mapping(Protocol protocol, int privatePort, int publicPort, int lifetime)
+ {
+ this.protocol = protocol;
+ this.privatePort = privatePort;
+ this.publicPort = publicPort;
+ this.lifetime = lifetime;
- if (lifetime == int.MaxValue)
- this.expiration = DateTime.MaxValue;
- else if (lifetime == 0)
- this.expiration = DateTime.Now;
- else
- this.expiration = DateTime.Now.AddSeconds (lifetime);
- }
+ if (lifetime == int.MaxValue)
+ this.expiration = DateTime.MaxValue;
+ else if (lifetime == 0)
+ this.expiration = DateTime.Now;
+ else
+ this.expiration = DateTime.Now.AddSeconds (lifetime);
+ }
public string Description
{
get { return description; }
set { description = value; }
}
-
- public Protocol Protocol
- {
- get { return protocol; }
- internal set { protocol = value; }
- }
- public int PrivatePort
- {
- get { return privatePort; }
- internal set { privatePort = value; }
- }
-
- public int PublicPort
- {
- get { return publicPort; }
- internal set { publicPort = value; }
- }
-
- public int Lifetime
- {
- get { return lifetime; }
- internal set { lifetime = value; }
- }
-
- public DateTime Expiration
- {
- get { return expiration; }
- internal set { expiration = value; }
- }
-
- public bool IsExpired ()
- {
- return expiration < DateTime.Now;
- }
+ public Protocol Protocol
+ {
+ get { return protocol; }
+ internal set { protocol = value; }
+ }
+
+ public int PrivatePort
+ {
+ get { return privatePort; }
+ internal set { privatePort = value; }
+ }
- public override bool Equals (object obj)
- {
- Mapping other = obj as Mapping;
- return other == null ? false : this.protocol == other.protocol &&
- this.privatePort == other.privatePort && this.publicPort == other.publicPort;
- }
+ public int PublicPort
+ {
+ get { return publicPort; }
+ internal set { publicPort = value; }
+ }
- public override int GetHashCode()
- {
- return this.protocol.GetHashCode() ^ this.privatePort.GetHashCode() ^ this.publicPort.GetHashCode();
- }
+ public int Lifetime
+ {
+ get { return lifetime; }
+ internal set { lifetime = value; }
+ }
+
+ public DateTime Expiration
+ {
+ get { return expiration; }
+ internal set { expiration = value; }
+ }
+
+ public bool IsExpired()
+ {
+ return expiration < DateTime.Now;
+ }
+
+ public override bool Equals(object obj)
+ {
+ Mapping other = obj as Mapping;
+ return other == null ? false : this.protocol == other.protocol &&
+ this.privatePort == other.privatePort && this.publicPort == other.publicPort;
+ }
+
+ public override int GetHashCode()
+ {
+ return this.protocol.GetHashCode() ^ this.privatePort.GetHashCode() ^ this.publicPort.GetHashCode();
+ }
- public override string ToString( )
+ public override string ToString()
{
- return String.Format( "Protocol: {0}, Public Port: {1}, Private Port: {2}, Description: {3}, Expiration: {4}, Lifetime: {5}",
- this.protocol, this.publicPort, this.privatePort, this.description, this.expiration, this.lifetime );
+ return String.Format( "Protocol: {0}, Public Port: {1}, Private Port: {2}, Description: {3}, Expiration: {4}, Lifetime: {5}",
+ this.protocol, this.publicPort, this.privatePort, this.description, this.expiration, this.lifetime );
}
- }
+ }
}
diff --git a/Mono.Nat/Pmp/PmpConstants.cs b/Mono.Nat/Pmp/PmpConstants.cs
index ff3eb6230..83fa8e07c 100644
--- a/Mono.Nat/Pmp/PmpConstants.cs
+++ b/Mono.Nat/Pmp/PmpConstants.cs
@@ -11,10 +11,10 @@
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
-//
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
-//
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -29,28 +29,28 @@ using System;
namespace Mono.Nat.Pmp
{
internal static class PmpConstants
- {
- public const byte Version = (byte)0;
-
- public const byte OperationCode = (byte)0;
- public const byte OperationCodeUdp = (byte)1;
- public const byte OperationCodeTcp = (byte)2;
+ {
+ public const byte Version = (byte)0;
+
+ public const byte OperationCode = (byte)0;
+ public const byte OperationCodeUdp = (byte)1;
+ public const byte OperationCodeTcp = (byte)2;
public const byte ServerNoop = (byte)128;
-
- public const int ClientPort = 5350;
- public const int ServerPort = 5351;
-
- public const int RetryDelay = 250;
- public const int RetryAttempts = 9;
-
- public const int RecommendedLeaseTime = 60 * 60;
- public const int DefaultLeaseTime = RecommendedLeaseTime;
-
- public const short ResultCodeSuccess = 0;
- public const short ResultCodeUnsupportedVersion = 1;
- public const short ResultCodeNotAuthorized = 2;
- public const short ResultCodeNetworkFailure = 3;
- public const short ResultCodeOutOfResources = 4;
- public const short ResultCodeUnsupportedOperationCode = 5;
- }
-} \ No newline at end of file
+
+ public const int ClientPort = 5350;
+ public const int ServerPort = 5351;
+
+ public const int RetryDelay = 250;
+ public const int RetryAttempts = 9;
+
+ public const int RecommendedLeaseTime = 60 * 60;
+ public const int DefaultLeaseTime = RecommendedLeaseTime;
+
+ public const short ResultCodeSuccess = 0;
+ public const short ResultCodeUnsupportedVersion = 1;
+ public const short ResultCodeNotAuthorized = 2;
+ public const short ResultCodeNetworkFailure = 3;
+ public const short ResultCodeOutOfResources = 4;
+ public const short ResultCodeUnsupportedOperationCode = 5;
+ }
+}
diff --git a/Mono.Nat/Pmp/PmpSearcher.cs b/Mono.Nat/Pmp/PmpSearcher.cs
index 98cf37f14..5e4155841 100644
--- a/Mono.Nat/Pmp/PmpSearcher.cs
+++ b/Mono.Nat/Pmp/PmpSearcher.cs
@@ -15,10 +15,10 @@
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
-//
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
-//
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -108,8 +108,8 @@ namespace Mono.Nat
foreach (var unicast in properties.UnicastAddresses)
{
if (/*unicast.DuplicateAddressDetectionState == DuplicateAddressDetectionState.Preferred
- && unicast.AddressPreferredLifetime != UInt32.MaxValue
- && */unicast.Address.AddressFamily == AddressFamily.InterNetwork)
+ && unicast.AddressPreferredLifetime != UInt32.MaxValue
+ && */unicast.Address.AddressFamily == AddressFamily.InterNetwork)
{
var bytes = unicast.Address.GetAddressBytes();
bytes[3] = 1;
@@ -165,7 +165,7 @@ namespace Mono.Nat
async Task Search(UdpClient client)
{
- // Sort out the time for the next search first. The spec says the
+ // Sort out the time for the next search first. The spec says the
// timeout should double after each attempt. Once it reaches 64 seconds
// (and that attempt fails), assume no devices available
nextSearch = DateTime.Now.AddMilliseconds(timeout);
diff --git a/Mono.Nat/Upnp/Searchers/UpnpSearcher.cs b/Mono.Nat/Upnp/Searchers/UpnpSearcher.cs
index bcf358d1c..17ce19768 100644
--- a/Mono.Nat/Upnp/Searchers/UpnpSearcher.cs
+++ b/Mono.Nat/Upnp/Searchers/UpnpSearcher.cs
@@ -15,10 +15,10 @@
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
-//
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
-//
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -58,8 +58,8 @@ namespace Mono.Nat
}
public void Search()
- {
- }
+ {
+ }
public async Task Handle(IPAddress localAddress, UpnpDeviceInfo deviceInfo, IPEndPoint endpoint)
{
@@ -70,16 +70,16 @@ namespace Mono.Nat
try
{
- /* For UPnP Port Mapping we need ot find either WANPPPConnection or WANIPConnection.
- Any other device type is no good to us for this purpose. See the IGP overview paper
- page 5 for an overview of device types and their hierarchy.
- http://upnp.org/specs/gw/UPnP-gw-InternetGatewayDevice-v1-Device.pdf */
+ /* For UPnP Port Mapping we need ot find either WANPPPConnection or WANIPConnection.
+ * Any other device type is no good to us for this purpose. See the IGP overview paper
+ * page 5 for an overview of device types and their hierarchy.
+ * http://upnp.org/specs/gw/UPnP-gw-InternetGatewayDevice-v1-Device.pdf */
/* TODO: Currently we are assuming version 1 of the protocol. We should figure out which
- version it is and apply the correct URN. */
+ * version it is and apply the correct URN. */
/* Some routers don't correctly implement the version ID on the URN, so we only search for the type
- prefix. */
+ * prefix. */
// We have an internet gateway device now
UpnpNatDevice d = new UpnpNatDevice(localAddress, deviceInfo, endpoint, string.Empty, _logger, _httpClient);