aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/RegionInfo.cs
diff options
context:
space:
mode:
authorKunnis2009-12-11 23:14:01 -0600
committerMelanie2009-12-12 04:44:32 +0000
commitd89f3e98111c7d228ab6196093eb308445429b72 (patch)
treea69a0e9db77fe80cc06210a1144f51430599f2f8 /OpenSim/Framework/RegionInfo.cs
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC-d89f3e98111c7d228ab6196093eb308445429b72.zip
opensim-SC-d89f3e98111c7d228ab6196093eb308445429b72.tar.gz
opensim-SC-d89f3e98111c7d228ab6196093eb308445429b72.tar.bz2
opensim-SC-d89f3e98111c7d228ab6196093eb308445429b72.tar.xz
Getting rid of SimpleRegionInfo and SerializableRegionInfo per Mel
Signed-off-by: Melanie <melanie@t-data.com>
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/RegionInfo.cs410
1 files changed, 147 insertions, 263 deletions
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index 721233d..88b62e0 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -38,238 +38,7 @@ using OpenSim.Framework.Console;
38 38
39namespace OpenSim.Framework 39namespace OpenSim.Framework
40{ 40{
41 [Serializable] 41 public class RegionInfo
42 public class SimpleRegionInfo
43 {
44 // private static readonly log4net.ILog m_log
45 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
46
47 /// <summary>
48 /// The port by which http communication occurs with the region (most noticeably, CAPS communication)
49 /// </summary>
50 public uint HttpPort
51 {
52 get { return m_httpPort; }
53 set { m_httpPort = value; }
54 }
55 protected uint m_httpPort;
56
57 /// <summary>
58 /// A well-formed URI for the host region server (namely "http://" + ExternalHostName)
59 /// </summary>
60 public string ServerURI
61 {
62 get { return m_serverURI; }
63 set { m_serverURI = value; }
64 }
65 protected string m_serverURI;
66
67 public string RegionName
68 {
69 get { return m_regionName; }
70 set { m_regionName = value; }
71 }
72 protected string m_regionName = String.Empty;
73
74 protected bool Allow_Alternate_Ports;
75 public bool m_allow_alternate_ports;
76 protected string m_externalHostName;
77
78 protected IPEndPoint m_internalEndPoint;
79 protected uint? m_regionLocX;
80 protected uint? m_regionLocY;
81 protected uint m_remotingPort;
82 public UUID RegionID = UUID.Zero;
83 public string RemotingAddress;
84 public UUID ScopeID = UUID.Zero;
85
86 public SimpleRegionInfo()
87 {
88 }
89
90 public SimpleRegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri)
91 {
92 m_regionLocX = regionLocX;
93 m_regionLocY = regionLocY;
94
95 m_internalEndPoint = internalEndPoint;
96 m_externalHostName = externalUri;
97 }
98
99 public SimpleRegionInfo(uint regionLocX, uint regionLocY, string externalUri, uint port)
100 {
101 m_regionLocX = regionLocX;
102 m_regionLocY = regionLocY;
103
104 m_externalHostName = externalUri;
105
106 m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int) port);
107 }
108
109 public SimpleRegionInfo(RegionInfo ConvertFrom)
110 {
111 m_regionName = ConvertFrom.RegionName;
112 m_regionLocX = ConvertFrom.RegionLocX;
113 m_regionLocY = ConvertFrom.RegionLocY;
114 m_internalEndPoint = ConvertFrom.InternalEndPoint;
115 m_externalHostName = ConvertFrom.ExternalHostName;
116 m_remotingPort = ConvertFrom.RemotingPort;
117 m_httpPort = ConvertFrom.HttpPort;
118 m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports;
119 RemotingAddress = ConvertFrom.RemotingAddress;
120 RegionID = UUID.Zero;
121 ServerURI = ConvertFrom.ServerURI;
122 }
123
124 public uint RemotingPort
125 {
126 get { return m_remotingPort; }
127 set { m_remotingPort = value; }
128 }
129
130 /// <value>
131 /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw.
132 ///
133 /// XXX Isn't this really doing too much to be a simple getter, rather than an explict method?
134 /// </value>
135 public IPEndPoint ExternalEndPoint
136 {
137 get
138 {
139 // Old one defaults to IPv6
140 //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port);
141
142 IPAddress ia = null;
143 // If it is already an IP, don't resolve it - just return directly
144 if (IPAddress.TryParse(m_externalHostName, out ia))
145 return new IPEndPoint(ia, m_internalEndPoint.Port);
146
147 // Reset for next check
148 ia = null;
149 try
150 {
151 foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName))
152 {
153 if (ia == null)
154 ia = Adr;
155
156 if (Adr.AddressFamily == AddressFamily.InterNetwork)
157 {
158 ia = Adr;
159 break;
160 }
161 }
162 }
163 catch (SocketException e)
164 {
165 throw new Exception(
166 "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" +
167 e + "' attached to this exception", e);
168 }
169
170 return new IPEndPoint(ia, m_internalEndPoint.Port);
171 }
172
173 set { m_externalHostName = value.ToString(); }
174 }
175
176 public string ExternalHostName
177 {
178 get { return m_externalHostName; }
179 set { m_externalHostName = value; }
180 }
181
182 public IPEndPoint InternalEndPoint
183 {
184 get { return m_internalEndPoint; }
185 set { m_internalEndPoint = value; }
186 }
187
188 public uint RegionLocX
189 {
190 get { return m_regionLocX.Value; }
191 set { m_regionLocX = value; }
192 }
193
194 public uint RegionLocY
195 {
196 get { return m_regionLocY.Value; }
197 set { m_regionLocY = value; }
198 }
199
200 public ulong RegionHandle
201 {
202 get { return Util.UIntsToLong((RegionLocX * (uint) Constants.RegionSize), (RegionLocY * (uint) Constants.RegionSize)); }
203 }
204
205 public int getInternalEndPointPort()
206 {
207 return m_internalEndPoint.Port;
208 }
209
210 public Dictionary<string, object> ToKeyValuePairs()
211 {
212 Dictionary<string, object> kvp = new Dictionary<string, object>();
213 kvp["uuid"] = RegionID.ToString();
214 kvp["locX"] = RegionLocX.ToString();
215 kvp["locY"] = RegionLocY.ToString();
216 kvp["external_ip_address"] = ExternalEndPoint.Address.ToString();
217 kvp["external_port"] = ExternalEndPoint.Port.ToString();
218 kvp["external_host_name"] = ExternalHostName;
219 kvp["http_port"] = HttpPort.ToString();
220 kvp["internal_ip_address"] = InternalEndPoint.Address.ToString();
221 kvp["internal_port"] = InternalEndPoint.Port.ToString();
222 kvp["alternate_ports"] = m_allow_alternate_ports.ToString();
223 kvp["server_uri"] = ServerURI;
224
225 return kvp;
226 }
227
228 public SimpleRegionInfo(Dictionary<string, object> kvp)
229 {
230 if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null))
231 {
232 int port = 0;
233 Int32.TryParse((string)kvp["external_port"], out port);
234 IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["external_ip_address"]), port);
235 ExternalEndPoint = ep;
236 }
237 else
238 ExternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
239
240 if (kvp["external_host_name"] != null)
241 ExternalHostName = (string)kvp["external_host_name"];
242
243 if (kvp["http_port"] != null)
244 {
245 UInt32 port = 0;
246 UInt32.TryParse((string)kvp["http_port"], out port);
247 HttpPort = port;
248 }
249
250 if ((kvp["internal_ip_address"] != null) && (kvp["internal_port"] != null))
251 {
252 int port = 0;
253 Int32.TryParse((string)kvp["internal_port"], out port);
254 IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["internal_ip_address"]), port);
255 InternalEndPoint = ep;
256 }
257 else
258 InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
259
260 if (kvp["alternate_ports"] != null)
261 {
262 bool alts = false;
263 Boolean.TryParse((string)kvp["alternate_ports"], out alts);
264 m_allow_alternate_ports = alts;
265 }
266
267 if (kvp["server_uri"] != null)
268 ServerURI = (string)kvp["server_uri"];
269 }
270 }
271
272 public class RegionInfo : SimpleRegionInfo
273 { 42 {
274 // private static readonly log4net.ILog m_log 43 // private static readonly log4net.ILog m_log
275 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 44 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
@@ -304,6 +73,19 @@ namespace OpenSim.Framework
304 private bool m_clampPrimSize = false; 73 private bool m_clampPrimSize = false;
305 private int m_objectCapacity = 0; 74 private int m_objectCapacity = 0;
306 private string m_regionType = String.Empty; 75 private string m_regionType = String.Empty;
76 protected uint m_httpPort;
77 protected string m_serverURI;
78 protected string m_regionName = String.Empty;
79 protected bool Allow_Alternate_Ports;
80 public bool m_allow_alternate_ports;
81 protected string m_externalHostName;
82 protected IPEndPoint m_internalEndPoint;
83 protected uint? m_regionLocX;
84 protected uint? m_regionLocY;
85 protected uint m_remotingPort;
86 public UUID RegionID = UUID.Zero;
87 public string RemotingAddress;
88 public UUID ScopeID = UUID.Zero;
307 89
308 90
309 // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. 91 // Apparently, we're applying the same estatesettings regardless of whether it's local or remote.
@@ -386,42 +168,17 @@ namespace OpenSim.Framework
386 configMember.performConfigurationRetrieve(); 168 configMember.performConfigurationRetrieve();
387 } 169 }
388 170
389 public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) : 171 public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri)
390 base(regionLocX, regionLocY, internalEndPoint, externalUri)
391 { 172 {
392 } 173 m_regionLocX = regionLocX;
393 174 m_regionLocY = regionLocY;
394 public RegionInfo()
395 {
396 }
397 175
398 public RegionInfo(SerializableRegionInfo ConvertFrom) 176 m_internalEndPoint = internalEndPoint;
399 { 177 m_externalHostName = externalUri;
400 m_regionLocX = ConvertFrom.RegionLocX;
401 m_regionLocY = ConvertFrom.RegionLocY;
402 m_internalEndPoint = ConvertFrom.InternalEndPoint;
403 m_externalHostName = ConvertFrom.ExternalHostName;
404 m_remotingPort = ConvertFrom.RemotingPort;
405 m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports;
406 RemotingAddress = ConvertFrom.RemotingAddress;
407 RegionID = UUID.Zero;
408 proxyUrl = ConvertFrom.ProxyUrl;
409 originRegionID = ConvertFrom.OriginRegionID;
410 RegionName = ConvertFrom.RegionName;
411 ServerURI = ConvertFrom.ServerURI;
412 } 178 }
413 179
414 public RegionInfo(SimpleRegionInfo ConvertFrom) 180 public RegionInfo()
415 { 181 {
416 m_regionLocX = ConvertFrom.RegionLocX;
417 m_regionLocY = ConvertFrom.RegionLocY;
418 m_internalEndPoint = ConvertFrom.InternalEndPoint;
419 m_externalHostName = ConvertFrom.ExternalHostName;
420 m_remotingPort = ConvertFrom.RemotingPort;
421 m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports;
422 RemotingAddress = ConvertFrom.RemotingAddress;
423 RegionID = UUID.Zero;
424 ServerURI = ConvertFrom.ServerURI;
425 } 182 }
426 183
427 public EstateSettings EstateSettings 184 public EstateSettings EstateSettings
@@ -484,6 +241,111 @@ namespace OpenSim.Framework
484 get { return m_regionType; } 241 get { return m_regionType; }
485 } 242 }
486 243
244 /// <summary>
245 /// The port by which http communication occurs with the region (most noticeably, CAPS communication)
246 /// </summary>
247 public uint HttpPort
248 {
249 get { return m_httpPort; }
250 set { m_httpPort = value; }
251 }
252
253 /// <summary>
254 /// A well-formed URI for the host region server (namely "http://" + ExternalHostName)
255 /// </summary>
256 public string ServerURI
257 {
258 get { return m_serverURI; }
259 set { m_serverURI = value; }
260 }
261
262 public string RegionName
263 {
264 get { return m_regionName; }
265 set { m_regionName = value; }
266 }
267
268 public uint RemotingPort
269 {
270 get { return m_remotingPort; }
271 set { m_remotingPort = value; }
272 }
273
274 /// <value>
275 /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw.
276 ///
277 /// XXX Isn't this really doing too much to be a simple getter, rather than an explict method?
278 /// </value>
279 public IPEndPoint ExternalEndPoint
280 {
281 get
282 {
283 // Old one defaults to IPv6
284 //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port);
285
286 IPAddress ia = null;
287 // If it is already an IP, don't resolve it - just return directly
288 if (IPAddress.TryParse(m_externalHostName, out ia))
289 return new IPEndPoint(ia, m_internalEndPoint.Port);
290
291 // Reset for next check
292 ia = null;
293 try
294 {
295 foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName))
296 {
297 if (ia == null)
298 ia = Adr;
299
300 if (Adr.AddressFamily == AddressFamily.InterNetwork)
301 {
302 ia = Adr;
303 break;
304 }
305 }
306 }
307 catch (SocketException e)
308 {
309 throw new Exception(
310 "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" +
311 e + "' attached to this exception", e);
312 }
313
314 return new IPEndPoint(ia, m_internalEndPoint.Port);
315 }
316
317 set { m_externalHostName = value.ToString(); }
318 }
319
320 public string ExternalHostName
321 {
322 get { return m_externalHostName; }
323 set { m_externalHostName = value; }
324 }
325
326 public IPEndPoint InternalEndPoint
327 {
328 get { return m_internalEndPoint; }
329 set { m_internalEndPoint = value; }
330 }
331
332 public uint RegionLocX
333 {
334 get { return m_regionLocX.Value; }
335 set { m_regionLocX = value; }
336 }
337
338 public uint RegionLocY
339 {
340 get { return m_regionLocY.Value; }
341 set { m_regionLocY = value; }
342 }
343
344 public ulong RegionHandle
345 {
346 get { return Util.UIntsToLong((RegionLocX * (uint) Constants.RegionSize), (RegionLocY * (uint) Constants.RegionSize)); }
347 }
348
487 public void SetEndPoint(string ipaddr, int port) 349 public void SetEndPoint(string ipaddr, int port)
488 { 350 {
489 IPAddress tmpIP = IPAddress.Parse(ipaddr); 351 IPAddress tmpIP = IPAddress.Parse(ipaddr);
@@ -1074,5 +936,27 @@ namespace OpenSim.Framework
1074 return regionInfo; 936 return regionInfo;
1075 } 937 }
1076 938
939 public int getInternalEndPointPort()
940 {
941 return m_internalEndPoint.Port;
942 }
943
944 public Dictionary<string, object> ToKeyValuePairs()
945 {
946 Dictionary<string, object> kvp = new Dictionary<string, object>();
947 kvp["uuid"] = RegionID.ToString();
948 kvp["locX"] = RegionLocX.ToString();
949 kvp["locY"] = RegionLocY.ToString();
950 kvp["external_ip_address"] = ExternalEndPoint.Address.ToString();
951 kvp["external_port"] = ExternalEndPoint.Port.ToString();
952 kvp["external_host_name"] = ExternalHostName;
953 kvp["http_port"] = HttpPort.ToString();
954 kvp["internal_ip_address"] = InternalEndPoint.Address.ToString();
955 kvp["internal_port"] = InternalEndPoint.Port.ToString();
956 kvp["alternate_ports"] = m_allow_alternate_ports.ToString();
957 kvp["server_uri"] = ServerURI;
958
959 return kvp;
960 }
1077 } 961 }
1078} 962}