diff options
author | Adam Frisby | 2007-07-11 08:10:25 +0000 |
---|---|---|
committer | Adam Frisby | 2007-07-11 08:10:25 +0000 |
commit | e2ff441e31328e60c8bb1d4bb32fa4ac64f91978 (patch) | |
tree | 8405b6cef57b66a58f31a24c859846085d0b81f7 /OpenSim/Framework/Servers/CheckSumServer.cs | |
parent | * Wiping trunk in prep for Sugilite (diff) | |
parent | * Applying dalien's patches from bug#177 and #179 (diff) | |
download | opensim-SC-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.zip opensim-SC-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.tar.gz opensim-SC-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.tar.bz2 opensim-SC-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.tar.xz |
* Bringing Sugilite in to trunk
Diffstat (limited to 'OpenSim/Framework/Servers/CheckSumServer.cs')
-rw-r--r-- | OpenSim/Framework/Servers/CheckSumServer.cs | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/OpenSim/Framework/Servers/CheckSumServer.cs b/OpenSim/Framework/Servers/CheckSumServer.cs new file mode 100644 index 0000000..89ec095 --- /dev/null +++ b/OpenSim/Framework/Servers/CheckSumServer.cs | |||
@@ -0,0 +1,127 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | namespace OpenSim.Framework.Servers | ||
29 | {/* | ||
30 | public class CheckSumServer : UDPServerBase | ||
31 | { | ||
32 | //protected ConsoleBase m_log; | ||
33 | |||
34 | public CheckSumServer(int port) | ||
35 | : base(port) | ||
36 | { | ||
37 | } | ||
38 | |||
39 | protected override void OnReceivedData(IAsyncResult result) | ||
40 | { | ||
41 | ipeSender = new IPEndPoint(IPAddress.Any, 0); | ||
42 | epSender = (EndPoint)ipeSender; | ||
43 | Packet packet = null; | ||
44 | int numBytes = Server.EndReceiveFrom(result, ref epSender); | ||
45 | int packetEnd = numBytes - 1; | ||
46 | |||
47 | packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); | ||
48 | |||
49 | if (packet.Type == PacketType.SecuredTemplateChecksumRequest) | ||
50 | { | ||
51 | SecuredTemplateChecksumRequestPacket checksum = (SecuredTemplateChecksumRequestPacket)packet; | ||
52 | TemplateChecksumReplyPacket checkreply = new TemplateChecksumReplyPacket(); | ||
53 | checkreply.DataBlock.Checksum = 3220703154;//180572585; | ||
54 | checkreply.DataBlock.Flags = 0; | ||
55 | checkreply.DataBlock.MajorVersion = 1; | ||
56 | checkreply.DataBlock.MinorVersion = 15; | ||
57 | checkreply.DataBlock.PatchVersion = 0; | ||
58 | checkreply.DataBlock.ServerVersion = 0; | ||
59 | checkreply.TokenBlock.Token = checksum.TokenBlock.Token; | ||
60 | this.SendPacket(checkreply, epSender); | ||
61 | |||
62 | /* | ||
63 | //if we wanted to echo the the checksum/ version from the client (so that any client worked) | ||
64 | SecuredTemplateChecksumRequestPacket checkrequest = new SecuredTemplateChecksumRequestPacket(); | ||
65 | checkrequest.TokenBlock.Token = checksum.TokenBlock.Token; | ||
66 | this.SendPacket(checkrequest, epSender); | ||
67 | |||
68 | } | ||
69 | else if (packet.Type == PacketType.TemplateChecksumReply) | ||
70 | { | ||
71 | //echo back the client checksum reply (Hegemon's method) | ||
72 | TemplateChecksumReplyPacket checksum2 = (TemplateChecksumReplyPacket)packet; | ||
73 | TemplateChecksumReplyPacket checkreply2 = new TemplateChecksumReplyPacket(); | ||
74 | checkreply2.DataBlock.Checksum = checksum2.DataBlock.Checksum; | ||
75 | checkreply2.DataBlock.Flags = checksum2.DataBlock.Flags; | ||
76 | checkreply2.DataBlock.MajorVersion = checksum2.DataBlock.MajorVersion; | ||
77 | checkreply2.DataBlock.MinorVersion = checksum2.DataBlock.MinorVersion; | ||
78 | checkreply2.DataBlock.PatchVersion = checksum2.DataBlock.PatchVersion; | ||
79 | checkreply2.DataBlock.ServerVersion = checksum2.DataBlock.ServerVersion; | ||
80 | checkreply2.TokenBlock.Token = checksum2.TokenBlock.Token; | ||
81 | this.SendPacket(checkreply2, epSender); | ||
82 | } | ||
83 | else | ||
84 | { | ||
85 | } | ||
86 | |||
87 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | ||
88 | } | ||
89 | |||
90 | private void SendPacket(Packet Pack, EndPoint endp) | ||
91 | { | ||
92 | if (!Pack.Header.Resent) | ||
93 | { | ||
94 | Pack.Header.Sequence = 1; | ||
95 | } | ||
96 | |||
97 | byte[] ZeroOutBuffer = new byte[4096]; | ||
98 | byte[] sendbuffer; | ||
99 | sendbuffer = Pack.ToBytes(); | ||
100 | |||
101 | try | ||
102 | { | ||
103 | if (Pack.Header.Zerocoded) | ||
104 | { | ||
105 | int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); | ||
106 | this.SendPackTo(ZeroOutBuffer, packetsize, SocketFlags.None, endp); | ||
107 | } | ||
108 | else | ||
109 | { | ||
110 | this.SendPackTo(sendbuffer, sendbuffer.Length, SocketFlags.None, endp); | ||
111 | } | ||
112 | } | ||
113 | catch (Exception) | ||
114 | { | ||
115 | OpenSim.Framework.Console.MainLog.Instance.Warn("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection "); | ||
116 | |||
117 | } | ||
118 | } | ||
119 | |||
120 | private void SendPackTo(byte[] buffer, int size, SocketFlags flags, EndPoint endp) | ||
121 | { | ||
122 | this.Server.SendTo(buffer, size, flags, endp); | ||
123 | } | ||
124 | * } | ||
125 | */ | ||
126 | |||
127 | } \ No newline at end of file | ||