Esempio n. 1
0
        /// <summary>
        /// Consume arguments
        /// </summary>
        /// <param name="position">Rhe position to parse</param>
        /// <param name="not"></param>
        /// <param name="version"></param>
        /// <returns>number of arguments consumed</returns>
        public int FeedToSkip(int position, bool not, int version)
        {
            Position = position;
            String option = GetCurrentArg();

            if (option == "-m")
            {
                LoadParserModule(GetNextArg(), version);
                return(1);
            }
            if (option == "-A")
            {
                _chainName = GetNextArg();
                return(1);
            }
            if (option == "-t")
            {
                _tableName = GetNextArg();
                return(1);
            }
            if (option == "-j")
            {
                LoadParserModule(GetNextArg(), version, true);
            }

            //All the preloaded modules are indexed here
            ModuleEntry mQuick;

            if (ModuleRegistry.PreloadOptions.TryGetValue(option, out mQuick))
            {
                IIpTablesModule module = _ipRule.GetModuleForParseInternal(mQuick.Name, mQuick.Activator, version);
                return(module.Feed(this, not));
            }

            //Search each module, do it verbosely from the most recently added
            for (int index = _parsers.Count - 1; index >= 0; index--)
            {
                ModuleEntry m = _parsers[index];
                if (m.Options.Contains(option))
                {
                    IIpTablesModule module = _ipRule.GetModuleForParseInternal(m.Name, m.Activator, version);
                    return(module.Feed(this, not));
                }
            }

            if (_polyfill != null)
            {
                IIpTablesModule module = _ipRule.GetModuleForParseInternal(_polyfill.Value.Name, _polyfill.Value.Activator, version);
                return(module.Feed(this, not));
            }

            throw new IpTablesNetException("Unknown option: \"" + option + "\"");
        }
Esempio n. 2
0
        /// <summary>
        /// Consume arguments
        /// </summary>
        /// <param name="position">Rhe position to parse</param>
        /// <param name="not"></param>
        /// <returns>number of arguments consumed</returns>
        public int FeedToSkip(int position, bool not)
        {
            Position = position;
            String option = GetCurrentArg();

            if (option == "-m")
            {
                LoadParserModule(GetNextArg());
                return(1);
            }
            if (option == "-A")
            {
                _chainName = GetNextArg();
                return(1);
            }
            if (option == "-t")
            {
                _tableName = GetNextArg();
                return(1);
            }
            if (option == "-j")
            {
                LoadParserModule(GetNextArg(), true);
            }
            foreach (ModuleEntry m in _parsers)
            {
                if (!m.Polyfill)
                {
                    if (m.Options.Contains(option))
                    {
                        IIpTablesModuleGod module = _ipRule.GetModuleForParseInternal(m.Name, m.Module);
                        return(module.Feed(this, not));
                    }
                }
            }
            foreach (ModuleEntry m in _parsers.Reverse <ModuleEntry>())
            {
                if (m.Polyfill)
                {
                    IIpTablesModuleGod module = _ipRule.GetModuleForParseInternal(m.Name, m.Module);
                    return(module.Feed(this, not));
                }
            }

            throw new IpTablesNetException("Unknown option: " + option);
        }