aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.Servers/CheckSumServer.cs
diff options
context:
space:
mode:
authorMW2007-05-19 14:08:58 +0000
committerMW2007-05-19 14:08:58 +0000
commitf5de37553d04b3a263ff54aca7e319550cba66ad (patch)
tree1c5e9e8d14c30d82e9fcb344f1d5fa8738677738 /OpenSim.Servers/CheckSumServer.cs
parentAdded a CheckSumServer (handles template checksum , so there is no longer the... (diff)
downloadopensim-SC_OLD-f5de37553d04b3a263ff54aca7e319550cba66ad.zip
opensim-SC_OLD-f5de37553d04b3a263ff54aca7e319550cba66ad.tar.gz
opensim-SC_OLD-f5de37553d04b3a263ff54aca7e319550cba66ad.tar.bz2
opensim-SC_OLD-f5de37553d04b3a263ff54aca7e319550cba66ad.tar.xz
Moved CheckSumServer (and added UDPServerBase ) to OpenSim.Servers
Diffstat (limited to '')
-rw-r--r--OpenSim.Servers/CheckSumServer.cs99
1 files changed, 99 insertions, 0 deletions
diff --git a/OpenSim.Servers/CheckSumServer.cs b/OpenSim.Servers/CheckSumServer.cs
new file mode 100644
index 0000000..dc83192
--- /dev/null
+++ b/OpenSim.Servers/CheckSumServer.cs
@@ -0,0 +1,99 @@
1using System;
2using System.Text;
3using System.IO;
4using System.Threading;
5using System.Net;
6using System.Net.Sockets;
7using System.Timers;
8using System.Reflection;
9using System.Collections;
10using System.Collections.Generic;
11using libsecondlife;
12using libsecondlife.Packets;
13using OpenSim.Framework.Console;
14
15
16namespace OpenSim.Servers
17{
18 public class CheckSumServer : UDPServerBase
19 {
20 protected ConsoleBase m_console;
21
22 public CheckSumServer(int port, ConsoleBase console)
23 {
24 listenPort = port;
25 this.m_console = console;
26 }
27
28 protected override void OnReceivedData(IAsyncResult result)
29 {
30 ipeSender = new IPEndPoint(IPAddress.Any, 0);
31 epSender = (EndPoint)ipeSender;
32 Packet packet = null;
33 int numBytes = Server.EndReceiveFrom(result, ref epSender);
34 int packetEnd = numBytes - 1;
35
36 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
37
38 // do we already have a circuit for this endpoint
39 if (packet.Type == PacketType.SecuredTemplateChecksumRequest)
40 {
41 SecuredTemplateChecksumRequestPacket checksum = (SecuredTemplateChecksumRequestPacket)packet;
42 TemplateChecksumReplyPacket checkreply = new TemplateChecksumReplyPacket();
43 checkreply.DataBlock.Checksum = 180572585;
44 checkreply.DataBlock.Flags = 0;
45 checkreply.DataBlock.MajorVersion = 1;
46 checkreply.DataBlock.MinorVersion = 15;
47 checkreply.DataBlock.PatchVersion = 0;
48 checkreply.DataBlock.ServerVersion = 2;
49 checkreply.TokenBlock.Token = checksum.TokenBlock.Token;
50 this.SendPacket(checkreply, epSender);
51
52 }
53 else
54 { // invalid client
55 // Console.Error.WriteLine("CheckSumServer.cs:OnReceivedData() - WARNING: Got a invalid packet from an invalid client - " + epSender.ToString());
56 }
57
58 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
59 }
60
61
62 private void SendPacket(Packet Pack, EndPoint endp)
63 {
64 if (!Pack.Header.Resent)
65 {
66 // Set the sequence number
67
68 Pack.Header.Sequence = 1;
69
70 }
71 byte[] ZeroOutBuffer = new byte[4096];
72 byte[] sendbuffer;
73 sendbuffer = Pack.ToBytes();
74
75 try
76 {
77 if (Pack.Header.Zerocoded)
78 {
79 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
80 this.SendPackTo(ZeroOutBuffer, packetsize, SocketFlags.None, endp);
81 }
82 else
83 {
84 this.SendPackTo(sendbuffer, sendbuffer.Length, SocketFlags.None, endp);
85 }
86 }
87 catch (Exception)
88 {
89 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection ");
90
91 }
92 }
93
94 private void SendPackTo(byte[] buffer, int size, SocketFlags flags, EndPoint endp)
95 {
96 this.Server.SendTo(buffer, size, flags, endp);
97 }
98 }
99} \ No newline at end of file