3
using System.Configuration;
5
using System.Web.Security;
7
using System.Web.UI.WebControls;
8
using System.Web.UI.WebControls.WebParts;
9
using System.Web.UI.HtmlControls;
14
/// Summary description for IPTools
16
public static class IPTools
18
public static int IPToInt(IPAddress address)
20
byte[] ip = address.GetAddressBytes();
21
if(ip.Length == 4) return (int)(ip[0] | (ip[1] << 8) | (ip[2] << 16) | (ip[3] << 24));
25
public static IPAddress IntToIp(int address)
27
byte[] octets = { (byte)(address & 0xFF), (byte)((address >> 8) & 0xFF), (byte)((address >> 16) & 0xFF), (byte)((address >> 24) & 0xFF) };
28
return new IPAddress(octets);