aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs206
1 files changed, 0 insertions, 206 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs
deleted file mode 100644
index f08b7be..0000000
--- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs
+++ /dev/null
@@ -1,206 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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.Net;
29using System.Net.Sockets;
30using OpenMetaverse;
31using OpenMetaverse.Packets;
32using OpenSim.Framework;
33
34namespace OpenSim.Region.ClientStack.LindenUDP
35{
36 /// <summary>
37 /// This class sets up new client stacks. It also handles the immediate distribution of incoming packets to
38 /// client stacks
39 /// </summary>
40 public class LLPacketServer
41 {
42// private static readonly log4net.ILog m_log
43// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
44
45 protected readonly LLUDPServer m_networkHandler;
46 protected IScene m_scene;
47
48 /// <summary>
49 /// Tweakable user settings
50 /// </summary>
51 private ClientStackUserSettings m_userSettings;
52
53 public LLPacketServer(LLUDPServer networkHandler, ClientStackUserSettings userSettings)
54 {
55 m_userSettings = userSettings;
56 m_networkHandler = networkHandler;
57
58 m_networkHandler.RegisterPacketServer(this);
59 }
60
61 public IScene LocalScene
62 {
63 set { m_scene = value; }
64 }
65
66 /// <summary>
67 /// Process an incoming packet.
68 /// </summary>
69 /// <param name="circuitCode"></param>
70 /// <param name="packet"></param>
71 public virtual void InPacket(uint circuitCode, Packet packet)
72 {
73 m_scene.ClientManager.InPacket(circuitCode, packet);
74 }
75
76 /// <summary>
77 /// Create a new client circuit
78 /// </summary>
79 /// <param name="remoteEP"></param>
80 /// <param name="scene"></param>
81 /// <param name="assetCache"></param>
82 /// <param name="packServer"></param>
83 /// <param name="sessionInfo"></param>
84 /// <param name="agentId"></param>
85 /// <param name="sessionId"></param>
86 /// <param name="circuitCode"></param>
87 /// <param name="proxyEP"></param>
88 /// <returns></returns>
89 protected virtual IClientAPI CreateNewCircuit(
90 EndPoint remoteEP, IScene scene,
91 LLPacketServer packServer, AuthenticateResponse sessionInfo,
92 UUID agentId, UUID sessionId, uint circuitCode, EndPoint proxyEP)
93 {
94 return
95 new LLClientView(
96 remoteEP, scene, packServer, sessionInfo, agentId, sessionId, circuitCode, proxyEP,
97 m_userSettings);
98 }
99
100 /// <summary>
101 /// Check whether a given client is authorized to connect.
102 /// </summary>
103 /// <param name="useCircuit"></param>
104 /// <param name="circuitManager"></param>
105 /// <param name="sessionInfo"></param>
106 /// <returns></returns>
107 public virtual bool IsClientAuthorized(
108 UseCircuitCodePacket useCircuit, AgentCircuitManager circuitManager, out AuthenticateResponse sessionInfo)
109 {
110 UUID agentId = useCircuit.CircuitCode.ID;
111 UUID sessionId = useCircuit.CircuitCode.SessionID;
112 uint circuitCode = useCircuit.CircuitCode.Code;
113
114 sessionInfo = circuitManager.AuthenticateSession(sessionId, agentId, circuitCode);
115
116 if (!sessionInfo.Authorised)
117 return false;
118
119 return true;
120 }
121
122 /// <summary>
123 /// Add a new client circuit. We assume that is has already passed an authorization check
124 /// </summary>
125 /// <param name="epSender"></param>
126 /// <param name="useCircuit"></param>
127 /// <param name="assetCache"></param>
128 /// <param name="sessionInfo"></param>
129 /// <param name="proxyEP"></param>
130 /// <returns>
131 /// true if a new circuit was created, false if a circuit with the given circuit code already existed
132 /// </returns>
133 public virtual bool AddNewClient(
134 EndPoint epSender, UseCircuitCodePacket useCircuit,
135 AuthenticateResponse sessionInfo, EndPoint proxyEP)
136 {
137 IClientAPI newuser;
138 uint circuitCode = useCircuit.CircuitCode.Code;
139
140 if (m_scene.ClientManager.TryGetClient(circuitCode, out newuser))
141 {
142 // The circuit is already known to the scene. This not actually a problem since this will currently
143 // occur if a client is crossing borders (hence upgrading its circuit). However, we shouldn't
144 // really by trying to add a new client if this is the case.
145 return false;
146 }
147
148 UUID agentId = useCircuit.CircuitCode.ID;
149 UUID sessionId = useCircuit.CircuitCode.SessionID;
150
151 newuser
152 = CreateNewCircuit(
153 epSender, m_scene, this, sessionInfo, agentId, sessionId, circuitCode, proxyEP);
154
155 m_scene.ClientManager.Add(circuitCode, newuser);
156
157 newuser.OnViewerEffect += m_scene.ClientManager.ViewerEffectHandler;
158 newuser.OnLogout += LogoutHandler;
159 newuser.OnConnectionClosed += CloseClient;
160
161 newuser.Start();
162
163 return true;
164 }
165
166 public void LogoutHandler(IClientAPI client)
167 {
168 client.SendLogoutPacket();
169 CloseClient(client);
170 }
171
172 /// <summary>
173 /// Send a packet to the given circuit
174 /// </summary>
175 /// <param name="buffer"></param>
176 /// <param name="size"></param>
177 /// <param name="flags"></param>
178 /// <param name="circuitcode"></param>
179 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
180 {
181 m_networkHandler.SendPacketTo(buffer, size, flags, circuitcode);
182 }
183
184 /// <summary>
185 /// Close a client circuit only
186 /// </summary>
187 /// <param name="circuitcode"></param>
188 public virtual void CloseCircuit(uint circuitcode)
189 {
190 m_networkHandler.RemoveClientCircuit(circuitcode);
191 }
192
193 /// <summary>
194 /// Completely close down the given client.
195 /// </summary>
196 /// <param name="client"></param>
197 public virtual void CloseClient(IClientAPI client)
198 {
199 //m_log.Info("PacketServer:CloseClient()");
200
201 CloseCircuit(client.CircuitCode);
202 m_scene.ClientManager.Remove(client.CircuitCode);
203 client.Close(false);
204 }
205 }
206}