public bool Matches(opaqueDataListOptionType that, @operator op)
        {
            if (that != null)
            {
                List <opaqueData> opaqueList = that.opaqueData;
                if (opaqueList != null)
                {
                    if (op.Equals(@operator.equals))
                    {
                        if (opaqueList.Count != opaqueDataList.Count)
                        {
                            return(false);
                        }
                        for (int i = 0; i < opaqueList.Count; i++)
                        {
                            BaseOpaqueData opaque   = new BaseOpaqueData(opaqueList[i]);
                            BaseOpaqueData myOpaque = opaqueDataList[i];
                            if (!OpaqueDataUtil.Equals(opaque, myOpaque))
                            {
                                return(false);
                            }
                        }
                        return(true);
                    }
                    else if (op.Equals(@operator.contains))
                    {
                        if (opaqueList.Count > opaqueDataList.Count)
                        {
                            return(false);
                        }
                        for (int i = 0; i < opaqueList.Count; i++)
                        {
                            BaseOpaqueData opaque = new BaseOpaqueData(opaqueList[i]);
                            bool           found  = false;
                            for (int j = 0; j < opaqueDataList.Count; j++)
                            {
                                BaseOpaqueData myOpaque = opaqueDataList[j];
                                if (OpaqueDataUtil.Equals(opaque, myOpaque))
                                {
                                    found = true;
                                    break;
                                }
                            }
                            if (!found)
                            {
                                return(false);
                            }
                        }
                        return(true);
                    }
                    else
                    {
                        log.Warn("Unsupported expression operator: " + op);
                    }
                }
            }

            return(false);
        }
예제 #2
0
        /**
         * The main method.
         *
         * @param args the arguments
         */
        public static void main(String[] args)
        {
            /*
             * OpaqueData o1 = OpaqueData.Factory.newInstance();
             * OpaqueData o2 = OpaqueData.Factory.newInstance();
             * o1.setHexValue(new byte[] { (byte)0xde, (byte)0xbb, (byte)0x1e });
             * o2.setHexValue(new byte[] { (byte)0xde, (byte)0xbb, (byte)0x1e });
             * System.out.println(equals(o1,o2));
             */
            OpaqueData opaque = generateDUID_LLT();

            System.out.println(OpaqueDataUtil.toString(opaque));
        }
예제 #3
0
        public virtual bool Matches(optionExpression expression)
        {
            if ((expression == null))
            {
                return(false);
            }

            if ((expression.code != this.code))
            {
                return(false);
            }

            return(OpaqueDataUtil.Matches(expression, this.opaqueData));
        }
예제 #4
0
        public bool Matches(v6ClientIdOption that, @operator op)
        {
            if (that == null)
            {
                return(false);
            }
            if (that.code != this.code)
            {
                return(false);
            }
            if (that.opaqueData == null)
            {
                return(false);
            }

            return(OpaqueDataUtil.Matches(opaqueData, that.opaqueData, op));
        }
예제 #5
0
        public bool Matches(v4VendorClassOption that, @operator op)
        {
            if (that == null)
            {
                return(false);
            }
            if (that.code != this.GetCode())
            {
                return(false);
            }
            if (that.opaqueData == null)
            {
                return(false);
            }

            return(OpaqueDataUtil.Matches(opaqueData, that.opaqueData, op));
        }
예제 #6
0
        public List <IaPrefix> FindUnusedIaPrefixes(IPAddress startAddr, IPAddress endAddr)
        {
            long offerExpiration = OpaqueDataUtil.GetCurrentMilli() - 12000;  // 2 min = 120 sec = 12000 ms

            List <DhcpLease> leases = _DhcpLeaseData.Where(d =>
                                                           ((d.GetState() == IaPrefix.ADVERTISED &&
                                                             d.GetStartTime() <= new DateTime(offerExpiration)) |
                                                            (d.GetState() == IaPrefix.EXPIRED |
                                                             d.GetState() == IaPrefix.RELEASED)) &&
                                                           d.GetIpAddress().GetLong() >= startAddr.GetLong() &&
                                                           d.GetIpAddress().GetLong() <= endAddr.GetLong()).
                                      OrderBy(s => s.GetState()).
                                      ThenBy(t => t.GetValidEndTime()).
                                      //ThenBy(d => d.GetIpAddress())
                                      ToList();

            return(ToIaPrefixes(leases));
        }
예제 #7
0
        public List <IaAddress> FindUnusedIaAddresses(IPAddress startAddr, IPAddress endAddr)
        {
            long offerExpireMillis =
                DhcpServerPolicies.GlobalPolicyAsLong(Property.BINDING_MANAGER_OFFER_EXPIRATION);
            long offerExpiration = OpaqueDataUtil.GetCurrentMilli() - offerExpireMillis;

            List <DhcpLease> leases = _DhcpLeaseData.Where(d =>
                                                           ((d.GetState() == IaAddress.ADVERTISED &&
                                                             d.GetStartTime() <= new DateTime(offerExpiration)) |
                                                            (d.GetState() == IaAddress.EXPIRED |
                                                             d.GetState() == IaAddress.RELEASED)) &&
                                                           d.GetIpAddress().GetLong() >= startAddr.GetLong() &&
                                                           d.GetIpAddress().GetLong() <= endAddr.GetLong()).
                                      OrderBy(s => s.GetState()).
                                      ThenBy(t => t.GetValidEndTime()).
                                      //ThenBy(d => d.GetIpAddress())
                                      ToList();

            return(ToIaAddresses(leases));
        }