Example #1
0
        public int Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionNameLong:
                Name = parser.GetNextArg();
                return(1);

            case OptionSetLong:
                Mode = new ValueOrNot <RecentMode>(RecentMode.Set);
                return(0);

            case OptionRsourceLong:
                Rsource = true;
                return(0);

            case OptionRdestLong:
                Rdest = true;
                return(0);

            case OptionRcheckLong:
                Mode = new ValueOrNot <RecentMode>(RecentMode.Rcheck);
                return(0);

            case OptionUpdateLong:
                Mode = new ValueOrNot <RecentMode>(RecentMode.Update);
                return(0);

            case OptionRemoveLong:
                Mode = new ValueOrNot <RecentMode>(RecentMode.Remove);
                return(0);

            case OptionSecondsLong:
                Seconds = int.Parse(parser.GetNextArg());
                return(1);

            case OptionReapLong:
                Reap = true;
                return(0);

            case OptionHitcountLong:
                HitCount = int.Parse(parser.GetNextArg());
                return(1);

            case OptionRttlLong:
                Rttl = true;
                return(0);

            case OptionMaskLong:
                var oldAf = Mask.AddressFamily;
                Mask = IPAddress.Parse(parser.GetNextArg());
                if (Mask.AddressFamily != oldAf)
                {
                    throw new IpTablesNetException("Invalid address family for mask " + parser.GetNextArg() + " should be " + oldAf);
                }
                return(1);
            }

            return(0);
        }
Example #2
0
        int IIpTablesModuleInternal.Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionUpto:
                Upto = int.Parse(parser.GetNextArg());
                return(1);

            case OptionAbove:
                Above = int.Parse(parser.GetNextArg());
                return(1);

            case OptionMask:
                Mask = int.Parse(parser.GetNextArg());
                return(1);

            case OptionSourceAddr:
                LimitMatch = AddrMode.Source;
                return(0);

            case OptionDestinationAddr:
                LimitMatch = AddrMode.Target;
                return(0);
            }

            return(0);
        }
Example #3
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);
        }
Example #4
0
        public int 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 = 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);
        }
        public int Feed(RuleParser parser, bool not)
        {
            int bits;

            switch (parser.GetCurrentArg())
            {
            case OptionSetXorMarkLong:
                _mode = Mode.SetMark;
                bits  = FlexibleInt32.Parse(parser.GetNextArg());
                SetXorMark(bits);
                return(1);

            case OptionSetAndMarkLong:
                _mode = Mode.SetMark;
                bits  = FlexibleInt32.Parse(parser.GetNextArg());
                SetAndMark(bits);
                return(1);

            case OptionSetOrMarkLong:
                _mode = Mode.SetMark;
                bits  = FlexibleInt32.Parse(parser.GetNextArg());
                SetOrMark(bits);
                return(1);

            case OptionSetMarkLong:
                _mode = Mode.SetMark;
                var s1 = parser.GetNextArg().Split('/');

                SetMark(FlexibleInt32.Parse(s1[0]), s1.Length == 1 ? DefaultMask : FlexibleInt32.Parse(s1[1]));
                return(1);

            case OptionSetXMarkLong:
                _mode = Mode.SetMark;
                var s2 = parser.GetNextArg().Split('/');

                SetXMark(FlexibleInt32.Parse(s2[0]), s2.Length == 1 ? DefaultMask : FlexibleInt32.Parse(s2[1]));
                return(1);

            case OptionRestoreMarkLong:
                _mode = Mode.RestoreMark;
                return(0);

            case OptionSaveMarkLong:
                _mode = Mode.SaveMark;
                return(0);

            case OptionCtMaskLong:
                _ctMask = FlexibleInt32.Parse(parser.GetNextArg());
                return(1);

            case OptionNfMaskLong:
                _nfMask = FlexibleInt32.Parse(parser.GetNextArg());
                return(1);
            }

            return(0);
        }
