Esempio n. 1
0
 public IPAddress(IPAddress old)
 {
     IP = new byte[4];
     if (old == null)
         return;
     for (var i = 0; i < 4; i++) {
         IP[i] = old.IP[i];
     }
 }
Esempio n. 2
0
 public static IPAddress operator ^(IPAddress a, IPAddress b)
 {
     var newIP = new IPAddress(a);
     for (var i = 0; i < 4; i++)
         newIP.IP[i] ^= b.IP[i];
     return newIP;
 }
Esempio n. 3
0
 public bool Compare(IPAddress b)
 {
     for (var i = 0; i < 4; i++) {
         if (IP[i] != b.IP[i])
             return false;
     }
     return true;
 }
Esempio n. 4
0
        public bool ValidateIPWithMask(IPAddress mask)
        {
            if (!mask.SubnetMaskValidation())
                throw new Exception(ClientServiceLocator.GetService<ILanguage>().GetText("NonValidSubNetMask"));

            IPAddress negMask = ~mask;
            IPAddress pcAddress = this & negMask;
            if (pcAddress.IsZero()) //address of network
                return false;
            IPAddress broadTest = pcAddress ^ negMask;
            return !broadTest.IsZero();
        }
Esempio n. 5
0
        public bool ComapreIPGWNet(IPAddress mask, IPAddress gw)
        {
            if (!mask.SubnetMaskValidation())
                throw new Exception(ClientServiceLocator.GetService<ILanguage>().GetText("NonValidSubNetMask"));

            IPAddress gwNet = gw & mask;
            IPAddress ipNet = this & mask;

            return gwNet.Compare(ipNet);
        }