aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Interfaces/IGridService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/Interfaces/IGridService.cs')
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs287
1 files changed, 276 insertions, 11 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}