コード例 #1
0
        /* (non-Javadoc)
         * @see com.jagornet.dhcpv6.option.DhcpComparableOption#matches(com.jagornet.dhcp.xml.OptionExpression)
         */
        public bool Matches(optionExpression expression)
        {
            //if (expression == null)
            //    return false;
            //if (expression.GetCode() != this.GetCode())
            //    return false;
            //if (unsignedShortList == null)
            //    return false;

            //UnsignedShortListOptionType exprOption = expression.getUShortListOption();
            //if (exprOption != null)
            //{
            //    List<Integer> exprUshorts = exprOption.getUnsignedShortList();
            //    Operator.Enum op = expression.getOperator();
            //    if (op.equals(Operator.EQUALS))
            //    {
            //        return unsignedShortList.equals(exprUshorts);
            //    }
            //    else if (op.equals(Operator.CONTAINS))
            //    {
            //        return unsignedShortList.containsAll(exprUshorts);
            //    }
            //    else
            //    {
            //        log.warn("Unsupported expression operator: " + op);
            //    }
            //}

            return(false);
        }
コード例 #2
0
 /* (non-Javadoc)
  * @see com.jagornet.dhcpv6.option.DhcpComparableOption#matches(com.jagornet.dhcp.xml.OptionExpression)
  */
 public bool Matches(optionExpression expression)
 {
     if (expression == null)
     {
         return(false);
     }
     if (expression.code != this.GetCode())
     {
         return(false);
     }
     return(true);
 }
コード例 #3
0
        /* (non-Javadoc)
         * @see com.jagornet.dhcpv6.option.DhcpComparableOption#matches(com.jagornet.dhcp.xml.OptionExpression)
         */
        public bool Matches(optionExpression expression)
        {
            if (expression == null)
            {
                return(false);
            }
            if (expression.code != this.GetCode())
            {
                return(false);
            }

            return(Matches((opaqueDataListOptionType)expression.Item, expression.@operator));
        }
コード例 #4
0
        /* (non-Javadoc)
         * @see com.jagornet.dhcpv6.option.DhcpComparableOption#matches(com.jagornet.dhcp.xml.OptionExpression)
         */
        public override bool Matches(optionExpression expression)
        {
            if (expression == null)
            {
                return(false);
            }
            if (expression.code != this.code)
            {
                return(false);
            }

            return(false);
        }
コード例 #5
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));
        }
コード例 #6
0
        /* (non-Javadoc)
         * @see com.jagornet.dhcpv6.option.DhcpComparableOption#matches(com.jagornet.dhcp.xml.OptionExpression)
         */
        public bool Matches(optionExpression expression)
        {
            if (expression == null)
            {
                return(false);
            }
            if (expression.code != this.GetCode())
            {
                return(false);
            }
            if (ipAddress == null)
            {
                return(false);
            }

            ipAddressOptionType exprOption = (ipAddressOptionType)expression.Item;

            if (exprOption != null)
            {
                String    exprIpAddress = exprOption.ipAddress;
                @operator op            = expression.@operator;
                if (op.Equals(@operator.equals))
                {
                    return(ipAddress.Equals(exprIpAddress));
                }
                else if (op.Equals(@operator.startsWith))
                {
                    return(ipAddress.StartsWith(exprIpAddress));
                }
                else if (op.Equals(@operator.endsWith))
                {
                    return(ipAddress.EndsWith(exprIpAddress));
                }
                else if (op.Equals(@operator.contains))
                {
                    return(ipAddress.Contains(exprIpAddress));
                }
                else if (op.Equals(@operator.regExp))
                {
                    Match m = Regex.Match(ipAddress, exprIpAddress);
                    return(m.Success);
                }
                else
                {
                    log.Warn("Unsupported expression operator: " + op);
                }
            }

            return(false);
        }
コード例 #7
0
        /**
         * Matches.
         *
         * @param expression the expression
         * @param myOpaque the my opaque
         *
         * @return true, if successful
         */
        public static bool Matches(optionExpression expression, BaseOpaqueData myOpaque)
        {
            if (expression == null)
            {
                return(false);
            }

            opaqueData data = (opaqueData)expression.Item;

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

            @operator op = expression.@operator;

            return(Matches(myOpaque, data, op));
        }
