aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/Interfaces')
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs287
-rw-r--r--OpenSim/Services/Interfaces/IHyperlink.cs49
-rw-r--r--OpenSim/Services/Interfaces/INeighbourService.cs3
3 files changed, 327 insertions, 12 deletions
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index ac4539a..2290530 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -25,8 +25,11 @@
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
28using OpenSim.Framework; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net;
31using System.Net.Sockets;
32using OpenSim.Framework;
30using OpenMetaverse; 33using OpenMetaverse;
31 34
32namespace OpenSim.Services.Interfaces 35namespace OpenSim.Services.Interfaces
@@ -39,7 +42,7 @@ namespace OpenSim.Services.Interfaces
39 /// <param name="regionInfos"> </param> 42 /// <param name="regionInfos"> </param>
40 /// <returns></returns> 43 /// <returns></returns>
41 /// <exception cref="System.Exception">Thrown if region registration failed</exception> 44 /// <exception cref="System.Exception">Thrown if region registration failed</exception>
42 bool RegisterRegion(UUID scopeID, RegionInfo regionInfos); 45 bool RegisterRegion(UUID scopeID, GridRegion regionInfos);
43 46
44 /// <summary> 47 /// <summary>
45 /// Deregister a region with the grid service. 48 /// Deregister a region with the grid service.
@@ -47,21 +50,28 @@ namespace OpenSim.Services.Interfaces
47 /// <param name="regionID"></param> 50 /// <param name="regionID"></param>
48 /// <returns></returns> 51 /// <returns></returns>
49 /// <exception cref="System.Exception">Thrown if region deregistration failed</exception> 52 /// <exception cref="System.Exception">Thrown if region deregistration failed</exception>
50 bool DeregisterRegion(UUID regionID); 53 bool DeregisterRegion(UUID regionID);
51 54
52 /// <summary> 55 /// <summary>
53 /// Get information about the regions neighbouring the given co-ordinates. 56 /// Get information about the regions neighbouring the given co-ordinates (in meters).
54 /// </summary> 57 /// </summary>
55 /// <param name="x"></param> 58 /// <param name="x"></param>
56 /// <param name="y"></param> 59 /// <param name="y"></param>
57 /// <returns></returns> 60 /// <returns></returns>
58 List<SimpleRegionInfo> GetNeighbours(UUID scopeID, uint x, uint y); 61 List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID);
59 62
60 SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID); 63 GridRegion GetRegionByUUID(UUID scopeID, UUID regionID);
64
65 /// <summary>
66 /// Get the region at the given position (in meters)
67 /// </summary>
68 /// <param name="scopeID"></param>
69 /// <param name="x"></param>
70 /// <param name="y"></param>
71 /// <returns></returns>
72 GridRegion GetRegionByPosition(UUID scopeID, int x, int y);
61 73
62 SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y); 74 GridRegion GetRegionByName(UUID scopeID, string regionName);
63
64 SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName);
65 75
66 /// <summary> 76 /// <summary>
67 /// Get information about regions starting with the provided name. 77 /// Get information about regions starting with the provided name.
@@ -76,11 +86,266 @@ namespace OpenSim.Services.Interfaces
76 /// A list of <see cref="RegionInfo"/>s of regions with matching name. If the 86 /// A list of <see cref="RegionInfo"/>s of regions with matching name. If the
77 /// grid-server couldn't be contacted or returned an error, return null. 87 /// grid-server couldn't be contacted or returned an error, return null.
78 /// </returns> 88 /// </returns>
79 List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber); 89 List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber);
90
91 List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax);
92
93 }
94
95 public class GridRegion
96 {
97
98 /// <summary>
99 /// The port by which http communication occurs with the region
100 /// </summary>
101 public uint HttpPort
102 {
103 get { return m_httpPort; }
104 set { m_httpPort = value; }
105 }
106 protected uint m_httpPort;
107
108 /// <summary>
109 /// A well-formed URI for the host region server (namely "http://" + ExternalHostName)
110 /// </summary>
111 public string ServerURI
112 {
113 get { return m_serverURI; }
114 set { m_serverURI = value; }
115 }
116 protected string m_serverURI;
117
118 public string RegionName
119 {
120 get { return m_regionName; }
121 set { m_regionName = value; }
122 }
123 protected string m_regionName = String.Empty;
124
125 protected string m_externalHostName;
126
127 protected IPEndPoint m_internalEndPoint;
128
129 public int RegionLocX
130 {
131 get { return m_regionLocX; }
132 set { m_regionLocX = value; }
133 }
134 protected int m_regionLocX;
135
136 public int RegionLocY
137 {
138 get { return m_regionLocY; }
139 set { m_regionLocY = value; }
140 }
141 protected int m_regionLocY;
142
143 public UUID RegionID = UUID.Zero;
144 public UUID ScopeID = UUID.Zero;
145
146 public UUID TerrainImage = UUID.Zero;
147 public byte Access;
148 public int Maturity;
149 public string RegionSecret;
150
151 public GridRegion()
152 {
153 }
154
155 public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri)
156 {
157 m_regionLocX = regionLocX;
158 m_regionLocY = regionLocY;
80 159
160 m_internalEndPoint = internalEndPoint;
161 m_externalHostName = externalUri;
162 }
81 163
82 // Not sure about these two (diva) 164 public GridRegion(int regionLocX, int regionLocY, string externalUri, uint port)
165 {
166 m_regionLocX = regionLocX;
167 m_regionLocY = regionLocY;
83 168
169 m_externalHostName = externalUri;
84 170
171 m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port);
172 }
173
174 public GridRegion(uint xcell, uint ycell)
175 {
176 m_regionLocX = (int)(xcell * Constants.RegionSize);
177 m_regionLocY = (int)(ycell * Constants.RegionSize);
178 }
179
180 public GridRegion(RegionInfo ConvertFrom)
181 {
182 m_regionName = ConvertFrom.RegionName;
183 m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize);
184 m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize);
185 m_internalEndPoint = ConvertFrom.InternalEndPoint;
186 m_externalHostName = ConvertFrom.ExternalHostName;
187 m_httpPort = ConvertFrom.HttpPort;
188 RegionID = ConvertFrom.RegionID;
189 ServerURI = ConvertFrom.ServerURI;
190 TerrainImage = ConvertFrom.RegionSettings.TerrainImageID;
191 Access = ConvertFrom.AccessLevel;
192 Maturity = ConvertFrom.RegionSettings.Maturity;
193 RegionSecret = ConvertFrom.regionSecret;
194 }
195
196 public GridRegion(GridRegion ConvertFrom)
197 {
198 m_regionName = ConvertFrom.RegionName;
199 m_regionLocX = ConvertFrom.RegionLocX;
200 m_regionLocY = ConvertFrom.RegionLocY;
201 m_internalEndPoint = ConvertFrom.InternalEndPoint;
202 m_externalHostName = ConvertFrom.ExternalHostName;
203 m_httpPort = ConvertFrom.HttpPort;
204 RegionID = ConvertFrom.RegionID;
205 ServerURI = ConvertFrom.ServerURI;
206 TerrainImage = ConvertFrom.TerrainImage;
207 Access = ConvertFrom.Access;
208 Maturity = ConvertFrom.Maturity;
209 RegionSecret = ConvertFrom.RegionSecret;
210 }
211
212 /// <value>
213 /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw.
214 ///
215 /// XXX Isn't this really doing too much to be a simple getter, rather than an explict method?
216 /// </value>
217 public IPEndPoint ExternalEndPoint
218 {
219 get
220 {
221 // Old one defaults to IPv6
222 //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port);
223
224 IPAddress ia = null;
225 // If it is already an IP, don't resolve it - just return directly
226 if (IPAddress.TryParse(m_externalHostName, out ia))
227 return new IPEndPoint(ia, m_internalEndPoint.Port);
228
229 // Reset for next check
230 ia = null;
231 try
232 {
233 foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName))
234 {
235 if (ia == null)
236 ia = Adr;
237
238 if (Adr.AddressFamily == AddressFamily.InterNetwork)
239 {
240 ia = Adr;
241 break;
242 }
243 }
244 }
245 catch (SocketException e)
246 {
247 throw new Exception(
248 "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" +
249 e + "' attached to this exception", e);
250 }
251
252 return new IPEndPoint(ia, m_internalEndPoint.Port);
253 }
254
255 set { m_externalHostName = value.ToString(); }
256 }
257
258 public string ExternalHostName
259 {
260 get { return m_externalHostName; }
261 set { m_externalHostName = value; }
262 }
263
264 public IPEndPoint InternalEndPoint
265 {
266 get { return m_internalEndPoint; }
267 set { m_internalEndPoint = value; }
268 }
269
270 public ulong RegionHandle
271 {
272 get { return Util.UIntsToLong((uint)RegionLocX, (uint)RegionLocY); }
273 }
274
275 public int getInternalEndPointPort()
276 {
277 return m_internalEndPoint.Port;
278 }
279
280 public Dictionary<string, object> ToKeyValuePairs()
281 {
282 Dictionary<string, object> kvp = new Dictionary<string, object>();
283 kvp["uuid"] = RegionID.ToString();
284 kvp["locX"] = RegionLocX.ToString();
285 kvp["locY"] = RegionLocY.ToString();
286 kvp["regionName"] = RegionName;
287 kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString();
288 kvp["serverHttpPort"] = HttpPort.ToString();
289 kvp["serverURI"] = ServerURI;
290 kvp["serverPort"] = InternalEndPoint.Port.ToString();
291 kvp["regionMapTexture"] = TerrainImage.ToString();
292 kvp["access"] = Access.ToString();
293 kvp["regionSecret"] = RegionSecret;
294 // Maturity doesn't seem to exist in the DB
295 return kvp;
296 }
297
298 public GridRegion(Dictionary<string, object> kvp)
299 {
300 if (kvp.ContainsKey("uuid"))
301 RegionID = new UUID((string)kvp["uuid"]);
302
303 if (kvp.ContainsKey("locX"))
304 RegionLocX = Convert.ToInt32((string)kvp["locX"]);
305
306 if (kvp.ContainsKey("locY"))
307 RegionLocY = Convert.ToInt32((string)kvp["locY"]);
308
309 if (kvp.ContainsKey("regionName"))
310 RegionName = (string)kvp["regionName"];
311
312 if (kvp.ContainsKey("serverIP"))
313 {
314 //int port = 0;
315 //Int32.TryParse((string)kvp["serverPort"], out port);
316 //IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["serverIP"]), port);
317 ExternalHostName = (string)kvp["serverIP"];
318 }
319 else
320 ExternalHostName = "127.0.0.1";
321
322 if (kvp.ContainsKey("serverPort"))
323 {
324 Int32 port = 0;
325 Int32.TryParse((string)kvp["serverPort"], out port);
326 InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port);
327 }
328
329 if (kvp.ContainsKey("serverHttpPort"))
330 {
331 UInt32 port = 0;
332 UInt32.TryParse((string)kvp["serverHttpPort"], out port);
333 HttpPort = port;
334 }
335
336 if (kvp.ContainsKey("serverURI"))
337 ServerURI = (string)kvp["serverURI"];
338
339 if (kvp.ContainsKey("regionMapTexture"))
340 UUID.TryParse((string)kvp["regionMapTexture"], out TerrainImage);
341
342 if (kvp.ContainsKey("access"))
343 Access = Byte.Parse((string)kvp["access"]);
344
345 if (kvp.ContainsKey("regionSecret"))
346 RegionSecret =(string)kvp["regionSecret"];
347
348 }
85 } 349 }
350
86} 351}
diff --git a/OpenSim/Services/Interfaces/IHyperlink.cs b/OpenSim/Services/Interfaces/IHyperlink.cs
new file mode 100644
index 0000000..ed3ff23
--- /dev/null
+++ b/OpenSim/Services/Interfaces/IHyperlink.cs
@@ -0,0 +1,49 @@
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 OpenSim.Framework;
29using GridRegion = OpenSim.Services.Interfaces.GridRegion;
30
31using OpenMetaverse;
32
33namespace OpenSim.Services.Interfaces
34{
35 public interface IHyperlinkService
36 {
37 GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor);
38 GridRegion GetHyperlinkRegion(ulong handle);
39 ulong FindRegionHandle(ulong handle);
40
41 bool SendUserInformation(GridRegion region, AgentCircuitData aCircuit);
42 void AdjustUserInformation(AgentCircuitData aCircuit);
43
44 bool CheckUserAtEntry(UUID userID, UUID sessionID, out bool comingHome);
45 void AcceptUser(ForeignUserProfileData user, GridRegion home);
46
47 bool IsLocalUser(UUID userID);
48 }
49}
diff --git a/OpenSim/Services/Interfaces/INeighbourService.cs b/OpenSim/Services/Interfaces/INeighbourService.cs
index 3944486..960e13d 100644
--- a/OpenSim/Services/Interfaces/INeighbourService.cs
+++ b/OpenSim/Services/Interfaces/INeighbourService.cs
@@ -28,11 +28,12 @@
28using System; 28using System;
29using OpenSim.Framework; 29using OpenSim.Framework;
30using OpenMetaverse; 30using OpenMetaverse;
31using GridRegion = OpenSim.Services.Interfaces.GridRegion;
31 32
32namespace OpenSim.Services.Interfaces 33namespace OpenSim.Services.Interfaces
33{ 34{
34 public interface INeighbourService 35 public interface INeighbourService
35 { 36 {
36 bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion); 37 GridRegion HelloNeighbour(ulong regionHandle, RegionInfo otherRegion);
37 } 38 }
38} 39}