mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-03-25 12:47:44 +01:00
Support for action in NAT rules Refs #84
This commit is contained in:
parent
dca59dd9ae
commit
0dc0a989f0
@ -53,6 +53,7 @@
|
||||
#include <QStackedWidget>
|
||||
#include <qcursor.h>
|
||||
#include <qregexp.h>
|
||||
#include <QtDebug>
|
||||
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
@ -103,7 +104,7 @@ ActionsDialog::~ActionsDialog()
|
||||
|
||||
void ActionsDialog::loadFWObject(FWObject *o)
|
||||
{
|
||||
setRule(PolicyRule::cast(o));
|
||||
setRule(Rule::cast(o));
|
||||
}
|
||||
|
||||
void ActionsDialog::getHelpName(QString *str)
|
||||
@ -163,23 +164,25 @@ void ActionsDialog::applyChanges()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
data.saveAll();
|
||||
|
||||
PolicyRule *policy_rule = PolicyRule::cast(rule);
|
||||
NATRule *nat_rule = NATRule::cast(rule);
|
||||
|
||||
FWOptions *ropt = rule->getOptionsObject();
|
||||
|
||||
if (editor=="TagInt")
|
||||
{
|
||||
FWObject *tag_object = m_dialog->iptTagDropArea->getObject();
|
||||
// if tag_object==NULL, setTagObject clears setting in the rule
|
||||
rule->setTagObject(tag_object);
|
||||
policy_rule->setTagObject(tag_object);
|
||||
}
|
||||
|
||||
if (editor=="TagStr")
|
||||
{
|
||||
FWObject *tag_object = m_dialog->pfTagDropArea->getObject();
|
||||
// if tag_object==NULL, setTagObject clears setting in the rule
|
||||
rule->setTagObject(tag_object);
|
||||
policy_rule->setTagObject(tag_object);
|
||||
}
|
||||
|
||||
if (editor=="BranchChain")
|
||||
@ -226,34 +229,31 @@ void ActionsDialog::iptRouteContinueToggled()
|
||||
m_dialog->ipt_tee->setEnabled( ! m_dialog->ipt_continue->isChecked() );
|
||||
}
|
||||
|
||||
void ActionsDialog::setRule(PolicyRule *r )
|
||||
void ActionsDialog::setRule(Rule *r)
|
||||
{
|
||||
rule=r;
|
||||
FWObject *o = rule;
|
||||
while (o!=NULL && Firewall::cast(o)==NULL) o=o->getParent();
|
||||
rule = r;
|
||||
|
||||
PolicyRule *policy_rule = PolicyRule::cast(r);
|
||||
NATRule *nat_rule = NATRule::cast(r);
|
||||
|
||||
FWObject *o = r;
|
||||
while (o!=NULL && Firewall::cast(o)==NULL) o = o->getParent();
|
||||
assert(o!=NULL);
|
||||
|
||||
FWOptions *ropt = rule->getOptionsObject();
|
||||
|
||||
Firewall *f=Firewall::cast(o);
|
||||
firewall=f;
|
||||
Firewall *f = Firewall::cast(o);
|
||||
firewall = f;
|
||||
|
||||
platform=f->getStr("platform");
|
||||
|
||||
// QString icn = ":/Icons/" ;
|
||||
// icn += r->getActionAsString().c_str();
|
||||
// m_dialog->icon->setPixmap(QIcon(icn).pixmap(25,25));
|
||||
string act;
|
||||
if (policy_rule) act = policy_rule->getActionAsString();
|
||||
if (nat_rule) act = nat_rule->getActionAsString();
|
||||
|
||||
// QString title=QString("%3 %1 / %2")
|
||||
// .arg(QString::fromUtf8(f->getName().c_str()))
|
||||
// .arg(rule->getPosition())
|
||||
// .arg(rule->getActionAsString().c_str());
|
||||
// m_dialog->action->setText(title);
|
||||
|
||||
string act = rule->getActionAsString();
|
||||
help_name = string(platform + "_" + act).c_str();
|
||||
|
||||
QStringList actionsOnReject=getActionsOnReject( platform.c_str() );
|
||||
QStringList actionsOnReject = getActionsOnReject( platform.c_str() );
|
||||
m_dialog->rejectvalue->clear();
|
||||
m_dialog->rejectvalue->addItems( getScreenNames( actionsOnReject ) );
|
||||
|
||||
@ -352,14 +352,14 @@ void ActionsDialog::setRule(PolicyRule *r )
|
||||
else if (editor=="TagInt")
|
||||
{
|
||||
w=m_dialog->TagIntPage;
|
||||
FWObject *o = rule->getTagObject();
|
||||
FWObject *o = policy_rule->getTagObject();
|
||||
m_dialog->iptTagDropArea->setObject(o);
|
||||
m_dialog->iptTagDropArea->update();
|
||||
}
|
||||
else if (editor=="TagStr")
|
||||
{
|
||||
w=m_dialog->TagStrPage;
|
||||
FWObject *o = rule->getTagObject();
|
||||
FWObject *o = policy_rule->getTagObject();
|
||||
m_dialog->pfTagDropArea->setObject(o);
|
||||
m_dialog->pfTagDropArea->update();
|
||||
}
|
||||
@ -385,7 +385,7 @@ void ActionsDialog::setRule(PolicyRule *r )
|
||||
}
|
||||
else if (editor=="BranchChain")
|
||||
{
|
||||
w=m_dialog->BranchChainPage;
|
||||
w = m_dialog->BranchChainPage;
|
||||
RuleSet *ruleset = r->getBranch();
|
||||
m_dialog->iptBranchDropArea->setObject(ruleset);
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
|
||||
namespace libfwbuilder
|
||||
{
|
||||
class PolicyRule;
|
||||
class Rule;
|
||||
class Firewall;
|
||||
}
|
||||
|
||||
@ -50,15 +50,16 @@ class FWObjectDropArea;
|
||||
|
||||
class ActionsDialog : public BaseObjectDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
Q_OBJECT;
|
||||
|
||||
private:
|
||||
libfwbuilder::Firewall *firewall;
|
||||
libfwbuilder::PolicyRule *rule;
|
||||
std::string editor;
|
||||
std::string platform;
|
||||
QLineEdit *branchNameInput;
|
||||
libfwbuilder::Rule *rule;
|
||||
std::string editor;
|
||||
std::string platform;
|
||||
QLineEdit *branchNameInput;
|
||||
|
||||
DialogData data;
|
||||
DialogData data;
|
||||
FWObjectDropArea * BranchChainArea ;
|
||||
FWObjectDropArea * BranchAnchorArea;
|
||||
FWObjectDropArea * TagIntArea ;
|
||||
@ -83,7 +84,7 @@ public slots:
|
||||
virtual void loadFWObject(libfwbuilder::FWObject *obj);
|
||||
virtual void validate(bool*);
|
||||
virtual void getHelpName(QString*);
|
||||
void setRule(libfwbuilder::PolicyRule*);
|
||||
void setRule(libfwbuilder::Rule*);
|
||||
|
||||
|
||||
};
|
||||
|
||||
BIN
src/gui/Icons/translate_16.png
Normal file
BIN
src/gui/Icons/translate_16.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 767 B |
BIN
src/gui/Icons/translate_25.png
Normal file
BIN
src/gui/Icons/translate_25.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
@ -1,5 +1,7 @@
|
||||
<RCC>
|
||||
<qresource prefix="/" >
|
||||
<file alias="Icons/Translate-tree" >Icons/translate_16.png</file>
|
||||
<file alias="Icons/Translate" >Icons/translate_25.png</file>
|
||||
<file alias="Icons/Routing/icon" >Icons/routing_25.png</file>
|
||||
<file alias="Icons/Routing/icon-tree" >Icons/routing_16.png</file>
|
||||
<file alias="Icons/FailoverClusterGroup/icon-neg-tree" >Icons/failover-cluster-group-neg_16.png</file>
|
||||
|
||||
@ -934,6 +934,9 @@ void RuleSetModel::setEnabled(const QModelIndex &index, bool flag)
|
||||
rowChanged(index);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: should just use FWObject::duplucate() since it does all of this
|
||||
*/
|
||||
void RuleSetModel::copyRuleContent(Rule *dst, Rule *src)
|
||||
{
|
||||
int id = dst->getId();
|
||||
@ -1101,8 +1104,6 @@ void RuleSetModel::resetAllSizes()
|
||||
|
||||
void PolicyModel::configure()
|
||||
{
|
||||
//if (fwbdebug) qDebug() << "PolicyModel::initModel";
|
||||
|
||||
supports_logging = false;
|
||||
supports_rule_options = false;
|
||||
supports_time = false;
|
||||
@ -1182,7 +1183,6 @@ QString PolicyModel::getRuleDirection(Rule* r) const
|
||||
QStringList PolicyModel::getRuleOptions(Rule* r) const
|
||||
{
|
||||
QStringList res;
|
||||
|
||||
PolicyRule *policyRule = PolicyRule::cast( r );
|
||||
if (policyRule->getLogging()) res << "Log";
|
||||
if (!isDefaultPolicyRuleOptions(r->getOptionsObject())) res << "Options";
|
||||
@ -1192,15 +1192,18 @@ QStringList PolicyModel::getRuleOptions(Rule* r) const
|
||||
|
||||
QString PolicyModel::getRuleAction(Rule* r) const
|
||||
{
|
||||
PolicyRule *policyRule = PolicyRule::cast( r );
|
||||
QString res = policyRule->getActionAsString().c_str();
|
||||
PolicyRule *policy_rule = PolicyRule::cast( r );
|
||||
NATRule *nat_rule = NATRule::cast( r );
|
||||
QString res;
|
||||
if (policy_rule) res = policy_rule->getActionAsString().c_str();
|
||||
if (nat_rule) res = nat_rule->getActionAsString().c_str();
|
||||
return res;
|
||||
}
|
||||
|
||||
void PolicyModel::initRule(Rule *new_rule, Rule *old_rule)
|
||||
{
|
||||
//if (fwbdebug) qDebug() << "PolicyModel::initRule";
|
||||
PolicyRule *newrule_as_policy_rule = PolicyRule::cast(new_rule);
|
||||
|
||||
if (newrule_as_policy_rule)
|
||||
{
|
||||
newrule_as_policy_rule->setLogging(supports_logging);
|
||||
@ -1209,9 +1212,7 @@ void PolicyModel::initRule(Rule *new_rule, Rule *old_rule)
|
||||
FWOptions *ruleopt = newrule_as_policy_rule->getOptionsObject();
|
||||
ruleopt->setBool("stateless",
|
||||
getStatelessFlagForAction(newrule_as_policy_rule));
|
||||
|
||||
}
|
||||
|
||||
if (old_rule!=NULL) copyRuleContent(new_rule, old_rule);
|
||||
}
|
||||
|
||||
@ -1228,16 +1229,28 @@ bool PolicyModel::checkRuleType(libfwbuilder::Rule *rule)
|
||||
|
||||
void NatModel::configure()
|
||||
{
|
||||
//if (fwbdebug) qDebug() << "NatModel::configure";
|
||||
supports_actions = false;
|
||||
|
||||
if (getFirewall())
|
||||
{
|
||||
try {
|
||||
supports_actions = Resources::getTargetCapabilityBool(
|
||||
getFirewall()->getStr("platform"), "actions_in_nat");
|
||||
} catch(FWException &ex) { }
|
||||
}
|
||||
|
||||
header << ColDesc(RuleElementOSrc::TYPENAME, ColDesc::Object) // 1
|
||||
<< ColDesc(RuleElementODst::TYPENAME, ColDesc::Object) // 2
|
||||
<< ColDesc(RuleElementOSrv::TYPENAME, ColDesc::Object) // 3
|
||||
<< ColDesc(RuleElementTSrc::TYPENAME, ColDesc::Object) // 4
|
||||
<< ColDesc(RuleElementTDst::TYPENAME, ColDesc::Object) // 5
|
||||
<< ColDesc(RuleElementTSrv::TYPENAME, ColDesc::Object) // 6
|
||||
<< ColDesc("Options", ColDesc::Options) // 7
|
||||
<< ColDesc("Comment", ColDesc::Comment); // 8
|
||||
<< ColDesc(RuleElementTSrv::TYPENAME, ColDesc::Object); // 6
|
||||
|
||||
if (supports_actions)
|
||||
header << ColDesc("Action", ColDesc::Action);
|
||||
|
||||
header << ColDesc("Options", ColDesc::Options) // 7
|
||||
<< ColDesc("Comment", ColDesc::Comment); // 8
|
||||
}
|
||||
|
||||
QVariant NatModel::getRuleDataForDisplayRole(const QModelIndex &index, RuleNode* node) const
|
||||
@ -1254,6 +1267,9 @@ QVariant NatModel::getRuleDataForDisplayRole(const QModelIndex &index, RuleNode*
|
||||
int idx = index.column()-1;
|
||||
switch (header[idx].type)
|
||||
{
|
||||
case ColDesc::Action :
|
||||
res.setValue<QString>(getRuleAction(node->rule));
|
||||
break;
|
||||
|
||||
case ColDesc::Options :
|
||||
res.setValue<QStringList>(getRuleOptions(node->rule));
|
||||
@ -1280,9 +1296,20 @@ QStringList NatModel::getRuleOptions(Rule* r) const
|
||||
return res;
|
||||
}
|
||||
|
||||
QString NatModel::getRuleAction(Rule* r) const
|
||||
{
|
||||
NATRule *natRule = NATRule::cast( r );
|
||||
QString res = natRule->getActionAsString().c_str();
|
||||
return res;
|
||||
}
|
||||
|
||||
void NatModel::initRule(Rule *new_rule, Rule *old_rule)
|
||||
{
|
||||
//if (fwbdebug) qDebug() << "NatModel::initRule";
|
||||
NATRule *natRule = NATRule::cast(new_rule);
|
||||
if (natRule)
|
||||
natRule->setAction(NATRule::Translate);
|
||||
|
||||
if (old_rule!=NULL) copyRuleContent(new_rule, old_rule);
|
||||
}
|
||||
|
||||
|
||||
@ -212,8 +212,11 @@ public:
|
||||
bool checkRuleType(libfwbuilder::Rule *rule);
|
||||
|
||||
private:
|
||||
bool supports_actions;
|
||||
|
||||
QVariant getRuleDataForDisplayRole(const QModelIndex &index, RuleNode* node) const;
|
||||
QStringList getRuleOptions(libfwbuilder::Rule* r) const;
|
||||
QString getRuleAction(libfwbuilder::Rule* r) const;
|
||||
void configure();
|
||||
};
|
||||
|
||||
|
||||
@ -347,7 +347,8 @@ QDrag* RuleSetView::dragObject()
|
||||
return drag;
|
||||
}
|
||||
|
||||
void RuleSetView::addColumnRelatedMenu(QMenu *menu,const QModelIndex &index, RuleNode* node, const QPoint& pos)
|
||||
void RuleSetView::addColumnRelatedMenu(QMenu *menu, const QModelIndex &index,
|
||||
RuleNode* node, const QPoint& pos)
|
||||
{
|
||||
RuleSetModel* md = ((RuleSetModel*)model());
|
||||
ColDesc colDesc = index.data(Qt::UserRole).value<ColDesc>();
|
||||
@ -356,96 +357,118 @@ void RuleSetView::addColumnRelatedMenu(QMenu *menu,const QModelIndex &index, Rul
|
||||
case ColDesc::Action:
|
||||
{
|
||||
Firewall *f = md->getFirewall();
|
||||
string platform=f->getStr("platform");
|
||||
string platform = f->getStr("platform");
|
||||
QString action_name;
|
||||
|
||||
if (Resources::isTargetActionSupported(platform,"Accept"))
|
||||
if (NATRule::isA(node->rule))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Accept,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Accept")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToAccept() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Deny"))
|
||||
if (Resources::isTargetActionSupported(platform,"Translate"))
|
||||
{
|
||||
action_name = getNatActionNameForPlatform(NATRule::Translate,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Continue")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToTranslate() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Branch"))
|
||||
{
|
||||
action_name = getNatActionNameForPlatform(NATRule::Branch,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Branch")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToNATBranch() ));
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Deny,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Deny")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToDeny() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Reject"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Reject,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Reject")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToReject() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Accounting"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Accounting,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Accounting")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToAccounting() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Pipe"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Pipe,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Pipe")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToPipe() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Tag"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Tag,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Tag")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToTag() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Classify"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Classify,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Classify")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToClassify() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Custom"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Custom,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Custom")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToCustom() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Branch"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Branch,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Branch")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToBranch() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Route"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Route,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Route")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToRoute() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Continue"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Continue,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Continue")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToContinue() ));
|
||||
if (Resources::isTargetActionSupported(platform,"Accept"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Accept,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Accept")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToAccept() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Deny"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Deny,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Deny")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToDeny() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Reject"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Reject,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Reject")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToReject() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Accounting"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Accounting,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Accounting")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToAccounting() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Pipe"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Pipe,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Pipe")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToPipe() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Tag"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Tag,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Tag")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToTag() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Classify"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Classify,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Classify")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToClassify() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Custom"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Custom,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Custom")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToCustom() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Branch"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Branch,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Branch")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToBranch() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Route"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Route,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Route")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToRoute() ));
|
||||
}
|
||||
if (Resources::isTargetActionSupported(platform,"Continue"))
|
||||
{
|
||||
action_name = getActionNameForPlatform(PolicyRule::Continue,
|
||||
platform.c_str());
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Continue")),
|
||||
action_name,
|
||||
this, SLOT( changeActionToContinue() ));
|
||||
}
|
||||
}
|
||||
|
||||
menu->addSeparator ();
|
||||
@ -463,6 +486,7 @@ void RuleSetView::addColumnRelatedMenu(QMenu *menu,const QModelIndex &index, Rul
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ColDesc::Direction:
|
||||
menu->addAction( QIcon(LoadPixmap(":/Icons/Inbound")),
|
||||
tr("Inbound"),
|
||||
@ -761,8 +785,8 @@ bool RuleSetView::switchObjectInEditor(const QModelIndex& index, bool validate)
|
||||
|
||||
case ColDesc::Action:
|
||||
{
|
||||
PolicyRule *prule = PolicyRule::cast( rule );
|
||||
object = prule;
|
||||
//PolicyRule *prule = PolicyRule::cast( rule );
|
||||
object = rule;
|
||||
operation = ObjectEditor::optAction;
|
||||
break;
|
||||
}
|
||||
@ -1555,8 +1579,11 @@ void RuleSetView::changeDitection(PolicyRule::Direction dir)
|
||||
|
||||
}
|
||||
|
||||
void RuleSetView::changeAction(PolicyRule::Action act)
|
||||
void RuleSetView::changeAction(int act)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug() << "RuleSetView::changeAction act=" << act;
|
||||
|
||||
RuleSetModel* md = ((RuleSetModel*)model());
|
||||
|
||||
if(!isTreeReadWrite(this,md->getRuleSet())) return;
|
||||
@ -1570,24 +1597,48 @@ void RuleSetView::changeAction(PolicyRule::Action act)
|
||||
|
||||
if (node->type != RuleNode::Rule) return;
|
||||
|
||||
PolicyRule *rule = PolicyRule::cast( node->rule );
|
||||
FWOptions *ruleopt = rule->getOptionsObject();
|
||||
PolicyRule::Action old_act=rule->getAction();
|
||||
RuleSet *subset = NULL;
|
||||
if (old_act==PolicyRule::Branch)
|
||||
subset = rule->getBranch();
|
||||
|
||||
if (act!=old_act)
|
||||
if (PolicyRule::isA(node->rule))
|
||||
{
|
||||
rule->setAction( act );
|
||||
QCoreApplication::postEvent(
|
||||
mw, new dataModifiedEvent(project->getFileName(), md->getRuleSet()->getId()));
|
||||
PolicyRule *rule = PolicyRule::cast( node->rule );
|
||||
FWOptions *ruleopt = rule->getOptionsObject();
|
||||
PolicyRule::Action old_act=rule->getAction();
|
||||
|
||||
if (fwbdebug) qDebug() << "PolicyRule old_action=" << old_act;
|
||||
|
||||
RuleSet *subset = NULL;
|
||||
if (old_act==PolicyRule::Branch) subset = rule->getBranch();
|
||||
if (act!=old_act)
|
||||
{
|
||||
rule->setAction(PolicyRule::Action(act));
|
||||
QCoreApplication::postEvent(
|
||||
mw, new dataModifiedEvent(project->getFileName(), md->getRuleSet()->getId()));
|
||||
}
|
||||
ruleopt->setBool("stateless", getStatelessFlagForAction(rule));
|
||||
}
|
||||
|
||||
ruleopt->setBool("stateless", getStatelessFlagForAction(rule));
|
||||
updateColumnSizeForIndex(index);
|
||||
if (NATRule::isA(node->rule))
|
||||
{
|
||||
NATRule *rule = NATRule::cast( node->rule );
|
||||
NATRule::NATAction old_act = rule->getAction();
|
||||
|
||||
mw->actionChangedEditor(rule);
|
||||
if (fwbdebug)
|
||||
qDebug() << "NATRule old_action=" << old_act
|
||||
<< "NATRule::Translate=" << NATRule::Translate
|
||||
<< "NATRule::Branch=" << NATRule::Branch;
|
||||
|
||||
|
||||
RuleSet *subset = NULL;
|
||||
if (old_act==NATRule::Branch) subset = rule->getBranch();
|
||||
if (act!=old_act)
|
||||
{
|
||||
rule->setAction(NATRule::NATAction(act));
|
||||
QCoreApplication::postEvent(
|
||||
mw, new dataModifiedEvent(project->getFileName(), md->getRuleSet()->getId()));
|
||||
}
|
||||
}
|
||||
|
||||
updateColumnSizeForIndex(index);
|
||||
mw->actionChangedEditor(node->rule);
|
||||
}
|
||||
|
||||
void RuleSetView::changeActionToAccept()
|
||||
@ -1645,6 +1696,17 @@ void RuleSetView::changeActionToBranch()
|
||||
changeAction( PolicyRule::Branch );
|
||||
}
|
||||
|
||||
void RuleSetView::changeActionToTranslate()
|
||||
{
|
||||
changeAction( NATRule::Translate );
|
||||
}
|
||||
|
||||
void RuleSetView::changeActionToNATBranch()
|
||||
{
|
||||
changeAction( NATRule::Branch );
|
||||
}
|
||||
|
||||
|
||||
void RuleSetView::changeLogToOn()
|
||||
{
|
||||
changeLogging(true);
|
||||
|
||||
@ -165,6 +165,8 @@ public slots:
|
||||
void changeActionToBranch();
|
||||
void changeActionToRoute();
|
||||
void changeActionToContinue();
|
||||
void changeActionToTranslate();
|
||||
void changeActionToNATBranch();
|
||||
|
||||
void changeLogToOn();
|
||||
void changeLogToOff();
|
||||
@ -235,7 +237,7 @@ private:
|
||||
void addColumnRelatedMenu(QMenu *menu,const QModelIndex &index, RuleNode *node, const QPoint& pos);
|
||||
|
||||
void changeDitection(libfwbuilder::PolicyRule::Direction dir);
|
||||
void changeAction(libfwbuilder::PolicyRule::Action act);
|
||||
void changeAction(int act);
|
||||
void changeLogging(bool flag);
|
||||
void configureGroups();
|
||||
bool showToolTip(QEvent *event);
|
||||
|
||||
@ -718,6 +718,24 @@ QString getActionNameForPlatform(PolicyRule::Action action,
|
||||
return action_name;
|
||||
}
|
||||
|
||||
QString getNatActionNameForPlatform(NATRule::NATAction action,
|
||||
const QString &platform)
|
||||
{
|
||||
Q_UNUSED(platform);
|
||||
QString action_name = "";
|
||||
switch (action)
|
||||
{
|
||||
case NATRule::Translate:
|
||||
action_name = QObject::tr("Translate");
|
||||
break;
|
||||
|
||||
case NATRule::Branch:
|
||||
action_name = QObject::tr("Branch");
|
||||
break;
|
||||
}
|
||||
return action_name;
|
||||
}
|
||||
|
||||
/*
|
||||
* this function provides logic for the decision whether the rule
|
||||
* should be stateless by default. Currently it only depends on the
|
||||
|
||||
@ -135,6 +135,8 @@ QString getScreenName(QString s,const QStringList &sl);
|
||||
|
||||
QString getActionNameForPlatform(libfwbuilder::PolicyRule::Action action,
|
||||
const QString &platform);
|
||||
QString getNatActionNameForPlatform(libfwbuilder::NATRule::NATAction action,
|
||||
const QString &platform);
|
||||
|
||||
bool getStatelessFlagForAction(libfwbuilder::PolicyRule *rule);
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE FWObjectDatabase SYSTEM "fwbuilder.dtd">
|
||||
<FWObjectDatabase xmlns="http://www.fwbuilder.org/1.0/" version="12" lastModified="1214961933" id="root">
|
||||
<FWObjectDatabase xmlns="http://www.fwbuilder.org/1.0/" version="13" lastModified="1214961933" id="root">
|
||||
<Library id="syslib000" color="#d4f8ff" name="Standard" comment="Standard objects" ro="False">
|
||||
<AnyNetwork id="sysid0" name="Any" comment="Any Network" ro="False" address="0.0.0.0" netmask="0.0.0.0"/>
|
||||
<AnyIPService id="sysid1" protocol_num="0" name="Any" comment="Any IP Service" ro="False"/>
|
||||
|
||||
@ -125,6 +125,7 @@ nameif %in %il security%sl
|
||||
<logging_in_policy>True</logging_in_policy>
|
||||
<options_in_policy>True</options_in_policy>
|
||||
<supports_nat>True</supports_nat>
|
||||
<actions_in_nat>False</actions_in_nat>
|
||||
<supports_time>False</supports_time>
|
||||
<supports_accounting>False</supports_accounting>
|
||||
<supports_routing_itf>True</supports_routing_itf>
|
||||
@ -174,6 +175,10 @@ nameif %in %il security%sl
|
||||
<supported>False</supported>
|
||||
<parameter>None</parameter>
|
||||
</Route>
|
||||
<Translate>
|
||||
<supported>True</supported>
|
||||
<parameter>None</parameter>
|
||||
</Translate>
|
||||
</actions>
|
||||
</capabilities>
|
||||
|
||||
|
||||
@ -48,6 +48,7 @@ interface %in
|
||||
<logging_in_policy>True</logging_in_policy>
|
||||
<options_in_policy>True</options_in_policy>
|
||||
<supports_nat>False</supports_nat>
|
||||
<actions_in_nat>False</actions_in_nat>
|
||||
<supports_time>False</supports_time>
|
||||
<supports_accounting>False</supports_accounting>
|
||||
<supports_routing_itf>False</supports_routing_itf>
|
||||
@ -97,6 +98,10 @@ interface %in
|
||||
<supported>False</supported>
|
||||
<parameter>None</parameter>
|
||||
</Route>
|
||||
<Translate>
|
||||
<supported>False</supported>
|
||||
<parameter>None</parameter>
|
||||
</Translate>
|
||||
</actions>
|
||||
</capabilities>
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
<logging_in_policy>True</logging_in_policy>
|
||||
<options_in_policy>True</options_in_policy>
|
||||
<supports_nat>True</supports_nat>
|
||||
<actions_in_nat>False</actions_in_nat>
|
||||
<supports_time>False</supports_time>
|
||||
<supports_accounting>True</supports_accounting>
|
||||
<supports_routing_itf>True</supports_routing_itf>
|
||||
@ -78,6 +79,10 @@
|
||||
<supported>True</supported>
|
||||
<parameter>RouteIPF</parameter>
|
||||
</Route>
|
||||
<Translate>
|
||||
<supported>True</supported>
|
||||
<parameter>None</parameter>
|
||||
</Translate>
|
||||
</actions>
|
||||
</capabilities>
|
||||
</Target>
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
<logging_in_policy>True</logging_in_policy>
|
||||
<options_in_policy>True</options_in_policy>
|
||||
<supports_nat>False</supports_nat>
|
||||
<actions_in_nat>False</actions_in_nat>
|
||||
<supports_time>False</supports_time>
|
||||
<supports_accounting>True</supports_accounting>
|
||||
<supports_routing_itf>True</supports_routing_itf>
|
||||
@ -76,6 +77,10 @@
|
||||
<supported>False</supported>
|
||||
<parameter>None</parameter>
|
||||
</Route>
|
||||
<Translate>
|
||||
<supported>False</supported>
|
||||
<parameter>None</parameter>
|
||||
</Translate>
|
||||
</actions>
|
||||
</capabilities>
|
||||
</Target>
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
<logging_in_policy>True</logging_in_policy>
|
||||
<options_in_policy>True</options_in_policy>
|
||||
<supports_nat>True</supports_nat>
|
||||
<actions_in_nat>True</actions_in_nat>
|
||||
<supports_time>True</supports_time>
|
||||
<supports_accounting>True</supports_accounting>
|
||||
<supports_routing_itf>True</supports_routing_itf>
|
||||
@ -91,6 +92,10 @@
|
||||
<supported>True</supported>
|
||||
<parameter>None</parameter>
|
||||
</Continue>
|
||||
<Translate>
|
||||
<supported>True</supported>
|
||||
<parameter>None</parameter>
|
||||
</Translate>
|
||||
</actions>
|
||||
</capabilities>
|
||||
</Target>
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
<logging_in_policy>True</logging_in_policy>
|
||||
<options_in_policy>True</options_in_policy>
|
||||
<supports_nat>True</supports_nat>
|
||||
<actions_in_nat>True</actions_in_nat>
|
||||
<supports_time>False</supports_time>
|
||||
<supports_accounting>True</supports_accounting>
|
||||
<supports_routing_itf>True</supports_routing_itf>
|
||||
@ -81,6 +82,10 @@
|
||||
<supported>True</supported>
|
||||
<parameter>RoutePF</parameter>
|
||||
</Route>
|
||||
<Translate>
|
||||
<supported>True</supported>
|
||||
<parameter>None</parameter>
|
||||
</Translate>
|
||||
</actions>
|
||||
</capabilities>
|
||||
</Target>
|
||||
|
||||
@ -396,6 +396,7 @@ exit
|
||||
<logging_in_policy>True</logging_in_policy>
|
||||
<options_in_policy>True</options_in_policy>
|
||||
<supports_nat>True</supports_nat>
|
||||
<actions_in_nat>False</actions_in_nat>
|
||||
<supports_time>False</supports_time>
|
||||
<supports_accounting>False</supports_accounting>
|
||||
<supports_routing_itf>True</supports_routing_itf>
|
||||
@ -445,6 +446,10 @@ exit
|
||||
<supported>False</supported>
|
||||
<parameter>None</parameter>
|
||||
</Route>
|
||||
<Translate>
|
||||
<supported>True</supported>
|
||||
<parameter>None</parameter>
|
||||
</Translate>
|
||||
</actions>
|
||||
</capabilities>
|
||||
</Target>
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
<logging_in_policy>False</logging_in_policy>
|
||||
<options_in_policy>False</options_in_policy>
|
||||
<supports_nat>False</supports_nat>
|
||||
<actions_in_nat>False</actions_in_nat>
|
||||
<supports_time>False</supports_time>
|
||||
<supports_accounting>False</supports_accounting>
|
||||
<supports_routing_itf>False</supports_routing_itf>
|
||||
@ -68,6 +69,10 @@
|
||||
<supported>False</supported>
|
||||
<parameter>None</parameter>
|
||||
</Route>
|
||||
<Translate>
|
||||
<supported>False</supported>
|
||||
<parameter>None</parameter>
|
||||
</Translate>
|
||||
</actions>
|
||||
</capabilities>
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE FWObjectDatabase SYSTEM "fwbuilder.dtd">
|
||||
<FWObjectDatabase xmlns="http://www.fwbuilder.org/1.0/" version="12" lastModified="1239820101" id="root">
|
||||
<FWObjectDatabase xmlns="http://www.fwbuilder.org/1.0/" version="13" lastModified="1239820101" id="root">
|
||||
<Library id="sysid99" name="Deleted Objects" comment="" ro="False"/>
|
||||
<Library id="syslib100" color="#ffb4b4" name="Firewall Templates" comment="Template objects that can be used to generate typical firewall configurations" ro="True">
|
||||
<ObjectGroup id="id4070BB9B" name="Objects" comment="" ro="False">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user