Beispiel #1
0
        public void DeleteDhcpOption(IaAddress iaAddr, BaseDhcpOption baseOption)
        {
            DhcpLease lease = FindDhcpLeaseForInetAddr(iaAddr.GetIpAddress());

            if (lease != null)
            {
                List <DhcpOption> iaAddrOptions = lease.GetIaAddrDhcpOptions();
                if (iaAddrOptions != null)
                {
                    bool deleted = false;
                    foreach (DhcpOption iaAddrOption in iaAddrOptions)
                    {
                        if (iaAddrOption.GetCode() == baseOption.GetCode())
                        {
                            iaAddrOptions.Remove(iaAddrOption);
                            deleted = true;
                            break;
                        }
                    }
                    if (deleted)
                    {
                        UpdateIpAddrOptions(iaAddr.GetIpAddress(), iaAddrOptions);
                    }
                }
            }
        }
Beispiel #2
0
 /**
  * Update dhcp lease.
  *
  * @param lease the lease
  */
 protected void UpdateDhcpLease(DhcpLease lease)
 {
     foreach (var item in _DhcpLeaseData.Where(p => p.GetIpAddress() == lease.GetIpAddress()))
     {
         item.SetState(lease.GetState());
         item.SetStartTime(lease.GetStartTime());
         item.SetPreferredEndTime(lease.GetPreferredEndTime());
         item.SetValidEndTime(lease.GetValidEndTime());
         item.SetIaDhcpOptions(lease.GetIaDhcpOptions());
         item.SetIaAddrDhcpOptions(lease.GetIaAddrDhcpOptions());
     }
 }
Beispiel #3
0
        /**
         * To ia address.
         *
         * @param lease the lease
         * @return the ia address
         */
        protected IaAddress ToIaAddress(DhcpLease lease)
        {
            IaAddress iaAddr = new IaAddress();

            iaAddr.SetIpAddress(lease.GetIpAddress());
            iaAddr.SetState(lease.GetState());
            iaAddr.SetStartTime(lease.GetStartTime());
            iaAddr.SetPreferredEndTime(lease.GetPreferredEndTime());
            iaAddr.SetValidEndTime(lease.GetValidEndTime());
            iaAddr.SetDhcpOptions(lease.GetIaAddrDhcpOptions());
            return(iaAddr);
        }
Beispiel #4
0
        /**
         * To ia prefix.
         *
         * @param lease the lease
         * @return the ia prefix
         */
        protected IaPrefix ToIaPrefix(DhcpLease lease)
        {
            IaPrefix iaPrefix = new IaPrefix();

            iaPrefix.SetIpAddress(lease.GetIpAddress());
            iaPrefix.SetPrefixLength(lease.GetPrefixLength());
            iaPrefix.SetState(lease.GetState());
            iaPrefix.SetStartTime(lease.GetStartTime());
            iaPrefix.SetPreferredEndTime(lease.GetPreferredEndTime());
            iaPrefix.SetValidEndTime(lease.GetValidEndTime());
            iaPrefix.SetDhcpOptions(lease.GetIaAddrDhcpOptions());
            return(iaPrefix);
        }
Beispiel #5
0
        protected DhcpOption FindIaAddressOption(IaAddress iaAddr, BaseDhcpOption baseOption)
        {
            DhcpOption dbOption = null;
            DhcpLease  lease    = FindDhcpLeaseForInetAddr(iaAddr.GetIpAddress());

            if (lease != null)
            {
                List <DhcpOption> iaAddrOptions = lease.GetIaAddrDhcpOptions();
                if (iaAddrOptions != null)
                {
                    foreach (DhcpOption iaAddrOption in iaAddrOptions)
                    {
                        if (iaAddrOption.GetCode() == baseOption.GetCode())
                        {
                            dbOption = iaAddrOption;
                            break;
                        }
                    }
                }
            }
            return(dbOption);
        }