Browse Source

Refresh the repository

Matt Coburn 5 years ago
parent
commit
cdcd3adab8

+ 1 - 1
CMakeLists.txt

@@ -33,7 +33,7 @@ set(ENET_SRCDIR "Source/Native")
 set(ENET_SRCS
 set(ENET_SRCS
 	${ENET_SRCDIR}/enet.c
 	${ENET_SRCDIR}/enet.c
 	${ENET_SRCDIR}/enet.h
 	${ENET_SRCDIR}/enet.h
-	${ENET_SRCDIR}/enet_log.h
+	${ENET_SRCDIR}/custom/enet_logging.h
 )
 )
 
 
 if(ENET_DEBUG)
 if(ENET_DEBUG)

File diff suppressed because it is too large
+ 18 - 11
DOCUMENTATION.md


+ 19 - 19
README.md

@@ -2,23 +2,18 @@
   <img src="https://i.imgur.com/CxkUxTs.png" alt="alt logo">
   <img src="https://i.imgur.com/CxkUxTs.png" alt="alt logo">
 </p>
 </p>
 
 
-[![PayPal](https://drive.google.com/uc?id=1OQrtNBVJehNVxgPf6T6yX1wIysz1ElLR)](https://www.paypal.me/coburn64)
+[![Ko-Fi](https://img.shields.io/badge/Donate-Ko--Fi-red)](https://ko-fi.com/coburn) 
+[![PayPal](https://img.shields.io/badge/Donate-PayPal-blue)](https://paypal.me/coburn64)
+![MIT Licensed](https://img.shields.io/badge/license-MIT-green.svg)
+_**Please consider a donation (see the Ko-Fi button above) if this project is useful to you.**_
 
 
-Welcome to a improved/refactored version of nxrighthere's ENET-CSharp repository. This repo started out as a clone of NX's repository but has since had some extras that the original repository did not. Some cherry picked commits are included from NX when deemed they are worthy of being blended into the repository.
 
 
-Some features included in this repository include:
+This is a improved/refactored version of ENet-CSharp. Due to unfortunate circumstances between two development entities, the upstream repository was archived and is only updated when patches are applied (all development work is done in private). Since you cannot interact with archived repositories outside of code-related things, this repository acts as a workaround to those issues.
 
 
-- Proper implementation of ENET_DEBUG definition, allowing logging output to be written to `enet_log.txt` for further diagnosis and troubleshooting
-- Code cleanups and optimizations for better performance
-- Supposedly-a-bug tickets actually get analyzed and if it's really a bug, it'll get fixed
-- We won't randomly close issue tickets for no apparent reason
-- And a bunch of other shit that this version superior and worthwhile using.
-
-If you want to know what started this repository, go [read my blog 
-post](https://www.coburnsdomain.com/2019/03/getting-blocked-from-an-upstream-github-repo-nx-edition) as it'll detail the whole show. It's a good read.
+Unlike the upstream repository code of conduct where issue tickets were closed randomly for no reason, if you have a problem with ENet-CSharp, we'll be able to investigate. We also have a proper implementation of the `ENET_DEBUG` definition, allowing logging output to be written to `enet_log.txt` for further diagnosis and troubleshooting. Code cleanups and optimizations for better performance are included, and if someone files a supposedly-a-bug tickets actually get analyzed and if it's really a bug, it'll get fixed.
 
 
 ### Compatibility with Upstream
 ### Compatibility with Upstream
-Don't even try using this version of ENET and ENET-CSharp with the upstream repository. It'll likely look at you strange and catch fire. Just don't.
+Don't use the upstream releases with the code in this repository. You will most likely get crashes or weird things happening.
 
 
 ### Building
 ### Building
 You can use the IDE of Visual Studio to build if you like. The following will be oriented for power users and command line heroes.
 You can use the IDE of Visual Studio to build if you like. The following will be oriented for power users and command line heroes.
@@ -38,7 +33,7 @@ Unlike upstream, this repo has a complete build system that harnesses the power
 
 
 You will see an anime babe appear followed by [Ignorance](https://github.com/SoftwareGuy/Ignorance) ASCII art. 
 You will see an anime babe appear followed by [Ignorance](https://github.com/SoftwareGuy/Ignorance) ASCII art. 
 
 
-CMake will fire up, configure itself after inspecting your build environment and hopefully spit out a binary blob inside a `Unity/Plugins` directory. On Windows, this will be a DLL, on Mac it will be a BUNDLE and on Linux it will be a shared object (`.so`). This can be used with Unity or another thing like a C# NET Core application or even other C/C++ apps. 
+CMake will fire up, configure itself after inspecting your build environment and hopefully spit out a binary blob inside a `Unity/Plugins` directory. On Windows, this will be a DLL, on Mac it will be a `.bundle` file and on Linux it will be a shared object (`.so`). This can be used with Unity or another thing like a C# NET Core application or even other C/C++ apps. 
 
 
 #### Testing
 #### Testing
 - `dotnet test` will run some sanity checks and make sure ENET initializes, data is received and sent correctly, etc.
 - `dotnet test` will run some sanity checks and make sure ENET initializes, data is received and sent correctly, etc.
@@ -208,9 +203,10 @@ Usage is almost the same as in the .NET environment, except that the console fun
 Multi-threading
 Multi-threading
 --------
 --------
 ### Strategy
 ### Strategy
-The best-known strategy is to use ENet in an independent I/O thread. This can be achieved by using Threads and enqueuing packets to be sent and received back and forth via ConcurrentQueues. 
+The best-known strategy is to use ENet in an independent I/O thread. This can be achieved by using Threads and enqueuing packets to be sent and received back and forth via ConcurrentQueues (this is what [Ignorance](https://github.com/SoftwareGuy/Ignorance) uses). In fact, some internal testing showed that ENet had very impressive performance using a thread and ConcurrentQueues approach to network I/O, even faster than RingBuffers/Disruptors. Use whatever queue system you feel comfortable with, just make sure you empty the queues as fast as possible in your applications.
 
 
-In fact, some internal testing showed that ENET had very impressive performance using a thread and ConcurrentQueues approach to network I/O, even faster than RingBuffers/Disruptors. Please be beware that using Threads inside a Unity environment can be problematic and can lead to the Unity Editor or built games randomly crashing without any warning. Use them with caution!
+Threading in Unity was problematic but later versions (2018.3+) have proven to be fine. 
+Please beware that using Threads inside a Unity environment can be problematic and can lead to the Unity Editor or built games randomly crashing without any warning. Use them with caution!
 
 
 ### Functionality
 ### Functionality
 In general, ENet is not thread-safe, but some of its functions can be used safely if the user is careful enough:
 In general, ENet is not thread-safe, but some of its functions can be used safely if the user is careful enough:
@@ -227,10 +223,14 @@ See `DOCUMENTATION.md` [here](https://github.com/SoftwareGuy/ENet-CSharp/blob/ma
 
 
 Credits
 Credits
 -------
 -------
+- Coburn
 - c6burns
 - c6burns
-- SoftwareGuy (Coburn)
-- The Mirror development and follower crew
+- Katori
+- Mirror Team & Discord Members
 
 
 Some thanks to:
 Some thanks to:
-- FSE
-- NX
+- FSE (actually a helpful person when he's in a good mood)
+- NX (well, he had the original ENet-CSharp repo I manually forked)
+
+Psst... If you want to know what started this repository, go [read my blog 
+post](https://www.coburnsdomain.com/2019/03/getting-blocked-from-an-upstream-github-repo-nx-edition) as it'll detail the whole show. It's a good read.

+ 888 - 944
Source/Managed/ENet.cs

@@ -1,7 +1,9 @@
 /*
 /*
  *  Managed C# wrapper for an extended version of ENet
  *  Managed C# wrapper for an extended version of ENet
+ * 	This is a fork from upstream and is available at http://github.com/SoftwareGuy/ENet-CSharp
+ *
  *  Copyright (c) 2019 Matt Coburn (SoftwareGuy/Coburn64), Chris Burns (c6burns)
  *  Copyright (c) 2019 Matt Coburn (SoftwareGuy/Coburn64), Chris Burns (c6burns)
- *  Copyright (c) 2013 - 2018 James Bellinger, Nate Shoffner, Stanislav Denisov
+ *  Copyright (c) 2013 James Bellinger, 2016 Nate Shoffner, 2018 Stanislav Denisov
  *
  *
  *  Permission is hereby granted, free of charge, to any person obtaining a copy
  *  Permission is hereby granted, free of charge, to any person obtaining a copy
  *  of this software and associated documentation files (the "Software"), to deal
  *  of this software and associated documentation files (the "Software"), to deal
@@ -27,1173 +29,1115 @@ using System.Runtime.InteropServices;
 using System.Security;
 using System.Security;
 using System.Text;
 using System.Text;
 
 
-namespace ENet
-{
-    [Flags]
-    public enum PacketFlags
-    {
-        None = 0,
-        Reliable = 1 << 0,
-        Unsequenced = 1 << 1,
-        NoAllocate = 1 << 2,
-        UnreliableFragmented = 1 << 3,
-        Instant = 1 << 4
-    }
-
-    public enum EventType
-    {
-        None = 0,
-        Connect = 1,
-        Disconnect = 2,
-        Receive = 3,
-        Timeout = 4
-    }
-
-    public enum PeerState
-    {
-        Uninitialized = -1,
-        Disconnected = 0,
-        Connecting = 1,
-        AcknowledgingConnect = 2,
-        ConnectionPending = 3,
-        ConnectionSucceeded = 4,
-        Connected = 5,
-        DisconnectLater = 6,
-        Disconnecting = 7,
-        AcknowledgingDisconnect = 8,
-        Zombie = 9
-    }
-
-    [StructLayout(LayoutKind.Explicit, Size = 18)]
-    internal struct ENetAddress
-    {
-        [FieldOffset(16)]
-        public ushort port;
-    }
-
-    [StructLayout(LayoutKind.Sequential)]
-    internal struct ENetEvent
-    {
-        public EventType type;
-        public IntPtr peer;
-        public byte channelID;
-        public uint data;
-        public IntPtr packet;
-    }
-
-    [StructLayout(LayoutKind.Sequential)]
-    internal struct ENetCallbacks
-    {
-        public AllocCallback malloc;
-        public FreeCallback free;
-        public NoMemoryCallback noMemory;
-    }
-
-    public delegate IntPtr AllocCallback(IntPtr size);
-    public delegate void FreeCallback(IntPtr memory);
-    public delegate void NoMemoryCallback();
-    public delegate void PacketFreeCallback(Packet packet);
-
-    internal static class ArrayPool
-    {
-        [ThreadStatic]
-        private static byte[] byteBuffer;
-        [ThreadStatic]
-        private static IntPtr[] pointerBuffer;
-
-        public static byte[] GetByteBuffer()
-        {
-            if (byteBuffer == null)
-                byteBuffer = new byte[64];
-
-            return byteBuffer;
-        }
-
-        public static IntPtr[] GetPointerBuffer()
-        {
-            if (pointerBuffer == null)
-                pointerBuffer = new IntPtr[Library.maxPeers];
-
-            return pointerBuffer;
-        }
-    }
-
-    public struct Address
-    {
-        private ENetAddress nativeAddress;
-
-        internal ENetAddress NativeData {
-            get {
-                return nativeAddress;
-            }
-
-            set {
-                nativeAddress = value;
-            }
-        }
-
-        internal Address(ENetAddress address)
-        {
-            nativeAddress = address;
-        }
-
-        public ushort Port {
-            get {
-                return nativeAddress.port;
-            }
-
-            set {
-                nativeAddress.port = value;
-            }
-        }
-
-        public string GetIP()
-        {
-            StringBuilder ip = new StringBuilder(1024);
+namespace ENet {
+	[Flags]
+	public enum PacketFlags {
+		None = 0,
+		Reliable = 1 << 0,
+		Unsequenced = 1 << 1,
+		NoAllocate = 1 << 2,
+		UnreliableFragmented = 1 << 3,
+		Instant = 1 << 4,
+		Crucial = 1 << 5,
+		Sent =  1 << 8
+	}
+
+	public enum EventType {
+		None = 0,
+		Connect = 1,
+		Disconnect = 2,
+		Receive = 3,
+		Timeout = 4
+	}
+
+	public enum PeerState {
+		Uninitialized = -1,
+		Disconnected = 0,
+		Connecting = 1,
+		AcknowledgingConnect = 2,
+		ConnectionPending = 3,
+		ConnectionSucceeded = 4,
+		Connected = 5,
+		DisconnectLater = 6,
+		Disconnecting = 7,
+		AcknowledgingDisconnect = 8,
+		Zombie = 9
+	}
+
+	[StructLayout(LayoutKind.Explicit, Size = 18)]
+	internal struct ENetAddress {
+		[FieldOffset(16)]
+		public ushort port;
+	}
+
+	[StructLayout(LayoutKind.Sequential)]
+	internal struct ENetEvent {
+		public EventType type;
+		public IntPtr peer;
+		public byte channelID;
+		public uint data;
+		public IntPtr packet;
+	}
+
+	[StructLayout(LayoutKind.Sequential)]
+	internal struct ENetCallbacks {
+		public AllocCallback malloc;
+		public FreeCallback free;
+		public NoMemoryCallback noMemory;
+	}
+
+	public delegate IntPtr AllocCallback(IntPtr size);
+	public delegate void FreeCallback(IntPtr memory);
+	public delegate void NoMemoryCallback();
+	public delegate void PacketFreeCallback(Packet packet);
+
+	internal static class ArrayPool {
+		[ThreadStatic]
+		private static byte[] byteBuffer;
+		[ThreadStatic]
+		private static IntPtr[] pointerBuffer;
+
+		public static byte[] GetByteBuffer() {
+			if (byteBuffer == null)
+				byteBuffer = new byte[64];
+
+			return byteBuffer;
+		}
+
+		public static IntPtr[] GetPointerBuffer() {
+			if (pointerBuffer == null)
+				pointerBuffer = new IntPtr[Library.maxPeers];
+
+			return pointerBuffer;
+		}
+	}
+
+	public struct Address {
+		private ENetAddress nativeAddress;
+
+		internal ENetAddress NativeData {
+			get {
+				return nativeAddress;
+			}
+
+			set {
+				nativeAddress = value;
+			}
+		}
+
+		internal Address(ENetAddress address) {
+			nativeAddress = address;
+		}
+
+		public ushort Port {
+			get {
+				return nativeAddress.port;
+			}
+
+			set {
+				nativeAddress.port = value;
+			}
+		}
+
+		public string GetIP() {
+			StringBuilder ip = new StringBuilder(1025);
+
+			if (Native.enet_address_get_ip(ref nativeAddress, ip, (IntPtr)ip.Capacity) != 0)
+				return String.Empty;
+
+			return ip.ToString();
+		}
+
+		public bool SetIP(string ip) {
+			if (ip == null)
+				throw new ArgumentNullException("ip");
+
+			return Native.enet_address_set_ip(ref nativeAddress, ip) == 0;
+		}
+
+		public string GetHost() {
+			StringBuilder hostName = new StringBuilder(1025);
+
+			if (Native.enet_address_get_hostname(ref nativeAddress, hostName, (IntPtr)hostName.Capacity) != 0)
+				return String.Empty;
+
+			return hostName.ToString();
+		}
+
+		public bool SetHost(string hostName) {
+			if (hostName == null)
+				throw new ArgumentNullException("hostName");
+
+			return Native.enet_address_set_hostname(ref nativeAddress, hostName) == 0;
+		}
+	}
+
+	public struct Event {
+		private ENetEvent nativeEvent;
+
+		internal ENetEvent NativeData {
+			get {
+				return nativeEvent;
+			}
+
+			set {
+				nativeEvent = value;
+			}
+		}
+
+		internal Event(ENetEvent @event) {
+			nativeEvent = @event;
+		}
+
+		public EventType Type {
+			get {
+				return nativeEvent.type;
+			}
+		}
+
+		public Peer Peer {
+			get {
+				return new Peer(nativeEvent.peer);
+			}
+		}
+
+		public byte ChannelID {
+			get {
+				return nativeEvent.channelID;
+			}
+		}
+
+		public uint Data {
+			get {
+				return nativeEvent.data;
+			}
+		}
+
+		public Packet Packet {
+			get {
+				return new Packet(nativeEvent.packet);
+			}
+		}
+	}
+
+	public class Callbacks {
+		private ENetCallbacks nativeCallbacks;
+
+		internal ENetCallbacks NativeData {
+			get {
+				return nativeCallbacks;
+			}
+
+			set {
+				nativeCallbacks = value;
+			}
+		}
+
+		public Callbacks(AllocCallback allocCallback, FreeCallback freeCallback, NoMemoryCallback noMemoryCallback) {
+			nativeCallbacks.malloc = allocCallback;
+			nativeCallbacks.free = freeCallback;
+			nativeCallbacks.noMemory = noMemoryCallback;
+		}
+	}
+
+	public struct Packet : IDisposable {
+		private IntPtr nativePacket;
+
+		internal IntPtr NativeData {
+			get {
+				return nativePacket;
+			}
+
+			set {
+				nativePacket = value;
+			}
+		}
+
+		internal Packet(IntPtr packet) {
+			nativePacket = packet;
+		}
+
+		public void Dispose() {
+			if (nativePacket != IntPtr.Zero) {
+				Native.enet_packet_dispose(nativePacket);
+				nativePacket = IntPtr.Zero;
+			}
+		}
+
+		public bool IsSet {
+			get {
+				return nativePacket != IntPtr.Zero;
+			}
+		}
+
+		public IntPtr Data {
+			get {
+				IsCreated();
+
+				return Native.enet_packet_get_data(nativePacket);
+			}
+		}
+
+		public IntPtr UserData {
+			get {
+				IsCreated();
+
+				return Native.enet_packet_get_user_data(nativePacket);
+			}
+
+			set {
+				IsCreated();
+
+				Native.enet_packet_set_user_data(nativePacket, value);
+			}
+		}
+
+		public int Length {
+			get {
+				IsCreated();
+
+				return Native.enet_packet_get_length(nativePacket);
+			}
+		}
 
 
-            if (Native.enet_address_get_host_ip(nativeAddress, ip, (IntPtr)ip.Capacity) != 0)
-                return String.Empty;
+		public bool HasReferences {
+			get {
+				IsCreated();
 
 
-            return ip.ToString();
-        }
+				return Native.enet_packet_check_references(nativePacket) != 0;
+			}
+		}
 
 
-        public bool SetIP(string ip)
-        {
-            if (ip == null)
-                throw new ArgumentNullException("ip");
+		internal void IsCreated() {
+			if (nativePacket == IntPtr.Zero)
+				throw new InvalidOperationException("Packet not created");
+		}
 
 
-            return Native.enet_address_set_host_ip(ref nativeAddress, ip) == 0;
-        }
+		public void SetFreeCallback(IntPtr callback) {
+			IsCreated();
 
 
-        public string GetHost()
-        {
-            StringBuilder hostName = new StringBuilder(1024);
+			Native.enet_packet_set_free_callback(nativePacket, callback);
+		}
 
 
-            if (Native.enet_address_get_host(nativeAddress, hostName, (IntPtr)hostName.Capacity) != 0)
-                return String.Empty;
+		public void SetFreeCallback(PacketFreeCallback callback) {
+			IsCreated();
 
 
-            return hostName.ToString();
-        }
+			Native.enet_packet_set_free_callback(nativePacket, Marshal.GetFunctionPointerForDelegate(callback));
+		}
 
 
-        public bool SetHost(string hostName)
-        {
-            if (hostName == null)
-                throw new ArgumentNullException("hostName");
+		public void Create(byte[] data) {
+			if (data == null)
+				throw new ArgumentNullException("data");
 
 
-            return Native.enet_address_set_host(ref nativeAddress, hostName) == 0;
-        }
-    }
+			Create(data, data.Length);
+		}
 
 
-    public struct Event
-    {
-        private ENetEvent nativeEvent;
+		public void Create(byte[] data, int length) {
+			Create(data, length, PacketFlags.None);
+		}
 
 
-        internal ENetEvent NativeData {
-            get {
-                return nativeEvent;
-            }
+		public void Create(byte[] data, PacketFlags flags) {
+			Create(data, data.Length, flags);
+		}
 
 
-            set {
-                nativeEvent = value;
-            }
-        }
+		public void Create(byte[] data, int length, PacketFlags flags) {
+			if (data == null)
+				throw new ArgumentNullException("data");
 
 
-        internal Event(ENetEvent @event)
-        {
-            nativeEvent = @event;
-        }
+			if (length < 0 || length > data.Length)
+				throw new ArgumentOutOfRangeException();
 
 
-        public EventType Type {
-            get {
-                return nativeEvent.type;
-            }
-        }
+			nativePacket = Native.enet_packet_create(data, (IntPtr)length, flags);
+		}
 
 
-        public Peer Peer {
-            get {
-                return new Peer(nativeEvent.peer);
-            }
-        }
+		public void Create(IntPtr data, int length, PacketFlags flags) {
+			if (data == IntPtr.Zero)
+				throw new ArgumentNullException("data");
 
 
-        public byte ChannelID {
-            get {
-                return nativeEvent.channelID;
-            }
-        }
+			if (length < 0)
+				throw new ArgumentOutOfRangeException();
 
 
-        public uint Data {
-            get {
-                return nativeEvent.data;
-            }
-        }
+			nativePacket = Native.enet_packet_create(data, (IntPtr)length, flags);
+		}
 
 
-        public Packet Packet {
-            get {
-                return new Packet(nativeEvent.packet);
-            }
-        }
-    }
+		public void Create(byte[] data, int offset, int length, PacketFlags flags) {
+			if (data == null)
+				throw new ArgumentNullException("data");
 
 
-    public class Callbacks
-    {
-        private ENetCallbacks nativeCallbacks;
+			if (offset < 0 || length < 0 || length > data.Length)
+				throw new ArgumentOutOfRangeException();
 
 
-        internal ENetCallbacks NativeData {
-            get {
-                return nativeCallbacks;
-            }
+			nativePacket = Native.enet_packet_create_offset(data, (IntPtr)length, (IntPtr)offset, flags);
+		}
 
 
-            set {
-                nativeCallbacks = value;
-            }
-        }
-
-        public Callbacks(AllocCallback allocCallback, FreeCallback freeCallback, NoMemoryCallback noMemoryCallback)
-        {
-            nativeCallbacks.malloc = allocCallback;
-            nativeCallbacks.free = freeCallback;
-            nativeCallbacks.noMemory = noMemoryCallback;
-        }
-    }
-
-    public struct Packet : IDisposable
-    {
-        private IntPtr nativePacket;
-
-        internal IntPtr NativeData {
-            get {
-                return nativePacket;
-            }
+		public void Create(IntPtr data, int offset, int length, PacketFlags flags) {
+			if (data == IntPtr.Zero)
+				throw new ArgumentNullException("data");
 
 
-            set {
-                nativePacket = value;
-            }
-        }
+			if (offset < 0 || length < 0)
+				throw new ArgumentOutOfRangeException();
 
 
-        internal Packet(IntPtr packet)
-        {
-            nativePacket = packet;
-        }
+			nativePacket = Native.enet_packet_create_offset(data, (IntPtr)length, (IntPtr)offset, flags);
+		}
 
 
-        public void Dispose()
-        {
-            if (nativePacket != IntPtr.Zero)
+		public void CopyTo(byte[] destination) {
+            if (destination == null)
+                throw new ArgumentNullException("destination");
+            
+			// Fix by katori, prevents trying to copy a NULL
+			// from native world (ie. disconnect a client)			
+			if (Data == null)
             {
             {
-                Native.enet_packet_dispose(nativePacket);
-                nativePacket = IntPtr.Zero;
+                return;
             }
             }
-        }
+			
+            Marshal.Copy(Data, destination, 0, Length);
+		}
+	}
+
+	public class Host : IDisposable {
+		private IntPtr nativeHost;
+
+		internal IntPtr NativeData {
+			get {
+				return nativeHost;
+			}
+
+			set {
+				nativeHost = value;
+			}
+		}
+
+		public void Dispose() {
+			Dispose(true);
+			GC.SuppressFinalize(this);
+		}
+
+		protected virtual void Dispose(bool disposing) {
+			if (nativeHost != IntPtr.Zero) {
+				Native.enet_host_destroy(nativeHost);
+				nativeHost = IntPtr.Zero;
+			}
+		}
+
+		~Host() {
+			Dispose(false);
+		}
+
+		public bool IsSet {
+			get {
+				return nativeHost != IntPtr.Zero;
+			}
+		}
+
+		public uint PeersCount {
+			get {
+				IsCreated();
+
+				return Native.enet_host_get_peers_count(nativeHost);
+			}
+		}
 
 
-        public bool IsSet {
-            get {
-                return nativePacket != IntPtr.Zero;
-            }
-        }
+		public uint PacketsSent {
+			get {
+				IsCreated();
+
+				return Native.enet_host_get_packets_sent(nativeHost);
+			}
+		}
 
 
-        public IntPtr Data {
-            get {
-                CheckCreated();
+		public uint PacketsReceived {
+			get {
+				IsCreated();
+
+				return Native.enet_host_get_packets_received(nativeHost);
+			}
+		}
 
 
-                return Native.enet_packet_get_data(nativePacket);
-            }
-        }
+		public uint BytesSent {
+			get {
+				IsCreated();
 
 
-        public int Length {
-            get {
-                CheckCreated();
+				return Native.enet_host_get_bytes_sent(nativeHost);
+			}
+		}
 
 
-                return Native.enet_packet_get_length(nativePacket);
-            }
-        }
+		public uint BytesReceived {
+			get {
+				IsCreated();
+
+				return Native.enet_host_get_bytes_received(nativeHost);
+			}
+		}
 
 
-        public bool HasReferences {
-            get {
-                CheckCreated();
+		internal void IsCreated() {
+			if (nativeHost == IntPtr.Zero)
+				throw new InvalidOperationException("Host not created");
+		}
 
 
-                return Native.enet_packet_check_references(nativePacket) != 0;
-            }
-        }
+		private void IsChannelLimited(int channelLimit) {
+			if (channelLimit < 0 || channelLimit > Library.maxChannelCount)
+				throw new ArgumentOutOfRangeException("channelLimit");
+		}
 
 
-        internal void CheckCreated()
-        {
-            if (nativePacket == IntPtr.Zero)
-                throw new InvalidOperationException("Packet not created");
-        }
+		public void Create() {
+			Create(null, 1, 0);
+		}
 
 
-        public void SetFreeCallback(IntPtr callback)
-        {
-            CheckCreated();
+		public void Create(int bufferSize) {
+			Create(null, 1, 0, 0, 0, bufferSize);
+		}
 
 
-            Native.enet_packet_set_free_callback(nativePacket, callback);
-        }
+		public void Create(Address? address, int peerLimit) {
+			Create(address, peerLimit, 0);
+		}
 
 
-        public void SetFreeCallback(PacketFreeCallback callback)
-        {
-            CheckCreated();
+		public void Create(Address? address, int peerLimit, int channelLimit) {
+			Create(address, peerLimit, channelLimit, 0, 0, 0);
+		}
 
 
-            Native.enet_packet_set_free_callback(nativePacket, Marshal.GetFunctionPointerForDelegate(callback));
-        }
+		public void Create(int peerLimit, int channelLimit) {
+			Create(null, peerLimit, channelLimit, 0, 0, 0);
+		}
 
 
-        public void Create(byte[] data)
-        {
-            if (data == null)
-                throw new ArgumentNullException("data");
+		public void Create(int peerLimit, int channelLimit, uint incomingBandwidth, uint outgoingBandwidth) {
+			Create(null, peerLimit, channelLimit, incomingBandwidth, outgoingBandwidth, 0);
+		}
 
 
-            Create(data, data.Length);
-        }
+		public void Create(Address? address, int peerLimit, int channelLimit, uint incomingBandwidth, uint outgoingBandwidth) {
+			Create(address, peerLimit, channelLimit, incomingBandwidth, outgoingBandwidth, 0);
+		}
 
 
-        public void Create(byte[] data, int length)
-        {
-            Create(data, length, PacketFlags.None);
-        }
+		public void Create(Address? address, int peerLimit, int channelLimit, uint incomingBandwidth, uint outgoingBandwidth, int bufferSize) {
+			if (nativeHost != IntPtr.Zero)
+				throw new InvalidOperationException("Host already created");
 
 
-        public void Create(byte[] data, PacketFlags flags)
-        {
-            Create(data, data.Length, flags);
-        }
+			if (peerLimit < 0 || peerLimit > Library.maxPeers)
+				throw new ArgumentOutOfRangeException("peerLimit");
 
 
-        public void Create(byte[] data, int length, PacketFlags flags)
-        {
-            if (data == null)
-                throw new ArgumentNullException("data");
+			IsChannelLimited(channelLimit);
 
 
-            if (length < 0 || length > data.Length)
-                throw new ArgumentOutOfRangeException();
+			if (address != null) {
+				var nativeAddress = address.Value.NativeData;
 
 
-            nativePacket = Native.enet_packet_create(data, (IntPtr)length, flags);
-        }
+				nativeHost = Native.enet_host_create(ref nativeAddress, (IntPtr)peerLimit, (IntPtr)channelLimit, incomingBandwidth, outgoingBandwidth, bufferSize);
+			} else {
+				nativeHost = Native.enet_host_create(IntPtr.Zero, (IntPtr)peerLimit, (IntPtr)channelLimit, incomingBandwidth, outgoingBandwidth, bufferSize);
+			}
 
 
-        public void Create(IntPtr data, int length, PacketFlags flags)
-        {
-            if (data == IntPtr.Zero)
-                throw new ArgumentNullException("data");
+			if (nativeHost == IntPtr.Zero)
+				throw new InvalidOperationException("Host creation call failed");
+		}
 
 
-            if (length < 0)
-                throw new ArgumentOutOfRangeException();
+		public void PreventConnections(bool state) {
+			IsCreated();
 
 
-            nativePacket = Native.enet_packet_create(data, (IntPtr)length, flags);
-        }
+			Native.enet_host_prevent_connections(nativeHost, (byte)(state ? 1 : 0));
+		}
 
 
-        public void Create(byte[] data, int offset, int length, PacketFlags flags)
-        {
-            if (data == null)
-                throw new ArgumentNullException("data");
+		public void Broadcast(byte channelID, ref Packet packet) {
+			IsCreated();
 
 
-            if (offset < 0 || length < 0 || length > data.Length)
-                throw new ArgumentOutOfRangeException();
+			packet.IsCreated();
+			Native.enet_host_broadcast(nativeHost, channelID, packet.NativeData);
+			packet.NativeData = IntPtr.Zero;
+		}
 
 
-            nativePacket = Native.enet_packet_create_offset(data, (IntPtr)length, (IntPtr)offset, flags);
-        }
+		public void Broadcast(byte channelID, ref Packet packet, Peer excludedPeer) {
+			IsCreated();
 
 
-        public void Create(IntPtr data, int offset, int length, PacketFlags flags)
-        {
-            if (data == IntPtr.Zero)
-                throw new ArgumentNullException("data");
+			packet.IsCreated();
+			Native.enet_host_broadcast_exclude(nativeHost, channelID, packet.NativeData, excludedPeer.NativeData);
+			packet.NativeData = IntPtr.Zero;
+		}
 
 
-            if (offset < 0 || length < 0)
-                throw new ArgumentOutOfRangeException();
+		public void Broadcast(byte channelID, ref Packet packet, Peer[] peers) {
+			IsCreated();
 
 
-            nativePacket = Native.enet_packet_create_offset(data, (IntPtr)length, (IntPtr)offset, flags);
-        }
+			packet.IsCreated();
 
 
-        public void CopyTo(byte[] destination)
-        {
-            if (destination == null)
-                throw new ArgumentNullException("destination");
-            if (Data == null)
-            {
-                return;
-            }
-            Marshal.Copy(Data, destination, 0, Length);
-        }
-    }
+			if (peers.Length > 0) {
+				IntPtr[] nativePeers = ArrayPool.GetPointerBuffer();
+				int nativeCount = 0;
 
 
-    public class Host : IDisposable
-    {
-        private IntPtr nativeHost;
+				for (int i = 0; i < peers.Length; i++) {
+					if (peers[i].NativeData != IntPtr.Zero) {
+						nativePeers[nativeCount] = peers[i].NativeData;
+						nativeCount++;
+					}
+				}
 
 
-        internal IntPtr NativeData {
-            get {
-                return nativeHost;
-            }
+				Native.enet_host_broadcast_selective(nativeHost, channelID, packet.NativeData, nativePeers, (IntPtr)nativeCount);
+			}
 
 
-            set {
-                nativeHost = value;
-            }
-        }
+			packet.NativeData = IntPtr.Zero;
+		}
 
 
-        public void Dispose()
-        {
-            Dispose(true);
-            GC.SuppressFinalize(this);
-        }
+		public int CheckEvents(out Event @event) {
+			IsCreated();
 
 
-        protected virtual void Dispose(bool disposing)
-        {
-            if (nativeHost != IntPtr.Zero)
-            {
-                Native.enet_host_destroy(nativeHost);
-                nativeHost = IntPtr.Zero;
-            }
-        }
+			ENetEvent nativeEvent;
 
 
-        ~Host()
-        {
-            Dispose(false);
-        }
+			var result = Native.enet_host_check_events(nativeHost, out nativeEvent);
 
 
-        public bool IsSet {
-            get {
-                return nativeHost != IntPtr.Zero;
-            }
-        }
+			if (result <= 0) {
+				@event = default;
 
 
-        public uint PeersCount {
-            get {
-                CheckCreated();
+				return result;
+			}
 
 
-                return Native.enet_host_get_peers_count(nativeHost);
-            }
-        }
+			@event = new Event(nativeEvent);
 
 
-        public uint PacketsSent {
-            get {
-                CheckCreated();
+			return result;
+		}
 
 
-                return Native.enet_host_get_packets_sent(nativeHost);
-            }
-        }
+		public Peer Connect(Address address) {
+			return Connect(address, 0, 0);
+		}
 
 
-        public uint PacketsReceived {
-            get {
-                CheckCreated();
+		public Peer Connect(Address address, int channelLimit) {
+			return Connect(address, channelLimit, 0);
+		}
 
 
-                return Native.enet_host_get_packets_received(nativeHost);
-            }
-        }
+		public Peer Connect(Address address, int channelLimit, uint data) {
+			IsCreated();
+			IsChannelLimited(channelLimit);
 
 
-        public uint BytesSent {
-            get {
-                CheckCreated();
+			var nativeAddress = address.NativeData;
+			var peer = new Peer(Native.enet_host_connect(nativeHost, ref nativeAddress, (IntPtr)channelLimit, data));
 
 
-                return Native.enet_host_get_bytes_sent(nativeHost);
-            }
-        }
+			if (peer.NativeData == IntPtr.Zero)
+				throw new InvalidOperationException("Host connect call failed");
 
 
-        public uint BytesReceived {
-            get {
-                CheckCreated();
+			return peer;
+		}
 
 
-                return Native.enet_host_get_bytes_received(nativeHost);
-            }
-        }
-
-        internal void CheckCreated()
-        {
-            if (nativeHost == IntPtr.Zero)
-                throw new InvalidOperationException("Host not created");
-        }
-
-        private void CheckChannelLimit(int channelLimit)
-        {
-            if (channelLimit < 0 || channelLimit > Library.maxChannelCount)
-                throw new ArgumentOutOfRangeException("channelLimit");
-        }
-
-        public void Create()
-        {
-            Create(null, 1, 0);
-        }
-
-        public void Create(int bufferSize)
-        {
-            Create(null, 1, 0, 0, 0, bufferSize);
-        }
-
-        public void Create(Address? address, int peerLimit)
-        {
-            Create(address, peerLimit, 0);
-        }
-
-        public void Create(Address? address, int peerLimit, int channelLimit)
-        {
-            Create(address, peerLimit, channelLimit, 0, 0, 0);
-        }
-
-        public void Create(int peerLimit, int channelLimit)
-        {
-            Create(null, peerLimit, channelLimit, 0, 0, 0);
-        }
-
-        public void Create(int peerLimit, int channelLimit, uint incomingBandwidth, uint outgoingBandwidth)
-        {
-            Create(null, peerLimit, channelLimit, incomingBandwidth, outgoingBandwidth, 0);
-        }
-
-        public void Create(Address? address, int peerLimit, int channelLimit, uint incomingBandwidth, uint outgoingBandwidth)
-        {
-            Create(address, peerLimit, channelLimit, incomingBandwidth, outgoingBandwidth, 0);
-        }
-
-        public void Create(Address? address, int peerLimit, int channelLimit, uint incomingBandwidth, uint outgoingBandwidth, int bufferSize)
-        {
-            if (nativeHost != IntPtr.Zero)
-                throw new InvalidOperationException("Host already created");
-
-            if (peerLimit < 0 || peerLimit > Library.maxPeers)
-                throw new ArgumentOutOfRangeException("peerLimit");
-
-            CheckChannelLimit(channelLimit);
-
-            if (address != null)
-            {
-                ENetAddress nativeAddress = address.Value.NativeData;
+		public int Service(int timeout, out Event @event) {
+			if (timeout < 0)
+				throw new ArgumentOutOfRangeException("timeout");
 
 
-                nativeHost = Native.enet_host_create(ref nativeAddress, (IntPtr)peerLimit, (IntPtr)channelLimit, incomingBandwidth, outgoingBandwidth, bufferSize);
-            }
-            else
-            {
-                nativeHost = Native.enet_host_create(IntPtr.Zero, (IntPtr)peerLimit, (IntPtr)channelLimit, incomingBandwidth, outgoingBandwidth, bufferSize);
-            }
+			IsCreated();
 
 
-            if (nativeHost == IntPtr.Zero)
-                throw new InvalidOperationException("Host creation call failed");
-        }
+			ENetEvent nativeEvent;
 
 
-        public void EnableCompression()
-        {
-            CheckCreated();
+			var result = Native.enet_host_service(nativeHost, out nativeEvent, (uint)timeout);
 
 
-            Native.enet_host_enable_compression(nativeHost);
-        }
+			if (result <= 0) {
+				@event = default;
 
 
-        public void PreventConnections(bool state)
-        {
-            CheckCreated();
+				return result;
+			}
 
 
-            Native.enet_host_prevent_connections(nativeHost, (byte)(state ? 1 : 0));
-        }
+			@event = new Event(nativeEvent);
 
 
-        public void Broadcast(byte channelID, ref Packet packet)
-        {
-            CheckCreated();
+			return result;
+		}
 
 
-            packet.CheckCreated();
-            Native.enet_host_broadcast(nativeHost, channelID, packet.NativeData);
-            packet.NativeData = IntPtr.Zero;
-        }
+		public void SetBandwidthLimit(uint incomingBandwidth, uint outgoingBandwidth) {
+			IsCreated();
 
 
-        public void Broadcast(byte channelID, ref Packet packet, Peer excludedPeer)
-        {
-            CheckCreated();
+			Native.enet_host_bandwidth_limit(nativeHost, incomingBandwidth, outgoingBandwidth);
+		}
 
 
-            packet.CheckCreated();
-            Native.enet_host_broadcast_exclude(nativeHost, channelID, packet.NativeData, excludedPeer.NativeData);
-            packet.NativeData = IntPtr.Zero;
-        }
+		public void SetChannelLimit(int channelLimit) {
+			IsCreated();
+			IsChannelLimited(channelLimit);
 
 
-        public void Broadcast(byte channelID, ref Packet packet, Peer[] peers)
-        {
-            CheckCreated();
+			Native.enet_host_channel_limit(nativeHost, (IntPtr)channelLimit);
+		}
 
 
-            packet.CheckCreated();
+		public void Flush() {
+			IsCreated();
 
 
-            if (peers.Length > 0)
-            {
-                IntPtr[] nativePeers = ArrayPool.GetPointerBuffer();
-                int nativeCount = 0;
-
-                for (int i = 0; i < peers.Length; i++)
-                {
-                    if (peers[i].NativeData != IntPtr.Zero)
-                    {
-                        nativePeers[nativeCount] = peers[i].NativeData;
-                        nativeCount++;
-                    }
-                }
-
-                Native.enet_host_broadcast_selective(nativeHost, channelID, packet.NativeData, nativePeers, (IntPtr)nativeCount);
-            }
+			Native.enet_host_flush(nativeHost);
+		}
+	}
 
 
-            packet.NativeData = IntPtr.Zero;
-        }
+	public struct Peer {
+		private IntPtr nativePeer;
+		private uint nativeID;
 
 
-        public int CheckEvents(out Event @event)
-        {
-            CheckCreated();
+		internal IntPtr NativeData {
+			get {
+				return nativePeer;
+			}
 
 
+			set {
+				nativePeer = value;
+			}
+		}
 
 
-            int result = Native.enet_host_check_events(nativeHost, out ENetEvent nativeEvent);
+		internal Peer(IntPtr peer) {
+			nativePeer = peer;
+			nativeID = nativePeer != IntPtr.Zero ? Native.enet_peer_get_id(nativePeer) : 0;
+		}
 
 
-            if (result <= 0)
-            {
-                @event = default;
+		public bool IsSet {
+			get {
+				return nativePeer != IntPtr.Zero;
+			}
+		}
 
 
-                return result;
-            }
+		public uint ID {
+			get {
+				return nativeID;
+			}
+		}
 
 
-            @event = new Event(nativeEvent);
+		public string IP {
+			get {
+				IsCreated();
 
 
-            return result;
-        }
+				byte[] ip = ArrayPool.GetByteBuffer();
 
 
-        public Peer Connect(Address address)
-        {
-            return Connect(address, 0, 0);
-        }
+				if (Native.enet_peer_get_ip(nativePeer, ip, (IntPtr)ip.Length) == 0)
+					return Encoding.ASCII.GetString(ip, 0, ip.StringLength());
+				else
+					return String.Empty;
+			}
+		}
 
 
-        public Peer Connect(Address address, int channelLimit)
-        {
-            return Connect(address, channelLimit, 0);
-        }
+		public ushort Port {
+			get {
+				IsCreated();
 
 
-        public Peer Connect(Address address, int channelLimit, uint data)
-        {
-            CheckCreated();
-            CheckChannelLimit(channelLimit);
+				return Native.enet_peer_get_port(nativePeer);
+			}
+		}
 
 
-            ENetAddress nativeAddress = address.NativeData;
-            Peer peer = new Peer(Native.enet_host_connect(nativeHost, ref nativeAddress, (IntPtr)channelLimit, data));
+		public uint MTU {
+			get {
+				IsCreated();
 
 
-            if (peer.NativeData == IntPtr.Zero)
-                throw new InvalidOperationException("Host connect call failed");
+				return Native.enet_peer_get_mtu(nativePeer);
+			}
+		}
 
 
-            return peer;
-        }
+		public PeerState State {
+			get {
+				return nativePeer == IntPtr.Zero ? PeerState.Uninitialized : Native.enet_peer_get_state(nativePeer);
+			}
+		}
 
 
-        public int Service(int timeout, out Event @event)
-        {
-            if (timeout < 0)
-                throw new ArgumentOutOfRangeException("timeout");
+		public uint RoundTripTime {
+			get {
+				IsCreated();
 
 
-            CheckCreated();
+				return Native.enet_peer_get_rtt(nativePeer);
+			}
+		}
 
 
+		public uint LastRoundTripTime {
+			get {
+				IsCreated();
 
 
-            int result = Native.enet_host_service(nativeHost, out ENetEvent nativeEvent, (uint)timeout);
+				return Native.enet_peer_get_last_rtt(nativePeer);
+			}
+		}
 
 
-            if (result <= 0)
-            {
-                @event = default;
+		public uint LastSendTime {
+			get {
+				IsCreated();
 
 
-                return result;
-            }
+				return Native.enet_peer_get_lastsendtime(nativePeer);
+			}
+		}
 
 
-            @event = new Event(nativeEvent);
+		public uint LastReceiveTime {
+			get {
+				IsCreated();
 
 
-            return result;
-        }
+				return Native.enet_peer_get_lastreceivetime(nativePeer);
+			}
+		}
 
 
-        public void SetBandwidthLimit(uint incomingBandwidth, uint outgoingBandwidth)
-        {
-            CheckCreated();
+		public ulong PacketsSent {
+			get {
+				IsCreated();
 
 
-            Native.enet_host_bandwidth_limit(nativeHost, incomingBandwidth, outgoingBandwidth);
-        }
+				return Native.enet_peer_get_packets_sent(nativePeer);
+			}
+		}
 
 
-        public void SetChannelLimit(int channelLimit)
-        {
-            CheckCreated();
-            CheckChannelLimit(channelLimit);
+		public ulong PacketsLost {
+			get {
+				IsCreated();
 
 
-            Native.enet_host_channel_limit(nativeHost, (IntPtr)channelLimit);
-        }
+				return Native.enet_peer_get_packets_lost(nativePeer);
+			}
+		}
 
 
-        public void Flush()
-        {
-            CheckCreated();
+		public ulong BytesSent {
+			get {
+				IsCreated();
 
 
-            Native.enet_host_flush(nativeHost);
-        }
-    }
+				return Native.enet_peer_get_bytes_sent(nativePeer);
+			}
+		}
 
 
-    public struct Peer
-    {
-        private IntPtr nativePeer;
-        private readonly uint nativeID;
+		public ulong BytesReceived {
+			get {
+				IsCreated();
 
 
-        internal IntPtr NativeData {
-            get {
-                return nativePeer;
-            }
+				return Native.enet_peer_get_bytes_received(nativePeer);
+			}
+		}
 
 
-            set {
-                nativePeer = value;
-            }
-        }
+		public IntPtr Data {
+			get {
+				IsCreated();
 
 
-        internal Peer(IntPtr peer)
-        {
-            nativePeer = peer;
-            nativeID = nativePeer != IntPtr.Zero ? Native.enet_peer_get_id(nativePeer) : 0;
-        }
+				return Native.enet_peer_get_data(nativePeer);
+			}
 
 
-        public bool IsSet {
-            get {
-                return nativePeer != IntPtr.Zero;
-            }
-        }
+			set {
+				IsCreated();
 
 
-        public uint ID {
-            get {
-                return nativeID;
-            }
-        }
+				Native.enet_peer_set_data(nativePeer, value);
+			}
+		}
 
 
-        public string IP {
-            get {
-                CheckCreated();
+		internal void IsCreated() {
+			if (nativePeer == IntPtr.Zero)
+				throw new InvalidOperationException("Peer not created");
+		}
 
 
-                byte[] ip = ArrayPool.GetByteBuffer();
+		public void ConfigureThrottle(uint interval, uint acceleration, uint deceleration, uint threshold) {
+			IsCreated();
 
 
-                if (Native.enet_peer_get_ip(nativePeer, ip, (IntPtr)ip.Length) == 0)
-                    return Encoding.ASCII.GetString(ip, 0, ip.StringLength());
-                else
-                    return String.Empty;
-            }
-        }
+			Native.enet_peer_throttle_configure(nativePeer, interval, acceleration, deceleration, threshold);
+		}
 
 
-        public ushort Port {
-            get {
-                CheckCreated();
+		public bool Send(byte channelID, ref Packet packet) {
+			IsCreated();
 
 
-                return Native.enet_peer_get_port(nativePeer);
-            }
-        }
+			packet.IsCreated();
 
 
-        public uint MTU {
-            get {
-                CheckCreated();
+			return Native.enet_peer_send(nativePeer, channelID, packet.NativeData) == 0;
+		}
 
 
-                return Native.enet_peer_get_mtu(nativePeer);
-            }
-        }
+		public bool Receive(out byte channelID, out Packet packet) {
+			IsCreated();
 
 
-        public PeerState State {
-            get {
-                return nativePeer == IntPtr.Zero ? PeerState.Uninitialized : Native.enet_peer_get_state(nativePeer);
-            }
-        }
+			IntPtr nativePacket = Native.enet_peer_receive(nativePeer, out channelID);
 
 
-        public uint RoundTripTime {
-            get {
-                CheckCreated();
+			if (nativePacket != IntPtr.Zero) {
+				packet = new Packet(nativePacket);
 
 
-                return Native.enet_peer_get_rtt(nativePeer);
-            }
-        }
+				return true;
+			}
 
 
-        public uint LastSendTime {
-            get {
-                CheckCreated();
+			packet = default;
 
 
-                return Native.enet_peer_get_lastsendtime(nativePeer);
-            }
-        }
+			return false;
+		}
 
 
-        public uint LastReceiveTime {
-            get {
-                CheckCreated();
+		public void Ping() {
+			IsCreated();
 
 
-                return Native.enet_peer_get_lastreceivetime(nativePeer);
-            }
-        }
+			Native.enet_peer_ping(nativePeer);
+		}
 
 
-        public ulong PacketsSent {
-            get {
-                CheckCreated();
+		public void PingInterval(uint interval) {
+			IsCreated();
 
 
-                return Native.enet_peer_get_packets_sent(nativePeer);
-            }
-        }
+			Native.enet_peer_ping_interval(nativePeer, interval);
+		}
 
 
-        public ulong PacketsLost {
-            get {
-                CheckCreated();
+		public void Timeout(uint timeoutLimit, uint timeoutMinimum, uint timeoutMaximum) {
+			IsCreated();
 
 
-                return Native.enet_peer_get_packets_lost(nativePeer);
-            }
-        }
+			Native.enet_peer_timeout(nativePeer, timeoutLimit, timeoutMinimum, timeoutMaximum);
+		}
 
 
-        public ulong BytesSent {
-            get {
-                CheckCreated();
+		public void Disconnect(uint data) {
+			IsCreated();
 
 
-                return Native.enet_peer_get_bytes_sent(nativePeer);
-            }
-        }
+			Native.enet_peer_disconnect(nativePeer, data);
+		}
 
 
-        public ulong BytesReceived {
-            get {
-                CheckCreated();
+		public void DisconnectNow(uint data) {
+			IsCreated();
 
 
-                return Native.enet_peer_get_bytes_received(nativePeer);
-            }
-        }
+			Native.enet_peer_disconnect_now(nativePeer, data);
+		}
 
 
-        public IntPtr Data {
-            get {
-                CheckCreated();
+		public void DisconnectLater(uint data) {
+			IsCreated();
 
 
-                return Native.enet_peer_get_data(nativePeer);
-            }
+			Native.enet_peer_disconnect_later(nativePeer, data);
+		}
 
 
-            set {
-                CheckCreated();
+		public void Reset() {
+			IsCreated();
 
 
-                Native.enet_peer_set_data(nativePeer, value);
-            }
-        }
+			Native.enet_peer_reset(nativePeer);
+		}
 
 
-        internal void CheckCreated()
-        {
-            if (nativePeer == IntPtr.Zero)
-                throw new InvalidOperationException("Peer not created");
-        }
+		// == ADDITIONS NOT AVAILABLE IN UPSTREAM REPOSITORY == //
+		// These are placed here to ensure that merge conflicts aren't a
+		// pain in the ass.
 
 
-        public void ConfigureThrottle(uint interval, uint acceleration, uint deceleration, uint threshold)
-        {
-            CheckCreated();
+		// SendAndReturnStatusCode returns either 0 if the send was successful,
+		// or the ENET return code if not. Sometimes a bool is not enough to determine
+		// the root cause of a issue.
+		public int SendAndReturnStatusCode(byte channelID, ref Packet packet)
+		{
+			IsCreated();
 
 
-            Native.enet_peer_throttle_configure(nativePeer, interval, acceleration, deceleration, threshold);
-        }
+			packet.IsCreated();
 
 
-        public bool Send(byte channelID, ref Packet packet)
-        {
-            CheckCreated();
+			return Native.enet_peer_send(nativePeer, channelID, packet.NativeData);
+		}
+	}
 
 
-            packet.CheckCreated();
+	public static class Extensions {
+		public static int StringLength(this byte[] data) {
+			if (data == null)
+				throw new ArgumentNullException("data");
 
 
-            return Native.enet_peer_send(nativePeer, channelID, packet.NativeData) == 0;
-        }
+			int i;
 
 
-        // Added by Coburn. This version returns either 0 if the send was successful,
-        // or the ENET return code if not. Sometimes a bool is not enough to determine
-        // the root cause of the issue.
-        public int SendAndReturnStatusCode(byte channelID, ref Packet packet)
-        {
-            CheckCreated();
+			for (i = 0; i < data.Length && data[i] != 0; i++);
 
 
-            packet.CheckCreated();
+			return i;
+		}
+	}
 
 
-            return Native.enet_peer_send(nativePeer, channelID, packet.NativeData);
-        }
+	public static class Library {
+		public const uint maxChannelCount = 0xFF;
+		public const uint maxPeers = 0xFFF;
+		public const uint maxPacketSize = 32 * 1024 * 1024;
+		public const uint throttleThreshold = 20;
+		public const uint throttleScale = 32;
+		public const uint throttleAcceleration = 2;
+		public const uint throttleDeceleration = 2;
+		public const uint throttleInterval = 5000;
+		public const uint timeoutLimit = 32;
+		public const uint timeoutMinimum = 5000;
+		public const uint timeoutMaximum = 30000;
+		
+		// Lock our version to 2.4.0, to avoid confusion with upstream.
+		public const uint version = (2 << 16) | (4 << 8) | (0);
 
 
+		public static bool Initialize() {
+			return Native.enet_initialize() == 0;
+		}
 
 
-        public bool Receive(out byte channelID, out Packet packet)
-        {
-            CheckCreated();
+		public static bool Initialize(Callbacks callbacks) {
+			ENetCallbacks nativeCallbacks = callbacks.NativeData;
 
 
-            IntPtr nativePacket = Native.enet_peer_receive(nativePeer, out channelID);
+			return Native.enet_initialize_with_callbacks(version, ref nativeCallbacks) == 0;
+		}
 
 
-            if (nativePacket != IntPtr.Zero)
-            {
-                packet = new Packet(nativePacket);
-
-                return true;
-            }
+		public static void Deinitialize() {
+			Native.enet_deinitialize();
+		}
 
 
-            packet = default;
+		public static uint Time {
+			get {
+				return Native.enet_time_get();
+			}
+		}
+	}
 
 
-            return false;
-        }
-
-        public void Ping()
-        {
-            CheckCreated();
-
-            Native.enet_peer_ping(nativePeer);
-        }
-
-        public void PingInterval(uint interval)
-        {
-            CheckCreated();
-
-            Native.enet_peer_ping_interval(nativePeer, interval);
-        }
-
-        public void Timeout(uint timeoutLimit, uint timeoutMinimum, uint timeoutMaximum)
-        {
-            CheckCreated();
-
-            Native.enet_peer_timeout(nativePeer, timeoutLimit, timeoutMinimum, timeoutMaximum);
-        }
-
-        public void Disconnect(uint data)
-        {
-            CheckCreated();
-
-            Native.enet_peer_disconnect(nativePeer, data);
-        }
-
-        public void DisconnectNow(uint data)
-        {
-            CheckCreated();
-
-            Native.enet_peer_disconnect_now(nativePeer, data);
-        }
-
-        public void DisconnectLater(uint data)
-        {
-            CheckCreated();
-
-            Native.enet_peer_disconnect_later(nativePeer, data);
-        }
-
-        public void Reset()
-        {
-            CheckCreated();
-
-            Native.enet_peer_reset(nativePeer);
-        }
-    }
-
-    public static class Extensions
-    {
-        public static int StringLength(this byte[] data)
-        {
-            if (data == null)
-                throw new ArgumentNullException("data");
-
-            int i;
-
-            for (i = 0; i < data.Length && data[i] != 0; i++) ;
-
-            return i;
-        }
-    }
-
-    public static class Library
-    {
-        public const uint maxChannelCount = 0xFF;
-        public const uint maxPeers = 0xFFF;
-        public const uint maxPacketSize = 32 * 1024 * 1024;	    
-    	public const uint throttleThreshold = 20; 		// Reasonable threshold to help reduce throttling.
-        public const uint throttleScale = 32;
-        public const uint throttleAcceleration = 2;
-        public const uint throttleDeceleration = 2;
-        public const uint throttleInterval = 5000;
-        public const uint timeoutLimit = 32;
-        public const uint timeoutMinimum = 5000;
-        public const uint timeoutMaximum = 30000;
-	    
-        public const uint version = (2 << 16) | (4 << 8) | (0);
-
-        public static bool Initialize()
-        {
-            return Native.enet_initialize() == 0;
-        }
-
-        public static bool Initialize(Callbacks inits)
-        {
-            return Native.enet_initialize_with_callbacks(version, inits.NativeData) == 0;
-        }
-
-        public static void Deinitialize()
-        {
-            Native.enet_deinitialize();
-        }
-
-        public static uint Time {
-            get {
-                return Native.enet_time_get();
-            }
-        }
-    }
-
-    [SuppressUnmanagedCodeSecurity]
-    internal static class Native
-    {
+	[SuppressUnmanagedCodeSecurity]
+	internal static class Native {
 #if __IOS__ || UNITY_IOS && !UNITY_EDITOR
 #if __IOS__ || UNITY_IOS && !UNITY_EDITOR
-        // iOS
+        // We're building for a certain mobile fruity OS.
 		private const string nativeLibrary = "__Internal";
 		private const string nativeLibrary = "__Internal";
 #elif __APPLE__ || UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
 #elif __APPLE__ || UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
-        // MacOS
-        // Custom ENet Repo builds as libenet.bundle; make sure it's the same.
+        // We're building for a certain fruity OS.
         private const string nativeLibrary = "libenet";
         private const string nativeLibrary = "libenet";
 #else
 #else
-        // Assume everything else, Windows et al...
-        // This might be interesting if someone's building for Nintendo Switch or whatnot...
+        // Assume everything else, Windows et al...		
         private const string nativeLibrary = "enet";
         private const string nativeLibrary = "enet";
-#endif
+#endif	
+
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern int enet_initialize();
+
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern int enet_initialize_with_callbacks(uint version, ref ENetCallbacks inits);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern int enet_initialize();
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_deinitialize();
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern int enet_initialize_with_callbacks(uint version, ENetCallbacks inits);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern uint enet_time_get();
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_deinitialize();
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern int enet_address_set_ip(ref ENetAddress address, string ip);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern uint enet_time_get();
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern int enet_address_set_hostname(ref ENetAddress address, string hostName);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
-        internal static extern int enet_address_set_host_ip(ref ENetAddress address, string ip);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern int enet_address_get_ip(ref ENetAddress address, StringBuilder ip, IntPtr ipLength);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
-        internal static extern int enet_address_set_host(ref ENetAddress address, string hostName);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern int enet_address_get_hostname(ref ENetAddress address, StringBuilder hostName, IntPtr nameLength);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
-        internal static extern int enet_address_get_host_ip(ENetAddress address, StringBuilder ip, IntPtr ipLength);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern IntPtr enet_packet_create(byte[] data, IntPtr dataLength, PacketFlags flags);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
-        internal static extern int enet_address_get_host(ENetAddress address, StringBuilder hostName, IntPtr nameLength);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern IntPtr enet_packet_create(IntPtr data, IntPtr dataLength, PacketFlags flags);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern IntPtr enet_packet_create(byte[] data, IntPtr dataLength, PacketFlags flags);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern IntPtr enet_packet_create_offset(byte[] data, IntPtr dataLength, IntPtr dataOffset, PacketFlags flags);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern IntPtr enet_packet_create(IntPtr data, IntPtr dataLength, PacketFlags flags);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern IntPtr enet_packet_create_offset(IntPtr data, IntPtr dataLength, IntPtr dataOffset, PacketFlags flags);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern IntPtr enet_packet_create_offset(byte[] data, IntPtr dataLength, IntPtr dataOffset, PacketFlags flags);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern int enet_packet_check_references(IntPtr packet);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern IntPtr enet_packet_create_offset(IntPtr data, IntPtr dataLength, IntPtr dataOffset, PacketFlags flags);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern IntPtr enet_packet_get_data(IntPtr packet);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern int enet_packet_check_references(IntPtr packet);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern IntPtr enet_packet_get_user_data(IntPtr packet);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern IntPtr enet_packet_get_data(IntPtr packet);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern IntPtr enet_packet_set_user_data(IntPtr packet, IntPtr userData);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern int enet_packet_get_length(IntPtr packet);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern int enet_packet_get_length(IntPtr packet);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_packet_set_free_callback(IntPtr packet, IntPtr callback);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_packet_set_free_callback(IntPtr packet, IntPtr callback);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_packet_dispose(IntPtr packet);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_packet_dispose(IntPtr packet);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern IntPtr enet_host_create(ref ENetAddress address, IntPtr peerLimit, IntPtr channelLimit, uint incomingBandwidth, uint outgoingBandwidth, int bufferSize);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern IntPtr enet_host_create(ref ENetAddress address, IntPtr peerLimit, IntPtr channelLimit, uint incomingBandwidth, uint outgoingBandwidth, int bufferSize);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern IntPtr enet_host_create(IntPtr address, IntPtr peerLimit, IntPtr channelLimit, uint incomingBandwidth, uint outgoingBandwidth, int bufferSize);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern IntPtr enet_host_create(IntPtr address, IntPtr peerLimit, IntPtr channelLimit, uint incomingBandwidth, uint outgoingBandwidth, int bufferSize);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern IntPtr enet_host_connect(IntPtr host, ref ENetAddress address, IntPtr channelCount, uint data);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern IntPtr enet_host_connect(IntPtr host, ref ENetAddress address, IntPtr channelCount, uint data);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_host_broadcast(IntPtr host, byte channelID, IntPtr packet);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_host_broadcast(IntPtr host, byte channelID, IntPtr packet);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_host_broadcast_exclude(IntPtr host, byte channelID, IntPtr packet, IntPtr excludedPeer);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_host_broadcast_exclude(IntPtr host, byte channelID, IntPtr packet, IntPtr excludedPeer);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_host_broadcast_selective(IntPtr host, byte channelID, IntPtr packet, IntPtr[] peers, IntPtr peersLength);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_host_broadcast_selective(IntPtr host, byte channelID, IntPtr packet, IntPtr[] peers, IntPtr peersLength);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern int enet_host_service(IntPtr host, out ENetEvent @event, uint timeout);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern int enet_host_service(IntPtr host, out ENetEvent @event, uint timeout);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern int enet_host_check_events(IntPtr host, out ENetEvent @event);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern int enet_host_check_events(IntPtr host, out ENetEvent @event);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_host_channel_limit(IntPtr host, IntPtr channelLimit);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_host_channel_limit(IntPtr host, IntPtr channelLimit);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_host_bandwidth_limit(IntPtr host, uint incomingBandwidth, uint outgoingBandwidth);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_host_bandwidth_limit(IntPtr host, uint incomingBandwidth, uint outgoingBandwidth);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern uint enet_host_get_peers_count(IntPtr host);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern uint enet_host_get_peers_count(IntPtr host);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern uint enet_host_get_packets_sent(IntPtr host);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern uint enet_host_get_packets_sent(IntPtr host);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern uint enet_host_get_packets_received(IntPtr host);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern uint enet_host_get_packets_received(IntPtr host);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern uint enet_host_get_bytes_sent(IntPtr host);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern uint enet_host_get_bytes_sent(IntPtr host);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern uint enet_host_get_bytes_received(IntPtr host);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern uint enet_host_get_bytes_received(IntPtr host);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_host_flush(IntPtr host);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_host_flush(IntPtr host);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_host_destroy(IntPtr host);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_host_destroy(IntPtr host);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_host_enable_compression(IntPtr host);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_host_prevent_connections(IntPtr host, byte state);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_host_prevent_connections(IntPtr host, byte state);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_peer_throttle_configure(IntPtr peer, uint interval, uint acceleration, uint deceleration, uint threshold);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_peer_throttle_configure(IntPtr peer, uint interval, uint acceleration, uint deceleration, uint threshold);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern uint enet_peer_get_id(IntPtr peer);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern uint enet_peer_get_id(IntPtr peer);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern int enet_peer_get_ip(IntPtr peer, byte[] ip, IntPtr ipLength);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern int enet_peer_get_ip(IntPtr peer, byte[] ip, IntPtr ipLength);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern ushort enet_peer_get_port(IntPtr peer);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern ushort enet_peer_get_port(IntPtr peer);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern uint enet_peer_get_mtu(IntPtr peer);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern uint enet_peer_get_mtu(IntPtr peer);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern PeerState enet_peer_get_state(IntPtr peer);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern PeerState enet_peer_get_state(IntPtr peer);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern uint enet_peer_get_rtt(IntPtr peer);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern uint enet_peer_get_rtt(IntPtr peer);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern uint enet_peer_get_last_rtt(IntPtr peer);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern uint enet_peer_get_lastsendtime(IntPtr peer);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern uint enet_peer_get_lastsendtime(IntPtr peer);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern uint enet_peer_get_lastreceivetime(IntPtr peer);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern uint enet_peer_get_lastreceivetime(IntPtr peer);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern ulong enet_peer_get_packets_sent(IntPtr peer);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern ulong enet_peer_get_packets_sent(IntPtr peer);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern ulong enet_peer_get_packets_lost(IntPtr peer);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern ulong enet_peer_get_packets_lost(IntPtr peer);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern ulong enet_peer_get_bytes_sent(IntPtr peer);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern ulong enet_peer_get_bytes_sent(IntPtr peer);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern ulong enet_peer_get_bytes_received(IntPtr peer);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern ulong enet_peer_get_bytes_received(IntPtr peer);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern IntPtr enet_peer_get_data(IntPtr peer);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern IntPtr enet_peer_get_data(IntPtr peer);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_peer_set_data(IntPtr peer, IntPtr data);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_peer_set_data(IntPtr peer, IntPtr data);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern int enet_peer_send(IntPtr peer, byte channelID, IntPtr packet);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern int enet_peer_send(IntPtr peer, byte channelID, IntPtr packet);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern IntPtr enet_peer_receive(IntPtr peer, out byte channelID);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern IntPtr enet_peer_receive(IntPtr peer, out byte channelID);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_peer_ping(IntPtr peer);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_peer_ping(IntPtr peer);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_peer_ping_interval(IntPtr peer, uint pingInterval);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_peer_ping_interval(IntPtr peer, uint pingInterval);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_peer_timeout(IntPtr peer, uint timeoutLimit, uint timeoutMinimum, uint timeoutMaximum);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_peer_timeout(IntPtr peer, uint timeoutLimit, uint timeoutMinimum, uint timeoutMaximum);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_peer_disconnect(IntPtr peer, uint data);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_peer_disconnect(IntPtr peer, uint data);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_peer_disconnect_now(IntPtr peer, uint data);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_peer_disconnect_now(IntPtr peer, uint data);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_peer_disconnect_later(IntPtr peer, uint data);
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_peer_disconnect_later(IntPtr peer, uint data);
 
 
-        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
-        internal static extern void enet_peer_reset(IntPtr peer);
-    }
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern void enet_peer_reset(IntPtr peer);
+	}
 }
 }

+ 10 - 9
Source/Native/CMakeLists.txt

@@ -4,21 +4,22 @@ project(enet C)
 set(ENET_DEBUG "0" CACHE BOOL "Enable debug functionality")
 set(ENET_DEBUG "0" CACHE BOOL "Enable debug functionality")
 set(ENET_STATIC "0" CACHE BOOL "Create a static library")
 set(ENET_STATIC "0" CACHE BOOL "Create a static library")
 set(ENET_SHARED "0" CACHE BOOL "Create a shared library")
 set(ENET_SHARED "0" CACHE BOOL "Create a shared library")
-set(ENET_LZ4 "0" CACHE BOOL "Add support for an optional packet-level compression")
 
 
-if (ENET_DEBUG)
-    add_definitions(-DENET_DEBUG)
+if (MSYS OR MINGW)
+    set(CMAKE_C_FLAGS "-static") 
+
+    add_definitions(-DWINVER=0x0601)
+    add_definitions(-D_WIN32_WINNT=0x0601)
 endif()
 endif()
 
 
-if (ENET_LZ4)
-    add_definitions(-DENET_LZ4)
-    set(SOURCES lz4/lz4.c)
+if (ENET_DEBUG)
+    add_definitions(-DENET_DEBUG)
 endif()
 endif()
 
 
 if (ENET_STATIC)
 if (ENET_STATIC)
     add_library(enet_static STATIC enet.c ${SOURCES})
     add_library(enet_static STATIC enet.c ${SOURCES})
 
 
-    if (WIN32)
+    if (NOT UNIX)
         target_link_libraries(enet_static winmm ws2_32)
         target_link_libraries(enet_static winmm ws2_32)
         SET_TARGET_PROPERTIES(enet_static PROPERTIES PREFIX "")
         SET_TARGET_PROPERTIES(enet_static PROPERTIES PREFIX "")
     endif()
     endif()
@@ -28,8 +29,8 @@ if (ENET_SHARED)
     add_definitions(-DENET_DLL)
     add_definitions(-DENET_DLL)
     add_library(enet SHARED enet.c ${SOURCES})
     add_library(enet SHARED enet.c ${SOURCES})
 
 
-    if (WIN32)
+    if (NOT UNIX)
         target_link_libraries(enet winmm ws2_32)
         target_link_libraries(enet winmm ws2_32)
         SET_TARGET_PROPERTIES(enet PROPERTIES PREFIX "")
         SET_TARGET_PROPERTIES(enet PROPERTIES PREFIX "")
     endif()
     endif()
-endif()
+endif()

+ 3 - 2
Source/Native/enet_log.h → Source/Native/custom/enet_logging.h

@@ -1,5 +1,5 @@
-#ifndef ENET_LOG_H
-#define ENET_LOG_H
+#ifndef ENET_LOGGING_H
+#define ENET_LOGGING_H
 
 
 #include <stdarg.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdio.h>
@@ -44,6 +44,7 @@ static inline void enet_log(enum enet_log_type type, const char *func, int line,
 	vfprintf(enet_log_fp, fmt, args);
 	vfprintf(enet_log_fp, fmt, args);
 	va_end(args);
 	va_end(args);
 
 
+	fprintf(enet_log_fp, "\n");
 	fflush(enet_log_fp);
 	fflush(enet_log_fp);
 }
 }
 
 

+ 4 - 1
Source/Native/enet.c

@@ -1,5 +1,8 @@
 /*
 /*
- *  ENet reliable UDP networking library 
+ *  ENet reliable UDP networking library
+ * 	This is a fork from upstream and is available at http://github.com/SoftwareGuy/ENet-CSharp
+ *
+ *  Copyright (c) 2019-2020 Matt Coburn (SoftwareGuy/Coburn64), Chris Burns (c6burns)
  *  Copyright (c) 2018 Lee Salzman, Vladyslav Hrytsenko, Dominik Madarász, Stanislav Denisov
  *  Copyright (c) 2018 Lee Salzman, Vladyslav Hrytsenko, Dominik Madarász, Stanislav Denisov
  *
  *
  *  Permission is hereby granted, free of charge, to any person obtaining a copy
  *  Permission is hereby granted, free of charge, to any person obtaining a copy

File diff suppressed because it is too large
+ 364 - 441
Source/Native/enet.h


+ 0 - 194
Source/Native/mingw/inet_ntop.c

@@ -1,194 +0,0 @@
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1996-1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_ntop.c,v 1.3.18.2 2005/11/03 23:02:22 marka Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#ifdef __FreeBSD__
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/libkern/inet_ntop.c 213103 2010-09-24 15:01:45Z attilio $");
-#endif
-
-#if !defined(_WIN32)
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#else
-#include <ws2tcpip.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#if !defined(_WIN32) && __FreeBSD_version < 700000
-#define strchr index
-#endif
-
-/*%
- * WARNING: Don't even consider trying to compile this on a system where
- * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
- */
-
-static char *inet_ntop4(const u_char * src, char *dst, socklen_t size);
-static char *inet_ntop6(const u_char * src, char *dst, socklen_t size);
-
-/* char *
- * inet_ntop(af, src, dst, size)
- *	convert a network format address to presentation format.
- * return:
- *	pointer to presentation format address (`dst'), or NULL (see errno).
- * author:
- *	Paul Vixie, 1996.
- */
-char *inet_ntop(int af, const void *src, char *dst, socklen_t size)
-{
-    switch (af) {
-    case AF_INET:
-        return (inet_ntop4(src, dst, size));
-    case AF_INET6:
-        return (inet_ntop6(src, dst, size));
-    default:
-        return (NULL);
-    }
-    /* NOTREACHED */
-}
-
-/* const char *
- * inet_ntop4(src, dst, size)
- *	format an IPv4 address
- * return:
- *	`dst' (as a const)
- * notes:
- *	(1) uses no statics
- *	(2) takes a u_char* not an in_addr as input
- * author:
- *	Paul Vixie, 1996.
- */
-static char *inet_ntop4(const u_char * src, char *dst, socklen_t size)
-{
-    static const char fmt[] = "%u.%u.%u.%u";
-    char tmp[sizeof "255.255.255.255"];
-    int l;
-
-    l = snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]);
-    if (l <= 0 || (socklen_t) l >= size) {
-        return (NULL);
-    }
-    /* strlcpy(dst, tmp, size); */
-    memcpy(dst, tmp, size);
-    dst[size] = '\0';
-    return (dst);
-}
-
-/* const char *
- * inet_ntop6(src, dst, size)
- *	convert IPv6 binary address into presentation (printable) format
- * author:
- *	Paul Vixie, 1996.
- */
-static char *inet_ntop6(const u_char * src, char *dst, socklen_t size)
-{
-    /*
-     * Note that int32_t and int16_t need only be "at least" large enough
-     * to contain a value of the specified size.  On some systems, like
-     * Crays, there is no such thing as an integer variable with 16 bits.
-     * Keep this in mind if you think this function should have been coded
-     * to use pointer overlays.  All the world's not a VAX.
-     */
-    char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
-    struct {
-        int base, len;
-    } best, cur;
-#define NS_IN6ADDRSZ	16
-#define NS_INT16SZ	2
-    u_int words[NS_IN6ADDRSZ / NS_INT16SZ];
-    int i;
-
-    /*
-     * Preprocess:
-     *      Copy the input (bytewise) array into a wordwise array.
-     *      Find the longest run of 0x00's in src[] for :: shorthanding.
-     */
-    memset(words, '\0', sizeof words);
-    for (i = 0; i < NS_IN6ADDRSZ; i++)
-        words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
-    best.base = -1;
-    best.len = 0;
-    cur.base = -1;
-    cur.len = 0;
-    for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
-        if (words[i] == 0) {
-            if (cur.base == -1)
-                cur.base = i, cur.len = 1;
-            else
-                cur.len++;
-        } else {
-            if (cur.base != -1) {
-                if (best.base == -1 || cur.len > best.len)
-                    best = cur;
-                cur.base = -1;
-            }
-        }
-    }
-    if (cur.base != -1) {
-        if (best.base == -1 || cur.len > best.len)
-            best = cur;
-    }
-    if (best.base != -1 && best.len < 2)
-        best.base = -1;
-
-    /*
-     * Format the result.
-     */
-    tp = tmp;
-    for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
-        /* Are we inside the best run of 0x00's? */
-        if (best.base != -1 && i >= best.base && i < (best.base + best.len)) {
-            if (i == best.base)
-                *tp++ = ':';
-            continue;
-        }
-        /* Are we following an initial run of 0x00s or any real hex? */
-        if (i != 0)
-            *tp++ = ':';
-        /* Is this address an encapsulated IPv4? */
-        if (i == 6 && best.base == 0 && (best.len == 6 ||
-                                         (best.len == 7 && words[7] != 0x0001) ||
-                                         (best.len == 5 && words[5] == 0xffff))) {
-            if (!inet_ntop4(src + 12, tp, sizeof tmp - (tp - tmp)))
-                return (NULL);
-            tp += strlen(tp);
-            break;
-        }
-        tp += sprintf(tp, "%x", words[i]);
-    }
-    /* Was it a trailing run of 0x00's? */
-    if (best.base != -1 && (best.base + best.len) == (NS_IN6ADDRSZ / NS_INT16SZ))
-        *tp++ = ':';
-    *tp++ = '\0';
-
-    /*
-     * Check for overflow, copy, and we're done.
-     */
-    if ((socklen_t) (tp - tmp) > size) {
-        return (NULL);
-    }
-    strcpy(dst, tmp);
-    return (dst);
-}
-/*! \file */

+ 0 - 222
Source/Native/mingw/inet_pton.c

@@ -1,222 +0,0 @@
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1996,1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_pton.c,v 1.3.18.2 2005/07/28 07:38:07 marka Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#ifdef __FreeBSD__
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/libkern/inet_pton.c 213103 2010-09-24 15:01:45Z attilio $");
-#endif
-
-#if !defined(_WIN32) 
-#include <sys/param.h>
-#include <sys/socket.h>
-
-#include <netinet/in.h>
-#else
-#include <ws2tcpip.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#if !defined(_WIN32) && __FreeBSD_version < 700000
-#define strchr index
-#endif
-
-/*%
- * WARNING: Don't even consider trying to compile this on a system where
- * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
- */
-
-static int inet_pton4(const char *src, u_char * dst);
-static int inet_pton6(const char *src, u_char * dst);
-
-/* int
- * inet_pton(af, src, dst)
- *	convert from presentation format (which usually means ASCII printable)
- *	to network format (which is usually some kind of binary format).
- * return:
- *	1 if the address was valid for the specified address family
- *	0 if the address wasn't valid (`dst' is untouched in this case)
- *	-1 if some other error occurred (`dst' is untouched in this case, too)
- * author:
- *	Paul Vixie, 1996.
- */
-int inet_pton(int af, const char *src, void *dst)
-{
-    switch (af) {
-    case AF_INET:
-        return (inet_pton4(src, dst));
-    case AF_INET6:
-        return (inet_pton6(src, dst));
-    default:
-        return (-1);
-    }
-    /* NOTREACHED */
-}
-
-/* int
- * inet_pton4(src, dst)
- *	like inet_aton() but without all the hexadecimal and shorthand.
- * return:
- *	1 if `src' is a valid dotted quad, else 0.
- * notice:
- *	does not touch `dst' unless it's returning 1.
- * author:
- *	Paul Vixie, 1996.
- */
-static int inet_pton4(const char *src, u_char * dst)
-{
-    static const char digits[] = "0123456789";
-    int saw_digit, octets, ch;
-#define NS_INADDRSZ	4
-    u_char tmp[NS_INADDRSZ], *tp;
-
-    saw_digit = 0;
-    octets = 0;
-    *(tp = tmp) = 0;
-    while ((ch = *src++) != '\0') {
-        const char *pch;
-
-        if ((pch = strchr(digits, ch)) != NULL) {
-            u_int new = *tp * 10 + (pch - digits);
-
-            if (saw_digit && *tp == 0)
-                return (0);
-            if (new > 255)
-                return (0);
-            *tp = new;
-            if (!saw_digit) {
-                if (++octets > 4)
-                    return (0);
-                saw_digit = 1;
-            }
-        } else if (ch == '.' && saw_digit) {
-            if (octets == 4)
-                return (0);
-            *++tp = 0;
-            saw_digit = 0;
-        } else
-            return (0);
-    }
-    if (octets < 4)
-        return (0);
-    memcpy(dst, tmp, NS_INADDRSZ);
-    return (1);
-}
-
-/* int
- * inet_pton6(src, dst)
- *	convert presentation level address to network order binary form.
- * return:
- *	1 if `src' is a valid [RFC1884 2.2] address, else 0.
- * notice:
- *	(1) does not touch `dst' unless it's returning 1.
- *	(2) :: in a full address is silently ignored.
- * credit:
- *	inspired by Mark Andrews.
- * author:
- *	Paul Vixie, 1996.
- */
-static int inet_pton6(const char *src, u_char * dst)
-{
-    static const char xdigits_l[] = "0123456789abcdef", xdigits_u[] = "0123456789ABCDEF";
-#define NS_IN6ADDRSZ	16
-#define NS_INT16SZ	2
-    u_char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
-    const char *xdigits, *curtok;
-    int ch, seen_xdigits;
-    u_int val;
-
-    memset((tp = tmp), '\0', NS_IN6ADDRSZ);
-    endp = tp + NS_IN6ADDRSZ;
-    colonp = NULL;
-    /* Leading :: requires some special handling. */
-    if (*src == ':')
-        if (*++src != ':')
-            return (0);
-    curtok = src;
-    seen_xdigits = 0;
-    val = 0;
-    while ((ch = *src++) != '\0') {
-        const char *pch;
-
-        if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
-            pch = strchr((xdigits = xdigits_u), ch);
-        if (pch != NULL) {
-            val <<= 4;
-            val |= (pch - xdigits);
-            if (++seen_xdigits > 4)
-                return (0);
-            continue;
-        }
-        if (ch == ':') {
-            curtok = src;
-            if (!seen_xdigits) {
-                if (colonp)
-                    return (0);
-                colonp = tp;
-                continue;
-            } else if (*src == '\0') {
-                return (0);
-            }
-            if (tp + NS_INT16SZ > endp)
-                return (0);
-            *tp++ = (u_char) (val >> 8) & 0xff;
-            *tp++ = (u_char) val & 0xff;
-            seen_xdigits = 0;
-            val = 0;
-            continue;
-        }
-        if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && inet_pton4(curtok, tp) > 0) {
-            tp += NS_INADDRSZ;
-            seen_xdigits = 0;
-            break;              /*%< '\\0' was seen by inet_pton4(). */
-        }
-        return (0);
-    }
-    if (seen_xdigits) {
-        if (tp + NS_INT16SZ > endp)
-            return (0);
-        *tp++ = (u_char) (val >> 8) & 0xff;
-        *tp++ = (u_char) val & 0xff;
-    }
-    if (colonp != NULL) {
-        /*
-         * Since some memmove()'s erroneously fail to handle
-         * overlapping regions, we'll do the shift by hand.
-         */
-        const int n = tp - colonp;
-        int i;
-
-        if (tp == endp)
-            return (0);
-        for (i = 1; i <= n; i++) {
-            endp[-i] = colonp[n - i];
-            colonp[n - i] = 0;
-        }
-        tp = endp;
-    }
-    if (tp != endp)
-        return (0);
-    memcpy(dst, tmp, NS_IN6ADDRSZ);
-    return (1);
-}
-/*! \file */

Some files were not shown because too many files changed in this diff