Exemplo n.º 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);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void UpdateIaAddr(IaAddress iaAddr)
        {
            _DhcpLeaseData.Where(d => d.GetIpAddress() == iaAddr.GetIpAddress()).ToList().ForEach(d =>
            {
                d.SetStartTime(iaAddr.GetStartTime());
                d.SetPreferredEndTime(iaAddr.GetPreferredEndTime());
                d.SetValidEndTime(iaAddr.GetValidEndTime());
            });



            //(_DhcpLeaseData.Where(d => d.GetIpAddress().ToString() == iaAddr.GetIpAddress().ToString()).First());
        }
Exemplo n.º 3
0
        /**
         * To dhcp lease.
         *
         * @param ia the ia
         * @param iaAddr the ia addr
         * @return the dhcp lease
         */
        protected DhcpLease ToDhcpLease(IdentityAssoc ia, IaAddress iaAddr)
        {
            DhcpLease lease = new DhcpLease();

            lease.SetDuid(ia.GetDuid());
            lease.SetIaid(ia.GetIaid());
            lease.SetIatype(ia.GetIatype());
            lease.SetIpAddress(iaAddr.GetIpAddress());
            if (iaAddr is IaPrefix)
            {
                lease.SetPrefixLength(((IaPrefix)iaAddr).GetPrefixLength());
            }
            lease.SetState(iaAddr.GetState());
            lease.SetStartTime(iaAddr.GetStartTime());
            lease.SetPreferredEndTime(iaAddr.GetPreferredEndTime());
            lease.SetValidEndTime(iaAddr.GetValidEndTime());
            lease.SetIaAddrDhcpOptions(iaAddr.GetDhcpOptions());
            lease.SetIaDhcpOptions(ia.GetDhcpOptions());
            return(lease);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
 public void DeleteIaAddr(IaAddress iaAddr)
 {
     _DhcpLeaseData.RemoveAll(d => d.GetIpAddress().ToString() == iaAddr.GetIpAddress().ToString());
 }
Exemplo n.º 6
0
 /* (non-Javadoc)
  * @see com.jagornet.dhcpv6.db.IaManager#findIA(com.jagornet.dhcpv6.db.IaAddress)
  */
 public IdentityAssoc FindIA(IaAddress iaAddress)
 {
     return(FindIA(iaAddress.GetIpAddress(), true));
 }
Exemplo n.º 7
0
 protected void SetDhcpOption(IaAddress iaAddr, DhcpOption option)
 {
     iaAddr.SetDhcpOption(option);
     UpdateIpAddrOptions(iaAddr.GetIpAddress(), iaAddr.GetDhcpOptions());
 }