private static DhcpServerIpRange FromCidr(string cidrSubnet, DhcpServerIpRangeType type, int bootpClientsAllocated, int maxBootpAllowed)
        {
            if (string.IsNullOrEmpty(cidrSubnet))
            {
                throw new ArgumentNullException(nameof(cidrSubnet));
            }

            var slashIndex = cidrSubnet.IndexOf('/');

            if (slashIndex < 7 || !BitHelper.TryParseByteFromSubstring(cidrSubnet, ++slashIndex, cidrSubnet.Length - slashIndex, out var significantBits))
            {
                throw new ArgumentException("Invalid CIDR subnet notation format");
            }

            var address = DhcpServerIpAddress.FromNative(BitHelper.StringToIpAddress(cidrSubnet, 0, --slashIndex));
            var mask    = DhcpServerIpMask.FromSignificantBits(significantBits);

            return(FromMask(address, mask, type, bootpClientsAllocated, maxBootpAllowed));
        }
 public DhcpServerIpAddress(string address)
 {
     this.address = BitHelper.StringToIpAddress(address);
 }
Exemple #3
0
 public DhcpServerIpMask(string mask)
 {
     this.mask = BitHelper.StringToIpAddress(mask);
 }