/** * Builds a binding pool from an V4AddressPool using the given link and filter. * * @param pool the V4AddressPool to wrap as an V4AddressBindingPool * @param link the link * @param linkFilter the link filter * * @return the binding pool * * @throws DhcpServerConfigException if there is a problem parsing the configured range */ protected V4AddressBindingPool BuildV4BindingPool(v4AddressPool pool, link link, linkFilter linkFilter) { V4AddressBindingPool bp = new V4AddressBindingPool(pool); long leasetime = DhcpServerPolicies.EffectivePolicyAsLong(bp, link, Property.V4_DEFAULT_LEASETIME); bp.SetLeasetime(leasetime); bp.SetLinkFilter(linkFilter); List <IPAddress> usedIps = iaMgr.FindExistingIPs(bp.GetStartAddress(), bp.GetEndAddress()); if ((usedIps != null) && usedIps.Count > 0) { foreach (IPAddress ip in usedIps) { //TODO: for the quickest startup?... // set IP as used without checking if the binding has expired // let the reaper thread deal with all binding cleanup activity bp.SetUsed(ip); } } log.Info("Built v4 address binding pool: " + bp.GetStartAddress().ToString() + "-" + bp.GetEndAddress().ToString() + " size=" + bp.GetSize()); return(bp); }
//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); }
/** * Sets the pool. * * @param pool the new pool */ public void SetV4AddressPool(v4AddressPool pool) { this.pool = pool; }
/** * Builds a binding pool from an V4AddressPool using the given link. * * @param pool the V4AddressPool to wrap as an V4AddressBindingPool * @param link the link * * @return the binding pool * * @throws DhcpServerConfigException if there is a problem parsing the configured range */ protected V4AddressBindingPool BuildV4BindingPool(v4AddressPool pool, link link) { return(BuildV4BindingPool(pool, link, null)); }