/**
  * Callback from the ExpireTimerTask started when the lease was granted.
  * NOT CURRENTLY USED
  *
  * @param iaPrefix the ia prefix
  */
 public void ExpireIaPrefix(IaPrefix iaPrefix)
 {
     try
     {
         if (DhcpServerPolicies.GlobalPolicyAsBoolean(
                 Property.BINDING_MANAGER_DELETE_OLD_BINDINGS))
         {
             log.Debug("Deleting expired prefix: " + iaPrefix.GetIpAddress());
             iaMgr.DeleteIaPrefix(iaPrefix);
             // free the prefix only if it is deleted from the db,
             // otherwise, we will get a unique constraint violation
             // if another client obtains this released prefix
             FreeAddress(iaPrefix.GetIpAddress());
         }
         else
         {
             iaPrefix.SetStartTime(DateTime.Now);
             iaPrefix.SetPreferredEndTime(DateTime.Now);
             iaPrefix.SetValidEndTime(DateTime.Now);
             iaPrefix.SetState(IaPrefix.EXPIRED);
             log.Debug("Updating expired prefix: " + iaPrefix.GetIpAddress());
             iaMgr.UpdateIaPrefix(iaPrefix);
         }
     }
     catch (Exception ex)
     {
         log.Error("Failed to expire address");
     }
 }
Пример #2
0
 /**
  * Instantiates a new binding address.
  *
  * @param iaPrefix the ia addr
  * @param configObj the config object
  */
 public V6BindingPrefix(IaPrefix iaPrefix, DhcpConfigObject configObj)
 {
     // populate *this* IaPrefix from the given one
     this.SetDhcpOptions(iaPrefix.GetDhcpOptions());
     this.SetId(iaPrefix.GetId());
     this.SetIdentityAssocId(iaPrefix.GetIdentityAssocId());
     this.SetIpAddress(iaPrefix.GetIpAddress());
     this.SetPreferredEndTime(iaPrefix.GetPreferredEndTime());
     this.SetPrefixLength(iaPrefix.GetPrefixLength());
     this.SetStartTime(iaPrefix.GetStartTime());
     this.SetState(iaPrefix.GetState());
     this.SetValidEndTime(iaPrefix.GetValidEndTime());
     this.configObj = configObj;
 }
        /**
         * Create a BindingPrefix given an IaPrefix loaded from the database.
         *
         * @param iaPrefix the ia prefix
         * @param clientLink the client link
         * @param requestMsg the request msg
         *
         * @return the binding address
         */
        private V6BindingPrefix BuildBindingAddrFromIaPrefix(IaPrefix iaPrefix,
                                                             link clientLink, DhcpMessage requestMsg)
        {
            IPAddress   inetAddr = iaPrefix.GetIpAddress();
            BindingPool bp       = FindBindingPool(clientLink, inetAddr, requestMsg);

            if (bp != null)
            {
                // TODO store the configured options in the persisted binding?
                // ipAddr.setDhcpOptions(bp.getDhcpOptions());
                return(new V6BindingPrefix(iaPrefix, (V6PrefixBindingPool)bp));
            }
            else
            {
                log.Error("Failed to create BindingPrefix: No BindingPool found for IP=" +
                          inetAddr.ToString());
            }
            // MUST have a BindingPool, otherwise something's broke
            return(null);
        }