protected override BindingObject BuildBindingObject(IPAddress inetAddr,
                                                            DhcpLink clientLink, DhcpMessage requestMsg)
        {
            V4AddressBindingPool bp =
                (V4AddressBindingPool)FindBindingPool(clientLink.GetLink(), inetAddr, requestMsg);

            if (bp != null)
            {
                bp.SetUsed(inetAddr);   // TODO check if this is necessary
                IaAddress iaAddr = new IaAddress();
                iaAddr.SetIpAddress(inetAddr);
                V4BindingAddress bindingAddr = new V4BindingAddress(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 V4BindingAddress: No V4BindingPool found for IP=" +
                          inetAddr.ToString());
            }
            // MUST have a BindingPool, otherwise something's broke
            return(null);
        }
        /**
         * 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);
        }
        /**
         * Build the list of V4AddressBindingPools from the list of configured V4AddressPools
         * for the given configuration link container object. The list of V4AddressBindingPools
         * starts with the filtered V4AddressPools followed by non-filtered V4AddressPools.
         *
         * @param link the configuration link object
         *
         * @return the list of V4AddressBindingPools (<? extends BindingPool>)
         *
         * @throws DhcpServerConfigException if there is a problem parsing a configured range
         */
        protected override List <BindingPool> BuildBindingPools(link link)
        {
            Debug.Assert(CheckIPIsUsed != null, "V4AddrBindingManagerImpl --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 <v4AddressPool> pools = linkFilter.v4AddrPools;

                    if ((pools != null) && pools.Count > 0)
                    {
                        foreach (v4AddressPool pool in pools)
                        {
                            V4AddressBindingPool abp = BuildV4BindingPool(pool, link, linkFilter);
                            abp.CheckIPIsUsed = CheckIPIsUsed;
                            bindingPools.Add(abp);
                        }
                    }
                    else
                    {
                        log.Error("PoolList is null for PoolsType");
                    }
                }
            }
            // add the unfiltered pools to the mapped list
            List <v4AddressPool> unpools = link.v4AddrPools;

            if ((unpools != null) && unpools.Count > 0)
            {
                foreach (v4AddressPool pool in unpools)
                {
                    V4AddressBindingPool abp = BuildV4BindingPool(pool, link);
                    abp.CheckIPIsUsed = CheckIPIsUsed;
                    bindingPools.Add(abp);
                }
            }
            else
            {
                log.Error("PoolList is null for PoolsType");
            }


            ReconcilePools(bindingPools);

            return(bindingPools);
        }