BF2Statistics.Net.Networking.CheckMask C# (CSharp) Method

CheckMask() private static method

private static CheckMask ( IPAddress address, IPAddress mask, IPAddress target ) : bool
address System.Net.IPAddress
mask System.Net.IPAddress
target System.Net.IPAddress
return bool
        private static bool CheckMask(IPAddress address, IPAddress mask, IPAddress target)
        {
            if (mask == null)
                return false;

            byte[] ba = address.GetAddressBytes();
            byte[] bm = mask.GetAddressBytes();
            byte[] bb = target.GetAddressBytes();

            if (ba.Length != bm.Length || bm.Length != bb.Length)
                return false;

            for (var i = 0; i < ba.Length; i++)
            {
                int m = bm[i];
                int a = ba[i] & m;
                int b = bb[i] & m;
                if (a != b)
                    return false;
            }

            return true;
        }