aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/PacketPool.cs
diff options
context:
space:
mode:
authorMelanie Thielker2008-08-08 11:04:24 +0000
committerMelanie Thielker2008-08-08 11:04:24 +0000
commiteaff580abe080add12d294f20c11dd5efdbed288 (patch)
tree5fc382171e3c8d836db774ab8bb99272cd1af790 /OpenSim/Framework/PacketPool.cs
parent* All CheckRegion within an instance would use the same, global, bool for 'Av... (diff)
downloadopensim-SC_OLD-eaff580abe080add12d294f20c11dd5efdbed288.zip
opensim-SC_OLD-eaff580abe080add12d294f20c11dd5efdbed288.tar.gz
opensim-SC_OLD-eaff580abe080add12d294f20c11dd5efdbed288.tar.bz2
opensim-SC_OLD-eaff580abe080add12d294f20c11dd5efdbed288.tar.xz
Patch #9160
Refactor proxy encode/decode methods out of the PacketPool into their own class.
Diffstat (limited to 'OpenSim/Framework/PacketPool.cs')
-rw-r--r--OpenSim/Framework/PacketPool.cs41
1 files changed, 1 insertions, 40 deletions
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
48 get { return instance; } 48 get { return instance; }
49 } 49 }
50 50
51 public static void EncodeProxyMessage(byte[] bytes, ref int numBytes, EndPoint trueEP)
52 {
53 if (numBytes > 4090) // max UPD size = 4096
54 {
55 throw new Exception("ERROR: No space to encode the proxy EP");
56 }
57
58 ushort port = (ushort) ((IPEndPoint) trueEP).Port;
59 bytes[numBytes++] = (byte) (port % 256);
60 bytes[numBytes++] = (byte) (port / 256);
61
62 foreach (byte b in ((IPEndPoint) trueEP).Address.GetAddressBytes())
63 {
64 bytes[numBytes++] = b;
65 }
66
67 int x = numBytes;
68
69 DecodeProxyMessage(bytes, ref numBytes);
70
71 numBytes = x;
72 }
73
74 public static EndPoint DecodeProxyMessage(byte[] bytes, ref int numBytes)
75 {
76 // IPv4 Only
77 byte[] addr = new byte[4];
78
79 addr[3] = bytes[--numBytes];
80 addr[2] = bytes[--numBytes];
81 addr[1] = bytes[--numBytes];
82 addr[0] = bytes[--numBytes];
83
84 ushort port = (ushort) (bytes[--numBytes] * 256);
85 port += (ushort) bytes[--numBytes];
86
87 return (EndPoint) new IPEndPoint(new IPAddress(addr), (int) port);
88 }
89
90 public Packet GetPacket(PacketType type) 51 public Packet GetPacket(PacketType type)
91 { 52 {
92 Packet packet; 53 Packet packet;
@@ -175,4 +136,4 @@ namespace OpenSim.Framework
175 */ 136 */
176 } 137 }
177 } 138 }
178} \ No newline at end of file 139}