diff options
Diffstat (limited to 'OpenSim/Framework/Servers')
-rw-r--r-- | OpenSim/Framework/Servers/BaseHttpServer.cs | 448 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/BaseStreamHandler.cs | 80 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/BinaryStreamHandler.cs | 98 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/CheckSumServer.cs | 252 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/IStreamHandler.cs | 44 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/RestMethod.cs | 62 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/RestStreamHandler.cs | 62 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/UDPServerBase.cs | 174 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/XmlRpcMethod.cs | 66 |
9 files changed, 643 insertions, 643 deletions
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs index f790477..4b3b3de 100644 --- a/OpenSim/Framework/Servers/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/BaseHttpServer.cs | |||
@@ -1,224 +1,224 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.IO; | 31 | using System.IO; |
32 | using System.Net; | 32 | using System.Net; |
33 | using System.Text; | 33 | using System.Text; |
34 | using System.Text.RegularExpressions; | 34 | using System.Text.RegularExpressions; |
35 | using System.Threading; | 35 | using System.Threading; |
36 | using Nwc.XmlRpc; | 36 | using Nwc.XmlRpc; |
37 | using OpenSim.Framework.Console; | 37 | using OpenSim.Framework.Console; |
38 | 38 | ||
39 | namespace OpenSim.Framework.Servers | 39 | namespace OpenSim.Framework.Servers |
40 | { | 40 | { |
41 | public class BaseHttpServer | 41 | public class BaseHttpServer |
42 | { | 42 | { |
43 | protected Thread m_workerThread; | 43 | protected Thread m_workerThread; |
44 | protected HttpListener m_httpListener; | 44 | protected HttpListener m_httpListener; |
45 | protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>(); | 45 | protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>(); |
46 | protected Dictionary<string, IStreamHandler> m_streamHandlers = new Dictionary<string, IStreamHandler>(); | 46 | protected Dictionary<string, IStreamHandler> m_streamHandlers = new Dictionary<string, IStreamHandler>(); |
47 | protected int m_port; | 47 | protected int m_port; |
48 | protected bool m_firstcaps = true; | 48 | protected bool m_firstcaps = true; |
49 | 49 | ||
50 | public BaseHttpServer(int port) | 50 | public BaseHttpServer(int port) |
51 | { | 51 | { |
52 | m_port = port; | 52 | m_port = port; |
53 | } | 53 | } |
54 | 54 | ||
55 | public void AddStreamHandler( IStreamHandler handler) | 55 | public void AddStreamHandler( IStreamHandler handler) |
56 | { | 56 | { |
57 | string httpMethod = handler.HttpMethod; | 57 | string httpMethod = handler.HttpMethod; |
58 | string path = handler.Path; | 58 | string path = handler.Path; |
59 | 59 | ||
60 | string handlerKey = GetHandlerKey(httpMethod, path); | 60 | string handlerKey = GetHandlerKey(httpMethod, path); |
61 | m_streamHandlers.Add(handlerKey, handler); | 61 | m_streamHandlers.Add(handlerKey, handler); |
62 | } | 62 | } |
63 | 63 | ||
64 | private static string GetHandlerKey(string httpMethod, string path) | 64 | private static string GetHandlerKey(string httpMethod, string path) |
65 | { | 65 | { |
66 | return httpMethod + ":" + path; | 66 | return httpMethod + ":" + path; |
67 | } | 67 | } |
68 | 68 | ||
69 | public bool AddXmlRPCHandler(string method, XmlRpcMethod handler) | 69 | public bool AddXmlRPCHandler(string method, XmlRpcMethod handler) |
70 | { | 70 | { |
71 | if (!this.m_rpcHandlers.ContainsKey(method)) | 71 | if (!this.m_rpcHandlers.ContainsKey(method)) |
72 | { | 72 | { |
73 | this.m_rpcHandlers.Add(method, handler); | 73 | this.m_rpcHandlers.Add(method, handler); |
74 | return true; | 74 | return true; |
75 | } | 75 | } |
76 | 76 | ||
77 | //must already have a handler for that path so return false | 77 | //must already have a handler for that path so return false |
78 | return false; | 78 | return false; |
79 | } | 79 | } |
80 | 80 | ||
81 | 81 | ||
82 | public virtual void HandleRequest(Object stateinfo) | 82 | public virtual void HandleRequest(Object stateinfo) |
83 | { | 83 | { |
84 | HttpListenerContext context = (HttpListenerContext)stateinfo; | 84 | HttpListenerContext context = (HttpListenerContext)stateinfo; |
85 | 85 | ||
86 | HttpListenerRequest request = context.Request; | 86 | HttpListenerRequest request = context.Request; |
87 | HttpListenerResponse response = context.Response; | 87 | HttpListenerResponse response = context.Response; |
88 | 88 | ||
89 | response.KeepAlive = false; | 89 | response.KeepAlive = false; |
90 | response.SendChunked = false; | 90 | response.SendChunked = false; |
91 | 91 | ||
92 | string path = request.RawUrl; | 92 | string path = request.RawUrl; |
93 | string handlerKey = GetHandlerKey( request.HttpMethod, path ); | 93 | string handlerKey = GetHandlerKey( request.HttpMethod, path ); |
94 | 94 | ||
95 | IStreamHandler streamHandler; | 95 | IStreamHandler streamHandler; |
96 | 96 | ||
97 | if (TryGetStreamHandler( handlerKey, out streamHandler)) | 97 | if (TryGetStreamHandler( handlerKey, out streamHandler)) |
98 | { | 98 | { |
99 | byte[] buffer = streamHandler.Handle(path, request.InputStream); | 99 | byte[] buffer = streamHandler.Handle(path, request.InputStream); |
100 | request.InputStream.Close(); | 100 | request.InputStream.Close(); |
101 | 101 | ||
102 | response.ContentType = streamHandler.ContentType; | 102 | response.ContentType = streamHandler.ContentType; |
103 | response.ContentLength64 = buffer.LongLength; | 103 | response.ContentLength64 = buffer.LongLength; |
104 | response.OutputStream.Write(buffer, 0, buffer.Length); | 104 | response.OutputStream.Write(buffer, 0, buffer.Length); |
105 | response.OutputStream.Close(); | 105 | response.OutputStream.Close(); |
106 | } | 106 | } |
107 | else | 107 | else |
108 | { | 108 | { |
109 | HandleXmlRpcRequests(request, response); | 109 | HandleXmlRpcRequests(request, response); |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | private bool TryGetStreamHandler(string handlerKey, out IStreamHandler streamHandler) | 113 | private bool TryGetStreamHandler(string handlerKey, out IStreamHandler streamHandler) |
114 | { | 114 | { |
115 | string bestMatch = null; | 115 | string bestMatch = null; |
116 | 116 | ||
117 | foreach (string pattern in m_streamHandlers.Keys) | 117 | foreach (string pattern in m_streamHandlers.Keys) |
118 | { | 118 | { |
119 | if (handlerKey.StartsWith(pattern)) | 119 | if (handlerKey.StartsWith(pattern)) |
120 | { | 120 | { |
121 | if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length) | 121 | if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length) |
122 | { | 122 | { |
123 | bestMatch = pattern; | 123 | bestMatch = pattern; |
124 | } | 124 | } |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | if (String.IsNullOrEmpty(bestMatch)) | 128 | if (String.IsNullOrEmpty(bestMatch)) |
129 | { | 129 | { |
130 | streamHandler = null; | 130 | streamHandler = null; |
131 | return false; | 131 | return false; |
132 | } | 132 | } |
133 | else | 133 | else |
134 | { | 134 | { |
135 | streamHandler = m_streamHandlers[bestMatch]; | 135 | streamHandler = m_streamHandlers[bestMatch]; |
136 | return true; | 136 | return true; |
137 | } | 137 | } |
138 | } | 138 | } |
139 | 139 | ||
140 | private void HandleXmlRpcRequests(HttpListenerRequest request, HttpListenerResponse response) | 140 | private void HandleXmlRpcRequests(HttpListenerRequest request, HttpListenerResponse response) |
141 | { | 141 | { |
142 | Stream requestStream = request.InputStream; | 142 | Stream requestStream = request.InputStream; |
143 | 143 | ||
144 | Encoding encoding = Encoding.UTF8; | 144 | Encoding encoding = Encoding.UTF8; |
145 | StreamReader reader = new StreamReader(requestStream, encoding); | 145 | StreamReader reader = new StreamReader(requestStream, encoding); |
146 | 146 | ||
147 | string requestBody = reader.ReadToEnd(); | 147 | string requestBody = reader.ReadToEnd(); |
148 | reader.Close(); | 148 | reader.Close(); |
149 | requestStream.Close(); | 149 | requestStream.Close(); |
150 | 150 | ||
151 | XmlRpcRequest xmlRprcRequest = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); | 151 | XmlRpcRequest xmlRprcRequest = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); |
152 | 152 | ||
153 | string methodName = xmlRprcRequest.MethodName; | 153 | string methodName = xmlRprcRequest.MethodName; |
154 | 154 | ||
155 | XmlRpcResponse xmlRpcResponse; | 155 | XmlRpcResponse xmlRpcResponse; |
156 | 156 | ||
157 | XmlRpcMethod method; | 157 | XmlRpcMethod method; |
158 | if (this.m_rpcHandlers.TryGetValue(methodName, out method)) | 158 | if (this.m_rpcHandlers.TryGetValue(methodName, out method)) |
159 | { | 159 | { |
160 | xmlRpcResponse = method(xmlRprcRequest); | 160 | xmlRpcResponse = method(xmlRprcRequest); |
161 | } | 161 | } |
162 | else | 162 | else |
163 | { | 163 | { |
164 | xmlRpcResponse = new XmlRpcResponse(); | 164 | xmlRpcResponse = new XmlRpcResponse(); |
165 | Hashtable unknownMethodError = new Hashtable(); | 165 | Hashtable unknownMethodError = new Hashtable(); |
166 | unknownMethodError["reason"] = "XmlRequest"; ; | 166 | unknownMethodError["reason"] = "XmlRequest"; ; |
167 | unknownMethodError["message"] = "Unknown Rpc Request ["+methodName+"]"; | 167 | unknownMethodError["message"] = "Unknown Rpc Request ["+methodName+"]"; |
168 | unknownMethodError["login"] = "false"; | 168 | unknownMethodError["login"] = "false"; |
169 | xmlRpcResponse.Value = unknownMethodError; | 169 | xmlRpcResponse.Value = unknownMethodError; |
170 | } | 170 | } |
171 | 171 | ||
172 | response.AddHeader("Content-type", "text/xml"); | 172 | response.AddHeader("Content-type", "text/xml"); |
173 | 173 | ||
174 | string responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse); | 174 | string responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse); |
175 | 175 | ||
176 | byte[] buffer = Encoding.UTF8.GetBytes(responseString); | 176 | byte[] buffer = Encoding.UTF8.GetBytes(responseString); |
177 | 177 | ||
178 | response.SendChunked = false; | 178 | response.SendChunked = false; |
179 | response.ContentLength64 = buffer.Length; | 179 | response.ContentLength64 = buffer.Length; |
180 | response.ContentEncoding = Encoding.UTF8; | 180 | response.ContentEncoding = Encoding.UTF8; |
181 | 181 | ||
182 | response.OutputStream.Write(buffer, 0, buffer.Length); | 182 | response.OutputStream.Write(buffer, 0, buffer.Length); |
183 | response.OutputStream.Close(); | 183 | response.OutputStream.Close(); |
184 | } | 184 | } |
185 | 185 | ||
186 | public void Start() | 186 | public void Start() |
187 | { | 187 | { |
188 | MainLog.Instance.WriteLine(LogPriority.LOW, "BaseHttpServer.cs: Starting up HTTP Server"); | 188 | MainLog.Instance.WriteLine(LogPriority.LOW, "BaseHttpServer.cs: Starting up HTTP Server"); |
189 | 189 | ||
190 | m_workerThread = new Thread(new ThreadStart(StartHTTP)); | 190 | m_workerThread = new Thread(new ThreadStart(StartHTTP)); |
191 | m_workerThread.IsBackground = true; | 191 | m_workerThread.IsBackground = true; |
192 | m_workerThread.Start(); | 192 | m_workerThread.Start(); |
193 | } | 193 | } |
194 | 194 | ||
195 | private void StartHTTP() | 195 | private void StartHTTP() |
196 | { | 196 | { |
197 | try | 197 | try |
198 | { | 198 | { |
199 | MainLog.Instance.WriteLine(LogPriority.LOW, "BaseHttpServer.cs: StartHTTP() - Spawned main thread OK"); | 199 | MainLog.Instance.WriteLine(LogPriority.LOW, "BaseHttpServer.cs: StartHTTP() - Spawned main thread OK"); |
200 | m_httpListener = new HttpListener(); | 200 | m_httpListener = new HttpListener(); |
201 | 201 | ||
202 | m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); | 202 | m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); |
203 | m_httpListener.Start(); | 203 | m_httpListener.Start(); |
204 | 204 | ||
205 | HttpListenerContext context; | 205 | HttpListenerContext context; |
206 | while (true) | 206 | while (true) |
207 | { | 207 | { |
208 | context = m_httpListener.GetContext(); | 208 | context = m_httpListener.GetContext(); |
209 | ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context); | 209 | ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context); |
210 | } | 210 | } |
211 | } | 211 | } |
212 | catch (Exception e) | 212 | catch (Exception e) |
213 | { | 213 | { |
214 | MainLog.Instance.WriteLine(LogPriority.MEDIUM, e.Message); | 214 | MainLog.Instance.WriteLine(LogPriority.MEDIUM, e.Message); |
215 | } | 215 | } |
216 | } | 216 | } |
217 | 217 | ||
218 | 218 | ||
219 | public void RemoveStreamHandler(string httpMethod, string path) | 219 | public void RemoveStreamHandler(string httpMethod, string path) |
220 | { | 220 | { |
221 | m_streamHandlers.Remove(GetHandlerKey(httpMethod, path)); | 221 | m_streamHandlers.Remove(GetHandlerKey(httpMethod, path)); |
222 | } | 222 | } |
223 | } | 223 | } |
224 | } | 224 | } |
diff --git a/OpenSim/Framework/Servers/BaseStreamHandler.cs b/OpenSim/Framework/Servers/BaseStreamHandler.cs index 0d9c674..0c714e6 100644 --- a/OpenSim/Framework/Servers/BaseStreamHandler.cs +++ b/OpenSim/Framework/Servers/BaseStreamHandler.cs | |||
@@ -1,40 +1,40 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using System.IO; | 4 | using System.IO; |
5 | 5 | ||
6 | namespace OpenSim.Framework.Servers | 6 | namespace OpenSim.Framework.Servers |
7 | { | 7 | { |
8 | public abstract class BaseStreamHandler : IStreamHandler | 8 | public abstract class BaseStreamHandler : IStreamHandler |
9 | { | 9 | { |
10 | virtual public string ContentType | 10 | virtual public string ContentType |
11 | { | 11 | { |
12 | get { return "application/xml"; } | 12 | get { return "application/xml"; } |
13 | } | 13 | } |
14 | 14 | ||
15 | private string m_httpMethod; | 15 | private string m_httpMethod; |
16 | virtual public string HttpMethod | 16 | virtual public string HttpMethod |
17 | { | 17 | { |
18 | get { return m_httpMethod; } | 18 | get { return m_httpMethod; } |
19 | } | 19 | } |
20 | 20 | ||
21 | private string m_path; | 21 | private string m_path; |
22 | virtual public string Path | 22 | virtual public string Path |
23 | { | 23 | { |
24 | get { return m_path; } | 24 | get { return m_path; } |
25 | } | 25 | } |
26 | 26 | ||
27 | protected string GetParam( string path ) | 27 | protected string GetParam( string path ) |
28 | { | 28 | { |
29 | return path.Substring( m_path.Length ); | 29 | return path.Substring( m_path.Length ); |
30 | } | 30 | } |
31 | 31 | ||
32 | public abstract byte[] Handle(string path, Stream request); | 32 | public abstract byte[] Handle(string path, Stream request); |
33 | 33 | ||
34 | protected BaseStreamHandler(string httpMethod, string path) | 34 | protected BaseStreamHandler(string httpMethod, string path) |
35 | { | 35 | { |
36 | m_httpMethod = httpMethod; | 36 | m_httpMethod = httpMethod; |
37 | m_path = path; | 37 | m_path = path; |
38 | } | 38 | } |
39 | } | 39 | } |
40 | } | 40 | } |
diff --git a/OpenSim/Framework/Servers/BinaryStreamHandler.cs b/OpenSim/Framework/Servers/BinaryStreamHandler.cs index 7d4e4ce..6e512f6 100644 --- a/OpenSim/Framework/Servers/BinaryStreamHandler.cs +++ b/OpenSim/Framework/Servers/BinaryStreamHandler.cs | |||
@@ -1,49 +1,49 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using System.IO; | 4 | using System.IO; |
5 | 5 | ||
6 | namespace OpenSim.Framework.Servers | 6 | namespace OpenSim.Framework.Servers |
7 | { | 7 | { |
8 | public delegate string BinaryMethod(byte[] data, string path, string param); | 8 | public delegate string BinaryMethod(byte[] data, string path, string param); |
9 | 9 | ||
10 | public class BinaryStreamHandler : BaseStreamHandler | 10 | public class BinaryStreamHandler : BaseStreamHandler |
11 | { | 11 | { |
12 | BinaryMethod m_method; | 12 | BinaryMethod m_method; |
13 | 13 | ||
14 | override public byte[] Handle(string path, Stream request) | 14 | override public byte[] Handle(string path, Stream request) |
15 | { | 15 | { |
16 | byte[] data = ReadFully(request); | 16 | byte[] data = ReadFully(request); |
17 | string param = GetParam(path); | 17 | string param = GetParam(path); |
18 | string responseString = m_method(data, path, param); | 18 | string responseString = m_method(data, path, param); |
19 | 19 | ||
20 | return Encoding.UTF8.GetBytes(responseString); | 20 | return Encoding.UTF8.GetBytes(responseString); |
21 | } | 21 | } |
22 | 22 | ||
23 | public BinaryStreamHandler(string httpMethod, string path, BinaryMethod binaryMethod) | 23 | public BinaryStreamHandler(string httpMethod, string path, BinaryMethod binaryMethod) |
24 | : base(httpMethod, path) | 24 | : base(httpMethod, path) |
25 | { | 25 | { |
26 | m_method = binaryMethod; | 26 | m_method = binaryMethod; |
27 | } | 27 | } |
28 | 28 | ||
29 | private byte[] ReadFully(Stream stream) | 29 | private byte[] ReadFully(Stream stream) |
30 | { | 30 | { |
31 | byte[] buffer = new byte[32768]; | 31 | byte[] buffer = new byte[32768]; |
32 | using (MemoryStream ms = new MemoryStream()) | 32 | using (MemoryStream ms = new MemoryStream()) |
33 | { | 33 | { |
34 | while (true) | 34 | while (true) |
35 | { | 35 | { |
36 | int read = stream.Read(buffer, 0, buffer.Length); | 36 | int read = stream.Read(buffer, 0, buffer.Length); |
37 | 37 | ||
38 | if (read <= 0) | 38 | if (read <= 0) |
39 | { | 39 | { |
40 | return ms.ToArray(); | 40 | return ms.ToArray(); |
41 | } | 41 | } |
42 | 42 | ||
43 | ms.Write(buffer, 0, read); | 43 | ms.Write(buffer, 0, read); |
44 | } | 44 | } |
45 | } | 45 | } |
46 | } | 46 | } |
47 | } | 47 | } |
48 | 48 | ||
49 | } | 49 | } |
diff --git a/OpenSim/Framework/Servers/CheckSumServer.cs b/OpenSim/Framework/Servers/CheckSumServer.cs index 89ec095..b1fa5cd 100644 --- a/OpenSim/Framework/Servers/CheckSumServer.cs +++ b/OpenSim/Framework/Servers/CheckSumServer.cs | |||
@@ -1,127 +1,127 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | namespace OpenSim.Framework.Servers | 28 | namespace OpenSim.Framework.Servers |
29 | {/* | 29 | {/* |
30 | public class CheckSumServer : UDPServerBase | 30 | public class CheckSumServer : UDPServerBase |
31 | { | 31 | { |
32 | //protected ConsoleBase m_log; | 32 | //protected ConsoleBase m_log; |
33 | 33 | ||
34 | public CheckSumServer(int port) | 34 | public CheckSumServer(int port) |
35 | : base(port) | 35 | : base(port) |
36 | { | 36 | { |
37 | } | 37 | } |
38 | 38 | ||
39 | protected override void OnReceivedData(IAsyncResult result) | 39 | protected override void OnReceivedData(IAsyncResult result) |
40 | { | 40 | { |
41 | ipeSender = new IPEndPoint(IPAddress.Any, 0); | 41 | ipeSender = new IPEndPoint(IPAddress.Any, 0); |
42 | epSender = (EndPoint)ipeSender; | 42 | epSender = (EndPoint)ipeSender; |
43 | Packet packet = null; | 43 | Packet packet = null; |
44 | int numBytes = Server.EndReceiveFrom(result, ref epSender); | 44 | int numBytes = Server.EndReceiveFrom(result, ref epSender); |
45 | int packetEnd = numBytes - 1; | 45 | int packetEnd = numBytes - 1; |
46 | 46 | ||
47 | packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); | 47 | packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); |
48 | 48 | ||
49 | if (packet.Type == PacketType.SecuredTemplateChecksumRequest) | 49 | if (packet.Type == PacketType.SecuredTemplateChecksumRequest) |
50 | { | 50 | { |
51 | SecuredTemplateChecksumRequestPacket checksum = (SecuredTemplateChecksumRequestPacket)packet; | 51 | SecuredTemplateChecksumRequestPacket checksum = (SecuredTemplateChecksumRequestPacket)packet; |
52 | TemplateChecksumReplyPacket checkreply = new TemplateChecksumReplyPacket(); | 52 | TemplateChecksumReplyPacket checkreply = new TemplateChecksumReplyPacket(); |
53 | checkreply.DataBlock.Checksum = 3220703154;//180572585; | 53 | checkreply.DataBlock.Checksum = 3220703154;//180572585; |
54 | checkreply.DataBlock.Flags = 0; | 54 | checkreply.DataBlock.Flags = 0; |
55 | checkreply.DataBlock.MajorVersion = 1; | 55 | checkreply.DataBlock.MajorVersion = 1; |
56 | checkreply.DataBlock.MinorVersion = 15; | 56 | checkreply.DataBlock.MinorVersion = 15; |
57 | checkreply.DataBlock.PatchVersion = 0; | 57 | checkreply.DataBlock.PatchVersion = 0; |
58 | checkreply.DataBlock.ServerVersion = 0; | 58 | checkreply.DataBlock.ServerVersion = 0; |
59 | checkreply.TokenBlock.Token = checksum.TokenBlock.Token; | 59 | checkreply.TokenBlock.Token = checksum.TokenBlock.Token; |
60 | this.SendPacket(checkreply, epSender); | 60 | this.SendPacket(checkreply, epSender); |
61 | 61 | ||
62 | /* | 62 | /* |
63 | //if we wanted to echo the the checksum/ version from the client (so that any client worked) | 63 | //if we wanted to echo the the checksum/ version from the client (so that any client worked) |
64 | SecuredTemplateChecksumRequestPacket checkrequest = new SecuredTemplateChecksumRequestPacket(); | 64 | SecuredTemplateChecksumRequestPacket checkrequest = new SecuredTemplateChecksumRequestPacket(); |
65 | checkrequest.TokenBlock.Token = checksum.TokenBlock.Token; | 65 | checkrequest.TokenBlock.Token = checksum.TokenBlock.Token; |
66 | this.SendPacket(checkrequest, epSender); | 66 | this.SendPacket(checkrequest, epSender); |
67 | 67 | ||
68 | } | 68 | } |
69 | else if (packet.Type == PacketType.TemplateChecksumReply) | 69 | else if (packet.Type == PacketType.TemplateChecksumReply) |
70 | { | 70 | { |
71 | //echo back the client checksum reply (Hegemon's method) | 71 | //echo back the client checksum reply (Hegemon's method) |
72 | TemplateChecksumReplyPacket checksum2 = (TemplateChecksumReplyPacket)packet; | 72 | TemplateChecksumReplyPacket checksum2 = (TemplateChecksumReplyPacket)packet; |
73 | TemplateChecksumReplyPacket checkreply2 = new TemplateChecksumReplyPacket(); | 73 | TemplateChecksumReplyPacket checkreply2 = new TemplateChecksumReplyPacket(); |
74 | checkreply2.DataBlock.Checksum = checksum2.DataBlock.Checksum; | 74 | checkreply2.DataBlock.Checksum = checksum2.DataBlock.Checksum; |
75 | checkreply2.DataBlock.Flags = checksum2.DataBlock.Flags; | 75 | checkreply2.DataBlock.Flags = checksum2.DataBlock.Flags; |
76 | checkreply2.DataBlock.MajorVersion = checksum2.DataBlock.MajorVersion; | 76 | checkreply2.DataBlock.MajorVersion = checksum2.DataBlock.MajorVersion; |
77 | checkreply2.DataBlock.MinorVersion = checksum2.DataBlock.MinorVersion; | 77 | checkreply2.DataBlock.MinorVersion = checksum2.DataBlock.MinorVersion; |
78 | checkreply2.DataBlock.PatchVersion = checksum2.DataBlock.PatchVersion; | 78 | checkreply2.DataBlock.PatchVersion = checksum2.DataBlock.PatchVersion; |
79 | checkreply2.DataBlock.ServerVersion = checksum2.DataBlock.ServerVersion; | 79 | checkreply2.DataBlock.ServerVersion = checksum2.DataBlock.ServerVersion; |
80 | checkreply2.TokenBlock.Token = checksum2.TokenBlock.Token; | 80 | checkreply2.TokenBlock.Token = checksum2.TokenBlock.Token; |
81 | this.SendPacket(checkreply2, epSender); | 81 | this.SendPacket(checkreply2, epSender); |
82 | } | 82 | } |
83 | else | 83 | else |
84 | { | 84 | { |
85 | } | 85 | } |
86 | 86 | ||
87 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | 87 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); |
88 | } | 88 | } |
89 | 89 | ||
90 | private void SendPacket(Packet Pack, EndPoint endp) | 90 | private void SendPacket(Packet Pack, EndPoint endp) |
91 | { | 91 | { |
92 | if (!Pack.Header.Resent) | 92 | if (!Pack.Header.Resent) |
93 | { | 93 | { |
94 | Pack.Header.Sequence = 1; | 94 | Pack.Header.Sequence = 1; |
95 | } | 95 | } |
96 | 96 | ||
97 | byte[] ZeroOutBuffer = new byte[4096]; | 97 | byte[] ZeroOutBuffer = new byte[4096]; |
98 | byte[] sendbuffer; | 98 | byte[] sendbuffer; |
99 | sendbuffer = Pack.ToBytes(); | 99 | sendbuffer = Pack.ToBytes(); |
100 | 100 | ||
101 | try | 101 | try |
102 | { | 102 | { |
103 | if (Pack.Header.Zerocoded) | 103 | if (Pack.Header.Zerocoded) |
104 | { | 104 | { |
105 | int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); | 105 | int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); |
106 | this.SendPackTo(ZeroOutBuffer, packetsize, SocketFlags.None, endp); | 106 | this.SendPackTo(ZeroOutBuffer, packetsize, SocketFlags.None, endp); |
107 | } | 107 | } |
108 | else | 108 | else |
109 | { | 109 | { |
110 | this.SendPackTo(sendbuffer, sendbuffer.Length, SocketFlags.None, endp); | 110 | this.SendPackTo(sendbuffer, sendbuffer.Length, SocketFlags.None, endp); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | catch (Exception) | 113 | catch (Exception) |
114 | { | 114 | { |
115 | OpenSim.Framework.Console.MainLog.Instance.Warn("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection "); | 115 | OpenSim.Framework.Console.MainLog.Instance.Warn("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection "); |
116 | 116 | ||
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | private void SendPackTo(byte[] buffer, int size, SocketFlags flags, EndPoint endp) | 120 | private void SendPackTo(byte[] buffer, int size, SocketFlags flags, EndPoint endp) |
121 | { | 121 | { |
122 | this.Server.SendTo(buffer, size, flags, endp); | 122 | this.Server.SendTo(buffer, size, flags, endp); |
123 | } | 123 | } |
124 | * } | 124 | * } |
125 | */ | 125 | */ |
126 | 126 | ||
127 | } \ No newline at end of file | 127 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Servers/IStreamHandler.cs b/OpenSim/Framework/Servers/IStreamHandler.cs index 6cab40d..8858c99 100644 --- a/OpenSim/Framework/Servers/IStreamHandler.cs +++ b/OpenSim/Framework/Servers/IStreamHandler.cs | |||
@@ -1,22 +1,22 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using System.IO; | 4 | using System.IO; |
5 | 5 | ||
6 | namespace OpenSim.Framework.Servers | 6 | namespace OpenSim.Framework.Servers |
7 | { | 7 | { |
8 | public interface IStreamHandler | 8 | public interface IStreamHandler |
9 | { | 9 | { |
10 | // Handle request stream, return byte array | 10 | // Handle request stream, return byte array |
11 | byte[] Handle(string path, Stream request ); | 11 | byte[] Handle(string path, Stream request ); |
12 | 12 | ||
13 | // Return response content type | 13 | // Return response content type |
14 | string ContentType { get; } | 14 | string ContentType { get; } |
15 | 15 | ||
16 | // Return required http method | 16 | // Return required http method |
17 | string HttpMethod { get;} | 17 | string HttpMethod { get;} |
18 | 18 | ||
19 | // Return path | 19 | // Return path |
20 | string Path { get; } | 20 | string Path { get; } |
21 | } | 21 | } |
22 | } | 22 | } |
diff --git a/OpenSim/Framework/Servers/RestMethod.cs b/OpenSim/Framework/Servers/RestMethod.cs index c6cb230..0c2624b 100644 --- a/OpenSim/Framework/Servers/RestMethod.cs +++ b/OpenSim/Framework/Servers/RestMethod.cs | |||
@@ -1,31 +1,31 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | namespace OpenSim.Framework.Servers | 28 | namespace OpenSim.Framework.Servers |
29 | { | 29 | { |
30 | public delegate string RestMethod( string request, string path, string param ); | 30 | public delegate string RestMethod( string request, string path, string param ); |
31 | } | 31 | } |
diff --git a/OpenSim/Framework/Servers/RestStreamHandler.cs b/OpenSim/Framework/Servers/RestStreamHandler.cs index 1b3b41c..6753a06 100644 --- a/OpenSim/Framework/Servers/RestStreamHandler.cs +++ b/OpenSim/Framework/Servers/RestStreamHandler.cs | |||
@@ -1,31 +1,31 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using System.IO; | 4 | using System.IO; |
5 | 5 | ||
6 | namespace OpenSim.Framework.Servers | 6 | namespace OpenSim.Framework.Servers |
7 | { | 7 | { |
8 | public class RestStreamHandler : BaseStreamHandler | 8 | public class RestStreamHandler : BaseStreamHandler |
9 | { | 9 | { |
10 | RestMethod m_restMethod; | 10 | RestMethod m_restMethod; |
11 | 11 | ||
12 | override public byte[] Handle(string path, Stream request ) | 12 | override public byte[] Handle(string path, Stream request ) |
13 | { | 13 | { |
14 | Encoding encoding = Encoding.UTF8; | 14 | Encoding encoding = Encoding.UTF8; |
15 | StreamReader streamReader = new StreamReader(request, encoding); | 15 | StreamReader streamReader = new StreamReader(request, encoding); |
16 | 16 | ||
17 | string requestBody = streamReader.ReadToEnd(); | 17 | string requestBody = streamReader.ReadToEnd(); |
18 | streamReader.Close(); | 18 | streamReader.Close(); |
19 | 19 | ||
20 | string param = GetParam(path); | 20 | string param = GetParam(path); |
21 | string responseString = m_restMethod(requestBody, path, param ); | 21 | string responseString = m_restMethod(requestBody, path, param ); |
22 | 22 | ||
23 | return Encoding.UTF8.GetBytes(responseString); | 23 | return Encoding.UTF8.GetBytes(responseString); |
24 | } | 24 | } |
25 | 25 | ||
26 | public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) : base( httpMethod, path ) | 26 | public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) : base( httpMethod, path ) |
27 | { | 27 | { |
28 | m_restMethod = restMethod; | 28 | m_restMethod = restMethod; |
29 | } | 29 | } |
30 | } | 30 | } |
31 | } | 31 | } |
diff --git a/OpenSim/Framework/Servers/UDPServerBase.cs b/OpenSim/Framework/Servers/UDPServerBase.cs index 508eb9d..8113207 100644 --- a/OpenSim/Framework/Servers/UDPServerBase.cs +++ b/OpenSim/Framework/Servers/UDPServerBase.cs | |||
@@ -1,87 +1,87 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Net; | 29 | using System.Net; |
30 | using System.Net.Sockets; | 30 | using System.Net.Sockets; |
31 | using libsecondlife.Packets; | 31 | using libsecondlife.Packets; |
32 | 32 | ||
33 | namespace OpenSim.Framework.Servers | 33 | namespace OpenSim.Framework.Servers |
34 | { | 34 | { |
35 | public class UDPServerBase | 35 | public class UDPServerBase |
36 | { | 36 | { |
37 | public Socket Server; | 37 | public Socket Server; |
38 | protected IPEndPoint ServerIncoming; | 38 | protected IPEndPoint ServerIncoming; |
39 | protected byte[] RecvBuffer = new byte[4096]; | 39 | protected byte[] RecvBuffer = new byte[4096]; |
40 | protected byte[] ZeroBuffer = new byte[8192]; | 40 | protected byte[] ZeroBuffer = new byte[8192]; |
41 | protected IPEndPoint ipeSender; | 41 | protected IPEndPoint ipeSender; |
42 | protected EndPoint epSender; | 42 | protected EndPoint epSender; |
43 | protected AsyncCallback ReceivedData; | 43 | protected AsyncCallback ReceivedData; |
44 | protected int listenPort; | 44 | protected int listenPort; |
45 | 45 | ||
46 | public UDPServerBase(int port) | 46 | public UDPServerBase(int port) |
47 | { | 47 | { |
48 | listenPort = port; | 48 | listenPort = port; |
49 | } | 49 | } |
50 | 50 | ||
51 | protected virtual void OnReceivedData(IAsyncResult result) | 51 | protected virtual void OnReceivedData(IAsyncResult result) |
52 | { | 52 | { |
53 | ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); | 53 | ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); |
54 | epSender = (EndPoint)ipeSender; | 54 | epSender = (EndPoint)ipeSender; |
55 | Packet packet = null; | 55 | Packet packet = null; |
56 | int numBytes = Server.EndReceiveFrom(result, ref epSender); | 56 | int numBytes = Server.EndReceiveFrom(result, ref epSender); |
57 | int packetEnd = numBytes - 1; | 57 | int packetEnd = numBytes - 1; |
58 | 58 | ||
59 | packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); | 59 | packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); |
60 | 60 | ||
61 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | 61 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); |
62 | } | 62 | } |
63 | 63 | ||
64 | protected virtual void AddNewClient(Packet packet) | 64 | protected virtual void AddNewClient(Packet packet) |
65 | { | 65 | { |
66 | } | 66 | } |
67 | 67 | ||
68 | public virtual void ServerListener() | 68 | public virtual void ServerListener() |
69 | { | 69 | { |
70 | 70 | ||
71 | ServerIncoming = new IPEndPoint(IPAddress.Parse("0.0.0.0"), listenPort); | 71 | ServerIncoming = new IPEndPoint(IPAddress.Parse("0.0.0.0"), listenPort); |
72 | Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); | 72 | Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); |
73 | Server.Bind(ServerIncoming); | 73 | Server.Bind(ServerIncoming); |
74 | 74 | ||
75 | ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); | 75 | ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); |
76 | epSender = (EndPoint)ipeSender; | 76 | epSender = (EndPoint)ipeSender; |
77 | ReceivedData = new AsyncCallback(this.OnReceivedData); | 77 | ReceivedData = new AsyncCallback(this.OnReceivedData); |
78 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | 78 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); |
79 | } | 79 | } |
80 | 80 | ||
81 | public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) | 81 | public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) |
82 | { | 82 | { |
83 | 83 | ||
84 | } | 84 | } |
85 | } | 85 | } |
86 | } | 86 | } |
87 | 87 | ||
diff --git a/OpenSim/Framework/Servers/XmlRpcMethod.cs b/OpenSim/Framework/Servers/XmlRpcMethod.cs index b76ac51..b8abecf 100644 --- a/OpenSim/Framework/Servers/XmlRpcMethod.cs +++ b/OpenSim/Framework/Servers/XmlRpcMethod.cs | |||
@@ -1,33 +1,33 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using Nwc.XmlRpc; | 28 | using Nwc.XmlRpc; |
29 | 29 | ||
30 | namespace OpenSim.Framework.Servers | 30 | namespace OpenSim.Framework.Servers |
31 | { | 31 | { |
32 | public delegate XmlRpcResponse XmlRpcMethod( XmlRpcRequest request ); | 32 | public delegate XmlRpcResponse XmlRpcMethod( XmlRpcRequest request ); |
33 | } | 33 | } |