diff options
Diffstat (limited to 'OpenSim/Framework/PacketPool.cs')
-rw-r--r-- | OpenSim/Framework/PacketPool.cs | 41 |
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 | } |