Ejemplo n.º 1
0
        public static bool IsValidNetmask(string sNetmask)
        {
            IPAddress netmask;

            if (IPAddress.TryParse(sNetmask, out netmask) && (netmask.AddressFamily == AddressFamily.InterNetwork))
            {
                return(IPNetwork.ValidNetmask(netmask));
            }

            return(false);
        }
Ejemplo n.º 2
0
        public static bool IsWildCardNetmask(string sMask)
        {
            IPAddress netmask;

            if (IPAddress.TryParse(sMask, out netmask) && (netmask.AddressFamily == AddressFamily.InterNetwork))
            {
                UInt32    maskInNumber = ~Ip2Number(sMask);
                string    wildcardMask = Number2Ip(maskInNumber);
                IPAddress wildmask;
                IPAddress.TryParse(wildcardMask, out wildmask);
                return(IPNetwork.ValidNetmask(wildmask));
            }

            return(false);
        }
Ejemplo n.º 3
0
        private static bool IsValidNetmask(String sNetmask, AddressFamily[] allowedAddressFamilies)
        {
            if (allowedAddressFamilies == null || allowedAddressFamilies.Length == 0)
            {
                return(false);
            }

            IPAddress netmask = null;

            if (IPAddress.TryParse(sNetmask, out netmask) && Array.Exists(allowedAddressFamilies, e => e == netmask.AddressFamily))
            {
                return(IPNetwork.ValidNetmask(netmask));
            }
            return(false);
        }