本文整理汇总了C++中FWOptions类的典型用法代码示例。如果您正苦于以下问题:C++ FWOptions类的具体用法?C++ FWOptions怎么用?C++ FWOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FWOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cmd
/*
* store all data in the object
*/
void pixosIfaceOptsDialog::accept()
{
// validate user input before saving
if (!validate()) return;
ProjectPanel *project = mw->activeProject();
std::unique_ptr<FWCmdChange> cmd( new FWCmdChange(project, obj));
// new_state is a copy of the interface object
FWObject* new_state = cmd->getNewState();
FWOptions* ifopt = Interface::cast(new_state)->getOptionsObject();
assert(ifopt!=NULL);
if (cluster_interface)
{
ifopt->setStr("type", "cluster_interface");
} else
{
QString new_type = m_dialog->iface_type->itemData(
m_dialog->iface_type->currentIndex()).toString();
ifopt->setStr("type", new_type.toStdString());
}
data.saveAll(ifopt);
if (!cmd->getOldState()->cmp(new_state, true))
project->undoStack->push(cmd.release());
QDialog::accept();
}
示例2: addSshAccessRule
void AutomaticRules_nxosacl::addSshAccessRule()
{
if (ruleset == NULL) return;
FWOptions *fwopt = fw->getOptionsObject();
if (fwopt->getBool("mgmt_ssh") && ! fwopt->getStr("mgmt_addr").empty())
{
AutomaticRules_cisco::addSshAccessRule();
/*
* AutomaticRules_cisco::addDefaultPolicyRule() adds a rule to
* permit backup ssh access to the firewall. Since NXOS ACL are
* stateless, we need to add another rule to permit reply
* packets.
*/
TCPService *ssh_rev = ruleset->getRoot()->createTCPService();
ssh_rev->setSrcRangeStart(22);
ssh_rev->setSrcRangeEnd(22);
persistent_objects->add(ssh_rev, false);
Network *mgmt_workstation = ruleset->getRoot()->createNetwork();
mgmt_workstation->setAddressNetmask(fwopt->getStr("mgmt_addr"));
persistent_objects->add(mgmt_workstation, false);
addMgmtRule(
fw, mgmt_workstation, ssh_rev,
NULL, PolicyRule::Outbound, PolicyRule::Accept,
"backup ssh access rule (out)");
}
}
示例3: QDialog
pixosIfaceOptsDialog::pixosIfaceOptsDialog(QWidget *parent, FWObject *o)
: QDialog(parent)
{
m_dialog = new Ui::pixosIfaceOptsDialog_q;
m_dialog->setupUi(this);
setWindowModality(Qt::WindowModal);
obj = o;
FWOptions *ifopt = (Interface::cast(obj))->getOptionsObject();
cluster_interface = (Cluster::cast(obj->getParent()) != NULL);
setInterfaceTypes(m_dialog->iface_type, Interface::cast(obj),
ifopt->getStr("type").c_str());
// Using "type" control only for subinterfaces
// and main interfaces of the firewall objects
if (cluster_interface)
{
m_dialog->iface_type->hide();
m_dialog->iface_type_label->hide();
} else
{
m_dialog->iface_type->show();
m_dialog->iface_type_label->show();
}
data.registerOption(m_dialog->vlan_id, ifopt, "vlan_id");
data.loadAll();
// special actions for different iface types
// VLAN (8021q)
typeChanged("");
}
示例4: prepareArgForCompiler
QStringList instDialog::prepareArgForCompiler(Firewall *fw)
{
FWOptions *fwopt = fw->getOptionsObject();
QStringList args;
/*
* I should be able to specify custom compiler for firewall with
* no platform (e.g. for experiments)
*/
string compiler = fwopt->getStr("compiler");
if (compiler=="")
{
compiler=Resources::platform_res[fw->getStr("platform")]->getCompiler();
}
if (compiler=="")
{
QMessageBox::warning(
this,"Firewall Builder",
tr("Firewall platform is not specified in this object.\n\
Can't compile firewall policy."),
tr("&Continue"), QString::null,QString::null,
0, 1 );
return args; // still empty list
}
示例5: script_skeleton
QString CompilerDriver_junosacl::assembleFwScript(Cluster *cluster,
Firewall *fw,
bool cluster_member,
OSConfigurator *oscnf)
{
Configlet script_skeleton(fw, "junos", "script_skeleton");
Configlet top_comment(fw, "junos", "top_comment");
script_skeleton.setVariable("system_configuration_script",
QString::fromUtf8(system_configuration_script.c_str()));
script_skeleton.setVariable("policy_script",
QString::fromUtf8(policy_script.c_str()));
FWOptions* options = fw->getOptionsObject();
options->setStr("prolog_script", options->getStr("junosacl_prolog_script"));
options->setStr("epilog_script", options->getStr("junosacl_epilog_script"));
// we do not offer user a choice of the place where to put prolog
// lines, therefore we can reset this attribute to make sure it
// does not interfere
options->setStr("prolog_place", "");
assembleFwScriptInternal(cluster, fw, cluster_member,
oscnf, &script_skeleton, &top_comment, "!", true);
return script_skeleton.expand();
}
示例6: setInterfaceVlanId
void Importer::setInterfaceVlanId(const std::string &vlan_id)
{
if (current_interface!=NULL)
{
FWOptions *ifopt = (Interface::cast(current_interface))->getOptionsObject();
ifopt->setStr("type", "8021q");
ifopt->setStr("vlan_id", vlan_id);
}
}
示例7: getActivationCmd
/*
* This method builds and returns activation command
* This method is used for all firewall platforms but PIX
*/
QString FirewallInstaller::getActivationCmd()
{
if (!cnf->activationCmd.isEmpty())
{
return cnf->activationCmd;
}
FWOptions *fwopt = cnf->fwobj->getOptionsObject();
QString configlet_name = "installer_commands_";
if (cnf->user=="root") configlet_name += "root";
else configlet_name += "reg_user";
string host_os = cnf->fwobj->getStr("host_OS");
string os_family = Resources::os_res[host_os]->
getResourceStr("/FWBuilderResources/Target/family");
// installer configlets should be different for each OS, but if
// some OS can use the same script, it will be placed in the file
// under os_family name. For example:
// for linksys/sveasoft configlet is in src/res/configlets/sveasoft
// but since linux24 and openwrt can use the same script, it is
// located in src/res/configlets/linux24 (openwrt.xml file defines
// family as "linux24")
Configlet configlet(host_os, os_family, configlet_name);
configlet.removeComments();
configlet.collapseEmptyStrings(true);
// test run and rollback were deprecated in 4.2.0. On Linux, BSD
// and PIX rollback was implemented by rebooting firewall which is
// too heavy-handed and it did not work on BSD at all.
configlet.setVariable("test", false);
configlet.setVariable("run", true);
configlet.setVariable("with_rollback", false);
configlet.setVariable("no_rollback", true);
configlet.setVariable("firewall_name",
QString::fromUtf8(cnf->fwobj->getName().c_str()));
configlet.setVariable("with_compression", cnf->compressScript);
configlet.setVariable("no_compression", ! cnf->compressScript);
// On FreeBSD where we can generate either shell script or rc.conf
// file, installation commands differ.
//
// TODO: find more generic way to do this so that GUI installer does not
// have to be aware of the differences in generated file format.
configlet.setVariable("rc_conf_format",
fwopt->getBool("generate_rc_conf_file"));
configlet.setVariable("shell_script_format",
! fwopt->getBool("generate_rc_conf_file"));
replaceMacrosInCommand(&configlet);
return configlet.expand().trimmed();
}
示例8: script
/*
* Generate calls to the shell function update_addresses_of_interface
* to add or remove ip addresses of interfaces. The following cases
* are supported, depending on the value of
* @add_virtual_addresses_for_nat and @configure_interfaces
*
* configure_interfaces == false && add_virtual_addresses_for_nat == false:
* do not generate any commands
*
* configure_interfaces == false && add_virtual_addresses_for_nat == true:
* use only virtual_addresses_for_nat, add normal addresses of the interface
* to the list of addresses we should ignore
*
* configure_interfaces == true && add_virtual_addresses_for_nat == false:
* ignore virtual_addresses_for_nat
*
* configure_interfaces == true && add_virtual_addresses_for_nat == true:
* use virtual_addresses_for_nat
*
*
*/
string OSConfigurator_linux24::printInterfaceConfigurationCommands()
{
FWOptions* options = fw->getOptionsObject();
std::unique_ptr<interfaceProperties> int_prop(
interfacePropertiesObjectFactory::getInterfacePropertiesObject(
fw->getStr("host_OS")));
Configlet script(fw, "linux24", "configure_interfaces");
script.removeComments();
script.collapseEmptyStrings(true);
list<FWObject*> interfaces = fw->getByTypeDeep(Interface::TYPENAME);
bool need_promote_command = false;
QStringList gencmd;
list<FWObject*>::iterator i;
for (i=interfaces.begin(); i!=interfaces.end(); ++i )
{
Interface *iface = Interface::cast(*i);
assert(iface);
string iface_name = iface->getName();
QStringList update_addresses;
QStringList ignore_addresses;
if (int_prop->manageIpAddresses(iface, update_addresses, ignore_addresses))
{
if (options->getBool("manage_virtual_addr") &&
virtual_addresses_for_nat.count(iface_name) > 0)
update_addresses.push_back(
virtual_addresses_for_nat[iface_name].c_str());
// generate update_addresses calls even if interface has
// no addresses in fwbuilder. This makes sure all
// addresses it might have on the machine will be
// removed. Say, interface was regular and had an address
// and then user converted it to unnumbered. In this case
// the address should be removed.
gencmd.push_back(
printUpdateAddressCommand(iface, update_addresses, ignore_addresses));
// update_addresses list looks like this:
// ("eth0", "22.22.22.22/24", "22.22.22.23/24")
// I need to add "promote" command only when there is more than 1 address.
need_promote_command |= (update_addresses.size() > 2);
}
known_interfaces.push_back(iface_name);
}
script.setVariable("have_interfaces", interfaces.size() > 0);
script.setVariable("need_promote_command", need_promote_command);
script.setVariable("configure_interfaces_script", gencmd.join("\n"));
return script.expand().toStdString() + "\n";
}
示例9:
string PolicyCompiler_iosacl::PrintRule::_printLog(PolicyRule *rule)
{
if (rule->getLogging())
{
FWOptions *ruleopt =rule->getOptionsObject();
if (ruleopt->getBool("iosacl_log_input")) return "log-input ";
return "log ";
}
return "";
}
示例10:
void NATCompiler_pf::PrintRule::_printNATRuleOptions(Rule *rule)
{
FWOptions *ruleopt =rule->getOptionsObject();
if (ruleopt->getBool("pf_bitmask")) compiler->output << "bitmask ";
if (ruleopt->getBool("pf_random")) compiler->output << "random ";
if (ruleopt->getBool("pf_source_hash")) compiler->output << "source-hash ";
if (ruleopt->getBool("pf_round_robin")) compiler->output << "round-robin ";
if (ruleopt->getBool("pf_static_port")) compiler->output << "static-port ";
}
示例11: getGeneratedFileName
QString FirewallInstaller::getGeneratedFileName(Firewall *fw)
{
FWOptions *fwopt = fw->getOptionsObject();
QString generated_file;
QString ofname = QString::fromUtf8(fwopt->getStr("output_file").c_str()).trimmed();
if (!ofname.isEmpty())
{
generated_file = ofname;
} else
generated_file = QString::fromUtf8(fw->getName().c_str()) + ".fw";
return generated_file;
}
示例12: OSConfigurator
OSConfigurator_linux24::OSConfigurator_linux24(FWObjectDatabase *_db,
Firewall *fw,
bool ipv6_policy) :
OSConfigurator(_db, fw, ipv6_policy) , os_data(fw->getStr("host_OS"))
{
command_wrappers = new Configlet(fw, "linux24", "run_time_wrappers");
FWOptions* fwopt = fw->getOptionsObject();
string version = fw->getStr("version");
using_ipset = (XMLTools::version_compare(version, "1.4.1.1") >= 0 &&
fwopt->getBool("use_m_set"));
}
示例13: if
bool PolicyCompiler_pf::ProcessScrubOption::processNext()
{
PolicyRule *rule=getNext(); if (rule==NULL) return false;
FWOptions *ruleopt =rule->getOptionsObject();
if ( ruleopt->getBool("scrub") ) {
if (rule->getAction()!=PolicyRule::Accept) {
ruleopt->setBool("scrub",false);
tmp_queue.push_back(rule);
compiler->abort(rule,
"Rule option 'scrub' is supported only for rules "
"with action 'Accept'");
return true;
}
PolicyRule *r = compiler->dbcopy->createPolicyRule();
compiler->temp_ruleset->add(r);
r->duplicate(rule);
r->setAction(PolicyRule::Scrub);
r->getOptionsObject()->setBool("scrub",false);
tmp_queue.push_back(r);
ruleopt->setBool("scrub",false);
tmp_queue.push_back(rule);
return true;
}
/* if service is ip_fragment and action is 'Deny', then add rule with scrub */
Service *srv=compiler->getFirstSrv(rule); assert(srv);
if ( (srv->getBool("short_fragm") || srv->getBool("fragm")) &&
( rule->getAction()==PolicyRule::Deny || rule->getAction()==PolicyRule::Reject) ) {
PolicyRule *r = compiler->dbcopy->createPolicyRule();
compiler->temp_ruleset->add(r);
r->duplicate(rule);
r->setAction(PolicyRule::Scrub);
r->getOptionsObject()->setBool("scrub",false);
tmp_queue.push_back(r);
return true;
}
tmp_queue.push_back(rule);
return true;
}
示例14: getFirewallObject
void Importer::newPolicyRule()
{
if (fwbdebug) qDebug() << "Importer::newPolicyRule()";
FWObjectDatabase *dbroot = getFirewallObject()->getRoot();
FWObject *nobj = dbroot->create(PolicyRule::TYPENAME);
current_rule = Rule::cast(nobj);
// check if all child objects were populated properly
FWOptions *ropt = current_rule->getOptionsObject();
assert(ropt!=NULL);
ropt->setBool("stateless", true);
}
示例15: if
bool PolicyCompiler_ipf::checkForKeepState::processNext()
{
PolicyRule *rule=getNext(); if (rule==NULL) return false;
tmp_queue.push_back(rule);
Service *srv=compiler->getFirstSrv(rule); assert(srv);
FWOptions *ruleopt =rule->getOptionsObject();
if (! ICMPService::isA(srv) &&
! UDPService::isA(srv) &&
! TCPService::isA(srv) ) ruleopt->setBool("stateless",true);
return true;
}