コード例 #1
0
        /**
         * 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);
        }
コード例 #2
0
        /**
         * Build a BindingAddress for the given InetAddress and DhcpLink.
         *
         * @param inetAddr the inet addr
         * @param clientLink the client link
         * @param requestMsg the request msg
         *
         * @return the binding address
         */
        protected override BindingObject BuildBindingObject(IPAddress inetAddr,
                                                            DhcpLink clientLink, DhcpMessage requestMsg)
        {
            V6AddressBindingPool bp =
                (V6AddressBindingPool)FindBindingPool(clientLink.GetLink(), inetAddr, requestMsg);

            if (bp != null)
            {
                bp.SetUsed(inetAddr);   // TODO check if this is necessary
                IaAddress iaAddr = new IaAddress();
                iaAddr.SetIpAddress(inetAddr);
                V6BindingAddress bindingAddr = new V6BindingAddress(iaAddr, bp);
                SetBindingObjectTimes(bindingAddr,
                                      bp.GetPreferredLifetimeMs(), bp.GetPreferredLifetimeMs());
                // TODO store the configured options in the persisted binding?
                // bindingAddr.setDhcpOptions(bp.getDhcpOptions());
                return(bindingAddr);
            }
            else
            {
                log.Error("Failed to create BindingAddress: No BindingPool found for IP=" +
                          inetAddr.ToString());
            }
            // MUST have a BindingPool, otherwise something's broke
            return(null);
        }
コード例 #3
0
        /**
         * Build the list of V6AddressBindingPools from the list of configured V6AddressPools
         * for the given configuration Link container object. The list of V6AddressBindingPools
         * starts with the filtered AddressPools followed by non-filtered AddressPools.
         *
         * @param link the configuration Link object
         *
         * @return the list of V6AddressBindingPools (<? extends BindingPool>)
         *
         * @throws DhcpServerConfigException if there is a problem parsing a configured range
         */
        protected override List <BindingPool> BuildBindingPools(link link)
        {
            Debug.Assert(CheckIPIsUsed != null, "V6AddrBindingManager --BuildBindingPools-- CheckIPIsUsed = null");
            List <BindingPool> bindingPools = new List <BindingPool>();
            // Put the filtered pools first in the list of pools on this link
            List <linkFilter> linkFilters = link.linkFilters;

            if ((linkFilters != null) && linkFilters.Count > 0)
            {
                foreach (linkFilter linkFilter in linkFilters)
                {
                    List <v6AddressPool> pools = GetV6AddressPools(linkFilter);
                    if ((pools != null) && pools.Count > 0)
                    {
                        foreach (v6AddressPool pool in pools)
                        {
                            V6AddressBindingPool abp = BuildV6BindingPool(pool, link, linkFilter);
                            abp.CheckIPIsUsed = CheckIPIsUsed;
                            bindingPools.Add(abp);
                        }
                    }
                    //else
                    //{
                    //    log.Error("PoolList is null for PoolsType: " + linkFilter);
                    //}
                }
            }

            List <v6AddressPool> unpools = GetV6AddressPools(link);

            // add the unfiltered pools to the mapped list
            if ((unpools != null) && unpools.Count > 0)
            {
                foreach (v6AddressPool pool in unpools)
                {
                    V6AddressBindingPool abp = BuildV6BindingPool(pool, link);
                    bindingPools.Add(abp);
                }
            }
            //else
            //{
            //    log.Error("PoolList is null for PoolsType: " + poolsType);
            //}

            //TODO this is very dangerous if the server is managing
            //	    both NA and TA address pools because we'd delete
            //	    all the addresses in pools of the other type
            //		reconcilePools(bindingPools);

            return(bindingPools);
        }