From b4a8266b640447fbd38d38b21d758d2cf86fb274 Mon Sep 17 00:00:00 2001 From: Vadim Kurland Date: Fri, 1 Apr 2011 11:39:45 -0700 Subject: [PATCH] see #2296 added log records for access-list lines --- src/import/Importer.cpp | 3 -- src/import/PIXImporter.cpp | 60 ++++++++++++++++++++++++++++++++--- src/import/PIXImporterNat.cpp | 14 -------- 3 files changed, 56 insertions(+), 21 deletions(-) diff --git a/src/import/Importer.cpp b/src/import/Importer.cpp index 23da4d24c..65e851325 100644 --- a/src/import/Importer.cpp +++ b/src/import/Importer.cpp @@ -522,9 +522,6 @@ void Importer::pushRule() assert(current_rule!=NULL); // populate all elements of the rule - //qDebug() << QString("Adding rule from line %1").arg(getCurrentLineNumber()) - // << "current_rule=" << current_rule; - PolicyRule *rule = PolicyRule::cast(current_rule); FWOptions *ropt = current_rule->getOptionsObject(); diff --git a/src/import/PIXImporter.cpp b/src/import/PIXImporter.cpp index 0d97d5114..20be24ce3 100644 --- a/src/import/PIXImporter.cpp +++ b/src/import/PIXImporter.cpp @@ -280,14 +280,66 @@ void PIXImporter::addLogging() void PIXImporter::pushRule() { -// assert(current_ruleset!=NULL); - if (current_rule==NULL) return; - if (rule_type == NATRule::Unknown) - IOSImporter::pushRule(); + pushPolicyRule(); else pushNATRule(); + + assert(current_rule!=NULL); + + if (error_tracker->hasErrors()) + { + QStringList err = error_tracker->getErrors(); + addMessageToLog("Error: " + err.join("\n")); + markCurrentRuleBad(); + } + + current_rule = NULL; + rule_comment = ""; + + clear(); + } + +void PIXImporter::pushPolicyRule() +{ + assert(current_ruleset!=NULL); + assert(current_rule!=NULL); + // populate all elements of the rule + + addMessageToLog(QString("access list rule, action %1").arg(action.c_str())); + + PolicyRule *rule = PolicyRule::cast(current_rule); + + FWOptions *ropt = current_rule->getOptionsObject(); + assert(ropt!=NULL); + + if (action=="permit") + { + rule->setAction(PolicyRule::Accept); + ropt->setBool("stateless", false); + } + + if (action=="deny") + { + rule->setAction(PolicyRule::Deny); + ropt->setBool("stateless", true); + } + + rule->setDirection(PolicyRule::Both); + + addSrc(); + addDst(); + addSrv(); + + addLogging(); + + // then add it to the current ruleset + current_ruleset->ruleset->add(current_rule); + addStandardImportComment( + current_rule, QString::fromUtf8(rule_comment.c_str())); +} + /* * Rearrange vlan interfaces. Importer creates all interfaces as diff --git a/src/import/PIXImporterNat.cpp b/src/import/PIXImporterNat.cpp index 595497001..0010bbcb1 100644 --- a/src/import/PIXImporterNat.cpp +++ b/src/import/PIXImporterNat.cpp @@ -111,20 +111,6 @@ void PIXImporter::pushNATRule() default: assert(rule_type!=NATRule::DNAT && rule_type!=NATRule::SNAT); } - - assert(current_rule!=NULL); - - if (error_tracker->hasErrors()) - { - QStringList err = error_tracker->getErrors(); - addMessageToLog("Error: " + err.join("\n")); - markCurrentRuleBad(); - } - - current_rule = NULL; - rule_comment = ""; - - clear(); } /*