aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/CheckSumServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim.RegionServer/CheckSumServer.cs')
-rw-r--r--OpenSim.RegionServer/CheckSumServer.cs120
1 files changed, 120 insertions, 0 deletions
diff --git a/OpenSim.RegionServer/CheckSumServer.cs b/OpenSim.RegionServer/CheckSumServer.cs
new file mode 100644
index 0000000..353383a
--- /dev/null
+++ b/OpenSim.RegionServer/CheckSumServer.cs
@@ -0,0 +1,120 @@
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.world;
14using OpenSim.Terrain;
15using OpenSim.Framework.Interfaces;
16using OpenSim.Framework.Types;
17using OpenSim.UserServer;
18using OpenSim.Assets;
19using OpenSim.CAPS;
20using OpenSim.Framework.Console;
21using Nwc.XmlRpc;
22using OpenSim.Servers;
23using OpenSim.GenericConfig;
24
25
26namespace OpenSim
27{
28 public class CheckSumServer : UDPServer
29 {
30 public CheckSumServer(int port, ConsoleBase console)
31 {
32 listenPort = port;
33 this.m_console = console;
34 }
35
36 protected override void CreatePacketServer()
37 {
38
39 }
40
41 public override void RegisterPacketServer(PacketServer server)
42 {
43
44 }
45
46 protected override void OnReceivedData(IAsyncResult result)
47 {
48 ipeSender = new IPEndPoint(IPAddress.Any, 0);
49 epSender = (EndPoint)ipeSender;
50 Packet packet = null;
51 int numBytes = Server.EndReceiveFrom(result, ref epSender);
52 int packetEnd = numBytes - 1;
53
54 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
55
56 // do we already have a circuit for this endpoint
57 if (packet.Type == PacketType.SecuredTemplateChecksumRequest)
58 {
59 SecuredTemplateChecksumRequestPacket checksum = (SecuredTemplateChecksumRequestPacket)packet;
60 TemplateChecksumReplyPacket checkreply = new TemplateChecksumReplyPacket();
61 checkreply.DataBlock.Checksum = 180572585;
62 checkreply.DataBlock.Flags = 0;
63 checkreply.DataBlock.MajorVersion = 1;
64 checkreply.DataBlock.MinorVersion = 15;
65 checkreply.DataBlock.PatchVersion = 0;
66 checkreply.DataBlock.ServerVersion = 2;
67 checkreply.TokenBlock.Token = checksum.TokenBlock.Token;
68 this.SendPacket(checkreply, epSender);
69
70 }
71 else
72 { // invalid client
73 // Console.Error.WriteLine("CheckSumServer.cs:OnReceivedData() - WARNING: Got a invalid packet from an invalid client - " + epSender.ToString());
74 }
75
76 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
77 }
78
79 protected override void AddNewClient(Packet packet)
80 {
81 }
82
83 private void SendPacket(Packet Pack, EndPoint endp)
84 {
85 if (!Pack.Header.Resent)
86 {
87 // Set the sequence number
88
89 Pack.Header.Sequence = 1;
90
91 }
92 byte[] ZeroOutBuffer = new byte[4096];
93 byte[] sendbuffer;
94 sendbuffer = Pack.ToBytes();
95
96 try
97 {
98 if (Pack.Header.Zerocoded)
99 {
100 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
101 this.SendPackTo(ZeroOutBuffer, packetsize, SocketFlags.None, endp);
102 }
103 else
104 {
105 this.SendPackTo(sendbuffer, sendbuffer.Length, SocketFlags.None, endp);
106 }
107 }
108 catch (Exception)
109 {
110 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " );
111
112 }
113 }
114
115 private void SendPackTo(byte[] buffer, int size, SocketFlags flags, EndPoint endp)
116 {
117 this.Server.SendTo(buffer, size, flags, endp);
118 }
119 }
120}