aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/NetworkUtil.cs
diff options
context:
space:
mode:
authorJeff Ames2009-05-31 18:35:00 +0000
committerJeff Ames2009-05-31 18:35:00 +0000
commit35b450d41d2695aa6a82a6d8e6bda5e327f431e1 (patch)
tree28028806a736a8f22b41ab0c7c8feec1f43fd0f9 /OpenSim/Framework/NetworkUtil.cs
parentUpdate svn properties. (diff)
downloadopensim-SC-35b450d41d2695aa6a82a6d8e6bda5e327f431e1.zip
opensim-SC-35b450d41d2695aa6a82a6d8e6bda5e327f431e1.tar.gz
opensim-SC-35b450d41d2695aa6a82a6d8e6bda5e327f431e1.tar.bz2
opensim-SC-35b450d41d2695aa6a82a6d8e6bda5e327f431e1.tar.xz
Add copyright headers, formatting cleanup, ignore some generated files.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/NetworkUtil.cs37
1 files changed, 32 insertions, 5 deletions
diff --git a/OpenSim/Framework/NetworkUtil.cs b/OpenSim/Framework/NetworkUtil.cs
index 351020b..5fe343d 100644
--- a/OpenSim/Framework/NetworkUtil.cs
+++ b/OpenSim/Framework/NetworkUtil.cs
@@ -1,4 +1,31 @@
1using System; 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;
2using System.Collections.Generic; 29using System.Collections.Generic;
3using System.Net.Sockets; 30using System.Net.Sockets;
4using System.Net; 31using System.Net;
@@ -34,7 +61,7 @@ namespace OpenSim.Framework
34 61
35 public static IPAddress GetIPFor(IPAddress user, IPAddress simulator) 62 public static IPAddress GetIPFor(IPAddress user, IPAddress simulator)
36 { 63 {
37 if(m_disabled) 64 if (m_disabled)
38 return simulator; 65 return simulator;
39 66
40 // Check if we're accessing localhost. 67 // Check if we're accessing localhost.
@@ -97,7 +124,7 @@ namespace OpenSim.Framework
97 } 124 }
98 } 125 }
99 126
100 if(destination.AddressFamily != AddressFamily.InterNetwork) 127 if (destination.AddressFamily != AddressFamily.InterNetwork)
101 return null; 128 return null;
102 129
103 // Check if we're accessing localhost. 130 // Check if we're accessing localhost.
@@ -118,12 +145,12 @@ namespace OpenSim.Framework
118 byte[] localBytes = subnet.Key.GetAddressBytes(); 145 byte[] localBytes = subnet.Key.GetAddressBytes();
119 byte[] destBytes = destination.GetAddressBytes(); 146 byte[] destBytes = destination.GetAddressBytes();
120 147
121 if(subnetBytes.Length != destBytes.Length || subnetBytes.Length != localBytes.Length) 148 if (subnetBytes.Length != destBytes.Length || subnetBytes.Length != localBytes.Length)
122 return null; 149 return null;
123 150
124 bool valid = true; 151 bool valid = true;
125 152
126 for(int i=0;i<subnetBytes.Length;i++) 153 for (int i=0;i<subnetBytes.Length;i++)
127 { 154 {
128 if ((localBytes[i] & subnetBytes[i]) != (destBytes[i] & subnetBytes[i])) 155 if ((localBytes[i] & subnetBytes[i]) != (destBytes[i] & subnetBytes[i]))
129 { 156 {