# Patch created by chilan # Date: Sun Mar 17 16:39:04 GMT 2002 # Repository: pnetlib # Comments: # Added implementation for GetHashCode, IsLoopback, Parse and ToString #### End of Preamble #### #### Patch data follows #### Index: System/Net/IPAddress.cs =================================================================== RCS file: /cvsroot/dotgnu-pnet/pnetlib/System/Net/IPAddress.cs,v retrieving revision 1.1 diff -c -r1.1 IPAddress.cs *** System/Net/IPAddress.cs 4 Mar 2002 01:58:24 -0000 1.1 --- System/Net/IPAddress.cs 17 Mar 2002 16:32:01 -0000 *************** *** 1,137 **** ! /* ! * IPAddress.cs - Implementation of the "System.Net.IPAddress" class. ! * ! * Copyright (C) 2002 Southern Storm Software, Pty Ltd. ! * ! * This program is free software; you can redistribute it and/or modify ! * it under the terms of the GNU General Public License as published by ! * the Free Software Foundation; either version 2 of the License, or ! * (at your option) any later version. ! * ! * This program is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License ! * along with this program; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! */ ! ! namespace System.Net ! { ! ! using System; ! ! public class IPAddress ! { ! private long value__; ! ! public IPAddress(long newAddress) ! { ! if ((newAddress < 0) || (newAddress > 0x00000000FFFFFFFF)) ! throw new ArgumentOutOfRangeException("newAddress",_("Arg_OutOfRange")); ! value__ = newAddress; ! ! Any = new IPAddress(0x0000000000000000); ! Broadcast = new IPAddress(0x00000000FFFFFFFF); ! Loopback = new IPAddress(0x000000000100007F); ! None = new IPAddress(0x00000000FFFFFFFF); ! } ! ! public override bool Equals(Object comparand) ! { ! if (comparand is IPAddress) ! { ! return (value__ == ((IPAddress)comparand).value__); ! } ! else ! { ! return false; ! } ! } ! ! [TODO] ! public override int GetHashCode() ! { ! ! } ! ! [TODO] ! public static long HostToNetworkOrder(long host) ! { ! return 0; ! } ! [TODO] ! public static int HostToNetworkOrder(int host) ! { ! return 0; ! } ! [TODO] ! public static short HostToNetworkOrder(short host) ! { ! return 0; ! } ! [TODO] ! public static bool IsLoopback(IPAddress address) ! { ! ! } ! ! [TODO] ! public static long NetworkToHostOrder(long network) ! { ! return 0; ! } ! [TODO] ! public static int NetworkToHostOrder(int network) ! { ! return 0; ! } ! [TODO] ! public static short NetworkToHostOrder(short network) ! { ! return 0; ! } ! [TODO] ! public static IPAddress Parse(string ipString) ! { ! ! } ! [TODO] ! public override string ToString() ! { ! return ""; ! } ! ! public static readonly IPAddress Any; ! public static readonly IPAddress Broadcast; ! public static readonly IPAddress Loopback; ! public static readonly IPAddress None; ! ! public long Address ! { ! get ! { ! return value__; ! } ! set ! { ! if ((value < 0) || (value > 0x00000000FFFFFFFF)) ! throw new ArgumentOutOfRangeException("newAddress",_("Arg_OutOfRange")); ! value__ = value; ! } ! } ! ! public AddressFamily AddressFamily ! { ! get ! { ! return AddressFamily.InterNetwork; ! } ! } ! ! }; // class IPAddress ! ! }; // namespace System.Net ! --- 1,185 ---- ! /* ! * IPAddress.cs - Implementation of the "System.Net.IPAddress" class. ! * ! * Copyright (C) 2002 Southern Storm Software, Pty Ltd. ! * ! * This program is free software; you can redistribute it and/or modify ! * it under the terms of the GNU General Public License as published by ! * the Free Software Foundation; either version 2 of the License, or ! * (at your option) any later version. ! * ! * This program is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License ! * along with this program; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! */ ! ! namespace System.Net ! { ! ! using System; ! ! public class IPAddress ! { ! private long value__; ! ! public IPAddress(long newAddress) ! { ! if ((newAddress < 0) || (newAddress > 0x00000000FFFFFFFF)) ! throw new ArgumentOutOfRangeException("newAddress",_("Arg_OutOfRange")); ! value__ = newAddress; ! ! Any = new IPAddress(0x0000000000000000); ! Broadcast = new IPAddress(0x00000000FFFFFFFF); ! Loopback = new IPAddress(0x000000000100007F); ! None = new IPAddress(0x00000000FFFFFFFF); ! } ! ! public override bool Equals(Object comparand) ! { ! if (comparand is IPAddress) ! { ! return (value__ == ((IPAddress)comparand).value__); ! } ! else ! { ! return false; ! } ! } ! ! public override int GetHashCode() ! { ! return unchecked(((int)(value__ ^ (value__ >> 32))) ! & 0xFFFFFFFF); ! } ! ! [TODO] ! public static long HostToNetworkOrder(long host) ! { ! return 0; ! } ! [TODO] ! public static int HostToNetworkOrder(int host) ! { ! return 0; ! } ! [TODO] ! public static short HostToNetworkOrder(short host) ! { ! return 0; ! } ! public static bool IsLoopback(IPAddress address) ! { ! if ((address.value__ >= 0x000000000000007F) && (address.value__ <= 0x00000000FFFFFF7F)) ! { ! return true; ! } ! else ! { ! return false; ! } ! } ! ! [TODO] ! public static long NetworkToHostOrder(long network) ! { ! return 0; ! } ! [TODO] ! public static int NetworkToHostOrder(int network) ! { ! return 0; ! } ! [TODO] ! public static short NetworkToHostOrder(short network) ! { ! return 0; ! } ! public static IPAddress Parse(string ipString) ! { ! IPAddress parsed; ! string[] tokenizedString; ! ulong quadA; ! ulong quadB; ! ulong quadC; ! ulong quadD; ! bool numbersign; ! ! if (ipString == null) ! { ! throw new ArgumentNullException("ipString",_("Arg_NotNull")); ! } ! ! tokenizedString = String.Split(".", 4); ! ! if (tokenizedString.Length < 4) ! { ! throw new FormatException("ipString", _("Format_IP")); ! } ! ! if ((!NumberParser.StringToNumber(tokenizedString[0], 10, quadA, numbersign)) || ! (!NumberParser.StringToNumber(tokenizedString[1], 10, quadB, numbersign)) || ! (!NumberParser.StringToNumber(tokenizedString[2], 10, quadC, numbersign)) || ! (!NumberParser.StringToNumber(tokenizedString[3], 10, quadD, numbersign))) ! { ! throw new FormatException("ipString", _("Format_IP")); ! } ! ! parsed = (quadA + (quadB << 2) + (quadC << 4) + (quadD << 6)); ! ! return parsed; ! } ! public override string ToString() ! { ! string ip; ! ! ip = NumberFormatter.FormatFixedPoint((ulong)value__ & 0x00000000000000FF, 0, 0, false, null, ! NumberFormatInfo.GetInstance(provider)) + ! "." + ! NumberFormatter.FormatFixedPoint((ulong)value__ & 0x000000000000FF, 0, 0, false, null, ! NumberFormatInfo.GetInstance(provider)) + ! "." + ! NumberFormatter.FormatFixedPoint((ulong)value__ & 0x0000000000FF, 0, 0, false, null, ! NumberFormatInfo.GetInstance(provider)) + ! "." + ! NumberFormatter.FormatFixedPoint((ulong)value__ & 0x00000000FF, 0, 0, false, null, ! NumberFormatInfo.GetInstance(provider)); ! ! return ip; ! } ! ! public static readonly IPAddress Any; ! public static readonly IPAddress Broadcast; ! public static readonly IPAddress Loopback; ! public static readonly IPAddress None; ! ! public long Address ! { ! get ! { ! return value__; ! } ! set ! { ! if ((value < 0) || (value > 0x00000000FFFFFFFF)) ! throw new ArgumentOutOfRangeException("newAddress",_("Arg_OutOfRange")); ! value__ = value; ! } ! } ! ! public AddressFamily AddressFamily ! { ! get ! { ! return AddressFamily.InterNetwork; ! } ! } ! ! }; // class IPAddress ! ! }; // namespace System.Net ! #### End of Patch data ####