From 5c25bfb71139ea07f45c47c06ad82bc3831c450b Mon Sep 17 00:00:00 2001 From: Vadim Kurland Date: Sun, 6 Mar 2011 13:16:11 -0800 Subject: [PATCH] * IPTImporter.cpp (pushPolicyRule): see #2189 Policy importer warnings and errors now include line numbers to help find relevant lines in the original configuration file. --- doc/ChangeLog | 6 + src/libgui/IPTImporter.cpp | 80 +++--- src/libgui/Importer.cpp | 3 +- src/libgui/Importer.h | 8 +- src/parsers/IOSCfgLexer.cpp | 10 +- src/parsers/IOSCfgParser.cpp | 176 +++++++------ src/parsers/IPTCfgLexer.cpp | 18 +- src/parsers/IPTCfgParser.cpp | 497 ++++++++++++++++++----------------- src/parsers/PIXCfgLexer.cpp | 10 +- src/parsers/PIXCfgParser.cpp | 166 ++++++------ src/parsers/iosacl.g | 4 + src/parsers/iptables.g | 1 + src/parsers/pix.g | 2 + 13 files changed, 507 insertions(+), 474 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index aff6afe12..4395bff0a 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2011-03-06 vadim + + * IPTImporter.cpp (pushPolicyRule): see #2189 Policy importer + warnings and errors now include line numbers to help find relevant + lines in the original configuration file. + 2011-03-05 vadim * importFirewallConfigurationWizard/IC_ProgressPage.cpp (logLine): diff --git a/src/libgui/IPTImporter.cpp b/src/libgui/IPTImporter.cpp index 3a4c040e2..35e38b115 100644 --- a/src/libgui/IPTImporter.cpp +++ b/src/libgui/IPTImporter.cpp @@ -755,7 +755,8 @@ void IPTImporter::pushPolicyRule() action_on_reject_code = "ICMP admin prohibited"; QString err = QObject::tr( - "Warning: Unknown parameter of target REJECT: %1.\n") + "Warning: Line %1: Unknown parameter of target REJECT: %2.\n") + .arg(getCurrentLineNumber()) .arg(iptables_reject_arg.c_str()); ropt->setStr("color", getBadRuleColor()); rule_comment += string(err.toUtf8().constData()); @@ -866,10 +867,9 @@ void IPTImporter::pushPolicyRule() { fwopt->setBool("clamp_mss_to_mtu", true); skip_rule = true; - *Importer::logger - << "Warning: Using automatic rule controlled by option " - << "Clamp MSS to MTU" - << "\n"; + QString err("Warning: Line %1: Using automatic rule controlled by option " + "Clamp MSS to MTU\n"); + *Importer::logger << err.arg(getCurrentLineNumber()).toStdString(); } if (target=="TOS") @@ -963,13 +963,14 @@ void IPTImporter::pushPolicyRule() srv->addRef(estab); } - *Importer::logger << - "Warning: Rule matches states 'RELATED,ESTABLISHED'. Consider using " - "automatic rule controlled by the checkbox in the firewall " - "settings dialog. Automatic rule matches in all standard chains " - "which may be different from the original imported configuration. " - "This requires manual checking." - "\n"; + QString err("Warning: Line %1: Rule matches states 'RELATED,ESTABLISHED'. " + "Consider using " + "automatic rule controlled by the checkbox in the firewall " + "settings dialog. Automatic rule matches in all standard chains " + "which may be different from the original imported configuration. " + "This requires manual checking." + "\n"); + *Importer::logger << err.arg(getCurrentLineNumber()).toStdString(); } if (rule->getSrc()->isAny() && @@ -980,11 +981,12 @@ void IPTImporter::pushPolicyRule() if (target=="DROP") fwopt->setBool("drop_invalid", true); if (target=="LOG") fwopt->setBool("log_invalid", true); skip_rule = true; - *Importer::logger << - "Warning: Using automatic rule controlled by option " - "'Drop packet that do not match any known connection' to match " - "state INVALID" - "\n"; + + QString err("Warning: Line %1: Using automatic rule controlled by option " + "'Drop packet that do not match any known connection' to match " + "state INVALID" + "\n"); + *Importer::logger << err.arg(getCurrentLineNumber()).toStdString(); } if (target=="CONNMARK" && @@ -995,10 +997,11 @@ void IPTImporter::pushPolicyRule() assert(lmr_ropt!=NULL); lmr_ropt->setBool("ipt_mark_connections", true); skip_rule = true; - *Importer::logger << - "Warning: Turned option on in previous rule with action Mark " - "for '-j CONNMARK --save-mark' " - "\n"; + QString err("Warning: Line %1: Turned option on in previous rule " + "with action Mark " + "for '-j CONNMARK --save-mark' " + "\n"); + *Importer::logger << err.arg(getCurrentLineNumber()).toStdString(); } if (target=="CONNMARK" && @@ -1008,10 +1011,10 @@ void IPTImporter::pushPolicyRule() // MangleTableCompiler_ipt::flushAndSetDefaultPolicy() // if we have at least one rule with CONNMARK target in the policy skip_rule = true; - *Importer::logger << - "Warning: Skip command with '-j CONNMARK --restore-mark' " - "This rule is generated automatically." - "\n"; + QString err("Warning: Line %1: Skip command with '-j CONNMARK --restore-mark' " + "This rule is generated automatically." + "\n"); + *Importer::logger << err.arg(getCurrentLineNumber()).toStdString(); } if (!skip_rule) @@ -1104,11 +1107,12 @@ void IPTImporter::pushPolicyRule() " Both inbound and outbound interfaces " "in original iptables command: %1").arg(interfaces).toStdString(); - QString log_str = QString("Warning: Creating branch ruleset '%1' to " - "match inbound and outbound interfaces %2\n") - .arg(branch_ruleset_name.c_str()).arg(interfaces); - - *Importer::logger << log_str.toUtf8().constData(); + QString log_str("Warning: Line %1: Creating branch ruleset '%2' to " + "match inbound and outbound interfaces %3\n"); + *Importer::logger << log_str + .arg(getCurrentLineNumber()) + .arg(branch_ruleset_name.c_str()).arg(interfaces) + .toUtf8().constData(); // markCurrentRuleBad( // std::string("Can not set inbound and outbound interface simultaneously. Was: -i ") + i_intf + " -o " + o_intf); @@ -1349,11 +1353,11 @@ Firewall* IPTImporter::finalize() if (rs_index.find("mangle") != string::npos) { QString err = QObject::tr( - "Warning: Can not reproduce default action in " + "Warning: Line %1: Can not reproduce default action in " "table 'mangle' chain 'FORWARD'.\n"); ropt->setStr("color", getBadRuleColor()); rule->setComment(err.toUtf8().constData()); - *Importer::logger << err.toUtf8().constData(); + *Importer::logger << err.arg(getCurrentLineNumber()).toStdString(); } } @@ -1367,11 +1371,11 @@ Firewall* IPTImporter::finalize() if (rs_index.find("mangle") != string::npos) { QString err = QObject::tr( - "Warning: Can not reproduce default action in " + "Warning: Line %1: Can not reproduce default action in " "table 'mangle' chain 'INPUT'.\n"); ropt->setStr("color", getBadRuleColor()); rule->setComment(err.toUtf8().constData()); - *Importer::logger << err.toUtf8().constData(); + *Importer::logger << err.arg(getCurrentLineNumber()).toStdString(); } } @@ -1394,9 +1398,11 @@ Firewall* IPTImporter::finalize() } rs->ruleset->add(rule); - QString l("Warning: Added rule to reproduce default " - "policy ACCEPT in %1\n"); - *Importer::logger << l.arg(rs_index.c_str()).toUtf8().constData(); + QString l("Warning: Line %1: Added rule to reproduce default " + "policy ACCEPT in %2\n"); + *Importer::logger << l.arg(getCurrentLineNumber()).arg(rs_index.c_str()).toUtf8().constData(); + + } } diff --git a/src/libgui/Importer.cpp b/src/libgui/Importer.cpp index 9f4afbbcd..d4899ffcf 100644 --- a/src/libgui/Importer.cpp +++ b/src/libgui/Importer.cpp @@ -1137,7 +1137,8 @@ void Importer::markCurrentRuleBad(const std::string &comment) rule_comment += comment; //current_rule->setComment(comment); - QString err = QObject::tr("Parser error: %1\n") + QString err = QObject::tr("Parser error: Line %1: %2\n") + .arg(getCurrentLineNumber()) .arg(QString::fromUtf8(comment.c_str())); *logger << err.toUtf8().constData(); error_counter++; diff --git a/src/libgui/Importer.h b/src/libgui/Importer.h index 9c8b4fbdc..ef0fa54db 100644 --- a/src/libgui/Importer.h +++ b/src/libgui/Importer.h @@ -90,8 +90,11 @@ class Importer protected: - int error_counter; + int error_counter; + // line number in the original stream being imported + int current_line_number; + libfwbuilder::FWObject *library; std::istringstream &input; @@ -317,6 +320,9 @@ public: virtual void newNATRule(); virtual void pushRule(); + void setCurrentLineNumber(int n) { current_line_number = n; } + int getCurrentLineNumber() { return current_line_number;} + void markCurrentRuleBad(const std::string &comment); diff --git a/src/parsers/IOSCfgLexer.cpp b/src/parsers/IOSCfgLexer.cpp index 0e25bf6f9..9841ce68a 100644 --- a/src/parsers/IOSCfgLexer.cpp +++ b/src/parsers/IOSCfgLexer.cpp @@ -432,7 +432,7 @@ void IOSCfgLexer::mNEWLINE(bool _createToken) { } if ( inputState->guessing==0 ) { -#line 698 "iosacl.g" +#line 702 "iosacl.g" newline(); #line 438 "IOSCfgLexer.cpp" } @@ -513,7 +513,7 @@ void IOSCfgLexer::mWhitespace(bool _createToken) { } } if ( inputState->guessing==0 ) { -#line 693 "iosacl.g" +#line 697 "iosacl.g" _ttype = ANTLR_USE_NAMESPACE(antlr)Token::SKIP; #line 519 "IOSCfgLexer.cpp" } @@ -749,7 +749,7 @@ void IOSCfgLexer::mNUMBER(bool _createToken) { } // ( ... )+ } if ( inputState->guessing==0 ) { -#line 718 "iosacl.g" +#line 722 "iosacl.g" _ttype = IPV4; #line 755 "IOSCfgLexer.cpp" } @@ -852,7 +852,7 @@ void IOSCfgLexer::mNUMBER(bool _createToken) { } // ( ... )+ } if ( inputState->guessing==0 ) { -#line 724 "iosacl.g" +#line 728 "iosacl.g" _ttype = HEX_CONST; #line 858 "IOSCfgLexer.cpp" } @@ -873,7 +873,7 @@ void IOSCfgLexer::mNUMBER(bool _createToken) { _loop124:; } // ( ... )+ if ( inputState->guessing==0 ) { -#line 722 "iosacl.g" +#line 726 "iosacl.g" _ttype = INT_CONST; #line 879 "IOSCfgLexer.cpp" } diff --git a/src/parsers/IOSCfgParser.cpp b/src/parsers/IOSCfgParser.cpp index 5955efc44..ded8ba8f4 100644 --- a/src/parsers/IOSCfgParser.cpp +++ b/src/parsers/IOSCfgParser.cpp @@ -283,7 +283,7 @@ void IOSCfgParser::intrface() { in = LT(1); match(WORD); if ( inputState->guessing==0 ) { -#line 480 "iosacl.g" +#line 484 "iosacl.g" importer->newInterface( in->getText() ); *dbg << in->getLine() << ":" @@ -308,7 +308,7 @@ void IOSCfgParser::controller() { try { // for error handling match(CONTROLLER); if ( inputState->guessing==0 ) { -#line 471 "iosacl.g" +#line 475 "iosacl.g" importer->clearCurrentInterface(); consumeUntil(NEWLINE); @@ -349,7 +349,7 @@ void IOSCfgParser::vlan() { } } if ( inputState->guessing==0 ) { -#line 462 "iosacl.g" +#line 466 "iosacl.g" importer->clearCurrentInterface(); consumeUntil(NEWLINE); @@ -435,7 +435,7 @@ void IOSCfgParser::description() { try { // for error handling match(DESCRIPTION); if ( inputState->guessing==0 ) { -#line 491 "iosacl.g" +#line 495 "iosacl.g" *dbg << LT(1)->getLine() << ":"; std::string descr; @@ -466,7 +466,7 @@ void IOSCfgParser::shutdown() { try { // for error handling match(SHUTDOWN); if ( inputState->guessing==0 ) { -#line 524 "iosacl.g" +#line 528 "iosacl.g" *dbg<< LT(1)->getLine() << ":" << " INTERFACE SHUTDOWN " << std::endl; @@ -680,22 +680,23 @@ void IOSCfgParser::permit_std() { try { // for error handling match(PERMIT); if ( inputState->guessing==0 ) { -#line 247 "iosacl.g" +#line 249 "iosacl.g" + importer->setCurrentLineNumber(LT(0)->getLine()); importer->newPolicyRule(); importer->action = "permit"; *dbg << LT(1)->getLine() << ":" << " permit "; -#line 690 "IOSCfgParser.cpp" +#line 691 "IOSCfgParser.cpp" } rule_std(); match(NEWLINE); if ( inputState->guessing==0 ) { -#line 253 "iosacl.g" +#line 256 "iosacl.g" importer->pushRule(); -#line 699 "IOSCfgParser.cpp" +#line 700 "IOSCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -713,22 +714,23 @@ void IOSCfgParser::deny_std() { try { // for error handling match(DENY); if ( inputState->guessing==0 ) { -#line 259 "iosacl.g" +#line 262 "iosacl.g" + importer->setCurrentLineNumber(LT(0)->getLine()); importer->newPolicyRule(); importer->action = "deny"; *dbg << LT(1)->getLine() << ":" << " deny "; -#line 723 "IOSCfgParser.cpp" +#line 725 "IOSCfgParser.cpp" } rule_std(); match(NEWLINE); if ( inputState->guessing==0 ) { -#line 265 "iosacl.g" +#line 269 "iosacl.g" importer->pushRule(); -#line 732 "IOSCfgParser.cpp" +#line 734 "IOSCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -748,20 +750,21 @@ void IOSCfgParser::permit_ext() { if ( inputState->guessing==0 ) { #line 222 "iosacl.g" + importer->setCurrentLineNumber(LT(0)->getLine()); importer->newPolicyRule(); importer->action = "permit"; *dbg << LT(1)->getLine() << ":" << " permit "; -#line 756 "IOSCfgParser.cpp" +#line 759 "IOSCfgParser.cpp" } rule_ext(); match(NEWLINE); if ( inputState->guessing==0 ) { -#line 228 "iosacl.g" +#line 229 "iosacl.g" importer->pushRule(); -#line 765 "IOSCfgParser.cpp" +#line 768 "IOSCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -779,22 +782,23 @@ void IOSCfgParser::deny_ext() { try { // for error handling match(DENY); if ( inputState->guessing==0 ) { -#line 234 "iosacl.g" +#line 235 "iosacl.g" + importer->setCurrentLineNumber(LT(0)->getLine()); importer->newPolicyRule(); importer->action = "deny"; *dbg << LT(1)->getLine() << ":" << " deny "; -#line 789 "IOSCfgParser.cpp" +#line 793 "IOSCfgParser.cpp" } rule_ext(); match(NEWLINE); if ( inputState->guessing==0 ) { -#line 240 "iosacl.g" +#line 242 "iosacl.g" importer->pushRule(); -#line 798 "IOSCfgParser.cpp" +#line 802 "IOSCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -812,7 +816,7 @@ void IOSCfgParser::remark() { try { // for error handling match(REMARK); if ( inputState->guessing==0 ) { -#line 509 "iosacl.g" +#line 513 "iosacl.g" *dbg << LT(1)->getLine() << ":"; std::string rem; @@ -825,7 +829,7 @@ void IOSCfgParser::remark() { *dbg << " REMARK " << rem << std::endl; //consumeUntil(NEWLINE); -#line 829 "IOSCfgParser.cpp" +#line 833 "IOSCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -849,15 +853,15 @@ void IOSCfgParser::rule_ext() { ip_protocols(); hostaddr_ext(); if ( inputState->guessing==0 ) { -#line 275 "iosacl.g" +#line 279 "iosacl.g" importer->SaveTmpAddrToSrc(); *dbg << "(src) "; -#line 855 "IOSCfgParser.cpp" +#line 859 "IOSCfgParser.cpp" } hostaddr_ext(); if ( inputState->guessing==0 ) { -#line 276 "iosacl.g" +#line 280 "iosacl.g" importer->SaveTmpAddrToDst(); *dbg << "(dst) "; -#line 861 "IOSCfgParser.cpp" +#line 865 "IOSCfgParser.cpp" } { switch ( LA(1)) { @@ -922,24 +926,24 @@ void IOSCfgParser::rule_ext() { { match(ICMP); if ( inputState->guessing==0 ) { -#line 282 "iosacl.g" +#line 286 "iosacl.g" importer->protocol = LT(0)->getText(); *dbg << "protocol " << LT(0)->getText() << " "; -#line 931 "IOSCfgParser.cpp" +#line 935 "IOSCfgParser.cpp" } hostaddr_ext(); if ( inputState->guessing==0 ) { -#line 286 "iosacl.g" +#line 290 "iosacl.g" importer->SaveTmpAddrToSrc(); *dbg << "(src) "; -#line 937 "IOSCfgParser.cpp" +#line 941 "IOSCfgParser.cpp" } hostaddr_ext(); if ( inputState->guessing==0 ) { -#line 287 "iosacl.g" +#line 291 "iosacl.g" importer->SaveTmpAddrToDst(); *dbg << "(dst) "; -#line 943 "IOSCfgParser.cpp" +#line 947 "IOSCfgParser.cpp" } { switch ( LA(1)) { @@ -1044,18 +1048,18 @@ void IOSCfgParser::rule_ext() { } } if ( inputState->guessing==0 ) { -#line 294 "iosacl.g" +#line 298 "iosacl.g" importer->protocol = LT(0)->getText(); *dbg << "protocol " << LT(0)->getText() << " "; -#line 1053 "IOSCfgParser.cpp" +#line 1057 "IOSCfgParser.cpp" } hostaddr_ext(); if ( inputState->guessing==0 ) { -#line 298 "iosacl.g" +#line 302 "iosacl.g" importer->SaveTmpAddrToSrc(); *dbg << "(src) "; -#line 1059 "IOSCfgParser.cpp" +#line 1063 "IOSCfgParser.cpp" } { switch ( LA(1)) { @@ -1067,9 +1071,9 @@ void IOSCfgParser::rule_ext() { { xoperator(); if ( inputState->guessing==0 ) { -#line 299 "iosacl.g" +#line 303 "iosacl.g" importer->SaveTmpPortToSrc(); -#line 1073 "IOSCfgParser.cpp" +#line 1077 "IOSCfgParser.cpp" } break; } @@ -1087,9 +1091,9 @@ void IOSCfgParser::rule_ext() { } hostaddr_ext(); if ( inputState->guessing==0 ) { -#line 300 "iosacl.g" +#line 304 "iosacl.g" importer->SaveTmpAddrToDst(); *dbg << "(dst) "; -#line 1093 "IOSCfgParser.cpp" +#line 1097 "IOSCfgParser.cpp" } { switch ( LA(1)) { @@ -1101,9 +1105,9 @@ void IOSCfgParser::rule_ext() { { xoperator(); if ( inputState->guessing==0 ) { -#line 301 "iosacl.g" +#line 305 "iosacl.g" importer->SaveTmpPortToDst(); -#line 1107 "IOSCfgParser.cpp" +#line 1111 "IOSCfgParser.cpp" } break; } @@ -1209,11 +1213,11 @@ void IOSCfgParser::rule_ext() { } } if ( inputState->guessing==0 ) { -#line 307 "iosacl.g" +#line 311 "iosacl.g" *dbg << std::endl; -#line 1217 "IOSCfgParser.cpp" +#line 1221 "IOSCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1232,9 +1236,9 @@ void IOSCfgParser::rule_std() { { hostaddr_std(); if ( inputState->guessing==0 ) { -#line 315 "iosacl.g" +#line 319 "iosacl.g" importer->SaveTmpAddrToSrc(); *dbg << "(std) "; -#line 1238 "IOSCfgParser.cpp" +#line 1242 "IOSCfgParser.cpp" } { switch ( LA(1)) { @@ -1256,11 +1260,11 @@ void IOSCfgParser::rule_std() { } } if ( inputState->guessing==0 ) { -#line 318 "iosacl.g" +#line 322 "iosacl.g" *dbg << std::endl; -#line 1264 "IOSCfgParser.cpp" +#line 1268 "IOSCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1295,12 +1299,12 @@ void IOSCfgParser::ip_protocols() { } } if ( inputState->guessing==0 ) { -#line 326 "iosacl.g" +#line 330 "iosacl.g" importer->protocol = LT(0)->getText(); *dbg << "protocol " << LT(0)->getText() << " "; -#line 1304 "IOSCfgParser.cpp" +#line 1308 "IOSCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1328,13 +1332,13 @@ void IOSCfgParser::hostaddr_ext() { match(IPV4); } if ( inputState->guessing==0 ) { -#line 378 "iosacl.g" +#line 382 "iosacl.g" importer->tmp_a = h->getText(); importer->tmp_nm = "0.0.0.0"; *dbg << h->getText() << "/0.0.0.0"; -#line 1338 "IOSCfgParser.cpp" +#line 1342 "IOSCfgParser.cpp" } break; } @@ -1347,13 +1351,13 @@ void IOSCfgParser::hostaddr_ext() { match(IPV4); } if ( inputState->guessing==0 ) { -#line 385 "iosacl.g" +#line 389 "iosacl.g" importer->tmp_a = a->getText(); importer->tmp_nm = m->getText(); *dbg << a->getText() << "/" << m->getText(); -#line 1357 "IOSCfgParser.cpp" +#line 1361 "IOSCfgParser.cpp" } break; } @@ -1361,13 +1365,13 @@ void IOSCfgParser::hostaddr_ext() { { match(ANY); if ( inputState->guessing==0 ) { -#line 392 "iosacl.g" +#line 396 "iosacl.g" importer->tmp_a = "0.0.0.0"; importer->tmp_nm = "0.0.0.0"; *dbg << "0.0.0.0/0.0.0.0"; -#line 1371 "IOSCfgParser.cpp" +#line 1375 "IOSCfgParser.cpp" } break; } @@ -1395,12 +1399,12 @@ void IOSCfgParser::time_range() { tr_name = LT(1); match(WORD); if ( inputState->guessing==0 ) { -#line 444 "iosacl.g" +#line 448 "iosacl.g" importer->time_range_name = tr_name->getText(); *dbg << "time_range " << tr_name->getText() << " "; -#line 1404 "IOSCfgParser.cpp" +#line 1408 "IOSCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1418,12 +1422,12 @@ void IOSCfgParser::fragments() { try { // for error handling match(FRAGMENTS); if ( inputState->guessing==0 ) { -#line 437 "iosacl.g" +#line 441 "iosacl.g" importer->fragments = true; *dbg << "fragments "; -#line 1427 "IOSCfgParser.cpp" +#line 1431 "IOSCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1458,12 +1462,12 @@ void IOSCfgParser::log() { } } if ( inputState->guessing==0 ) { -#line 423 "iosacl.g" +#line 427 "iosacl.g" importer->logging = true; *dbg << "logging "; -#line 1467 "IOSCfgParser.cpp" +#line 1471 "IOSCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1493,7 +1497,7 @@ void IOSCfgParser::icmp_spec() { match(INT_CONST); } if ( inputState->guessing==0 ) { -#line 334 "iosacl.g" +#line 338 "iosacl.g" importer->icmp_type = icmp_type->getText(); importer->icmp_code = icmp_code->getText(); @@ -1501,7 +1505,7 @@ void IOSCfgParser::icmp_spec() { *dbg << icmp_type->getText() << " " << icmp_code->getText() << " "; -#line 1505 "IOSCfgParser.cpp" +#line 1509 "IOSCfgParser.cpp" } break; } @@ -1510,12 +1514,12 @@ void IOSCfgParser::icmp_spec() { icmp_word = LT(1); match(WORD); if ( inputState->guessing==0 ) { -#line 343 "iosacl.g" +#line 347 "iosacl.g" importer->icmp_spec = icmp_word->getText(); *dbg << icmp_word->getText() << " "; -#line 1519 "IOSCfgParser.cpp" +#line 1523 "IOSCfgParser.cpp" } break; } @@ -1574,12 +1578,12 @@ void IOSCfgParser::established() { try { // for error handling match(ESTABLISHED); if ( inputState->guessing==0 ) { -#line 430 "iosacl.g" +#line 434 "iosacl.g" importer->established = true; *dbg << "established "; -#line 1583 "IOSCfgParser.cpp" +#line 1587 "IOSCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1604,13 +1608,13 @@ void IOSCfgParser::hostaddr_std() { match(IPV4); } if ( inputState->guessing==0 ) { -#line 401 "iosacl.g" +#line 405 "iosacl.g" importer->tmp_a = h->getText(); importer->tmp_nm = "0.0.0.0"; *dbg << h->getText() << "/0.0.0.0"; -#line 1614 "IOSCfgParser.cpp" +#line 1618 "IOSCfgParser.cpp" } } else if ((LA(1) == IPV4) && (LA(2) == IPV4)) { @@ -1621,25 +1625,25 @@ void IOSCfgParser::hostaddr_std() { match(IPV4); } if ( inputState->guessing==0 ) { -#line 408 "iosacl.g" +#line 412 "iosacl.g" importer->tmp_a = a->getText(); importer->tmp_nm = m->getText(); *dbg << a->getText() << "/" << m->getText(); -#line 1631 "IOSCfgParser.cpp" +#line 1635 "IOSCfgParser.cpp" } } else if ((LA(1) == ANY)) { match(ANY); if ( inputState->guessing==0 ) { -#line 415 "iosacl.g" +#line 419 "iosacl.g" importer->tmp_a = "0.0.0.0"; importer->tmp_nm = "0.0.0.0"; *dbg << "0.0.0.0/0.0.0.0"; -#line 1643 "IOSCfgParser.cpp" +#line 1647 "IOSCfgParser.cpp" } } else { @@ -1689,12 +1693,12 @@ void IOSCfgParser::single_port_op() { } } if ( inputState->guessing==0 ) { -#line 354 "iosacl.g" +#line 358 "iosacl.g" importer->tmp_port_op = LT(0)->getText(); *dbg << LT(0)->getText() << " "; -#line 1698 "IOSCfgParser.cpp" +#line 1702 "IOSCfgParser.cpp" } port_spec(); } @@ -1713,12 +1717,12 @@ void IOSCfgParser::port_range() { try { // for error handling match(P_RANGE); if ( inputState->guessing==0 ) { -#line 362 "iosacl.g" +#line 366 "iosacl.g" importer->tmp_port_op = LT(0)->getText(); *dbg << LT(0)->getText() << " "; -#line 1722 "IOSCfgParser.cpp" +#line 1726 "IOSCfgParser.cpp" } port_spec(); port_spec(); @@ -1755,12 +1759,12 @@ void IOSCfgParser::port_spec() { } } if ( inputState->guessing==0 ) { -#line 370 "iosacl.g" +#line 374 "iosacl.g" importer->tmp_port_spec += (std::string(" ") + LT(0)->getText()); *dbg << LT(0)->getText() << " "; -#line 1764 "IOSCfgParser.cpp" +#line 1768 "IOSCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1784,7 +1788,7 @@ void IOSCfgParser::access_group_by_name() { dir = LT(1); match(WORD); if ( inputState->guessing==0 ) { -#line 550 "iosacl.g" +#line 554 "iosacl.g" importer->setInterfaceAndDirectionForRuleSet( acln->getText(), @@ -1794,7 +1798,7 @@ void IOSCfgParser::access_group_by_name() { << " INTRFACE: ACL '" << acln->getText() << "'" << " " << dir->getText() << std::endl; -#line 1798 "IOSCfgParser.cpp" +#line 1802 "IOSCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1818,7 +1822,7 @@ void IOSCfgParser::access_group_by_number() { dir = LT(1); match(WORD); if ( inputState->guessing==0 ) { -#line 565 "iosacl.g" +#line 569 "iosacl.g" importer->setInterfaceAndDirectionForRuleSet( std::string("acl_") + acln->getText(), @@ -1828,7 +1832,7 @@ void IOSCfgParser::access_group_by_number() { << " INTRFACE: ACL '" << acln->getText() << "'" << " " << dir->getText() << std::endl; -#line 1832 "IOSCfgParser.cpp" +#line 1836 "IOSCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1871,7 +1875,7 @@ void IOSCfgParser::intf_address() { } } if ( inputState->guessing==0 ) { -#line 577 "iosacl.g" +#line 581 "iosacl.g" importer->addInterfaceAddress(a->getText(), m->getText()); *dbg << LT(1)->getLine() << ":" @@ -1883,7 +1887,7 @@ void IOSCfgParser::intf_address() { } *dbg << std::endl; -#line 1887 "IOSCfgParser.cpp" +#line 1891 "IOSCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { diff --git a/src/parsers/IPTCfgLexer.cpp b/src/parsers/IPTCfgLexer.cpp index e3335fa3f..7b0d76e77 100644 --- a/src/parsers/IPTCfgLexer.cpp +++ b/src/parsers/IPTCfgLexer.cpp @@ -681,7 +681,7 @@ void IPTCfgLexer::mNEWLINE(bool _createToken) { } if ( inputState->guessing==0 ) { -#line 1182 "iptables.g" +#line 1183 "iptables.g" newline(); resetText(); #line 687 "IPTCfgLexer.cpp" } @@ -762,7 +762,7 @@ void IPTCfgLexer::mWhitespace(bool _createToken) { } } if ( inputState->guessing==0 ) { -#line 1180 "iptables.g" +#line 1181 "iptables.g" _ttype = ANTLR_USE_NAMESPACE(antlr)Token::SKIP; #line 768 "IPTCfgLexer.cpp" } @@ -1029,7 +1029,7 @@ void IPTCfgLexer::mNUMBER(bool _createToken) { match('.' /* charlit */ ); mNUM_3DIGIT(false); if ( inputState->guessing==0 ) { -#line 1245 "iptables.g" +#line 1246 "iptables.g" _ttype = IPV4; #line 1035 "IPTCfgLexer.cpp" } @@ -1055,7 +1055,7 @@ void IPTCfgLexer::mNUMBER(bool _createToken) { } // ( ... )+ } if ( inputState->guessing==0 ) { -#line 1248 "iptables.g" +#line 1249 "iptables.g" _ttype = HEX_CONST; #line 1061 "IPTCfgLexer.cpp" } @@ -1076,7 +1076,7 @@ void IPTCfgLexer::mNUMBER(bool _createToken) { _loop198:; } // ( ... )+ if ( inputState->guessing==0 ) { -#line 1250 "iptables.g" +#line 1251 "iptables.g" _ttype = INT_CONST; #line 1082 "IPTCfgLexer.cpp" } @@ -1392,7 +1392,7 @@ void IPTCfgLexer::mRSOURCE(bool _createToken) { match("--rsource"); if ( inputState->guessing==0 ) { -#line 1274 "iptables.g" +#line 1275 "iptables.g" _ttype = UNSUPPORTED_OPTION; #line 1398 "IPTCfgLexer.cpp" } @@ -2055,7 +2055,7 @@ void IPTCfgLexer::mULOG_QTHR(bool _createToken) { match("--ulog-qthreshold"); if ( inputState->guessing==0 ) { -#line 1341 "iptables.g" +#line 1342 "iptables.g" _ttype = UNSUPPORTED_OPTION; #line 2061 "IPTCfgLexer.cpp" } @@ -2074,7 +2074,7 @@ void IPTCfgLexer::mULOG_NLG(bool _createToken) { match("--ulog-nlgroup"); if ( inputState->guessing==0 ) { -#line 1342 "iptables.g" +#line 1343 "iptables.g" _ttype = UNSUPPORTED_OPTION; #line 2080 "IPTCfgLexer.cpp" } @@ -2093,7 +2093,7 @@ void IPTCfgLexer::mULOG_CPR(bool _createToken) { match("--ulog-cprange"); if ( inputState->guessing==0 ) { -#line 1343 "iptables.g" +#line 1344 "iptables.g" _ttype = UNSUPPORTED_OPTION; #line 2099 "IPTCfgLexer.cpp" } diff --git a/src/parsers/IPTCfgParser.cpp b/src/parsers/IPTCfgParser.cpp index 5cd063460..acd6521ec 100644 --- a/src/parsers/IPTCfgParser.cpp +++ b/src/parsers/IPTCfgParser.cpp @@ -253,6 +253,7 @@ void IPTCfgParser::add_rule() { *dbg << std::endl; importer->pushRule(); // start new one + importer->setCurrentLineNumber(LT(0)->getLine()); if (importer->current_table=="nat") importer->newNATRule(); else @@ -261,7 +262,7 @@ void IPTCfgParser::add_rule() { *dbg << "add_rule: line=" << LT(0)->getLine() << " chain=" << LT(0)->getText(); -#line 265 "IPTCfgParser.cpp" +#line 266 "IPTCfgParser.cpp" } { // ( ... )+ int _cnt14=0; @@ -302,7 +303,7 @@ void IPTCfgParser::commit() { // clear current table importer->current_table = ""; -#line 306 "IPTCfgParser.cpp" +#line 307 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -581,9 +582,9 @@ void IPTCfgParser::match_mark() { { match(EXCLAMATION); if ( inputState->guessing==0 ) { -#line 666 "iptables.g" +#line 667 "iptables.g" importer->neg_match_mark = true; -#line 587 "IPTCfgParser.cpp" +#line 588 "IPTCfgParser.cpp" } break; } @@ -617,12 +618,12 @@ void IPTCfgParser::match_mark() { } } if ( inputState->guessing==0 ) { -#line 668 "iptables.g" +#line 669 "iptables.g" importer->match_mark = LT(0)->getText(); *dbg << " MATCH MARK " << LT(0)->getText(); -#line 626 "IPTCfgParser.cpp" +#line 627 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -670,11 +671,11 @@ void IPTCfgParser::src() { try { // for error handling match(OPT_SRC); if ( inputState->guessing==0 ) { -#line 309 "iptables.g" +#line 310 "iptables.g" *dbg << " SRC="; -#line 678 "IPTCfgParser.cpp" +#line 679 "IPTCfgParser.cpp" } { switch ( LA(1)) { @@ -682,11 +683,11 @@ void IPTCfgParser::src() { { match(EXCLAMATION); if ( inputState->guessing==0 ) { -#line 314 "iptables.g" +#line 315 "iptables.g" importer->src_neg = true; -#line 690 "IPTCfgParser.cpp" +#line 691 "IPTCfgParser.cpp" } break; } @@ -721,12 +722,12 @@ void IPTCfgParser::src() { } } if ( inputState->guessing==0 ) { -#line 319 "iptables.g" +#line 320 "iptables.g" importer->src_a = LT(0)->getText(); *dbg << LT(0)->getText(); -#line 730 "IPTCfgParser.cpp" +#line 731 "IPTCfgParser.cpp" } { switch ( LA(1)) { @@ -752,12 +753,12 @@ void IPTCfgParser::src() { } } if ( inputState->guessing==0 ) { -#line 324 "iptables.g" +#line 325 "iptables.g" importer->src_nm = LT(0)->getText(); *dbg << "/" << LT(0)->getText(); -#line 761 "IPTCfgParser.cpp" +#line 762 "IPTCfgParser.cpp" } break; } @@ -815,11 +816,11 @@ void IPTCfgParser::dst() { try { // for error handling match(OPT_DST); if ( inputState->guessing==0 ) { -#line 333 "iptables.g" +#line 334 "iptables.g" *dbg << " DST="; -#line 823 "IPTCfgParser.cpp" +#line 824 "IPTCfgParser.cpp" } { switch ( LA(1)) { @@ -827,11 +828,11 @@ void IPTCfgParser::dst() { { match(EXCLAMATION); if ( inputState->guessing==0 ) { -#line 338 "iptables.g" +#line 339 "iptables.g" importer->dst_neg = true; -#line 835 "IPTCfgParser.cpp" +#line 836 "IPTCfgParser.cpp" } break; } @@ -866,12 +867,12 @@ void IPTCfgParser::dst() { } } if ( inputState->guessing==0 ) { -#line 343 "iptables.g" +#line 344 "iptables.g" importer->dst_a = LT(0)->getText(); *dbg << LT(0)->getText(); -#line 875 "IPTCfgParser.cpp" +#line 876 "IPTCfgParser.cpp" } { switch ( LA(1)) { @@ -897,12 +898,12 @@ void IPTCfgParser::dst() { } } if ( inputState->guessing==0 ) { -#line 348 "iptables.g" +#line 349 "iptables.g" importer->dst_nm = LT(0)->getText(); *dbg << "/" << LT(0)->getText(); -#line 906 "IPTCfgParser.cpp" +#line 907 "IPTCfgParser.cpp" } break; } @@ -966,11 +967,11 @@ void IPTCfgParser::i_intf() { { match(EXCLAMATION); if ( inputState->guessing==0 ) { -#line 359 "iptables.g" +#line 360 "iptables.g" importer->intf_neg = true; -#line 974 "IPTCfgParser.cpp" +#line 975 "IPTCfgParser.cpp" } break; } @@ -987,12 +988,12 @@ void IPTCfgParser::i_intf() { i = LT(1); match(WORD); if ( inputState->guessing==0 ) { -#line 364 "iptables.g" +#line 365 "iptables.g" importer->i_intf = LT(0)->getText(); *dbg << " I_INTF=" << i->getText(); -#line 996 "IPTCfgParser.cpp" +#line 997 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1016,11 +1017,11 @@ void IPTCfgParser::o_intf() { { match(EXCLAMATION); if ( inputState->guessing==0 ) { -#line 374 "iptables.g" +#line 375 "iptables.g" importer->intf_neg = true; -#line 1024 "IPTCfgParser.cpp" +#line 1025 "IPTCfgParser.cpp" } break; } @@ -1037,12 +1038,12 @@ void IPTCfgParser::o_intf() { i = LT(1); match(WORD); if ( inputState->guessing==0 ) { -#line 379 "iptables.g" +#line 380 "iptables.g" importer->o_intf = LT(0)->getText(); *dbg << " O_INTF=" << i->getText(); -#line 1046 "IPTCfgParser.cpp" +#line 1047 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1065,11 +1066,11 @@ void IPTCfgParser::proto() { { match(EXCLAMATION); if ( inputState->guessing==0 ) { -#line 392 "iptables.g" +#line 393 "iptables.g" importer->srv_neg = true; -#line 1073 "IPTCfgParser.cpp" +#line 1074 "IPTCfgParser.cpp" } break; } @@ -1089,7 +1090,7 @@ void IPTCfgParser::proto() { } protocol_word(); if ( inputState->guessing==0 ) { -#line 397 "iptables.g" +#line 398 "iptables.g" std::string tmp_s = LT(0)->getText(); importer->protocol.resize(tmp_s.size()); @@ -1099,7 +1100,7 @@ void IPTCfgParser::proto() { ::tolower); *dbg << " PROTO=" << importer->protocol; -#line 1103 "IPTCfgParser.cpp" +#line 1104 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1120,12 +1121,12 @@ void IPTCfgParser::target() { t = LT(1); match(WORD); if ( inputState->guessing==0 ) { -#line 410 "iptables.g" +#line 411 "iptables.g" importer->target = LT(0)->getText(); *dbg << " TARGET=" << t->getText(); -#line 1129 "IPTCfgParser.cpp" +#line 1130 "IPTCfgParser.cpp" } { // ( ... )* for (;;) { @@ -1155,12 +1156,12 @@ void IPTCfgParser::fragm() { try { // for error handling match(OPT_FRAGM); if ( inputState->guessing==0 ) { -#line 615 "iptables.g" +#line 616 "iptables.g" importer->fragments = true; *dbg << " FRAGM"; -#line 1164 "IPTCfgParser.cpp" +#line 1165 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1183,12 +1184,12 @@ void IPTCfgParser::icmp_type_spec() { { match(WORD); if ( inputState->guessing==0 ) { -#line 898 "iptables.g" +#line 899 "iptables.g" importer->icmp_spec = LT(0)->getText(); *dbg << " ICMP_SPEC=" << LT(0)->getText(); -#line 1192 "IPTCfgParser.cpp" +#line 1193 "IPTCfgParser.cpp" } break; } @@ -1197,13 +1198,13 @@ void IPTCfgParser::icmp_type_spec() { { match(INT_CONST); if ( inputState->guessing==0 ) { -#line 905 "iptables.g" +#line 906 "iptables.g" importer->icmp_type = LT(0)->getText(); importer->icmp_code = "-1"; *dbg << " ICMP_TYPE=" << LT(0)->getText(); -#line 1207 "IPTCfgParser.cpp" +#line 1208 "IPTCfgParser.cpp" } { switch ( LA(1)) { @@ -1212,12 +1213,12 @@ void IPTCfgParser::icmp_type_spec() { match(SLASH); match(INT_CONST); if ( inputState->guessing==0 ) { -#line 912 "iptables.g" +#line 913 "iptables.g" importer->icmp_code = LT(0)->getText(); *dbg << " ICMP_CODE=" << LT(0)->getText(); -#line 1221 "IPTCfgParser.cpp" +#line 1222 "IPTCfgParser.cpp" } break; } @@ -1309,11 +1310,11 @@ void IPTCfgParser::basic_tcp_udp_port_spec() { { match(EXCLAMATION); if ( inputState->guessing==0 ) { -#line 996 "iptables.g" +#line 997 "iptables.g" importer->srv_neg = true; -#line 1317 "IPTCfgParser.cpp" +#line 1318 "IPTCfgParser.cpp" } break; } @@ -1349,11 +1350,11 @@ void IPTCfgParser::basic_tcp_udp_port_spec() { } } if ( inputState->guessing==0 ) { -#line 1001 "iptables.g" +#line 1002 "iptables.g" importer->pushTmpPortSpecToSrcPortList(); -#line 1357 "IPTCfgParser.cpp" +#line 1358 "IPTCfgParser.cpp" } break; } @@ -1384,11 +1385,11 @@ void IPTCfgParser::basic_tcp_udp_port_spec() { { match(EXCLAMATION); if ( inputState->guessing==0 ) { -#line 1008 "iptables.g" +#line 1009 "iptables.g" importer->srv_neg = true; -#line 1392 "IPTCfgParser.cpp" +#line 1393 "IPTCfgParser.cpp" } break; } @@ -1424,11 +1425,11 @@ void IPTCfgParser::basic_tcp_udp_port_spec() { } } if ( inputState->guessing==0 ) { -#line 1013 "iptables.g" +#line 1014 "iptables.g" importer->pushTmpPortSpecToDstPortList(); -#line 1432 "IPTCfgParser.cpp" +#line 1433 "IPTCfgParser.cpp" } break; } @@ -1458,20 +1459,20 @@ void IPTCfgParser::multiport_tcp_udp_port_spec() { { match(MATCH_SRC_MULTIPORT); if ( inputState->guessing==0 ) { -#line 835 "iptables.g" +#line 836 "iptables.g" importer->startSrcMultiPort(); *dbg << " SRC MULTIPORT="; -#line 1467 "IPTCfgParser.cpp" +#line 1468 "IPTCfgParser.cpp" } port_def_no_range(); if ( inputState->guessing==0 ) { -#line 840 "iptables.g" +#line 841 "iptables.g" importer->pushTmpPortSpecToSrcPortList(); -#line 1475 "IPTCfgParser.cpp" +#line 1476 "IPTCfgParser.cpp" } { // ( ... )* for (;;) { @@ -1479,11 +1480,11 @@ void IPTCfgParser::multiport_tcp_udp_port_spec() { match(COMMA); port_def_no_range(); if ( inputState->guessing==0 ) { -#line 844 "iptables.g" +#line 845 "iptables.g" importer->pushTmpPortSpecToSrcPortList(); -#line 1487 "IPTCfgParser.cpp" +#line 1488 "IPTCfgParser.cpp" } } else { @@ -1501,20 +1502,20 @@ void IPTCfgParser::multiport_tcp_udp_port_spec() { { match(MATCH_DST_MULTIPORT); if ( inputState->guessing==0 ) { -#line 851 "iptables.g" +#line 852 "iptables.g" importer->startDstMultiPort(); *dbg << " DST MULTIPORT="; -#line 1510 "IPTCfgParser.cpp" +#line 1511 "IPTCfgParser.cpp" } port_def_no_range(); if ( inputState->guessing==0 ) { -#line 856 "iptables.g" +#line 857 "iptables.g" importer->pushTmpPortSpecToDstPortList(); -#line 1518 "IPTCfgParser.cpp" +#line 1519 "IPTCfgParser.cpp" } { // ( ... )* for (;;) { @@ -1522,11 +1523,11 @@ void IPTCfgParser::multiport_tcp_udp_port_spec() { match(COMMA); port_def_no_range(); if ( inputState->guessing==0 ) { -#line 860 "iptables.g" +#line 861 "iptables.g" importer->pushTmpPortSpecToDstPortList(); -#line 1530 "IPTCfgParser.cpp" +#line 1531 "IPTCfgParser.cpp" } } else { @@ -1544,20 +1545,20 @@ void IPTCfgParser::multiport_tcp_udp_port_spec() { { match(MATCH_BOTH_MULTIPORT); if ( inputState->guessing==0 ) { -#line 867 "iptables.g" +#line 868 "iptables.g" importer->startBothMultiPort(); *dbg << " MULTIPORT PORTS="; -#line 1553 "IPTCfgParser.cpp" +#line 1554 "IPTCfgParser.cpp" } port_def_no_range(); if ( inputState->guessing==0 ) { -#line 872 "iptables.g" +#line 873 "iptables.g" importer->pushTmpPortSpecToBothPortList(); -#line 1561 "IPTCfgParser.cpp" +#line 1562 "IPTCfgParser.cpp" } { // ( ... )* for (;;) { @@ -1565,11 +1566,11 @@ void IPTCfgParser::multiport_tcp_udp_port_spec() { match(COMMA); port_def_no_range(); if ( inputState->guessing==0 ) { -#line 876 "iptables.g" +#line 877 "iptables.g" importer->pushTmpPortSpecToBothPortList(); -#line 1573 "IPTCfgParser.cpp" +#line 1574 "IPTCfgParser.cpp" } } else { @@ -1608,9 +1609,9 @@ void IPTCfgParser::tcp_options() { { match(EXCLAMATION); if ( inputState->guessing==0 ) { -#line 1042 "iptables.g" +#line 1043 "iptables.g" importer->srv_neg = true; -#line 1614 "IPTCfgParser.cpp" +#line 1615 "IPTCfgParser.cpp" } break; } @@ -1682,12 +1683,12 @@ void IPTCfgParser::match_limit_burst() { match(MATCH_LIMIT_BURST); match(INT_CONST); if ( inputState->guessing==0 ) { -#line 699 "iptables.g" +#line 700 "iptables.g" importer->limit_burst = LT(0)->getText(); *dbg << " LIMIT BURST " << LT(0)->getText(); -#line 1691 "IPTCfgParser.cpp" +#line 1692 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1739,12 +1740,12 @@ void IPTCfgParser::match_iprange_src() { } } if ( inputState->guessing==0 ) { -#line 722 "iptables.g" +#line 723 "iptables.g" importer->iprange_src_from = LT(0)->getText(); importer->using_iprange_src = true; -#line 1748 "IPTCfgParser.cpp" +#line 1749 "IPTCfgParser.cpp" } match(MINUS); { @@ -1766,11 +1767,11 @@ void IPTCfgParser::match_iprange_src() { } } if ( inputState->guessing==0 ) { -#line 727 "iptables.g" +#line 728 "iptables.g" importer->iprange_src_to = LT(0)->getText(); -#line 1774 "IPTCfgParser.cpp" +#line 1775 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1806,12 +1807,12 @@ void IPTCfgParser::match_iprange_dst() { } } if ( inputState->guessing==0 ) { -#line 733 "iptables.g" +#line 734 "iptables.g" importer->iprange_dst_from = LT(0)->getText(); importer->using_iprange_dst = true; -#line 1815 "IPTCfgParser.cpp" +#line 1816 "IPTCfgParser.cpp" } match(MINUS); { @@ -1833,11 +1834,11 @@ void IPTCfgParser::match_iprange_dst() { } } if ( inputState->guessing==0 ) { -#line 738 "iptables.g" +#line 739 "iptables.g" importer->iprange_dst_to = LT(0)->getText(); -#line 1841 "IPTCfgParser.cpp" +#line 1842 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1858,13 +1859,13 @@ void IPTCfgParser::unknown_option() { match(MINUS); match(WORD); if ( inputState->guessing==0 ) { -#line 240 "iptables.g" +#line 241 "iptables.g" importer->markCurrentRuleBad( std::string("Unknown option: -")+LT(0)->getText()); *dbg << " UNKNOWN OPTION=-" << LT(0)->getText(); -#line 1868 "IPTCfgParser.cpp" +#line 1869 "IPTCfgParser.cpp" } { switch ( LA(1)) { @@ -1922,13 +1923,13 @@ void IPTCfgParser::unknown_option() { match(WORD); } if ( inputState->guessing==0 ) { -#line 250 "iptables.g" +#line 251 "iptables.g" importer->markCurrentRuleBad( std::string("Unknown option: --")+LT(0)->getText()); *dbg << " UNKNOWN OPTION=--" << LT(0)->getText(); -#line 1932 "IPTCfgParser.cpp" +#line 1933 "IPTCfgParser.cpp" } { switch ( LA(1)) { @@ -1982,13 +1983,13 @@ void IPTCfgParser::unknown_option() { { match(UNSUPPORTED_OPTION); if ( inputState->guessing==0 ) { -#line 260 "iptables.g" +#line 261 "iptables.g" importer->markCurrentRuleBad( std::string("Unknown option: ")+LT(0)->getText()); *dbg << " UNKNOWN OPTION=" << LT(0)->getText(); -#line 1992 "IPTCfgParser.cpp" +#line 1993 "IPTCfgParser.cpp" } { switch ( LA(1)) { @@ -2054,9 +2055,9 @@ void IPTCfgParser::unknown_option() { } void IPTCfgParser::unknown_parameter() { -#line 269 "iptables.g" +#line 270 "iptables.g" std::string s; -#line 2060 "IPTCfgParser.cpp" +#line 2061 "IPTCfgParser.cpp" try { // for error handling if ((LA(1) == INT_CONST || LA(1) == DIGIT) && (LA(2) == SLASH)) { @@ -2068,9 +2069,9 @@ void IPTCfgParser::unknown_parameter() { { match(DIGIT); if ( inputState->guessing==0 ) { -#line 275 "iptables.g" +#line 276 "iptables.g" s+=LT(0)->getText(); -#line 2074 "IPTCfgParser.cpp" +#line 2075 "IPTCfgParser.cpp" } break; } @@ -2078,9 +2079,9 @@ void IPTCfgParser::unknown_parameter() { { match(INT_CONST); if ( inputState->guessing==0 ) { -#line 277 "iptables.g" +#line 278 "iptables.g" s+=LT(0)->getText(); -#line 2084 "IPTCfgParser.cpp" +#line 2085 "IPTCfgParser.cpp" } break; } @@ -2092,25 +2093,25 @@ void IPTCfgParser::unknown_parameter() { } match(SLASH); if ( inputState->guessing==0 ) { -#line 279 "iptables.g" +#line 280 "iptables.g" s+=LT(0)->getText(); -#line 2098 "IPTCfgParser.cpp" +#line 2099 "IPTCfgParser.cpp" } match(WORD); if ( inputState->guessing==0 ) { -#line 280 "iptables.g" +#line 281 "iptables.g" s+=LT(0)->getText(); -#line 2104 "IPTCfgParser.cpp" +#line 2105 "IPTCfgParser.cpp" } } if ( inputState->guessing==0 ) { -#line 282 "iptables.g" +#line 283 "iptables.g" importer->markCurrentRuleBad( std::string("Unknown parameter: ")+s); *dbg << " UNKNOWN PARMETER=" << s; -#line 2114 "IPTCfgParser.cpp" +#line 2115 "IPTCfgParser.cpp" } } } @@ -2140,13 +2141,13 @@ void IPTCfgParser::unknown_parameter() { } } if ( inputState->guessing==0 ) { -#line 291 "iptables.g" +#line 292 "iptables.g" importer->markCurrentRuleBad( std::string("Unknown parameter: ")+LT(0)->getText()); *dbg << " UNKNOWN PARMETER=" << LT(0)->getText(); -#line 2150 "IPTCfgParser.cpp" +#line 2151 "IPTCfgParser.cpp" } } } @@ -2171,19 +2172,19 @@ void IPTCfgParser::m_state() { match(M_STATE); match(MATCH_STATE); if ( inputState->guessing==0 ) { -#line 636 "iptables.g" +#line 637 "iptables.g" importer->current_state = ""; -#line 2179 "IPTCfgParser.cpp" +#line 2180 "IPTCfgParser.cpp" } state_word(); if ( inputState->guessing==0 ) { -#line 640 "iptables.g" +#line 641 "iptables.g" importer->current_state += LT(0)->getText(); -#line 2187 "IPTCfgParser.cpp" +#line 2188 "IPTCfgParser.cpp" } { switch ( LA(1)) { @@ -2192,11 +2193,11 @@ void IPTCfgParser::m_state() { match(COMMA); state_word(); if ( inputState->guessing==0 ) { -#line 645 "iptables.g" +#line 646 "iptables.g" importer->current_state += std::string(",") + LT(0)->getText(); -#line 2200 "IPTCfgParser.cpp" +#line 2201 "IPTCfgParser.cpp" } break; } @@ -2238,11 +2239,11 @@ void IPTCfgParser::m_state() { } } if ( inputState->guessing==0 ) { -#line 649 "iptables.g" +#line 650 "iptables.g" *dbg << " STATE MATCH=" << importer->current_state; -#line 2246 "IPTCfgParser.cpp" +#line 2247 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -2260,11 +2261,11 @@ void IPTCfgParser::m_mport() { try { // for error handling match(M_MPORT); if ( inputState->guessing==0 ) { -#line 807 "iptables.g" +#line 808 "iptables.g" *dbg << " MULTIPORT"; -#line 2268 "IPTCfgParser.cpp" +#line 2269 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -2282,12 +2283,12 @@ void IPTCfgParser::m_icmp() { try { // for error handling match(ICMP); if ( inputState->guessing==0 ) { -#line 888 "iptables.g" +#line 889 "iptables.g" importer->protocol = "icmp"; *dbg << " ICMP"; -#line 2291 "IPTCfgParser.cpp" +#line 2292 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -2305,12 +2306,12 @@ void IPTCfgParser::m_tcp() { try { // for error handling match(TCP); if ( inputState->guessing==0 ) { -#line 1031 "iptables.g" +#line 1032 "iptables.g" importer->protocol = "tcp"; *dbg << " TCP"; -#line 2314 "IPTCfgParser.cpp" +#line 2315 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -2328,12 +2329,12 @@ void IPTCfgParser::m_udp() { try { // for error handling match(UDP); if ( inputState->guessing==0 ) { -#line 1022 "iptables.g" +#line 1023 "iptables.g" importer->protocol = "udp"; *dbg << " UDP"; -#line 2337 "IPTCfgParser.cpp" +#line 2338 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -2351,11 +2352,11 @@ void IPTCfgParser::m_limit() { try { // for error handling match(M_LIMIT); if ( inputState->guessing==0 ) { -#line 677 "iptables.g" +#line 678 "iptables.g" *dbg << " LIMIT"; -#line 2359 "IPTCfgParser.cpp" +#line 2360 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -2373,11 +2374,11 @@ void IPTCfgParser::m_length() { try { // for error handling match(M_LENGTH); if ( inputState->guessing==0 ) { -#line 772 "iptables.g" +#line 773 "iptables.g" *dbg << " LENGTH"; -#line 2381 "IPTCfgParser.cpp" +#line 2382 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -2395,11 +2396,11 @@ void IPTCfgParser::m_iprange() { try { // for error handling match(M_IPRANGE); if ( inputState->guessing==0 ) { -#line 716 "iptables.g" +#line 717 "iptables.g" *dbg << " IPRANGE"; -#line 2403 "IPTCfgParser.cpp" +#line 2404 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -2419,11 +2420,11 @@ void IPTCfgParser::m_comment() { match(MATCH_COMMENT); match(STRING); if ( inputState->guessing==0 ) { -#line 815 "iptables.g" +#line 816 "iptables.g" *dbg << " COMMENT=" << LT(0)->getText(); -#line 2427 "IPTCfgParser.cpp" +#line 2428 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -2458,13 +2459,13 @@ void IPTCfgParser::m_unknown_module() { try { // for error handling match(WORD); if ( inputState->guessing==0 ) { -#line 623 "iptables.g" +#line 624 "iptables.g" *dbg << " UNKNOWN MODULE=" << LT(0)->getText(); importer->markCurrentRuleBad( std::string("Unknown module: ")+LT(0)->getText()); -#line 2468 "IPTCfgParser.cpp" +#line 2469 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -2534,12 +2535,12 @@ void IPTCfgParser::target_options() { match(REJECT_WITH); match(WORD); if ( inputState->guessing==0 ) { -#line 421 "iptables.g" +#line 422 "iptables.g" importer->action_params["reject_with"] = LT(0)->getText(); *dbg << " REJECT WITH=" << LT(0)->getText(); -#line 2543 "IPTCfgParser.cpp" +#line 2544 "IPTCfgParser.cpp" } break; } @@ -2565,12 +2566,12 @@ void IPTCfgParser::target_options() { } } if ( inputState->guessing==0 ) { -#line 427 "iptables.g" +#line 428 "iptables.g" importer->action_params["log_prefix"] = LT(0)->getText(); *dbg << " LOG PREFIX=" << LT(0)->getText(); -#line 2574 "IPTCfgParser.cpp" +#line 2575 "IPTCfgParser.cpp" } break; } @@ -2578,12 +2579,12 @@ void IPTCfgParser::target_options() { { match(LOG_TCP_SEQ); if ( inputState->guessing==0 ) { -#line 433 "iptables.g" +#line 434 "iptables.g" importer->action_params["log_tcp_seq"] = LT(0)->getText(); *dbg << " LOG TCP SEQUENCE="; -#line 2587 "IPTCfgParser.cpp" +#line 2588 "IPTCfgParser.cpp" } break; } @@ -2591,12 +2592,12 @@ void IPTCfgParser::target_options() { { match(LOG_TCP_OPT); if ( inputState->guessing==0 ) { -#line 439 "iptables.g" +#line 440 "iptables.g" importer->action_params["log_tcp_options"] = LT(0)->getText(); *dbg << " LOG TCP OPTIONS="; -#line 2600 "IPTCfgParser.cpp" +#line 2601 "IPTCfgParser.cpp" } break; } @@ -2604,12 +2605,12 @@ void IPTCfgParser::target_options() { { match(LOG_IP_OPT); if ( inputState->guessing==0 ) { -#line 445 "iptables.g" +#line 446 "iptables.g" importer->action_params["log_ip_options"] = LT(0)->getText(); *dbg << " LOG IP OPTIONS="; -#line 2613 "IPTCfgParser.cpp" +#line 2614 "IPTCfgParser.cpp" } break; } @@ -2635,12 +2636,12 @@ void IPTCfgParser::target_options() { } } if ( inputState->guessing==0 ) { -#line 451 "iptables.g" +#line 452 "iptables.g" importer->action_params["log_prefix"] = LT(0)->getText(); *dbg << " ULOG PREFIX=" << LT(0)->getText(); -#line 2644 "IPTCfgParser.cpp" +#line 2645 "IPTCfgParser.cpp" } break; } @@ -2666,12 +2667,12 @@ void IPTCfgParser::target_options() { } } if ( inputState->guessing==0 ) { -#line 457 "iptables.g" +#line 458 "iptables.g" importer->action_params["log_level"] = LT(0)->getText(); *dbg << " LOG LEVEL=" << LT(0)->getText(); -#line 2675 "IPTCfgParser.cpp" +#line 2676 "IPTCfgParser.cpp" } break; } @@ -2697,12 +2698,12 @@ void IPTCfgParser::target_options() { } } if ( inputState->guessing==0 ) { -#line 463 "iptables.g" +#line 464 "iptables.g" importer->action_params["set_mark"] = LT(0)->getText(); *dbg << " SET MARK=" << LT(0)->getText(); -#line 2706 "IPTCfgParser.cpp" +#line 2707 "IPTCfgParser.cpp" } break; } @@ -2710,12 +2711,12 @@ void IPTCfgParser::target_options() { { match(SAVE_MARK); if ( inputState->guessing==0 ) { -#line 481 "iptables.g" +#line 482 "iptables.g" importer->action_params["connmark_save_mark"] = "--save-mark"; *dbg << " SAVE MARK"; -#line 2719 "IPTCfgParser.cpp" +#line 2720 "IPTCfgParser.cpp" } break; } @@ -2723,12 +2724,12 @@ void IPTCfgParser::target_options() { { match(RESTORE_MARK); if ( inputState->guessing==0 ) { -#line 487 "iptables.g" +#line 488 "iptables.g" importer->action_params["connmark_restore_mark"] = "--restore-mark"; *dbg << " RESTORE MARK"; -#line 2732 "IPTCfgParser.cpp" +#line 2733 "IPTCfgParser.cpp" } break; } @@ -2736,12 +2737,12 @@ void IPTCfgParser::target_options() { { match(CONTINUE); if ( inputState->guessing==0 ) { -#line 493 "iptables.g" +#line 494 "iptables.g" importer->action_params["route_continue"] = "--continue"; *dbg << " CONTINUE"; -#line 2745 "IPTCfgParser.cpp" +#line 2746 "IPTCfgParser.cpp" } break; } @@ -2750,12 +2751,12 @@ void IPTCfgParser::target_options() { match(ROUTE_IIF); match(WORD); if ( inputState->guessing==0 ) { -#line 499 "iptables.g" +#line 500 "iptables.g" importer->action_params["route_iif"] = LT(0)->getText(); *dbg << " ROUTE_IIF=" << LT(0)->getText(); -#line 2759 "IPTCfgParser.cpp" +#line 2760 "IPTCfgParser.cpp" } break; } @@ -2764,12 +2765,12 @@ void IPTCfgParser::target_options() { match(ROUTE_OIF); match(WORD); if ( inputState->guessing==0 ) { -#line 505 "iptables.g" +#line 506 "iptables.g" importer->action_params["route_oif"] = LT(0)->getText(); *dbg << " ROUTE_OIF=" << LT(0)->getText(); -#line 2773 "IPTCfgParser.cpp" +#line 2774 "IPTCfgParser.cpp" } break; } @@ -2778,12 +2779,12 @@ void IPTCfgParser::target_options() { match(ROUTE_GW); match(IPV4); if ( inputState->guessing==0 ) { -#line 511 "iptables.g" +#line 512 "iptables.g" importer->action_params["route_gw"] = LT(0)->getText(); *dbg << " ROUTE_GW=" << LT(0)->getText(); -#line 2787 "IPTCfgParser.cpp" +#line 2788 "IPTCfgParser.cpp" } break; } @@ -2791,12 +2792,12 @@ void IPTCfgParser::target_options() { { match(ROUTE_TEE); if ( inputState->guessing==0 ) { -#line 517 "iptables.g" +#line 518 "iptables.g" importer->action_params["route_tee"] = "--tee"; *dbg << " ROUTE_TEE"; -#line 2800 "IPTCfgParser.cpp" +#line 2801 "IPTCfgParser.cpp" } break; } @@ -2804,11 +2805,11 @@ void IPTCfgParser::target_options() { { match(TO_SOURCE); if ( inputState->guessing==0 ) { -#line 523 "iptables.g" +#line 524 "iptables.g" *dbg << " TO-SOURCE"; -#line 2812 "IPTCfgParser.cpp" +#line 2813 "IPTCfgParser.cpp" } nat_spec(); break; @@ -2817,11 +2818,11 @@ void IPTCfgParser::target_options() { { match(TO_DESTINATION); if ( inputState->guessing==0 ) { -#line 529 "iptables.g" +#line 530 "iptables.g" *dbg << " TO-DESTINATION"; -#line 2825 "IPTCfgParser.cpp" +#line 2826 "IPTCfgParser.cpp" } nat_spec(); break; @@ -2836,22 +2837,22 @@ void IPTCfgParser::target_options() { { match(TO_NETMAP); if ( inputState->guessing==0 ) { -#line 537 "iptables.g" +#line 538 "iptables.g" *dbg << " TO-NETMAP"; -#line 2844 "IPTCfgParser.cpp" +#line 2845 "IPTCfgParser.cpp" } { match(IPV4); if ( inputState->guessing==0 ) { -#line 542 "iptables.g" +#line 543 "iptables.g" importer->nat_addr1 = LT(0)->getText(); importer->nat_addr2 = LT(0)->getText(); *dbg << LT(0)->getText(); -#line 2855 "IPTCfgParser.cpp" +#line 2856 "IPTCfgParser.cpp" } match(SLASH); { @@ -2873,12 +2874,12 @@ void IPTCfgParser::target_options() { } } if ( inputState->guessing==0 ) { -#line 548 "iptables.g" +#line 549 "iptables.g" importer->nat_nm = LT(0)->getText(); *dbg << "/" << LT(0)->getText(); -#line 2882 "IPTCfgParser.cpp" +#line 2883 "IPTCfgParser.cpp" } } break; @@ -2887,12 +2888,12 @@ void IPTCfgParser::target_options() { { match(CLAMP_MSS); if ( inputState->guessing==0 ) { -#line 555 "iptables.g" +#line 556 "iptables.g" importer->action_params["clamp-mss-to-pmtu"] = "--clamp-mss-to-pmtu"; *dbg << " TO-NETMAP"; -#line 2896 "IPTCfgParser.cpp" +#line 2897 "IPTCfgParser.cpp" } break; } @@ -2901,24 +2902,24 @@ void IPTCfgParser::target_options() { match(SET_TOS); match(HEX_CONST); if ( inputState->guessing==0 ) { -#line 469 "iptables.g" +#line 470 "iptables.g" importer->action_params["set_tos"] = LT(0)->getText(); *dbg << " SET TOS=" << LT(0)->getText(); -#line 2910 "IPTCfgParser.cpp" +#line 2911 "IPTCfgParser.cpp" } } else if ((LA(1) == SET_TOS) && (LA(2) == WORD)) { match(SET_TOS); match(WORD); if ( inputState->guessing==0 ) { -#line 475 "iptables.g" +#line 476 "iptables.g" importer->action_params["set_tos"] = LT(0)->getText(); *dbg << " SET TOS=" << LT(0)->getText(); -#line 2922 "IPTCfgParser.cpp" +#line 2923 "IPTCfgParser.cpp" } } else { @@ -3008,7 +3009,7 @@ void IPTCfgParser::nat_spec() { } } if ( inputState->guessing==0 ) { -#line 566 "iptables.g" +#line 567 "iptables.g" *dbg << " " << importer->nat_addr1 @@ -3019,7 +3020,7 @@ void IPTCfgParser::nat_spec() { << "-" << importer->nat_port_range_end; -#line 3023 "IPTCfgParser.cpp" +#line 3024 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -3037,7 +3038,7 @@ void IPTCfgParser::redirect_spec() { try { // for error handling nat_port_def_with_range(); if ( inputState->guessing==0 ) { -#line 601 "iptables.g" +#line 602 "iptables.g" *dbg << " TO-PORTS " << importer->nat_addr1 @@ -3048,7 +3049,7 @@ void IPTCfgParser::redirect_spec() { << "-" << importer->nat_port_range_end; -#line 3052 "IPTCfgParser.cpp" +#line 3053 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -3089,28 +3090,28 @@ void IPTCfgParser::nat_addr_range() { s = LT(1); match(IPV4); if ( inputState->guessing==0 ) { -#line 582 "iptables.g" +#line 583 "iptables.g" importer->nat_port_range_start = ""; importer->nat_port_range_end = ""; importer->nat_addr1 = LT(0)->getText(); importer->nat_addr2 = s->getText(); -#line 3100 "IPTCfgParser.cpp" +#line 3101 "IPTCfgParser.cpp" } } } else if ((LA(1) == IPV4) && (_tokenSet_8.member(LA(2)))) { match(IPV4); if ( inputState->guessing==0 ) { -#line 591 "iptables.g" +#line 592 "iptables.g" importer->nat_port_range_start = ""; importer->nat_port_range_end = ""; importer->nat_addr1 = LT(0)->getText(); importer->nat_addr2 = LT(0)->getText(); -#line 3114 "IPTCfgParser.cpp" +#line 3115 "IPTCfgParser.cpp" } } else { @@ -3186,13 +3187,13 @@ void IPTCfgParser::nat_port_def_with_range() { } } if ( inputState->guessing==0 ) { -#line 971 "iptables.g" +#line 972 "iptables.g" importer->nat_port_range_start = LT(0)->getText(); importer->nat_port_range_end = LT(0)->getText(); *dbg << " PORT=" << LT(0)->getText(); -#line 3196 "IPTCfgParser.cpp" +#line 3197 "IPTCfgParser.cpp" } match(MINUS); { @@ -3214,12 +3215,12 @@ void IPTCfgParser::nat_port_def_with_range() { } } if ( inputState->guessing==0 ) { -#line 977 "iptables.g" +#line 978 "iptables.g" importer->nat_port_range_end = LT(0)->getText(); *dbg << ":" << LT(0)->getText(); -#line 3223 "IPTCfgParser.cpp" +#line 3224 "IPTCfgParser.cpp" } } } @@ -3243,13 +3244,13 @@ void IPTCfgParser::nat_port_def_with_range() { } } if ( inputState->guessing==0 ) { -#line 984 "iptables.g" +#line 985 "iptables.g" importer->nat_port_range_start = LT(0)->getText(); importer->nat_port_range_end = LT(0)->getText(); *dbg << " PORT=" << LT(0)->getText(); -#line 3253 "IPTCfgParser.cpp" +#line 3254 "IPTCfgParser.cpp" } } else { @@ -3314,11 +3315,11 @@ void IPTCfgParser::m_mark() { try { // for error handling match(M_MARK); if ( inputState->guessing==0 ) { -#line 658 "iptables.g" +#line 659 "iptables.g" *dbg << " MARK"; -#line 3322 "IPTCfgParser.cpp" +#line 3323 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -3336,25 +3337,25 @@ void IPTCfgParser::limit_rate() { try { // for error handling match(INT_CONST); if ( inputState->guessing==0 ) { -#line 688 "iptables.g" +#line 689 "iptables.g" importer->limit_val = LT(0)->getText(); -#line 3342 "IPTCfgParser.cpp" +#line 3343 "IPTCfgParser.cpp" } match(SLASH); match(WORD); if ( inputState->guessing==0 ) { -#line 690 "iptables.g" +#line 691 "iptables.g" importer->limit_suffix = LT(0)->getText(); -#line 3349 "IPTCfgParser.cpp" +#line 3350 "IPTCfgParser.cpp" } if ( inputState->guessing==0 ) { -#line 691 "iptables.g" +#line 692 "iptables.g" *dbg << " MATCH LIMIT " << importer->limit_val << "/" << importer->limit_suffix; -#line 3358 "IPTCfgParser.cpp" +#line 3359 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -3372,11 +3373,11 @@ void IPTCfgParser::m_recent() { try { // for error handling match(M_RECENT); if ( inputState->guessing==0 ) { -#line 708 "iptables.g" +#line 709 "iptables.g" *dbg << " RECENT"; -#line 3380 "IPTCfgParser.cpp" +#line 3381 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -3474,9 +3475,9 @@ void IPTCfgParser::recent_args_no_param() { } } if ( inputState->guessing==0 ) { -#line 760 "iptables.g" +#line 761 "iptables.g" importer->recent_match += LT(0)->getText() + " "; -#line 3480 "IPTCfgParser.cpp" +#line 3481 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -3516,9 +3517,9 @@ void IPTCfgParser::recent_args_param() { } } if ( inputState->guessing==0 ) { -#line 764 "iptables.g" +#line 765 "iptables.g" importer->recent_match += LT(0)->getText() + " "; -#line 3522 "IPTCfgParser.cpp" +#line 3523 "IPTCfgParser.cpp" } { switch ( LA(1)) { @@ -3539,9 +3540,9 @@ void IPTCfgParser::recent_args_param() { } } if ( inputState->guessing==0 ) { -#line 766 "iptables.g" +#line 767 "iptables.g" importer->recent_match += LT(0)->getText() + " "; -#line 3545 "IPTCfgParser.cpp" +#line 3546 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -3559,24 +3560,24 @@ void IPTCfgParser::length_spec() { try { // for error handling match(INT_CONST); if ( inputState->guessing==0 ) { -#line 783 "iptables.g" +#line 784 "iptables.g" importer->length_spec = LT(0)->getText(); -#line 3565 "IPTCfgParser.cpp" +#line 3566 "IPTCfgParser.cpp" } match(COLON); match(INT_CONST); if ( inputState->guessing==0 ) { -#line 785 "iptables.g" +#line 786 "iptables.g" importer->length_spec += ":"; importer->length_spec += LT(0)->getText(); -#line 3573 "IPTCfgParser.cpp" +#line 3574 "IPTCfgParser.cpp" } if ( inputState->guessing==0 ) { -#line 787 "iptables.g" +#line 788 "iptables.g" *dbg << " MATCH LENGTH " << importer->length_spec; -#line 3580 "IPTCfgParser.cpp" +#line 3581 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -3616,12 +3617,12 @@ void IPTCfgParser::pkt_type_spec() { } } if ( inputState->guessing==0 ) { -#line 798 "iptables.g" +#line 799 "iptables.g" importer->pkt_type_spec = LT(0)->getText(); *dbg << " PKT_TYPE " << importer->pkt_type_spec; -#line 3625 "IPTCfgParser.cpp" +#line 3626 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -3656,13 +3657,13 @@ void IPTCfgParser::port_def_no_range() { } } if ( inputState->guessing==0 ) { -#line 924 "iptables.g" +#line 925 "iptables.g" importer->tmp_port_range_start = LT(0)->getText(); importer->tmp_port_range_end = LT(0)->getText(); *dbg << " PORT=" << LT(0)->getText(); -#line 3666 "IPTCfgParser.cpp" +#line 3667 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -3706,13 +3707,13 @@ void IPTCfgParser::port_def_with_range() { } } if ( inputState->guessing==0 ) { -#line 942 "iptables.g" +#line 943 "iptables.g" importer->tmp_port_range_start = LT(0)->getText(); importer->tmp_port_range_end = LT(0)->getText(); *dbg << " PORT=" << LT(0)->getText(); -#line 3716 "IPTCfgParser.cpp" +#line 3717 "IPTCfgParser.cpp" } { switch ( LA(1)) { @@ -3769,12 +3770,12 @@ void IPTCfgParser::port_def_with_range() { } } if ( inputState->guessing==0 ) { -#line 949 "iptables.g" +#line 950 "iptables.g" importer->tmp_port_range_end = LT(0)->getText(); *dbg << ":" << LT(0)->getText(); -#line 3778 "IPTCfgParser.cpp" +#line 3779 "IPTCfgParser.cpp" } break; } @@ -3849,13 +3850,13 @@ void IPTCfgParser::port_def_with_incomplete_range() { } } if ( inputState->guessing==0 ) { -#line 958 "iptables.g" +#line 959 "iptables.g" importer->tmp_port_range_start = "0"; importer->tmp_port_range_end = LT(0)->getText(); *dbg << "PORT 0:" << LT(0)->getText(); -#line 3859 "IPTCfgParser.cpp" +#line 3860 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -3873,7 +3874,7 @@ void IPTCfgParser::syn() { try { // for error handling match(MATCH_SYN); if ( inputState->guessing==0 ) { -#line 1047 "iptables.g" +#line 1048 "iptables.g" importer->tcp_flags_mask.clear(); importer->tcp_flags_mask.push_back(libfwbuilder::TCPService::SYN); @@ -3883,7 +3884,7 @@ void IPTCfgParser::syn() { importer->tcp_flags_comp.clear(); importer->tcp_flags_comp.push_back(libfwbuilder::TCPService::SYN); -#line 3887 "IPTCfgParser.cpp" +#line 3888 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -3902,16 +3903,16 @@ void IPTCfgParser::tcp_flags() { match(MATCH_TCP_FLAGS); tcp_flags_list(); if ( inputState->guessing==0 ) { -#line 1098 "iptables.g" +#line 1099 "iptables.g" importer->tcp_flags_mask = importer->tmp_tcp_flags_list; importer->tmp_tcp_flags_list.clear(); -#line 3911 "IPTCfgParser.cpp" +#line 3912 "IPTCfgParser.cpp" } tcp_flags_list(); if ( inputState->guessing==0 ) { -#line 1103 "iptables.g" +#line 1104 "iptables.g" importer->tcp_flags_comp = importer->tmp_tcp_flags_list; importer->tmp_tcp_flags_list.clear(); @@ -3925,7 +3926,7 @@ void IPTCfgParser::tcp_flags() { i!=importer->tcp_flags_comp.end(); ++i) *dbg << *i << "|"; -#line 3929 "IPTCfgParser.cpp" +#line 3930 "IPTCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -3981,9 +3982,9 @@ void IPTCfgParser::tcp_flag_word() { { match(SYN); if ( inputState->guessing==0 ) { -#line 1060 "iptables.g" +#line 1061 "iptables.g" importer->tmp_tcp_flag_code = libfwbuilder::TCPService::SYN; -#line 3987 "IPTCfgParser.cpp" +#line 3988 "IPTCfgParser.cpp" } break; } @@ -3991,9 +3992,9 @@ void IPTCfgParser::tcp_flag_word() { { match(ACK); if ( inputState->guessing==0 ) { -#line 1062 "iptables.g" +#line 1063 "iptables.g" importer->tmp_tcp_flag_code = libfwbuilder::TCPService::ACK; -#line 3997 "IPTCfgParser.cpp" +#line 3998 "IPTCfgParser.cpp" } break; } @@ -4001,9 +4002,9 @@ void IPTCfgParser::tcp_flag_word() { { match(FIN); if ( inputState->guessing==0 ) { -#line 1064 "iptables.g" +#line 1065 "iptables.g" importer->tmp_tcp_flag_code = libfwbuilder::TCPService::FIN; -#line 4007 "IPTCfgParser.cpp" +#line 4008 "IPTCfgParser.cpp" } break; } @@ -4011,9 +4012,9 @@ void IPTCfgParser::tcp_flag_word() { { match(RST); if ( inputState->guessing==0 ) { -#line 1066 "iptables.g" +#line 1067 "iptables.g" importer->tmp_tcp_flag_code = libfwbuilder::TCPService::RST; -#line 4017 "IPTCfgParser.cpp" +#line 4018 "IPTCfgParser.cpp" } break; } @@ -4021,9 +4022,9 @@ void IPTCfgParser::tcp_flag_word() { { match(URG); if ( inputState->guessing==0 ) { -#line 1068 "iptables.g" +#line 1069 "iptables.g" importer->tmp_tcp_flag_code = libfwbuilder::TCPService::URG; -#line 4027 "IPTCfgParser.cpp" +#line 4028 "IPTCfgParser.cpp" } break; } @@ -4031,9 +4032,9 @@ void IPTCfgParser::tcp_flag_word() { { match(PSH); if ( inputState->guessing==0 ) { -#line 1070 "iptables.g" +#line 1071 "iptables.g" importer->tmp_tcp_flag_code = libfwbuilder::TCPService::PSH; -#line 4037 "IPTCfgParser.cpp" +#line 4038 "IPTCfgParser.cpp" } break; } @@ -4041,9 +4042,9 @@ void IPTCfgParser::tcp_flag_word() { { match(ALL); if ( inputState->guessing==0 ) { -#line 1072 "iptables.g" +#line 1073 "iptables.g" importer->tmp_tcp_flag_code = 99; -#line 4047 "IPTCfgParser.cpp" +#line 4048 "IPTCfgParser.cpp" } break; } @@ -4051,9 +4052,9 @@ void IPTCfgParser::tcp_flag_word() { { match(NONE); if ( inputState->guessing==0 ) { -#line 1074 "iptables.g" +#line 1075 "iptables.g" importer->tmp_tcp_flag_code = 98; -#line 4057 "IPTCfgParser.cpp" +#line 4058 "IPTCfgParser.cpp" } break; } @@ -4078,20 +4079,20 @@ void IPTCfgParser::tcp_flags_list() { try { // for error handling if ( inputState->guessing==0 ) { -#line 1079 "iptables.g" +#line 1080 "iptables.g" importer->tmp_tcp_flags_list.clear(); importer->tmp_tcp_flag_code = 0; -#line 4087 "IPTCfgParser.cpp" +#line 4088 "IPTCfgParser.cpp" } tcp_flag_word(); if ( inputState->guessing==0 ) { -#line 1084 "iptables.g" +#line 1085 "iptables.g" importer->tmp_tcp_flags_list.push_back(importer->tmp_tcp_flag_code); -#line 4095 "IPTCfgParser.cpp" +#line 4096 "IPTCfgParser.cpp" } { // ( ... )* for (;;) { @@ -4099,12 +4100,12 @@ void IPTCfgParser::tcp_flags_list() { match(COMMA); tcp_flag_word(); if ( inputState->guessing==0 ) { -#line 1089 "iptables.g" +#line 1090 "iptables.g" importer->tmp_tcp_flags_list.push_back( importer->tmp_tcp_flag_code); -#line 4108 "IPTCfgParser.cpp" +#line 4109 "IPTCfgParser.cpp" } } else { diff --git a/src/parsers/PIXCfgLexer.cpp b/src/parsers/PIXCfgLexer.cpp index 527fe75fe..2c0228831 100644 --- a/src/parsers/PIXCfgLexer.cpp +++ b/src/parsers/PIXCfgLexer.cpp @@ -443,7 +443,7 @@ void PIXCfgLexer::mNEWLINE(bool _createToken) { } if ( inputState->guessing==0 ) { -#line 784 "pix.g" +#line 786 "pix.g" newline(); #line 449 "PIXCfgLexer.cpp" } @@ -567,7 +567,7 @@ void PIXCfgLexer::mWhitespace(bool _createToken) { } } if ( inputState->guessing==0 ) { -#line 779 "pix.g" +#line 781 "pix.g" _ttype = ANTLR_USE_NAMESPACE(antlr)Token::SKIP; #line 573 "PIXCfgLexer.cpp" } @@ -803,7 +803,7 @@ void PIXCfgLexer::mNUMBER(bool _createToken) { } // ( ... )+ } if ( inputState->guessing==0 ) { -#line 804 "pix.g" +#line 806 "pix.g" _ttype = IPV4; #line 809 "PIXCfgLexer.cpp" } @@ -906,7 +906,7 @@ void PIXCfgLexer::mNUMBER(bool _createToken) { } // ( ... )+ } if ( inputState->guessing==0 ) { -#line 810 "pix.g" +#line 812 "pix.g" _ttype = HEX_CONST; #line 912 "PIXCfgLexer.cpp" } @@ -927,7 +927,7 @@ void PIXCfgLexer::mNUMBER(bool _createToken) { _loop133:; } // ( ... )+ if ( inputState->guessing==0 ) { -#line 808 "pix.g" +#line 810 "pix.g" _ttype = INT_CONST; #line 933 "PIXCfgLexer.cpp" } diff --git a/src/parsers/PIXCfgParser.cpp b/src/parsers/PIXCfgParser.cpp index 1b8d9db70..2b69a9efe 100644 --- a/src/parsers/PIXCfgParser.cpp +++ b/src/parsers/PIXCfgParser.cpp @@ -331,7 +331,7 @@ void PIXCfgParser::intrface() { in = LT(1); match(WORD); if ( inputState->guessing==0 ) { -#line 463 "pix.g" +#line 465 "pix.g" importer->newInterface( in->getText() ); *dbg << in->getLine() << ":" @@ -359,7 +359,7 @@ void PIXCfgParser::vlan_interface() { vlan_id = LT(1); match(INT_CONST); if ( inputState->guessing==0 ) { -#line 472 "pix.g" +#line 474 "pix.g" importer->setInterfaceVlanId(vlan_id->getText()); *dbg << " VLAN: " << vlan_id->getText() << std::endl; @@ -386,7 +386,7 @@ void PIXCfgParser::sec_level() { sec_level = LT(1); match(INT_CONST); if ( inputState->guessing==0 ) { -#line 480 "pix.g" +#line 482 "pix.g" importer->setInterfaceSecurityLevel(sec_level->getText()); *dbg << "SEC_LEVEL: " << sec_level->getText() << std::endl; @@ -437,7 +437,7 @@ void PIXCfgParser::nameif() { } } if ( inputState->guessing==0 ) { -#line 488 "pix.g" +#line 490 "pix.g" std::string label = (intf_label) ? intf_label->getText() : ""; std::string seclevel = (sec_level) ? sec_level->getText() : ""; @@ -463,7 +463,7 @@ void PIXCfgParser::controller() { try { // for error handling match(CONTROLLER); if ( inputState->guessing==0 ) { -#line 417 "pix.g" +#line 419 "pix.g" importer->clearCurrentInterface(); consumeUntil(NEWLINE); @@ -551,7 +551,7 @@ void PIXCfgParser::description() { try { // for error handling match(DESCRIPTION); if ( inputState->guessing==0 ) { -#line 500 "pix.g" +#line 502 "pix.g" *dbg << LT(1)->getLine() << ":"; std::string descr; @@ -582,7 +582,7 @@ void PIXCfgParser::shutdown() { try { // for error handling match(SHUTDOWN); if ( inputState->guessing==0 ) { -#line 535 "pix.g" +#line 537 "pix.g" *dbg<< LT(1)->getLine() << ":" << " INTERFACE SHUTDOWN " << std::endl; @@ -804,20 +804,21 @@ void PIXCfgParser::permit_ext() { if ( inputState->guessing==0 ) { #line 221 "pix.g" + importer->setCurrentLineNumber(LT(0)->getLine()); importer->newPolicyRule(); importer->action = "permit"; *dbg << LT(1)->getLine() << ":" << " permit "; -#line 812 "PIXCfgParser.cpp" +#line 813 "PIXCfgParser.cpp" } rule_ext(); match(NEWLINE); if ( inputState->guessing==0 ) { -#line 227 "pix.g" +#line 228 "pix.g" importer->pushRule(); -#line 821 "PIXCfgParser.cpp" +#line 822 "PIXCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -835,22 +836,23 @@ void PIXCfgParser::deny_ext() { try { // for error handling match(DENY); if ( inputState->guessing==0 ) { -#line 233 "pix.g" +#line 234 "pix.g" + importer->setCurrentLineNumber(LT(0)->getLine()); importer->newPolicyRule(); importer->action = "deny"; *dbg << LT(1)->getLine() << ":" << " deny "; -#line 845 "PIXCfgParser.cpp" +#line 847 "PIXCfgParser.cpp" } rule_ext(); match(NEWLINE); if ( inputState->guessing==0 ) { -#line 239 "pix.g" +#line 241 "pix.g" importer->pushRule(); -#line 854 "PIXCfgParser.cpp" +#line 856 "PIXCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -868,7 +870,7 @@ void PIXCfgParser::remark() { try { // for error handling match(REMARK); if ( inputState->guessing==0 ) { -#line 520 "pix.g" +#line 522 "pix.g" *dbg << LT(1)->getLine() << ":"; std::string rem; @@ -881,7 +883,7 @@ void PIXCfgParser::remark() { *dbg << " REMARK " << rem << std::endl; //consumeUntil(NEWLINE); -#line 885 "PIXCfgParser.cpp" +#line 887 "PIXCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -905,15 +907,15 @@ void PIXCfgParser::rule_ext() { ip_protocols(); hostaddr_ext(); if ( inputState->guessing==0 ) { -#line 249 "pix.g" +#line 251 "pix.g" importer->SaveTmpAddrToSrc(); *dbg << "(src) "; -#line 911 "PIXCfgParser.cpp" +#line 913 "PIXCfgParser.cpp" } hostaddr_ext(); if ( inputState->guessing==0 ) { -#line 250 "pix.g" +#line 252 "pix.g" importer->SaveTmpAddrToDst(); *dbg << "(dst) "; -#line 917 "PIXCfgParser.cpp" +#line 919 "PIXCfgParser.cpp" } { switch ( LA(1)) { @@ -978,24 +980,24 @@ void PIXCfgParser::rule_ext() { { match(ICMP); if ( inputState->guessing==0 ) { -#line 256 "pix.g" +#line 258 "pix.g" importer->protocol = LT(0)->getText(); *dbg << "protocol " << LT(0)->getText() << " "; -#line 987 "PIXCfgParser.cpp" +#line 989 "PIXCfgParser.cpp" } hostaddr_ext(); if ( inputState->guessing==0 ) { -#line 260 "pix.g" +#line 262 "pix.g" importer->SaveTmpAddrToSrc(); *dbg << "(src) "; -#line 993 "PIXCfgParser.cpp" +#line 995 "PIXCfgParser.cpp" } hostaddr_ext(); if ( inputState->guessing==0 ) { -#line 261 "pix.g" +#line 263 "pix.g" importer->SaveTmpAddrToDst(); *dbg << "(dst) "; -#line 999 "PIXCfgParser.cpp" +#line 1001 "PIXCfgParser.cpp" } { switch ( LA(1)) { @@ -1100,18 +1102,18 @@ void PIXCfgParser::rule_ext() { } } if ( inputState->guessing==0 ) { -#line 268 "pix.g" +#line 270 "pix.g" importer->protocol = LT(0)->getText(); *dbg << "protocol " << LT(0)->getText() << " "; -#line 1109 "PIXCfgParser.cpp" +#line 1111 "PIXCfgParser.cpp" } hostaddr_ext(); if ( inputState->guessing==0 ) { -#line 272 "pix.g" +#line 274 "pix.g" importer->SaveTmpAddrToSrc(); *dbg << "(src) "; -#line 1115 "PIXCfgParser.cpp" +#line 1117 "PIXCfgParser.cpp" } { switch ( LA(1)) { @@ -1123,9 +1125,9 @@ void PIXCfgParser::rule_ext() { { xoperator(); if ( inputState->guessing==0 ) { -#line 273 "pix.g" +#line 275 "pix.g" importer->SaveTmpPortToSrc(); -#line 1129 "PIXCfgParser.cpp" +#line 1131 "PIXCfgParser.cpp" } break; } @@ -1143,9 +1145,9 @@ void PIXCfgParser::rule_ext() { } hostaddr_ext(); if ( inputState->guessing==0 ) { -#line 274 "pix.g" +#line 276 "pix.g" importer->SaveTmpAddrToDst(); *dbg << "(dst) "; -#line 1149 "PIXCfgParser.cpp" +#line 1151 "PIXCfgParser.cpp" } { switch ( LA(1)) { @@ -1157,9 +1159,9 @@ void PIXCfgParser::rule_ext() { { xoperator(); if ( inputState->guessing==0 ) { -#line 275 "pix.g" +#line 277 "pix.g" importer->SaveTmpPortToDst(); -#line 1163 "PIXCfgParser.cpp" +#line 1165 "PIXCfgParser.cpp" } break; } @@ -1265,11 +1267,11 @@ void PIXCfgParser::rule_ext() { } } if ( inputState->guessing==0 ) { -#line 281 "pix.g" +#line 283 "pix.g" *dbg << std::endl; -#line 1273 "PIXCfgParser.cpp" +#line 1275 "PIXCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1304,12 +1306,12 @@ void PIXCfgParser::ip_protocols() { } } if ( inputState->guessing==0 ) { -#line 289 "pix.g" +#line 291 "pix.g" importer->protocol = LT(0)->getText(); *dbg << "protocol " << LT(0)->getText() << " "; -#line 1313 "PIXCfgParser.cpp" +#line 1315 "PIXCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1337,13 +1339,13 @@ void PIXCfgParser::hostaddr_ext() { match(IPV4); } if ( inputState->guessing==0 ) { -#line 341 "pix.g" +#line 343 "pix.g" importer->tmp_a = h->getText(); importer->tmp_nm = "0.0.0.0"; *dbg << h->getText() << "/0.0.0.0"; -#line 1347 "PIXCfgParser.cpp" +#line 1349 "PIXCfgParser.cpp" } break; } @@ -1356,13 +1358,13 @@ void PIXCfgParser::hostaddr_ext() { match(IPV4); } if ( inputState->guessing==0 ) { -#line 348 "pix.g" +#line 350 "pix.g" importer->tmp_a = a->getText(); importer->tmp_nm = m->getText(); *dbg << a->getText() << "/" << m->getText(); -#line 1366 "PIXCfgParser.cpp" +#line 1368 "PIXCfgParser.cpp" } break; } @@ -1370,13 +1372,13 @@ void PIXCfgParser::hostaddr_ext() { { match(ANY); if ( inputState->guessing==0 ) { -#line 355 "pix.g" +#line 357 "pix.g" importer->tmp_a = "0.0.0.0"; importer->tmp_nm = "0.0.0.0"; *dbg << "0.0.0.0/0.0.0.0"; -#line 1380 "PIXCfgParser.cpp" +#line 1382 "PIXCfgParser.cpp" } break; } @@ -1404,12 +1406,12 @@ void PIXCfgParser::time_range() { tr_name = LT(1); match(WORD); if ( inputState->guessing==0 ) { -#line 407 "pix.g" +#line 409 "pix.g" importer->time_range_name = tr_name->getText(); *dbg << "time_range " << tr_name->getText() << " "; -#line 1413 "PIXCfgParser.cpp" +#line 1415 "PIXCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1427,12 +1429,12 @@ void PIXCfgParser::fragments() { try { // for error handling match(FRAGMENTS); if ( inputState->guessing==0 ) { -#line 400 "pix.g" +#line 402 "pix.g" importer->fragments = true; *dbg << "fragments "; -#line 1436 "PIXCfgParser.cpp" +#line 1438 "PIXCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1467,12 +1469,12 @@ void PIXCfgParser::log() { } } if ( inputState->guessing==0 ) { -#line 386 "pix.g" +#line 388 "pix.g" importer->logging = true; *dbg << "logging "; -#line 1476 "PIXCfgParser.cpp" +#line 1478 "PIXCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1502,7 +1504,7 @@ void PIXCfgParser::icmp_spec() { match(INT_CONST); } if ( inputState->guessing==0 ) { -#line 297 "pix.g" +#line 299 "pix.g" importer->icmp_type = icmp_type->getText(); importer->icmp_code = icmp_code->getText(); @@ -1510,7 +1512,7 @@ void PIXCfgParser::icmp_spec() { *dbg << icmp_type->getText() << " " << icmp_code->getText() << " "; -#line 1514 "PIXCfgParser.cpp" +#line 1516 "PIXCfgParser.cpp" } break; } @@ -1519,12 +1521,12 @@ void PIXCfgParser::icmp_spec() { icmp_word = LT(1); match(WORD); if ( inputState->guessing==0 ) { -#line 306 "pix.g" +#line 308 "pix.g" importer->icmp_spec = icmp_word->getText(); *dbg << icmp_word->getText() << " "; -#line 1528 "PIXCfgParser.cpp" +#line 1530 "PIXCfgParser.cpp" } break; } @@ -1583,12 +1585,12 @@ void PIXCfgParser::established() { try { // for error handling match(ESTABLISHED); if ( inputState->guessing==0 ) { -#line 393 "pix.g" +#line 395 "pix.g" importer->established = true; *dbg << "established "; -#line 1592 "PIXCfgParser.cpp" +#line 1594 "PIXCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1633,12 +1635,12 @@ void PIXCfgParser::single_port_op() { } } if ( inputState->guessing==0 ) { -#line 317 "pix.g" +#line 319 "pix.g" importer->tmp_port_op = LT(0)->getText(); *dbg << LT(0)->getText() << " "; -#line 1642 "PIXCfgParser.cpp" +#line 1644 "PIXCfgParser.cpp" } port_spec(); } @@ -1657,12 +1659,12 @@ void PIXCfgParser::port_range() { try { // for error handling match(P_RANGE); if ( inputState->guessing==0 ) { -#line 325 "pix.g" +#line 327 "pix.g" importer->tmp_port_op = LT(0)->getText(); *dbg << LT(0)->getText() << " "; -#line 1666 "PIXCfgParser.cpp" +#line 1668 "PIXCfgParser.cpp" } port_spec(); port_spec(); @@ -1699,12 +1701,12 @@ void PIXCfgParser::port_spec() { } } if ( inputState->guessing==0 ) { -#line 333 "pix.g" +#line 335 "pix.g" importer->tmp_port_spec += (std::string(" ") + LT(0)->getText()); *dbg << LT(0)->getText() << " "; -#line 1708 "PIXCfgParser.cpp" +#line 1710 "PIXCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1729,13 +1731,13 @@ void PIXCfgParser::hostaddr_std() { match(IPV4); } if ( inputState->guessing==0 ) { -#line 364 "pix.g" +#line 366 "pix.g" importer->tmp_a = h->getText(); importer->tmp_nm = "0.0.0.0"; *dbg << h->getText() << "/0.0.0.0"; -#line 1739 "PIXCfgParser.cpp" +#line 1741 "PIXCfgParser.cpp" } } else if ((LA(1) == IPV4) && (LA(2) == IPV4)) { @@ -1746,25 +1748,25 @@ void PIXCfgParser::hostaddr_std() { match(IPV4); } if ( inputState->guessing==0 ) { -#line 371 "pix.g" +#line 373 "pix.g" importer->tmp_a = a->getText(); importer->tmp_nm = m->getText(); *dbg << a->getText() << "/" << m->getText(); -#line 1756 "PIXCfgParser.cpp" +#line 1758 "PIXCfgParser.cpp" } } else if ((LA(1) == ANY)) { match(ANY); if ( inputState->guessing==0 ) { -#line 378 "pix.g" +#line 380 "pix.g" importer->tmp_a = "0.0.0.0"; importer->tmp_nm = "0.0.0.0"; *dbg << "0.0.0.0/0.0.0.0"; -#line 1768 "PIXCfgParser.cpp" +#line 1770 "PIXCfgParser.cpp" } } else { @@ -1826,10 +1828,10 @@ void PIXCfgParser::switchport() { vlan_num = LT(1); match(WORD); if ( inputState->guessing==0 ) { -#line 640 "pix.g" +#line 642 "pix.g" -#line 1833 "PIXCfgParser.cpp" +#line 1835 "PIXCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1906,7 +1908,7 @@ void PIXCfgParser::v6_dhcp_address() { dhcp = LT(1); match(DHCP); if ( inputState->guessing==0 ) { -#line 578 "pix.g" +#line 580 "pix.g" std::string label = lbl->getText(); std::string addr = dhcp->getText(); @@ -1917,7 +1919,7 @@ void PIXCfgParser::v6_dhcp_address() { // which we do not support consumeUntil(NEWLINE); -#line 1921 "PIXCfgParser.cpp" +#line 1923 "PIXCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1943,7 +1945,7 @@ void PIXCfgParser::v6_static_address() { m = LT(1); match(IPV4); if ( inputState->guessing==0 ) { -#line 591 "pix.g" +#line 593 "pix.g" std::string label = lbl->getText(); std::string addr = a->getText(); @@ -1954,7 +1956,7 @@ void PIXCfgParser::v6_static_address() { // in case there are some other parameters after address and netmask consumeUntil(NEWLINE); -#line 1958 "PIXCfgParser.cpp" +#line 1960 "PIXCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -1974,7 +1976,7 @@ void PIXCfgParser::v7_dhcp_address() { dhcp = LT(1); match(DHCP); if ( inputState->guessing==0 ) { -#line 608 "pix.g" +#line 610 "pix.g" std::string addr = dhcp->getText(); importer->addInterfaceAddress(addr, ""); @@ -1982,7 +1984,7 @@ void PIXCfgParser::v7_dhcp_address() { << " INTRFACE ADDRESS: " << addr << std::endl; consumeUntil(NEWLINE); -#line 1986 "PIXCfgParser.cpp" +#line 1988 "PIXCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -2024,7 +2026,7 @@ void PIXCfgParser::v7_static_address() { } } if ( inputState->guessing==0 ) { -#line 619 "pix.g" +#line 621 "pix.g" std::string addr = a->getText(); std::string netm = m->getText(); @@ -2041,7 +2043,7 @@ void PIXCfgParser::v7_static_address() { } consumeUntil(NEWLINE); -#line 2045 "PIXCfgParser.cpp" +#line 2047 "PIXCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { @@ -2069,7 +2071,7 @@ void PIXCfgParser::access_group_by_name() { intf_label = LT(1); match(WORD); if ( inputState->guessing==0 ) { -#line 647 "pix.g" +#line 649 "pix.g" importer->setInterfaceAndDirectionForRuleSet( acln->getText(), @@ -2080,7 +2082,7 @@ void PIXCfgParser::access_group_by_name() { << " " << intf_label->getText() << " " << dir->getText() << std::endl; -#line 2084 "PIXCfgParser.cpp" +#line 2086 "PIXCfgParser.cpp" } } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { diff --git a/src/parsers/iosacl.g b/src/parsers/iosacl.g index 981692308..cb7e475bf 100644 --- a/src/parsers/iosacl.g +++ b/src/parsers/iosacl.g @@ -220,6 +220,7 @@ ip_access_list_ext : ACCESS_LIST EXTENDED name:WORD //**************************************************************** permit_ext: PERMIT { + importer->setCurrentLineNumber(LT(0)->getLine()); importer->newPolicyRule(); importer->action = "permit"; *dbg << LT(1)->getLine() << ":" << " permit "; @@ -232,6 +233,7 @@ permit_ext: PERMIT deny_ext: DENY { + importer->setCurrentLineNumber(LT(0)->getLine()); importer->newPolicyRule(); importer->action = "deny"; *dbg << LT(1)->getLine() << ":" << " deny "; @@ -245,6 +247,7 @@ deny_ext: DENY //**************************************************************** permit_std: PERMIT { + importer->setCurrentLineNumber(LT(0)->getLine()); importer->newPolicyRule(); importer->action = "permit"; *dbg << LT(1)->getLine() << ":" << " permit "; @@ -257,6 +260,7 @@ permit_std: PERMIT deny_std: DENY { + importer->setCurrentLineNumber(LT(0)->getLine()); importer->newPolicyRule(); importer->action = "deny"; *dbg << LT(1)->getLine() << ":" << " deny "; diff --git a/src/parsers/iptables.g b/src/parsers/iptables.g index 55cd7e1c8..fd416a59e 100644 --- a/src/parsers/iptables.g +++ b/src/parsers/iptables.g @@ -177,6 +177,7 @@ add_rule : ADD_RULE chain_def *dbg << std::endl; importer->pushRule(); // start new one + importer->setCurrentLineNumber(LT(0)->getLine()); if (importer->current_table=="nat") importer->newNATRule(); else diff --git a/src/parsers/pix.g b/src/parsers/pix.g index b96ecf547..8acb7d835 100644 --- a/src/parsers/pix.g +++ b/src/parsers/pix.g @@ -219,6 +219,7 @@ ip_access_list_ext : ACCESS_LIST name:WORD //**************************************************************** permit_ext: PERMIT { + importer->setCurrentLineNumber(LT(0)->getLine()); importer->newPolicyRule(); importer->action = "permit"; *dbg << LT(1)->getLine() << ":" << " permit "; @@ -231,6 +232,7 @@ permit_ext: PERMIT deny_ext: DENY { + importer->setCurrentLineNumber(LT(0)->getLine()); importer->newPolicyRule(); importer->action = "deny"; *dbg << LT(1)->getLine() << ":" << " deny ";