diff options
author | Melanie Thielker | 2008-08-08 11:04:24 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-08-08 11:04:24 +0000 |
commit | eaff580abe080add12d294f20c11dd5efdbed288 (patch) | |
tree | 5fc382171e3c8d836db774ab8bb99272cd1af790 /OpenSim | |
parent | * All CheckRegion within an instance would use the same, global, bool for 'Av... (diff) | |
download | opensim-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')
-rw-r--r-- | OpenSim/Framework/PacketPool.cs | 41 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | 4 |
2 files changed, 3 insertions, 42 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 | } |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 41a3197..b08b59d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | |||
@@ -259,7 +259,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
259 | epProxy = epSender; | 259 | epProxy = epSender; |
260 | if (proxyPortOffset != 0) | 260 | if (proxyPortOffset != 0) |
261 | { | 261 | { |
262 | epSender = PacketPool.DecodeProxyMessage(RecvBuffer, ref numBytes); | 262 | epSender = ProxyCodec.DecodeProxyMessage(RecvBuffer, ref numBytes); |
263 | } | 263 | } |
264 | 264 | ||
265 | int packetEnd = numBytes - 1; | 265 | int packetEnd = numBytes - 1; |
@@ -463,7 +463,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
463 | if (proxyPortOffset != 0) | 463 | if (proxyPortOffset != 0) |
464 | { | 464 | { |
465 | //MainLog.Instance.Verbose("UDPSERVER", "SendPacketTo proxy " + proxyCircuits[circuitcode].ToString() + ": client " + sendto.ToString()); | 465 | //MainLog.Instance.Verbose("UDPSERVER", "SendPacketTo proxy " + proxyCircuits[circuitcode].ToString() + ": client " + sendto.ToString()); |
466 | PacketPool.EncodeProxyMessage(buffer, ref size, sendto); | 466 | ProxyCodec.EncodeProxyMessage(buffer, ref size, sendto); |
467 | m_socket.SendTo(buffer, size, flags, proxyCircuits[circuitcode]); | 467 | m_socket.SendTo(buffer, size, flags, proxyCircuits[circuitcode]); |
468 | } | 468 | } |
469 | else | 469 | else |