Example #1
0
        public int Feed(CommandParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionSourcePortLong:
            case OptionSourcePortShort:
                SourcePort.Set(not, PortOrRange.Parse(parser.GetNextArg(), ':'));
                return(1);

            case OptionDestinationPortLong:
            case OptionDestinationPortShort:
                DestinationPort.Set(not, PortOrRange.Parse(parser.GetNextArg(), ':'));
                return(1);

            case OptionDestinationTcpFlags:
                TcpFlags = new ValueOrNot <TcpFlagMatch>(TcpFlagMatch.Parse(parser.GetNextArg(), parser.GetNextArg(2)), not);
                return(2);

            case OptionSyn:
                TcpFlags = new ValueOrNot <TcpFlagMatch>(TcpFlagMatch.Syn, not);
                return(0);

            case OptionTcpOption:
                TcpOption.Set(not, int.Parse(parser.GetNextArg()));
                return(1);
            }

            return(0);
        }
Example #2
0
        int IIpTablesModuleInternal.Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionSourcePortLong:
            case OptionSourcePortShort:
                SourcePort.Set(not, PortOrRange.Parse(parser.GetNextArg(), ':'));
                return(1);

            case OptionDestinationPortLong:
            case OptionDestinationPortShort:
                DestinationPort.Set(not, PortOrRange.Parse(parser.GetNextArg(), ':'));
                return(1);

            case OptionDestinationTcpFlags:
                TcpFlags = TcpFlagMatch.Parse(parser.GetNextArg(), parser.GetNextArg(2));
                return(2);

            case OptionSyn:
                TcpFlags = not ? TcpFlagMatch.NotSyn : TcpFlagMatch.Syn;
                return(0);

            case OptionTcpOption:
                TcpOption.Set(not, int.Parse(parser.GetNextArg()));
                return(1);
            }

            return(0);
        }