Example #6
0
        public int Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionProtocolLong:
            case OptionProtocolShort:
                Protocol = new ValueOrNot <string>(parser.GetNextArg(), not);
                return(1);

            case OptionSourceLong:
            case OptionSourceShort:
                Source = new ValueOrNot <IpCidr>(IpCidr.Parse(parser.GetNextArg()), IpCidr.Any, not);
                return(1);

            case OptionDestinationLong:
            case OptionDestinationShort:
                Destination = new ValueOrNot <IpCidr>(IpCidr.Parse(parser.GetNextArg()), IpCidr.Any, not);
                return(1);

            case OptionJumpLong:
            case OptionJumpShort:
                Jump = parser.GetNextArg();
                return(1);

            case OptionGotoLong:
            case OptionGotoShort:
                Goto = parser.GetNextArg();
                return(1);

            case OptionInInterfaceLong:
            case OptionInInterfaceShort:
                InInterface = new ValueOrNot <string>(parser.GetNextArg(), not);
                return(1);

            case OptionOutInterfaceLong:
            case OptionOutInterfaceShort:
                OutInterface = new ValueOrNot <string>(parser.GetNextArg(), not);
                return(1);

            case OptionFragmentLong:
            case OptionFragmentShort:
                Fragmented = new ValueOrNot <bool>(true, not);
                return(0);

            case OptionSetCountersLong:
            case OptionSetCountersShort:
                SetCounters =
                    new ValueOrNot <CounterPacketsAndBytes>(
                        new CounterPacketsAndBytes(uint.Parse(parser.GetNextArg(1)),
                                                   uint.Parse(parser.GetNextArg(2))), not);
                return(2);
            }

            return(0);
        }
Example #7
0
        int IIpTablesModuleInternal.Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionNameLong:
                Name = parser.GetNextArg();
                return(1);

            case OptionSetLong:
                Mode = new ValueOrNot <RecentMode>(RecentMode.Set);
                return(0);

            case OptionRsourceLong:
                Rsource = true;
                return(0);

            case OptionRdestLong:
                Rdest = true;
                return(0);

            case OptionRcheckLong:
                Mode = new ValueOrNot <RecentMode>(RecentMode.Rcheck);
                return(0);

            case OptionUpdateLong:
                Mode = new ValueOrNot <RecentMode>(RecentMode.Update);
                return(0);

            case OptionRemoveLong:
                Mode = new ValueOrNot <RecentMode>(RecentMode.Remove);
                return(0);

            case OptionSecondsLong:
                Seconds = int.Parse(parser.GetNextArg());
                return(1);

            case OptionReapLong:
                Reap = true;
                return(0);

            case OptionHitcountLong:
                HitCount = int.Parse(parser.GetNextArg());
                return(1);

            case OptionRttlLong:
                Rttl = true;
                return(0);

            case OptionMaskLong:
                Mask = IPAddress.Parse(parser.GetNextArg());
                return(1);
            }

            return(0);
        }
        public int Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionRejectWith:
                RejectWith = parser.GetNextArg();
                return(1);
            }

            return(0);
        }
Example #9
0
        int IIpTablesModuleInternal.Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionLengthLong:
                Length = new ValueOrNot <PortOrRange>(PortOrRange.Parse(parser.GetNextArg(), ':'), not);
                return(1);
            }

            return(0);
        }
Example #10
0
        int IIpTablesModuleInternal.Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionState:
                State = ConnectionStateSet.Parse(parser.GetNextArg());
                return(1);
            }

            return(0);
        }
Example #11
0
        public int Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionState:
                State = ConnectionStateSet.Parse(parser.GetNextArg());
                return(1);
            }

            return(0);
        }
Example #12
0
        public int Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionBytecode:
                ByteCode = parser.GetNextArg();
                return(1);
            }

            return(0);
        }
Example #13
0
        public int Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionHelperLong:
                Helper = new ValueOrNot <String>(parser.GetNextArg(), not);
                return(1);
            }

            return(0);
        }
Example #14
0
        public int Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionNameLong:
                Name = parser.GetNextArg();
                return(1);
            }

            return(0);
        }
Example #15
0
        int IIpTablesModuleInternal.Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionRejectWith:
                RejectWith = parser.GetNextArg();
                return(1);
            }

            return(0);
        }
Example #16
0
        public int Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionMatchSet:
                MatchSet      = new ValueOrNot <String>(parser.GetNextArg(), not);
                MatchSetFlags = parser.GetNextArg(2);
                return(2);

            case OptionNoMatch:
                ReturnNoMatch = !not;
                break;

            case OptionUpdateCounters:
                UpdateCounters = !not;
                break;

            case OptionUpdateSubCounters:
                UpdateSubCounters = !not;
                break;

            case OptionPacketsEq:
                PacketsMatch = not ? MatchMode.NotEqual : MatchMode.Equal;
                PacketsValue = int.Parse(parser.GetNextArg());
                return(1);

            case OptionBytesEq:
                BytesMatch = not ? MatchMode.NotEqual : MatchMode.Equal;
                BytesValue = int.Parse(parser.GetNextArg());
                return(1);

            case OptionPacketsLt:
                PacketsMatch = MatchMode.Lt;
                PacketsValue = int.Parse(parser.GetNextArg());
                return(1);

            case OptionBytesLt:
                BytesMatch = MatchMode.Lt;
                BytesValue = int.Parse(parser.GetNextArg());
                return(1);

            case OptionPacketsGt:
                PacketsMatch = MatchMode.Gt;
                PacketsValue = int.Parse(parser.GetNextArg());
                return(1);

            case OptionBytesGt:
                BytesMatch = MatchMode.Gt;
                BytesValue = int.Parse(parser.GetNextArg());
                return(1);
            }

            return(0);
        }
