aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Servers')
-rw-r--r--OpenSim/Framework/Servers/BaseHttpServer.cs312
-rw-r--r--OpenSim/Framework/Servers/CheckSumServer.cs141
-rw-r--r--OpenSim/Framework/Servers/IRestHandler.cs35
-rw-r--r--OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj116
-rw-r--r--OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj.user12
-rw-r--r--OpenSim/Framework/Servers/UDPServerBase.cs95
-rw-r--r--OpenSim/Framework/Servers/XmlRpcMethod.cs34
7 files changed, 745 insertions, 0 deletions
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs
new file mode 100644
index 0000000..e55e33c
--- /dev/null
+++ b/OpenSim/Framework/Servers/BaseHttpServer.cs
@@ -0,0 +1,312 @@
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*/
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Text;
32using System.Text.RegularExpressions;
33using System.Threading;
34//using OpenSim.CAPS;
35using Nwc.XmlRpc;
36using System.Collections;
37using OpenSim.Framework.Console;
38
39namespace OpenSim.Servers
40{
41 public class BaseHttpServer
42 {
43 protected class RestMethodEntry
44 {
45 private string m_path;
46 public string Path
47 {
48 get { return m_path; }
49 }
50
51 private RestMethod m_restMethod;
52 public RestMethod RestMethod
53 {
54 get { return m_restMethod; }
55 }
56
57 public RestMethodEntry(string path, RestMethod restMethod)
58 {
59 m_path = path;
60 m_restMethod = restMethod;
61 }
62 }
63
64 protected Thread m_workerThread;
65 protected HttpListener m_httpListener;
66 protected Dictionary<string, RestMethodEntry> m_restHandlers = new Dictionary<string, RestMethodEntry>();
67 protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>();
68 protected int m_port;
69 protected bool firstcaps = true;
70
71 public BaseHttpServer(int port)
72 {
73 m_port = port;
74 }
75
76 public bool AddRestHandler(string method, string path, RestMethod handler)
77 {
78 //Console.WriteLine("adding new REST handler for path " + path);
79 string methodKey = String.Format("{0}: {1}", method, path);
80
81 if (!this.m_restHandlers.ContainsKey(methodKey))
82 {
83 this.m_restHandlers.Add(methodKey, new RestMethodEntry(path, handler));
84 return true;
85 }
86
87 //must already have a handler for that path so return false
88 return false;
89 }
90
91 public bool RemoveRestHandler(string method, string path)
92 {
93 string methodKey = String.Format("{0}: {1}", method, path);
94 if (this.m_restHandlers.ContainsKey(methodKey))
95 {
96 this.m_restHandlers.Remove(methodKey);
97 return true;
98 }
99 return false;
100 }
101
102 public bool AddXmlRPCHandler(string method, XmlRpcMethod handler)
103 {
104 if (!this.m_rpcHandlers.ContainsKey(method))
105 {
106 this.m_rpcHandlers.Add(method, handler);
107 return true;
108 }
109
110 //must already have a handler for that path so return false
111 return false;
112 }
113
114 protected virtual string ProcessXMLRPCMethod(string methodName, XmlRpcRequest request)
115 {
116 XmlRpcResponse response;
117
118 XmlRpcMethod method;
119 if (this.m_rpcHandlers.TryGetValue(methodName, out method))
120 {
121 response = method(request);
122 }
123 else
124 {
125 response = new XmlRpcResponse();
126 Hashtable unknownMethodError = new Hashtable();
127 unknownMethodError["reason"] = "XmlRequest"; ;
128 unknownMethodError["message"] = "Unknown Rpc request";
129 unknownMethodError["login"] = "false";
130 response.Value = unknownMethodError;
131 }
132
133 return XmlRpcResponseSerializer.Singleton.Serialize(response);
134 }
135
136 protected virtual string ParseREST(string request, string path, string method)
137 {
138 string response;
139
140 string requestKey = String.Format("{0}: {1}", method, path);
141
142 string bestMatch = String.Empty;
143 foreach (string currentKey in m_restHandlers.Keys)
144 {
145 if (requestKey.StartsWith(currentKey))
146 {
147 if (currentKey.Length > bestMatch.Length)
148 {
149 bestMatch = currentKey;
150 }
151 }
152 }
153
154 RestMethodEntry restMethodEntry;
155 if (m_restHandlers.TryGetValue(bestMatch, out restMethodEntry))
156 {
157 RestMethod restMethod = restMethodEntry.RestMethod;
158
159 string param = path.Substring(restMethodEntry.Path.Length);
160 response = restMethod(request, path, param);
161
162 }
163 else
164 {
165 response = String.Empty;
166 }
167
168 return response;
169 }
170
171 protected virtual string ParseLLSDXML(string requestBody)
172 {
173 // dummy function for now - IMPLEMENT ME!
174 Console.WriteLine("LLSD request "+requestBody);
175 string resp = "";
176 if (firstcaps)
177 {
178 resp = "<llsd><map><key>MapLayer</key><string>http://127.0.0.1:9000/CAPS/</string></map></llsd>";
179 firstcaps = false;
180 }
181 return resp;
182 }
183
184 protected virtual string ParseXMLRPC(string requestBody)
185 {
186 string responseString = String.Empty;
187
188 try
189 {
190 XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
191
192 string methodName = request.MethodName;
193
194 responseString = ProcessXMLRPCMethod(methodName, request);
195 }
196 catch (Exception e)
197 {
198 Console.WriteLine(e.ToString());
199 }
200 return responseString;
201 }
202
203 public virtual void HandleRequest(Object stateinfo)
204 {
205 try
206 {
207 HttpListenerContext context = (HttpListenerContext)stateinfo;
208
209 HttpListenerRequest request = context.Request;
210 HttpListenerResponse response = context.Response;
211
212 response.KeepAlive = false;
213 response.SendChunked = false;
214
215 System.IO.Stream body = request.InputStream;
216 System.Text.Encoding encoding = System.Text.Encoding.UTF8;
217 System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
218
219 string requestBody = reader.ReadToEnd();
220 body.Close();
221 reader.Close();
222
223 //Console.WriteLine(request.HttpMethod + " " + request.RawUrl + " Http/" + request.ProtocolVersion.ToString() + " content type: " + request.ContentType);
224 //Console.WriteLine(requestBody);
225
226 string responseString = "";
227 // Console.WriteLine("new request " + request.ContentType +" at "+ request.RawUrl);
228 switch (request.ContentType)
229 {
230 case "text/xml":
231 // must be XML-RPC, so pass to the XML-RPC parser
232
233 responseString = ParseXMLRPC(requestBody);
234 responseString = Regex.Replace(responseString, "utf-16", "utf-8");
235
236 response.AddHeader("Content-type", "text/xml");
237 break;
238
239 case "application/xml":
240 // probably LLSD we hope, otherwise it should be ignored by the parser
241 // responseString = ParseLLSDXML(requestBody);
242 responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod);
243 response.AddHeader("Content-type", "application/xml");
244 break;
245
246 case "application/octet-stream":
247 // probably LLSD we hope, otherwise it should be ignored by the parser
248 // responseString = ParseLLSDXML(requestBody);
249 responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod);
250 response.AddHeader("Content-type", "application/xml");
251 break;
252
253 case "application/x-www-form-urlencoded":
254 // a form data POST so send to the REST parser
255 responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod);
256 response.AddHeader("Content-type", "text/html");
257 break;
258
259 case null:
260 // must be REST or invalid crap, so pass to the REST parser
261 responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod);
262 response.AddHeader("Content-type", "text/html");
263 break;
264
265 }
266
267 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
268 System.IO.Stream output = response.OutputStream;
269 response.SendChunked = false;
270 response.ContentLength64 = buffer.Length;
271 output.Write(buffer, 0, buffer.Length);
272 output.Close();
273 }
274 catch (Exception e)
275 {
276 Console.WriteLine(e.ToString());
277 }
278 }
279
280 public void Start()
281 {
282 OpenSim.Framework.Console.MainLog.Instance.WriteLine(LogPriority.LOW, "BaseHttpServer.cs: Starting up HTTP Server");
283
284 m_workerThread = new Thread(new ThreadStart(StartHTTP));
285 m_workerThread.IsBackground = true;
286 m_workerThread.Start();
287 }
288
289 private void StartHTTP()
290 {
291 try
292 {
293 OpenSim.Framework.Console.MainLog.Instance.WriteLine(LogPriority.LOW, "BaseHttpServer.cs: StartHTTP() - Spawned main thread OK");
294 m_httpListener = new HttpListener();
295
296 m_httpListener.Prefixes.Add("http://+:" + m_port + "/");
297 m_httpListener.Start();
298
299 HttpListenerContext context;
300 while (true)
301 {
302 context = m_httpListener.GetContext();
303 ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
304 }
305 }
306 catch (Exception e)
307 {
308 OpenSim.Framework.Console.MainLog.Instance.WriteLine(LogPriority.MEDIUM, e.Message);
309 }
310 }
311 }
312}
diff --git a/OpenSim/Framework/Servers/CheckSumServer.cs b/OpenSim/Framework/Servers/CheckSumServer.cs
new file mode 100644
index 0000000..a359205
--- /dev/null
+++ b/OpenSim/Framework/Servers/CheckSumServer.cs
@@ -0,0 +1,141 @@
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*/
28using System;
29using System.Text;
30using System.IO;
31using System.Threading;
32using System.Net;
33using System.Net.Sockets;
34using System.Timers;
35using System.Reflection;
36using System.Collections;
37using System.Collections.Generic;
38using libsecondlife;
39using libsecondlife.Packets;
40using OpenSim.Framework.Console;
41
42
43namespace OpenSim.Servers
44{
45/* public class CheckSumServer : UDPServerBase
46 {
47 //protected ConsoleBase m_log;
48
49 public CheckSumServer(int port)
50 : base(port)
51 {
52 }
53
54 protected override void OnReceivedData(IAsyncResult result)
55 {
56 ipeSender = new IPEndPoint(IPAddress.Any, 0);
57 epSender = (EndPoint)ipeSender;
58 Packet packet = null;
59 int numBytes = Server.EndReceiveFrom(result, ref epSender);
60 int packetEnd = numBytes - 1;
61
62 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
63
64 if (packet.Type == PacketType.SecuredTemplateChecksumRequest)
65 {
66 SecuredTemplateChecksumRequestPacket checksum = (SecuredTemplateChecksumRequestPacket)packet;
67 TemplateChecksumReplyPacket checkreply = new TemplateChecksumReplyPacket();
68 checkreply.DataBlock.Checksum = 3220703154;//180572585;
69 checkreply.DataBlock.Flags = 0;
70 checkreply.DataBlock.MajorVersion = 1;
71 checkreply.DataBlock.MinorVersion = 15;
72 checkreply.DataBlock.PatchVersion = 0;
73 checkreply.DataBlock.ServerVersion = 0;
74 checkreply.TokenBlock.Token = checksum.TokenBlock.Token;
75 this.SendPacket(checkreply, epSender);
76
77 /*
78 //if we wanted to echo the the checksum/ version from the client (so that any client worked)
79 SecuredTemplateChecksumRequestPacket checkrequest = new SecuredTemplateChecksumRequestPacket();
80 checkrequest.TokenBlock.Token = checksum.TokenBlock.Token;
81 this.SendPacket(checkrequest, epSender);
82
83 }
84 else if (packet.Type == PacketType.TemplateChecksumReply)
85 {
86 //echo back the client checksum reply (Hegemon's method)
87 TemplateChecksumReplyPacket checksum2 = (TemplateChecksumReplyPacket)packet;
88 TemplateChecksumReplyPacket checkreply2 = new TemplateChecksumReplyPacket();
89 checkreply2.DataBlock.Checksum = checksum2.DataBlock.Checksum;
90 checkreply2.DataBlock.Flags = checksum2.DataBlock.Flags;
91 checkreply2.DataBlock.MajorVersion = checksum2.DataBlock.MajorVersion;
92 checkreply2.DataBlock.MinorVersion = checksum2.DataBlock.MinorVersion;
93 checkreply2.DataBlock.PatchVersion = checksum2.DataBlock.PatchVersion;
94 checkreply2.DataBlock.ServerVersion = checksum2.DataBlock.ServerVersion;
95 checkreply2.TokenBlock.Token = checksum2.TokenBlock.Token;
96 this.SendPacket(checkreply2, epSender);
97 }
98 else
99 {
100 }
101
102 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
103 }
104
105 private void SendPacket(Packet Pack, EndPoint endp)
106 {
107 if (!Pack.Header.Resent)
108 {
109 Pack.Header.Sequence = 1;
110 }
111
112 byte[] ZeroOutBuffer = new byte[4096];
113 byte[] sendbuffer;
114 sendbuffer = Pack.ToBytes();
115
116 try
117 {
118 if (Pack.Header.Zerocoded)
119 {
120 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
121 this.SendPackTo(ZeroOutBuffer, packetsize, SocketFlags.None, endp);
122 }
123 else
124 {
125 this.SendPackTo(sendbuffer, sendbuffer.Length, SocketFlags.None, endp);
126 }
127 }
128 catch (Exception)
129 {
130 OpenSim.Framework.Console.MainLog.Instance.Warn("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection ");
131
132 }
133 }
134
135 private void SendPackTo(byte[] buffer, int size, SocketFlags flags, EndPoint endp)
136 {
137 this.Server.SendTo(buffer, size, flags, endp);
138 }
139 *
140 }*/
141} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/IRestHandler.cs b/OpenSim/Framework/Servers/IRestHandler.cs
new file mode 100644
index 0000000..3aa508c
--- /dev/null
+++ b/OpenSim/Framework/Servers/IRestHandler.cs
@@ -0,0 +1,35 @@
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*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32namespace OpenSim.Servers
33{
34 public delegate string RestMethod( string request, string path, string param );
35}
diff --git a/OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj b/OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj
new file mode 100644
index 0000000..399f456
--- /dev/null
+++ b/OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj
@@ -0,0 +1,116 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{2CC71860-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Framework.Servers</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Framework.Servers</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="libsecondlife.dll" >
62 <HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System" >
66 <HintPath>System.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="System.Xml" >
70 <HintPath>System.Xml.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="XMLRPC.dll" >
74 <HintPath>..\..\..\bin\XMLRPC.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 </ItemGroup>
78 <ItemGroup>
79 <ProjectReference Include="..\General\OpenSim.Framework.csproj">
80 <Name>OpenSim.Framework</Name>
81 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
82 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
83 <Private>False</Private>
84 </ProjectReference>
85 <ProjectReference Include="..\Console\OpenSim.Framework.Console.csproj">
86 <Name>OpenSim.Framework.Console</Name>
87 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
88 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
89 <Private>False</Private>
90 </ProjectReference>
91 </ItemGroup>
92 <ItemGroup>
93 <Compile Include="BaseHttpServer.cs">
94 <SubType>Code</SubType>
95 </Compile>
96 <Compile Include="CheckSumServer.cs">
97 <SubType>Code</SubType>
98 </Compile>
99 <Compile Include="IRestHandler.cs">
100 <SubType>Code</SubType>
101 </Compile>
102 <Compile Include="UDPServerBase.cs">
103 <SubType>Code</SubType>
104 </Compile>
105 <Compile Include="XmlRpcMethod.cs">
106 <SubType>Code</SubType>
107 </Compile>
108 </ItemGroup>
109 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
110 <PropertyGroup>
111 <PreBuildEvent>
112 </PreBuildEvent>
113 <PostBuildEvent>
114 </PostBuildEvent>
115 </PropertyGroup>
116</Project>
diff --git a/OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj.user b/OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj.user
new file mode 100644
index 0000000..6841907
--- /dev/null
+++ b/OpenSim/Framework/Servers/OpenSim.Framework.Servers.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-06\NameSpaceChanges\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/OpenSim/Framework/Servers/UDPServerBase.cs b/OpenSim/Framework/Servers/UDPServerBase.cs
new file mode 100644
index 0000000..b472c97
--- /dev/null
+++ b/OpenSim/Framework/Servers/UDPServerBase.cs
@@ -0,0 +1,95 @@
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*/
28using System;
29using System.Text;
30using System.IO;
31using System.Threading;
32using System.Net;
33using System.Net.Sockets;
34using System.Timers;
35using System.Reflection;
36using System.Collections;
37using System.Collections.Generic;
38using libsecondlife;
39using libsecondlife.Packets;
40
41namespace OpenSim.Servers
42{
43 public class UDPServerBase
44 {
45 public Socket Server;
46 protected IPEndPoint ServerIncoming;
47 protected byte[] RecvBuffer = new byte[4096];
48 protected byte[] ZeroBuffer = new byte[8192];
49 protected IPEndPoint ipeSender;
50 protected EndPoint epSender;
51 protected AsyncCallback ReceivedData;
52 protected int listenPort;
53
54 public UDPServerBase(int port)
55 {
56 listenPort = port;
57 }
58
59 protected virtual void OnReceivedData(IAsyncResult result)
60 {
61 ipeSender = new IPEndPoint(IPAddress.Any, 0);
62 epSender = (EndPoint)ipeSender;
63 Packet packet = null;
64 int numBytes = Server.EndReceiveFrom(result, ref epSender);
65 int packetEnd = numBytes - 1;
66
67 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
68
69 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
70 }
71
72 protected virtual void AddNewClient(Packet packet)
73 {
74 }
75
76 public virtual void ServerListener()
77 {
78
79 ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort);
80 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
81 Server.Bind(ServerIncoming);
82
83 ipeSender = new IPEndPoint(IPAddress.Any, 0);
84 epSender = (EndPoint)ipeSender;
85 ReceivedData = new AsyncCallback(this.OnReceivedData);
86 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
87 }
88
89 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
90 {
91
92 }
93 }
94}
95
diff --git a/OpenSim/Framework/Servers/XmlRpcMethod.cs b/OpenSim/Framework/Servers/XmlRpcMethod.cs
new file mode 100644
index 0000000..05cbf2e
--- /dev/null
+++ b/OpenSim/Framework/Servers/XmlRpcMethod.cs
@@ -0,0 +1,34 @@
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*/
28using System;
29using Nwc.XmlRpc;
30
31namespace OpenSim.Servers
32{
33 public delegate XmlRpcResponse XmlRpcMethod( XmlRpcRequest request );
34}