コード例 #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);
                    }
                }
            }
        }
コード例 #2
0
        /* (non-Javadoc)
         * @see java.lang.Object#toString()
         */
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder(Util.LINE_SEPARATOR);

            sb.Append(KeyToString(this.GetDuid(), this.GetIatype(), this.GetIaid()));
            sb.Append(" state=");
            sb.Append(this.GetState());
            sb.Append('(');
            sb.Append(IaAddress.StateToString(this.GetState()));
            sb.Append(')');
            List <IaAddress> iaAddrs = this.GetIaAddresses();

            if (iaAddrs != null)
            {
                foreach (IaAddress iaAddr in iaAddrs)
                {
                    sb.Append(Util.LINE_SEPARATOR);
                    sb.Append('\t');
                    sb.Append(iaAddr.ToString());
                }
            }
            List <DhcpOption> opts = this.GetDhcpOptions();

            if (opts != null)
            {
                foreach (BaseIpAddressOption dhcpOption in opts)
                {
                    sb.Append(Util.LINE_SEPARATOR);
                    sb.Append("\tIA Option: ");
                    sb.Append(dhcpOption.ToString());
                }
            }
            return(sb.ToString());
        }
コード例 #3
0
ファイル: IaAddress.cs プロジェクト: NatChung/PacketTestTools
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("IA_ADDR: ");
            sb.Append(" ip=");
            sb.Append(this.GetIpAddress().ToString());
            sb.Append(" state=");
            sb.Append((this.GetState() + ("("
                                          + (IaAddress.StateToString(this.GetState()) + ")"))));
            sb.Append(" startTime=");
            if ((this.GetStartTime() != null))
            {
                sb.Append(this.GetStartTime().ToString(Util.GMT_DATEFORMAT));
            }

            sb.Append(" preferredEndTime=");
            if ((this.GetPreferredEndTime() != null))
            {
                if ((this.GetPreferredEndTime().Millisecond < 0))
                {
                    sb.Append("infinite");
                }
                else
                {
                    sb.Append(this.GetPreferredEndTime().ToString(Util.GMT_DATEFORMAT));
                }
            }

            sb.Append(" validEndTime=");
            if ((this.GetValidEndTime() != null))
            {
                if ((this.GetValidEndTime().Millisecond < 0))
                {
                    sb.Append("infinite");
                }
                else
                {
                    sb.Append(this.GetValidEndTime().ToString(Util.GMT_DATEFORMAT));
                }
            }

            List <DhcpOption> opts = this.GetDhcpOptions();

            if ((opts != null))
            {
                foreach (BaseIpAddressOption dhcpOption in opts)
                {
                    sb.Append(Util.LINE_SEPARATOR);
                    sb.Append("\t\tIA_ADDR Option: ");
                    sb.Append(dhcpOption.ToString());
                }
            }

            return(sb.ToString());
        }
コード例 #4
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);
        }
コード例 #5
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());
        }
コード例 #6
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);
        }
コード例 #7
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);
        }
コード例 #8
0
 public void SaveDhcpOption(IaAddress iaAddr, BaseDhcpOption baseOption)
 {
     try
     {
         //byte[] newVal = baseOption.encode().array();
         // don't store the option code, start with length to
         // simplify decoding when retrieving from database
         //if (baseOption.IsV4())
         //{
         //    newVal = Arrays.copyOfRange(newVal, 1, newVal.length);
         //}
         //else
         //{
         //    newVal = Arrays.copyOfRange(newVal, 2, newVal.length);
         //}
         ////			DhcpOption dbOption = iaAddr.getDhcpOption(baseOption.getCode());
         //DhcpOption dbOption = FindIaAddressOption(iaAddr, baseOption);
         //if (dbOption == null)
         //{
         //    dbOption = new DhcpOption();
         //    dbOption.SetCode(baseOption.GetCode());
         //    dbOption.SetValue(newVal);
         //    SetDhcpOption(iaAddr, dbOption);
         //}
         //else
         //{
         //    if (!Arrays.equals(dbOption.getValue(), newVal))
         //    {
         //        dbOption.setValue(newVal);
         //        setDhcpOption(iaAddr, dbOption);
         //    }
         //}
     }
     catch (Exception ex)
     {
         log.Error("Failed to update binding with option");
     }
 }
コード例 #9
0
 public IdentityAssoc FindIA(IaAddress iaAddress)
 {
     return(null);
 }
コード例 #10
0
 public void DeleteIaAddr(IaAddress iaAddr)
 {
     _DhcpLeaseData.RemoveAll(d => d.GetIpAddress().ToString() == iaAddr.GetIpAddress().ToString());
 }
コード例 #11
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));
 }
コード例 #12
0
 protected void SetDhcpOption(IaAddress iaAddr, DhcpOption option)
 {
     iaAddr.SetDhcpOption(option);
     UpdateIpAddrOptions(iaAddr.GetIpAddress(), iaAddr.GetDhcpOptions());
 }
コード例 #13
0
 public void SaveDhcpOption(IaAddress iaAddr, BaseDhcpOption option)
 {
 }
コード例 #14
0
ファイル: IaAddress.cs プロジェクト: NatChung/PacketTestTools
        public override bool Equals(Object obj)
        {
            if ((this == obj))
            {
                return(true);
            }

            if ((obj == null))
            {
                return(false);
            }

            if ((this.GetType() != obj.GetType()))
            {
                return(false);
            }

            if (!(obj is IaAddress))
            {
                return(false);
            }

            IaAddress other = ((IaAddress)(obj));

            if ((this.id == 0))
            {
                if ((other.id != 0))
                {
                    return(false);
                }
            }
            else if (!this.id.Equals(other.id))
            {
                return(false);
            }

            if ((this.identityAssocId == 0))
            {
                if ((other.identityAssocId != 0))
                {
                    return(false);
                }
            }
            else if (!this.identityAssocId.Equals(other.identityAssocId))
            {
                return(false);
            }

            if ((this.ipAddress == null))
            {
                if ((other.ipAddress != null))
                {
                    return(false);
                }
            }
            else if (!this.ipAddress.Equals(other.ipAddress))
            {
                return(false);
            }

            if ((this.preferredEndTime == null))
            {
                if ((other.preferredEndTime != null))
                {
                    return(false);
                }
            }
            else if (!this.preferredEndTime.Equals(other.preferredEndTime))
            {
                return(false);
            }

            if ((this.startTime == null))
            {
                if ((other.startTime != null))
                {
                    return(false);
                }
            }
            else if (!this.startTime.Equals(other.startTime))
            {
                return(false);
            }

            if ((this.state != other.state))
            {
                return(false);
            }

            if ((this.validEndTime == null))
            {
                if ((other.validEndTime != null))
                {
                    return(false);
                }
            }
            else if (!this.validEndTime.Equals(other.validEndTime))
            {
                return(false);
            }

            return(true);
        }
コード例 #15
0
 public void DeleteIaAddr(IaAddress iaAddr)
 {
 }
コード例 #16
0
 public void UpdateIaAddr(IaAddress iaAddr)
 {
 }
コード例 #17
0
 public void DeleteDhcpOption(IaAddress iaAddr, BaseDhcpOption option)
 {
 }