/** * 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); }
/** * Builds a binding pool from an AddressPool using the given link. * * @param pool the AddressPool to wrap as an AddressBindingPool * @param link the link * * @return the binding pool * * @throws DhcpServerConfigException if there is a problem parsing the configured range */ private V6AddressBindingPool BuildV6BindingPool(v6AddressPool pool, link link, linkFilter linkFilter) { Debug.Assert(CheckIPIsUsed != null, "V6AddrBindingManager --BuildV6BindingPool-- CheckIPIsUsed = null"); V6AddressBindingPool bp = new V6AddressBindingPool(pool); long pLifetime = long.Parse(Property.PREFERRED_LIFETIME.Value()); // DhcpServerPolicies.EffectivePolicyAsLong(bp, link, Property.PREFERRED_LIFETIME); bp.SetPreferredLifetime(pLifetime); long vLifetime = long.Parse(Property.VALID_LIFETIME.Value()); // DhcpServerPolicies.EffectivePolicyAsLong(bp, link, Property.VALID_LIFETIME); bp.SetValidLifetime(vLifetime); bp.SetLinkFilter(linkFilter); bp.CheckIPIsUsed = CheckIPIsUsed; List <IPAddress> usedIps = null;// 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 address binding pool: " + bp.GetStartAddress().ToString() + "-" + bp.GetEndAddress().ToString()); return(bp); }
protected bool AllIaAddrsOnLink(DhcpV6IaNaOption dhcpIaNaOption, DhcpLink clientLink) { bool onLink = true; // assume all IPs are on link if ((dhcpIaNaOption != null)) { List <DhcpV6IaAddrOption> iaAddrOpts = dhcpIaNaOption.GetIaAddrOptions(); if ((iaAddrOpts != null)) { foreach (DhcpV6IaAddrOption iaAddrOpt in iaAddrOpts) { if (this.clientLink.GetSubnet().GetSubnetAddress().IsIPv6LinkLocal) { // if the Link address is link-local, then check if the // address is within one of the pools configured for this // local Link, which automatically makes this server // "authoritative" (in ISC parlance) for this local net v6AddressPool p = DhcpServerConfiguration.FindNaAddrPool(this.clientLink.GetLink(), iaAddrOpt.GetInetAddress()); if ((p == null)) { log.Info(("No local address pool found for requested IA_NA: " + (iaAddrOpt.ToString() + " - considered to be off link"))); iaAddrOpt.SetPreferredLifetime(0); iaAddrOpt.SetValidLifetime(0); onLink = false; } } else { // it the Link address is remote, then check // if the address is valid for that link if (!this.clientLink.GetSubnet().Contains(iaAddrOpt.GetInetAddress())) { log.Info("Setting zero(0) lifetimes for off link address: " + iaAddrOpt.GetIpAddress()); iaAddrOpt.SetPreferredLifetime(0); iaAddrOpt.SetValidLifetime(0); onLink = false; } } } } } return(onLink); }
/** * Builds a binding pool from an AddressPool using the given link. * * @param pool the AddressPool to wrap as an AddressBindingPool * @param link the link * * @return the binding pool * * @throws DhcpServerConfigException if there is a problem parsing the configured range */ protected V6AddressBindingPool BuildV6BindingPool(v6AddressPool pool, link link) { return(BuildV6BindingPool(pool, link, null)); }
/** * Sets the pool. * * @param pool the new pool */ public void SetV6AddressPool(v6AddressPool pool) { this.pool = pool; }