From eaff580abe080add12d294f20c11dd5efdbed288 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 8 Aug 2008 11:04:24 +0000 Subject: Patch #9160 Refactor proxy encode/decode methods out of the PacketPool into their own class. --- OpenSim/Framework/PacketPool.cs | 41 +---------------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) (limited to 'OpenSim/Framework/PacketPool.cs') diff --git a/OpenSim/Framework/PacketPool.cs b/OpenSim/Framework/PacketPool.cs index 4e71d5e..acd1425 100644 --- a/OpenSim/Framework/PacketPool.cs +++ b/OpenSim/Framework/PacketPool.cs @@ -48,45 +48,6 @@ namespace OpenSim.Framework get { return instance; } } - public static void EncodeProxyMessage(byte[] bytes, ref int numBytes, EndPoint trueEP) - { - if (numBytes > 4090) // max UPD size = 4096 - { - throw new Exception("ERROR: No space to encode the proxy EP"); - } - - ushort port = (ushort) ((IPEndPoint) trueEP).Port; - bytes[numBytes++] = (byte) (port % 256); - bytes[numBytes++] = (byte) (port / 256); - - foreach (byte b in ((IPEndPoint) trueEP).Address.GetAddressBytes()) - { - bytes[numBytes++] = b; - } - - int x = numBytes; - - DecodeProxyMessage(bytes, ref numBytes); - - numBytes = x; - } - - public static EndPoint DecodeProxyMessage(byte[] bytes, ref int numBytes) - { - // IPv4 Only - byte[] addr = new byte[4]; - - addr[3] = bytes[--numBytes]; - addr[2] = bytes[--numBytes]; - addr[1] = bytes[--numBytes]; - addr[0] = bytes[--numBytes]; - - ushort port = (ushort) (bytes[--numBytes] * 256); - port += (ushort) bytes[--numBytes]; - - return (EndPoint) new IPEndPoint(new IPAddress(addr), (int) port); - } - public Packet GetPacket(PacketType type) { Packet packet; @@ -175,4 +136,4 @@ namespace OpenSim.Framework */ } } -} \ No newline at end of file +} -- cgit v1.1