aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs66
1 files changed, 42 insertions, 24 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index ceb99ae..5625854 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -75,7 +75,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
75 protected IPAddress listenIP = IPAddress.Parse("0.0.0.0"); 75 protected IPAddress listenIP = IPAddress.Parse("0.0.0.0");
76 protected IScene m_localScene; 76 protected IScene m_localScene;
77 protected AssetCache m_assetCache; 77 protected AssetCache m_assetCache;
78 protected AgentCircuitManager m_authenticateSessionsClass; 78
79 /// <value>
80 /// Manages authentication for agent circuits
81 /// </value>
82 protected AgentCircuitManager m_circuitManager;
79 83
80 public LLPacketServer PacketServer 84 public LLPacketServer PacketServer
81 { 85 {
@@ -132,14 +136,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
132 Initialise(_listenIP, ref port, proxyPortOffset, allow_alternate_port, assetCache, authenticateClass); 136 Initialise(_listenIP, ref port, proxyPortOffset, allow_alternate_port, assetCache, authenticateClass);
133 } 137 }
134 138
135 public void Initialise(IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, AssetCache assetCache, AgentCircuitManager authenticateClass) 139 /// <summary>
140 /// Initialize the server
141 /// </summary>
142 /// <param name="_listenIP"></param>
143 /// <param name="port"></param>
144 /// <param name="proxyPortOffset"></param>
145 /// <param name="allow_alternate_port"></param>
146 /// <param name="assetCache"></param>
147 /// <param name="circuitManager"></param>
148 public void Initialise(
149 IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, AssetCache assetCache, AgentCircuitManager circuitManager)
136 { 150 {
137 this.proxyPortOffset = proxyPortOffset; 151 this.proxyPortOffset = proxyPortOffset;
138 listenPort = (uint) (port + proxyPortOffset); 152 listenPort = (uint) (port + proxyPortOffset);
139 listenIP = _listenIP; 153 listenIP = _listenIP;
140 Allow_Alternate_Port = allow_alternate_port; 154 Allow_Alternate_Port = allow_alternate_port;
141 m_assetCache = assetCache; 155 m_assetCache = assetCache;
142 m_authenticateSessionsClass = authenticateClass; 156 m_circuitManager = circuitManager;
143 CreatePacketServer(); 157 CreatePacketServer();
144 158
145 // Return new port 159 // Return new port
@@ -177,7 +191,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
177 { 191 {
178 // TODO : Actually only handle those states that we have control over, re-throw everything else, 192 // TODO : Actually only handle those states that we have control over, re-throw everything else,
179 // TODO: implement cases as we encounter them. 193 // TODO: implement cases as we encounter them.
180 //m_log.Error("[UDPSERVER]: Connection Error! - " + e.ToString()); 194 //m_log.Error("[[CLIENT]: ]: Connection Error! - " + e.ToString());
181 switch (e.SocketErrorCode) 195 switch (e.SocketErrorCode)
182 { 196 {
183 case SocketError.AlreadyInProgress: 197 case SocketError.AlreadyInProgress:
@@ -193,7 +207,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
193 } 207 }
194 catch (ObjectDisposedException e) 208 catch (ObjectDisposedException e)
195 { 209 {
196 m_log.DebugFormat("ObjectDisposedException: Object {0} disposed.", e.ObjectName); 210 m_log.DebugFormat("[CLIENT]: ObjectDisposedException: Object {0} disposed.", e.ObjectName);
197 // Uhh, what object, and why? this needs better handling. 211 // Uhh, what object, and why? this needs better handling.
198 } 212 }
199 213
@@ -213,15 +227,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
213 } 227 }
214 catch (MalformedDataException e) 228 catch (MalformedDataException e)
215 { 229 {
216 m_log.DebugFormat("Dropped Malformed Packet due to MalformedDataException: {0}", e.StackTrace); 230 m_log.DebugFormat("[CLIENT]: Dropped Malformed Packet due to MalformedDataException: {0}", e.StackTrace);
217 } 231 }
218 catch (IndexOutOfRangeException e) 232 catch (IndexOutOfRangeException e)
219 { 233 {
220 m_log.DebugFormat("Dropped Malformed Packet due to IndexOutOfRangeException: {0}", e.StackTrace); 234 m_log.DebugFormat("[CLIENT]: Dropped Malformed Packet due to IndexOutOfRangeException: {0}", e.StackTrace);
221 } 235 }
222 catch (Exception e) 236 catch (Exception e)
223 { 237 {
224 m_log.Debug("[UDPSERVER]: " + e.ToString()); 238 m_log.Debug("[CLIENT]: " + e.ToString());
225 } 239 }
226 } 240 }
227 241
@@ -249,8 +263,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
249 } 263 }
250 else if (packet.Type == PacketType.UseCircuitCode) 264 else if (packet.Type == PacketType.UseCircuitCode)
251 { 265 {
252 // new client
253 m_log.Debug("[UDPSERVER]: Adding New Client");
254 AddNewClient(packet); 266 AddNewClient(packet);
255 267
256 UseCircuitCodePacket p = (UseCircuitCodePacket)packet; 268 UseCircuitCodePacket p = (UseCircuitCodePacket)packet;
@@ -267,7 +279,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
267 } 279 }
268 catch (Exception e) 280 catch (Exception e)
269 { 281 {
270 m_log.Error("[UDPSERVER]: Exception in processing packet - ignoring: ", e); 282 m_log.Error("[CLIENT]: Exception in processing packet - ignoring: ", e);
271 } 283 }
272 } 284 }
273 } 285 }
@@ -280,7 +292,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
280 } 292 }
281 catch (SocketException e) 293 catch (SocketException e)
282 { 294 {
283 m_log.ErrorFormat("[UDPSERVER]: BeginRecieve threw exception " + e.Message + ": " + e.StackTrace ); 295 m_log.ErrorFormat("[CLIENT]: BeginRecieve threw exception " + e.Message + ": " + e.StackTrace );
284 ResetEndPoint(); 296 ResetEndPoint();
285 } 297 }
286 } 298 }
@@ -339,19 +351,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
339 return; 351 return;
340 352
341 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket) packet; 353 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket) packet;
354
355 m_log.DebugFormat("[CLIENT]: Adding new circuit for agent {0}, circuit code {1}", useCircuit.CircuitCode.ID, useCircuit.CircuitCode.Code);
356
342 lock (clientCircuits) 357 lock (clientCircuits)
343 { 358 {
344 if (!clientCircuits.ContainsKey(epSender)) 359 if (!clientCircuits.ContainsKey(epSender))
345 clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); 360 clientCircuits.Add(epSender, useCircuit.CircuitCode.Code);
346 else 361 else
347 m_log.Error("[UDPSERVER]: clientCircuits already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); 362 m_log.Error("[CLIENT]: clientCircuits already contains entry for user " + useCircuit.CircuitCode.Code + ". NOT adding.");
348 } 363 }
349 364
350 // This doesn't need locking as it's synchronized data 365 // This doesn't need locking as it's synchronized data
351 if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code)) 366 if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code))
352 clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, epSender); 367 clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, epSender);
353 else 368 else
354 m_log.Error("[UDPSERVER]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); 369 m_log.Error("[CLIENT]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code + ". NOT adding.");
355 370
356 371
357 lock (proxyCircuits) 372 lock (proxyCircuits)
@@ -359,10 +374,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
359 if (!proxyCircuits.ContainsKey(useCircuit.CircuitCode.Code)) 374 if (!proxyCircuits.ContainsKey(useCircuit.CircuitCode.Code))
360 proxyCircuits.Add(useCircuit.CircuitCode.Code, epProxy); 375 proxyCircuits.Add(useCircuit.CircuitCode.Code, epProxy);
361 else 376 else
362 m_log.Error("[UDPSERVER]: proxyCircuits already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); 377 m_log.Error("[CLIENT]: proxyCircuits already contains entry for user " + useCircuit.CircuitCode.Code + ". NOT adding.");
363 } 378 }
364 379
365 PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_authenticateSessionsClass, epProxy); 380 if (!PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_circuitManager, epProxy))
381 m_log.ErrorFormat(
382 "[CLIENT]: A circuit already existed for agent {0}, circuit {1}",
383 useCircuit.CircuitCode.ID, useCircuit.CircuitCode.Code);
366 } 384 }
367 385
368 PacketPool.Instance.ReturnPacket(packet); 386 PacketPool.Instance.ReturnPacket(packet);
@@ -371,7 +389,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
371 public void ServerListener() 389 public void ServerListener()
372 { 390 {
373 uint newPort = listenPort; 391 uint newPort = listenPort;
374 m_log.Info("[SERVER]: Opening UDP socket on " + listenIP + " " + newPort + "."); 392 m_log.Info("[UDPSERVER]: Opening UDP socket on " + listenIP + " " + newPort + ".");
375 393
376 ServerIncoming = new IPEndPoint(listenIP, (int)newPort); 394 ServerIncoming = new IPEndPoint(listenIP, (int)newPort);
377 m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); 395 m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
@@ -385,14 +403,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
385 403
386 listenPort = newPort; 404 listenPort = newPort;
387 405
388 m_log.Info("[SERVER]: UDP socket bound, getting ready to listen"); 406 m_log.Info("[UDPSERVER]: UDP socket bound, getting ready to listen");
389 407
390 ipeSender = new IPEndPoint(listenIP, 0); 408 ipeSender = new IPEndPoint(listenIP, 0);
391 epSender = (EndPoint)ipeSender; 409 epSender = (EndPoint)ipeSender;
392 ReceivedData = new AsyncCallback(OnReceivedData); 410 ReceivedData = new AsyncCallback(OnReceivedData);
393 m_socket.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); 411 m_socket.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
394 412
395 m_log.Info("[SERVER]: Listening on port " + newPort); 413 m_log.Info("[UDPSERVER]: Listening on port " + newPort);
396 } 414 }
397 415
398 public virtual void RegisterPacketServer(LLPacketServer server) 416 public virtual void RegisterPacketServer(LLPacketServer server)
@@ -409,7 +427,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
409 sendto = (EndPoint)clientCircuits_reverse[circuitcode]; 427 sendto = (EndPoint)clientCircuits_reverse[circuitcode];
410 } catch { 428 } catch {
411 // Exceptions here mean there is no circuit 429 // Exceptions here mean there is no circuit
412 m_log.Warn("Circuit not found, not sending packet"); 430 m_log.Warn("[CLIENT]: Circuit not found, not sending packet");
413 return; 431 return;
414 } 432 }
415 433
@@ -448,7 +466,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
448 else 466 else
449 { 467 {
450 m_log.DebugFormat( 468 m_log.DebugFormat(
451 "[UDPSERVER]: endpoint for circuit code {0} in RemoveClientCircuit() was unexpectedly null!", circuitcode); 469 "[CLIENT]: endpoint for circuit code {0} in RemoveClientCircuit() was unexpectedly null!", circuitcode);
452 } 470 }
453 } 471 }
454 lock (proxyCircuits) 472 lock (proxyCircuits)
@@ -472,14 +490,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
472 if (!clientCircuits.ContainsKey(userEP)) 490 if (!clientCircuits.ContainsKey(userEP))
473 clientCircuits.Add(userEP, useCircuit.CircuitCode.Code); 491 clientCircuits.Add(userEP, useCircuit.CircuitCode.Code);
474 else 492 else
475 m_log.Error("[UDPSERVER]: clientCircuits already contans entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); 493 m_log.Error("[CLIENT]: clientCircuits already contans entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding.");
476 } 494 }
477 495
478 // This data structure is synchronized, so we don't need the lock 496 // This data structure is synchronized, so we don't need the lock
479 if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code)) 497 if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code))
480 clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, userEP); 498 clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, userEP);
481 else 499 else
482 m_log.Error("[UDPSERVER]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); 500 m_log.Error("[CLIENT]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding.");
483 501
484 lock (proxyCircuits) 502 lock (proxyCircuits)
485 { 503 {
@@ -495,7 +513,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
495 } 513 }
496 } 514 }
497 515
498 PacketServer.AddNewClient(userEP, useCircuit, m_assetCache, m_authenticateSessionsClass, proxyEP); 516 PacketServer.AddNewClient(userEP, useCircuit, m_assetCache, m_circuitManager, proxyEP);
499 } 517 }
500 } 518 }
501} 519}