Example #1
0
        public static U32Location Parse(ref String expr)
        {
            Regex r     = new Regex(@"^(0x[a-f0-9A-F]+|[0-9]+)");
            var   match = r.Match(expr);

            expr = expr.Substring(match.Length);

            U32Location loc = new U32Location(null, Operator.None, FlexibleUInt32.Parse(match.Groups[1].Value));

            do
            {
                r     = new Regex(@"^(\&|\<\<|\>\>|\@)(0x[A-Fa-f0-9]+|[0-9]+)");
                match = r.Match(expr);
                if (!match.Success)
                {
                    break;
                }
                expr = expr.Substring(match.Length);

                loc = new U32Location(
                    loc,
                    OpStr(match.Groups[1].Value),
                    FlexibleUInt32.Parse(match.Groups[2].Value));
            } while (true);

            return(loc);
        }
Example #2
0
        public int Feed(CommandParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionToSource:
                ToSource = IPPortOrRange.Parse(parser.GetNextArg());
                return(1);

            case OptionToDestination:
                ToDestination = IPPortOrRange.Parse(parser.GetNextArg());
                return(1);

            case OptionRandom:
                Random = true;
                return(0);

            case OptionPersisent:
                Persistent = true;
                return(0);

            case OptionCtMark:
                CtMark = FlexibleUInt32.Parse(parser.GetNextArg());
                return(1);

            case OptionCtMask:
                CtMask = FlexibleUInt32.Parse(parser.GetNextArg());
                return(1);
            }

            return(0);
        }
Example #3
0
        public static U32Range Parse(ref String expr)
        {
            Regex r     = new Regex(@"^(0x[A-Fa-f0-9]+|[0-9]+)(?:\:(0x[A-Fa-f0-9]+|[0-9]+))?");
            var   match = r.Match(expr);

            expr = expr.Substring(match.Length);
            return(new U32Range(FlexibleUInt32.Parse(match.Groups[1].Value),
                                FlexibleUInt32.Parse(String.IsNullOrEmpty(match.Groups[2].Value) ? match.Groups[1].Value : match.Groups[2].Value)));
        }
Example #4
0
        public int Feed(CommandParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionSrcGroup:
                SrcGroup = new ValueOrNot <UInt32>(FlexibleUInt32.Parse(parser.GetNextArg()), not);
                return(1);

            case OptionDstGroup:
                DstGroup = new ValueOrNot <UInt32>(FlexibleUInt32.Parse(parser.GetNextArg()), not);
                return(1);
            }

            return(0);
        }