System.Net.Topology.NetMaskExtensions.GetSiblingCount C# (CSharp) Method

GetSiblingCount() public static method

Gets the number of siblings an T:System.Net.IPAddress can have in a given network.
public static GetSiblingCount ( this mask, SiblingOptions options ) : int
mask this The net mask of the network
options SiblingOptions Options which addresses to include an which not
return int
        public static int GetSiblingCount(this NetMask mask, SiblingOptions options)
        {
            if (mask == null)
                throw new ArgumentNullException(nameof(mask));

            bool includeSelf = BitHelper.IsOptionSet(options, SiblingOptions.IncludeSelf);
            bool includeBroadcast = BitHelper.IsOptionSet(options, SiblingOptions.IncludeBroadcast);
            bool includeNetworkIdentifier = BitHelper.IsOptionSet(options, SiblingOptions.IncludeNetworkIdentifier);

            var hostPartBits = mask.GetMaskBytes().CountFromRight(false);
            var total = 1 << hostPartBits;
            total -= includeSelf ? 0 : 1;
            total -= includeBroadcast ? 0 : 1;
            total -= includeNetworkIdentifier ? 0 : 1;

            // TODO: Testing

            return total;
        }
    }

Same methods

NetMaskExtensions::GetSiblingCount ( this mask ) : int
NetMaskExtensions