public static readonly IPAddress Broadcast = IPAddress.Parse ("255.255.255.255");
public static readonly IPAddress Loopback = IPAddress.Parse ("127.0.0.1");
public static readonly IPAddress None = IPAddress.Parse ("255.255.255.255");
-
-#if NET_1_1
public static readonly IPAddress IPv6Any = IPAddress.ParseIPV6 ("::");
public static readonly IPAddress IPv6Loopback = IPAddress.ParseIPV6 ("::1");
public static readonly IPAddress IPv6None = IPAddress.ParseIPV6 ("::");
-#endif
private static short SwapShort (short number)
{
m_Address = addr;
}
-#if NET_1_1
public IPAddress (byte[] address)
{
+ if (address == null)
+ throw new ArgumentNullException ("address");
+
int len = address.Length;
+
#if NET_2_0
if (len != 16 && len != 4)
- throw new ArgumentException ("address");
+ throw new ArgumentException ("An invalid IP address was specified.",
+ "address");
#else
if (len != 16)
throw new ArgumentException ("address");
#endif
+
if (len == 16) {
Buffer.BlockCopy(address, 0, m_Numbers, 0, 16);
m_Family = AddressFamily.InterNetworkV6;
public IPAddress(byte[] address, long scopeId)
{
+ if (address == null)
+ throw new ArgumentNullException ("address");
+
if (address.Length != 16)
+#if NET_2_0
+ throw new ArgumentException ("An invalid IP address was specified.",
+ "address");
+#else
throw new ArgumentException("address");
+#endif
Buffer.BlockCopy(address, 0, m_Numbers, 0, 16);
m_Family = AddressFamily.InterNetworkV6;
m_Family = AddressFamily.InterNetworkV6;
m_ScopeId = scopeId;
}
-#endif
public static IPAddress Parse (string ip)
{
if (ip == null)
throw new ArgumentNullException ("Value cannot be null.");
-#if NET_1_1
if( (address = ParseIPV4(ip)) == null)
if( (address = ParseIPV6(ip)) == null)
return false;
-#else
- if( (address = ParseIPV4(ip)) == null)
- return false;
-#endif
return true;
}
int pos = ip.IndexOf (' ');
if (pos != -1)
- ip = ip.Substring (0, pos);
+ ip = ip.Substring (0, pos);
if (ip.Length == 0 || ip [ip.Length - 1] == '.')
return null;
}
}
-#if NET_1_1
private static IPAddress ParseIPV6 (string ip)
{
try
}
[Obsolete("This property is obsolete. Use GetAddressBytes.")]
-#endif
public long Address
{
get {
}
#endif
-#if NET_1_1
public long ScopeId {
get {
if(m_Family != AddressFamily.InterNetworkV6)
(byte)(m_Address >> 24) };
}
}
-#endif
+
public AddressFamily AddressFamily
{
get {