Example #17
0
        int IIpTablesModuleInternal.Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionCommentLong:
                CommentText = parser.GetNextArg();
                return(1);
            }

            return(0);
        }
Example #18
0
        public int Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionTransparent:
                Transparent = true;
                break;
            }

            return(0);
        }
Example #19
0
        int IIpTablesModuleInternal.Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionHelperLong:
                Helper = new ValueOrNot <String>(parser.GetNextArg(), not);
                return(1);
            }

            return(0);
        }
Example #20
0
        int IIpTablesModuleInternal.Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionBytecode:
                ByteCode = parser.GetNextArg();
                return(1);
            }

            return(0);
        }
Example #21
0
        public int Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionCommentLong:
                CommentText = parser.GetNextArg();
                return(1);
            }

            return(0);
        }
Example #22
0
        int IIpTablesModuleInternal.Feed(RuleParser parser, bool not)
        {
            int bits;

            switch (parser.GetCurrentArg())
            {
            case OptionHelperLong:
                Helper = parser.GetNextArg();
                return(1);
            }

            return(0);
        }
Example #23
0
        public int Feed(RuleParser parser, bool not)
        {
            String current = parser.GetCurrentArg();

            switch (current)
            {
            case OptionHashRouteMode:
                Mode = parser.GetNextArg();
                return(1);

            case OptionHashRouteSrcMask:
                SrcMask = int.Parse(parser.GetNextArg());
                return(1);

            case OptionHashRouteDstMask:
                DstMask = int.Parse(parser.GetNextArg());
                return(1);

            case OptionHashRouteHtableSize:
                HtableSize = int.Parse(parser.GetNextArg());
                return(1);

            case OptionHashRouteHtableMax:
                HtableMax = int.Parse(parser.GetNextArg());
                return(1);

            case OptionHashRouteHtableExpire:
                HtableExpire = int.Parse(parser.GetNextArg());
                return(1);

            case OptionHashRouteHtableGcInterval:
                HtableGcInterval = int.Parse(parser.GetNextArg());
                return(1);

            case OptionHashRouteMatchOnly:
                MatchOnly = true;
                return(0);

            case OptionHashRouteName:
                Name = parser.GetNextArg();
                if (Name.Length > 15)
                {
                    Name = Name.Substring(0, 15);
                }
                return(1);
            }

            return(0);
        }
Example #24
0
        public int Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionQueueNumber:
                Num = int.Parse(parser.GetNextArg());
                return(1);

            case OptionQueueBypass:
                Bypass = true;
                return(0);
            }

            return(0);
        }
Example #25
0
        int IIpTablesModuleInternal.Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionPrefixLong:
                LogPrefix = parser.GetNextArg();
                return(1);

            case OptionLevelLong:
                LogLevel = int.Parse(parser.GetNextArg());
                return(1);
            }

            return(0);
        }
Example #26
0
        public int Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionClampMssToPmtuLong:
                ClampMssToPmtu = true;
                return(1);

            case OptionSetMss:
                SetMss = int.Parse(parser.GetNextArg());
                return(1);
            }

            return(0);
        }
Example #27
0
        public int Feed(RuleParser 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);
        }
Example #28
0
        int IIpTablesModuleInternal.Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionQueueNumber:
                Num = int.Parse(parser.GetNextArg());
                return(1);

            case OptionQueueBypass:
                Bypass = true;
                return(0);
            }

            return(0);
        }
Example #29
0
        public int Feed(RuleParser parser, bool not)
        {
            switch (parser.GetCurrentArg())
            {
            case OptionPrefixLong:
                LogPrefix = parser.GetNextArg();
                return(1);

            case OptionLevelLong:
                LogLevel = int.Parse(parser.GetNextArg());
                return(1);
            }

            return(0);
        }
Example #30
0
        int IIpTablesModuleInternal.Feed(RuleParser parser, bool not)
        {
            String current = parser.GetCurrentArg();

            _data.Add(current, new List <string>());
            for (int i = 1; i < parser.GetRemainingArgs(); i++)
            {
                string arg = parser.GetNextArg(i);
                if (arg[0] == '-')
                {
                    return(i - 1);
                }
                _data[current].Add(arg);
            }
            return(0);
        }