/**
         * Instantiates a new binding pool.
         *
         * @param pool the pool
         *
         * @throws DhcpServerConfigException if the AddressPool definition is invalid
         */
        public V6AddressBindingPool(v6AddressPool pool)
        {
            this.pool = pool;
            //this._assignDhcpV6Rule = pool.assignDhcpv6Rule;
            try
            {
                this.range = new Range(pool.range);
            }
            catch (Exception ex)
            {
                log.Error("Invalid AddressPool definition");
                throw new Exception("Invalid AddressPool definition", ex);
            }
            //catch (UnknownHostException ex)
            //{
            //    log.error("Invalid AddressPool definition", ex);
            //    throw new DhcpServerConfigException("Invalid AddressPool definition", ex);
            //}
            freeList =

                new FreeList(new BigInteger(range.GetStartAddress().GetAddressBytes()),
                             new BigInteger(range.GetEndAddress().GetAddressBytes()));
            //reaper = new Timer(pool.getRange() + "_Reaper");
            dhcpConfigOptions = new DhcpV6ConfigOptions(pool.addrConfigOptions);
        }
        // protected Timer reaper;

        /**
         * Instantiates a new binding pool.
         *
         * @param pool the pool
         *
         * @throws DhcpServerConfigException if the PrefixPool definition is invalid
         */
        public V6PrefixBindingPool(v6PrefixPool pool)
        {
            try
            {
                this.pool      = pool;
                allocPrefixLen = pool.prefixLength;
                string[] cidr = pool.range.Split('/');
                if ((cidr == null) || (cidr.Length != 2))
                {
                    throw new Exception(
                              "Prefix pool must be specified in prefix/len notation");
                }
                subnet = new Subnet(cidr[0], cidr[1]);
                if (allocPrefixLen < subnet.GetPrefixLength())
                {
                    throw new Exception(
                              "Allocation prefix length must be greater or equal to pool prefix length");
                }
                int numPrefixes = (int)Math.Pow(2, (allocPrefixLen - subnet.GetPrefixLength()));
                freeList = new FreeList(new BigInteger(0),
                                        new BigInteger(numPrefixes) - new BigInteger(1));
                //reaper = new Timer(pool.getRange() + "_Reaper");
                dhcpConfigOptions = new DhcpV6ConfigOptions(pool.prefixConfigOptions);
            }
            catch (Exception ex)
            {
                log.Error("Invalid PrefixPool definition");
                throw new Exception("Invalid PrefixPool definition", ex);
            }
        }
Esempio n. 3
0
        //protected Timer reaper;

        /**
         * Instantiates a new binding pool.
         *
         * @param pool the pool
         *
         * @throws DhcpServerConfigException if the AddressPool definition is invalid
         */
        public V4AddressBindingPool(v4AddressPool pool)
        {
            this.pool = pool;
            try
            {
                this.range = new Range(pool.range);
            }
            catch (Exception ex)
            {
                log.Error("Invalid AddressPool definition");
                throw new Exception("Invalid AddressPool definition", ex);
            }
            freeList =

                new FreeList(new BigInteger(range.GetStartAddress().GetAddressBytes()),
                             new BigInteger(range.GetEndAddress().GetAddressBytes()));
            //reaper = new Timer(pool.getRange() + "_Reaper");
            v4ConfigOptions = new DhcpV4ConfigOptions(pool.configOptions);
        }