コード例 #8
0
        /* (non-Javadoc)
         * @see com.jagornet.dhcpv6.option.DhcpComparableOption#matches(com.jagornet.dhcp.xml.OptionExpression)
         */
        public bool Matches(optionExpression expression)
        {
            if (expression == null)
            {
                return(false);
            }
            if (expression.code != this.GetCode())
            {
                return(false);
            }
            if (unsignedByteList == null)
            {
                return(false);
            }

            unsignedByteListOptionType exprOption = (unsignedByteListOptionType)expression.Item;

            if (exprOption != null)
            {
                List <short> exprUbytes = exprOption.unsignedByte;
                @operator    op         = expression.@operator;
                if (op.Equals(@operator.equals))
                {
                    return(unsignedByteList.Equals(exprUbytes));
                }
                else if (op.Equals(@operator.contains))
                {
                    foreach (var item in exprUbytes)
                    {
                        if (!unsignedByteList.Contains(item))
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
                else
                {
                    log.Warn("Unsupported expression operator: " + op);
                }
            }

            return(false);
        }
コード例 #9
0
        //public ByteBuffer Encode()
        //{
        //    ByteBuffer buf = base.EncodeCodeAndLength();
        //    buf.putShort((short)statusCode);
        //    if (message != null)
        //    {
        //        buf.put(message.GetBytes());
        //    }
        //    return (ByteBuffer)buf.flip();
        //}

        ///* (non-Javadoc)
        // * @see com.jagornet.dhcpv6.option.Decodable#decode(java.nio.ByteBuffer)
        // */
        //public void Decode(ByteBuffer buf)
        //{
        //    int len = base.DecodeLength(buf);
        //    if ((len > 0) && (len <= buf.remaining()))
        //    {
        //        long eof = buf.position() + len;
        //        if (buf.position() < eof)
        //        {
        //            statusCode = Util.DetUnsignedShort(buf);
        //            if (buf.position() < eof)
        //            {
        //                if (len > 2)
        //                {
        //                    byte[] data = new byte[len - 2];  // minus 2 for the status code
        //                    buf.get(data);
        //                    message = new string(data);
        //                }
        //            }
        //        }
        //    }
        //}

        /**
         * Matches only the status code, not the message text.
         *
         * @param expression the expression
         *
         * @return true, if matches
         */
        public bool Matches(optionExpression expression)
        {
            if (expression == null)
            {
                return(false);
            }
            if (expression.code != this.GetCode())
            {
                return(false);
            }


            /*
             *      OpaqueData opaque = expression.getData();
             *      if (opaque != null) {
             *          String ascii = opaque.getAsciiValue();
             *          if (ascii != null) {
             *              try {
             *                  // need an int to handle unsigned short
             *                  if (statusCodeOption.getStatusCode() == Integer.parseInt(ascii)) {
             *                      return true;
             *                  }
             *              }
             *              catch (NumberFormatException ex) { }
             *          }
             *          else {
             *              byte[] hex = opaque.getHexValue();
             *              if ( (hex != null) &&
             *                   (hex.length >= 1) && (hex.length <= 2) ) {
             *                  int hexInt = Integer.parseInt(Util.toHexString(hex));
             *                  if (statusCodeOption.getStatusCode() == hexInt) {
             *                      return true;
             *                  }
             *              }
             *          }
             *      }
             */
            return(false);
        }
コード例 #10
0
        /* (non-Javadoc)
         * @see com.jagornet.dhcpv6.option.DhcpComparableOption#matches(com.jagornet.dhcp.xml.OptionExpression)
         */
        public bool Matches(optionExpression expression)
        {
            if (expression == null)
            {
                return(false);
            }
            if (expression.code != this.code)
            {
                return(false);
            }
            if (domainNameList == null)
            {
                return(false);
            }

            // first see if we have a domain name list option to compare to
            //domainNameListOptionType exprOption = [email protected]();
            //if (exprOption != null)
            //{
            //    List<String> exprDomainNames = exprOption.getDomainNameList();
            //    Operator.Enum op = expression.getOperator();
            //    if (op.equals(Operator.EQUALS))
            //    {
            //        return domainNameList.equals(exprDomainNames);
            //    }
            //    else if (op.equals(Operator.CONTAINS))
            //    {
            //        return domainNameList.containsAll(exprDomainNames);
            //    }
            //    else
            //    {
            //        log.warn("Unsupported expression operator: " + op);
            //    }
            //}

            return(false);
        }
コード例 #11
0
        public bool Matches(optionExpression expression)
        {
            if (expression == null)
            {
                return(false);
            }
            if (expression.code != this.code)
            {
                return(false);
            }

            unsignedShortOptionType exprOption = (unsignedShortOptionType)expression.Item;

            if (exprOption != null)
            {
                int       exprUshort = exprOption.unsignedShort;
                @operator op         = expression.@operator;
                if (op.Equals(@operator.equals))
                {
                    return(unsignedShort == exprUshort);
                }
                else if (op.Equals(@operator.lessThan))
                {
                    return(unsignedShort < exprUshort);
                }
                else if (op.Equals(@operator.lessThanOrEqual))
                {
                    return(unsignedShort <= exprUshort);
                }
                else if (op.Equals(@operator.greaterThan))
                {
                    return(unsignedShort > exprUshort);
                }
                else if (op.Equals(@operator.greaterThanOrEqual))
                {
                    return(unsignedShort >= exprUshort);
                }
                else
                {
                    log.Warn("Unsupported expression operator: " + op);
                }
            }

            // then see if we have an opaque option
            opaqueDataOptionType opaqueOption = (opaqueDataOptionType)expression.Item;

            if (opaqueOption != null)
            {
                opaqueData opaque = opaqueOption.opaqueData;
                if (opaque != null)
                {
                    string ascii = opaque.asciiValue;
                    if (ascii != null)
                    {
                        try
                        {
                            // need an Integer to handle unsigned short
                            if (unsignedShort == int.Parse(ascii))
                            {
                                return(true);
                            }
                        }
                        catch (Exception ex)
                        {
                            log.Error("Invalid unsigned short ASCII value for OpaqueData: " + ascii);
                        }
                    }
                    else
                    {
                        byte[] hex = opaque.hexValue;
                        if ((hex != null) &&
                            (hex.Length >= 1) && (hex.Length <= 2))
                        {
                            int hexUnsignedShort = Convert.ToInt32(Util.ToHexString(hex), 16);
                            if (unsignedShort == hexUnsignedShort)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
コード例 #12
0
 public bool Matches(optionExpression expression)
 {
     return(false);
 }
コード例 #13
0
 public bool Matches(optionExpression expression)
 {
     throw new NotImplementedException();
 }