本文整理汇总了C++中Firewall::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ Firewall::getName方法的具体用法?C++ Firewall::getName怎么用?C++ Firewall::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Firewall
的用法示例。
在下文中一共展示了Firewall::getName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPossibleMembers
void clusterMembersDialog::getPossibleMembers()
{
t_fwList fwlist;
mw->findAllFirewalls(fwlist);
Firewall *fw;
for (t_fwList::iterator it = fwlist.begin(); it != fwlist.end(); it++)
{
// does host_OS and platform match?
fw = *it;
if (fw->getStr("host_OS").c_str() != host_os ||
fw->getStr("platform").c_str() != platform)
{
continue;
}
// does the firewall provide at least one phys. interface?
FWObjectTypedChildIterator iface_i = fw->findByType(Interface::TYPENAME);
if (iface_i == iface_i.end())
{
continue;
}
else
{
// previously selected? skip
PredFindFw pred;
pred.setSearchString(fw->getName().c_str());
t_memberList::iterator it = find_if(selected.begin(),
selected.end(), pred);
if (it != selected.end())
{
continue;
}
// valid member, add to member list
ClusterMember *new_member = createMember(fw);
if (new_member == NULL)
{
qWarning() << "clusterMembersDialog: could not create new "
"cluster member";
return;
}
available.push_back(new_member);
}
}
fwlist.sort(FWObjectNameCmpPredicate());
}
示例2: run
QString CompilerDriver_pix::run(const std::string &cluster_id,
const std::string &firewall_id,
const std::string &single_rule_id)
{
Cluster *cluster = NULL;
Firewall *fw = NULL;
getFirewallAndClusterObjects(cluster_id, firewall_id, &cluster, &fw);
// Copy rules from the cluster object
populateClusterElements(cluster, fw);
if (cluster)
{
// PIX failover is dfferent from VRRP and other failover protocols
// in that it does not create new virtual address. Instead, each
// unit is configured with two ip addresses, one for the active
// unit and another for standby one. When active unit fails, the
// other one assumes its address.
//
// This matters because when we use cluster object or one of its
// interfaces in rules, compiler should expand it to the set of
// addresses that includes addresses of the corresponding
// interface of both member firewalls. Method
// CompilerDriver::copyFailoverInterface adds a copy of firewall
// interface to the cluster object. This works for all firewalls,
// but for PIX we need to add copies of interfaces from both
// members.
//
FWObjectTypedChildIterator cl_iface = cluster->findByType(Interface::TYPENAME);
for (; cl_iface != cl_iface.end(); ++cl_iface)
{
FailoverClusterGroup *failover_group =
FailoverClusterGroup::cast(
(*cl_iface)->getFirstByType(FailoverClusterGroup::TYPENAME));
if (failover_group)
{
//FWObject *this_member_interface = NULL; //UNUSED
list<FWObject*> other_member_interfaces;
for (FWObjectTypedChildIterator it =
failover_group->findByType(FWObjectReference::TYPENAME);
it != it.end(); ++it)
{
FWObject *intf = FWObjectReference::getObject(*it);
assert(intf);
//if (intf->isChildOf(fw)) this_member_interface = intf; //UNUSED
//else other_member_interfaces.push_back(intf);
if (!intf->isChildOf(fw)) other_member_interfaces.push_back(intf);
}
if (!other_member_interfaces.empty())
{
for (list<FWObject*>::iterator it=other_member_interfaces.begin();
it!=other_member_interfaces.end(); ++it)
{
cluster->addCopyOf(*it, true);
}
}
}
}
}
#if 0
FWObjectTypedChildIterator iface = fw->findByType(Interface::TYPENAME);
for (; iface != iface.end(); ++iface)
{
(*iface)->dump(true, true);
}
#endif
determineOutputFileNames(cluster, fw, !cluster_id.empty(),
QStringList(""), QStringList("fw"),
QStringList(""));
FWOptions* options = fw->getOptionsObject();
QString script_buffer;
std::auto_ptr<NATCompiler_pix> n;
std::auto_ptr<PolicyCompiler_pix> c;
std::auto_ptr<RoutingCompiler_pix> r;
try
{
clearReadOnly(fw);
commonChecks2(cluster, fw);
pixClusterConfigurationChecks(cluster, fw);
// Note that fwobjectname may be different from the name of the
// firewall fw This happens when we compile a member of a cluster
current_firewall_name = fw->getName().c_str();
bool pix_acl_basic = options->getBool("pix_acl_basic");
bool pix_acl_no_clear = options->getBool("pix_acl_no_clear");
bool pix_acl_substitution = options->getBool("pix_acl_substitution");
bool pix_add_clear_statements = options->getBool("pix_add_clear_statements");
//.........这里部分代码省略.........
示例3: run
QString CompilerDriver_junosacl::run(const string &cluster_id,
const string &firewall_id,
const string &single_rule_id)
{
Cluster *cluster = NULL;
Firewall *fw = NULL;
getFirewallAndClusterObjects(cluster_id, firewall_id, &cluster, &fw);
try
{
clearReadOnly(fw);
// Copy rules from the cluster object
populateClusterElements(cluster, fw);
commonChecks2(cluster, fw);
// Note that fwobjectname may be different from the name of the
// firewall fw This happens when we compile a member of a cluster
current_firewall_name = fw->getName().c_str();
determineOutputFileNames(cluster, fw, !cluster_id.empty(),
QStringList(""), QStringList("fw"),
QStringList(""));
/* Now that all checks are done, we can drop copies of cluster
* interfaces that were added to the firewall by
* CompilerDriver::populateClusterElements()
*/
list<FWObject*> all_interfaces = fw->getByTypeDeep(Interface::TYPENAME);
list<FWObject*> copies_of_cluster_interfaces;
for (std::list<FWObject*>::iterator i=all_interfaces.begin(); i!=all_interfaces.end(); ++i)
{
Interface *iface = Interface::cast(*i);
assert(iface);
if (iface->getOptionsObject()->getBool("cluster_interface"))
copies_of_cluster_interfaces.push_back(iface);
}
while (copies_of_cluster_interfaces.size())
{
fw->remove(copies_of_cluster_interfaces.front());
copies_of_cluster_interfaces.pop_front();
}
FWOptions* options = fw->getOptionsObject();
string fwvers = fw->getStr("version");
if (fwvers == "") fw->setStr("version", "11.2");
if (fwvers == "11.x") fw->setStr("version", "11.2");
string platform = fw->getStr("platform");
std::auto_ptr<OSConfigurator_junos> oscnf(new OSConfigurator_junos(objdb, fw, false));
oscnf->prolog();
oscnf->processFirewallOptions();
list<FWObject*> all_policies = fw->getByType(Policy::TYPENAME);
// assign unique rule ids that later will be used to generate
// chain names. This should be done after calls to
// findImportedRuleSets()
// NB: these ids are not used by this compiler
assignUniqueRuleIds(all_policies);
vector<int> ipv4_6_runs;
// // // // //NamedObjectsManager named_objects_manager(persistent_objects, fw);
// command line options -4 and -6 control address family for which
// script will be generated. If "-4" is used, only ipv4 part will
// be generated. If "-6" is used, only ipv6 part will be generated.
// If neither is used, both parts will be done.
if (options->getStr("ipv4_6_order").empty() ||
options->getStr("ipv4_6_order") == "ipv4_first")
{
if (ipv4_run) ipv4_6_runs.push_back(AF_INET);
if (ipv6_run) ipv4_6_runs.push_back(AF_INET6);
}
if (options->getStr("ipv4_6_order") == "ipv6_first")
{
if (ipv6_run) ipv4_6_runs.push_back(AF_INET6);
if (ipv4_run) ipv4_6_runs.push_back(AF_INET);
}
string object_groups_definitions;
for (vector<int>::iterator i=ipv4_6_runs.begin();
i!=ipv4_6_runs.end(); ++i)
{
int policy_af = *i;
bool ipv6_policy = (policy_af == AF_INET6);
// Count rules for each address family
int policy_count = 0;
//.........这里部分代码省略.........
示例4: run
/*
* Go through paces to compile firewall which may be a member of a
* cluster. Note that both firewall and cluster are defined by their
* unique string IDs. This is necessary because CompilerDriver
* operates with a copy of the object database which is not exposed
* outside, so the caller can not provide pointers to these obejcts.
*/
QString CompilerDriver_ipt::run(const std::string &cluster_id,
const std::string &firewall_id,
const std::string &single_rule_id)
{
FWObjectDatabase::registerObjectType(combinedAddress::TYPENAME,
&create_combinedAddress);
// see #2212 Create temporary copy of the firewall and cluster
// objects and pass them to the compilers.
Cluster *cluster = NULL;
Firewall *fw = NULL;
getFirewallAndClusterObjects(cluster_id, firewall_id, &cluster, &fw);
string generated_script;
try
{
clearReadOnly(fw);
// Copy rules from the cluster object
populateClusterElements(cluster, fw);
commonChecks2(cluster, fw);
string fw_version = fw->getStr("version");
if (fw_version.empty()) fw_version = "(any version)";
string platform = fw->getStr("platform");
string host_os = fw->getStr("host_OS");
FWOptions* options = fw->getOptionsObject();
string s;
// Note that fwobjectname may be different from the name of the
// firewall fw This happens when we compile a member of a cluster
current_firewall_name = fw->getName().c_str();
if (fw->getOptionsObject()->getStr("prolog_place") == "after_flush" &&
fw->getOptionsObject()->getBool("use_iptables_restore"))
{
abort("Prolog place \"after policy reset\" can not be used"
" when policy is activated with iptables-restore");
}
string firewall_dir = options->getStr("firewall_dir");
if (firewall_dir=="") firewall_dir="/etc";
bool debug=options->getBool("debug");
QString shell_dbg = (debug)?"set -x":"" ;
std::auto_ptr<OSConfigurator_linux24> oscnf;
string platform_family = Resources::platform_res[platform]->
getResourceStr("/FWBuilderResources/Target/family");
string os_family = Resources::os_res[host_os]->
getResourceStr("/FWBuilderResources/Target/family");
bool supports_prolog_epilog = Resources::getTargetCapabilityBool(
platform, "supports_prolog_epilog");
if (!supports_prolog_epilog)
{
prolog_done = true;
epilog_done = true;
}
string os_variant = DISTRO;
/* minimal sanity checking */
if (os_family == "ipcop")
{
os_variant = "ipcop";
// can't use iptables-restore with ipcop
fw->getOptionsObject()->setBool("use_iptables_restore", false);
// ipcop has its own iptables commands that accept packets
// in states ESTABLISHED,RELATED
fw->getOptionsObject()->setBool("accept_established", false);
oscnf = std::auto_ptr<OSConfigurator_linux24>(
new OSConfigurator_ipcop(objdb , fw, false));
}
if (os_family == "linux24" ||
os_family == "openwrt" ||
os_family == "dd-wrt-nvram" ||
os_family == "dd-wrt-jffs" ||
os_family == "sveasoft")
oscnf = std::auto_ptr<OSConfigurator_linux24>(
new OSConfigurator_linux24(objdb , fw, false));
//.........这里部分代码省略.........
示例5: loadFWObject
void FirewallDialog::loadFWObject(FWObject *o)
{
try
{
obj = o;
Firewall *s = dynamic_cast<Firewall*>(obj);
assert(s!=nullptr);
init = true;
QString platform = obj->getStr("platform").c_str();
/* fill in platform */
setPlatform(m_dialog->platform, platform);
fillVersion();
/* fill in host OS */
setHostOS(m_dialog->hostOS, platform, obj->getStr("host_OS").c_str());
/* ---------------- */
updateTimeStamps();
#ifndef NDEBUG
Management *mgmt=s->getManagementObject();
assert(mgmt!=nullptr);
#endif
// FWOptions *opt =s->getOptionsObject();
m_dialog->obj_name->setText( QString::fromUtf8(s->getName().c_str()) );
m_dialog->commentKeywords->loadFWObject(o);
m_dialog->inactive->setChecked(s->getInactive());
m_dialog->obj_name->setEnabled(!o->isReadOnly());
setDisabledPalette(m_dialog->obj_name);
m_dialog->platform->setEnabled(!o->isReadOnly());
setDisabledPalette(m_dialog->platform);
m_dialog->version->setEnabled(!o->isReadOnly());
setDisabledPalette(m_dialog->version);
m_dialog->hostOS->setEnabled(!o->isReadOnly());
setDisabledPalette(m_dialog->hostOS);
m_dialog->fwAdvanced->setEnabled(!o->isReadOnly());
setDisabledPalette(m_dialog->fwAdvanced);
m_dialog->osAdvanced->setEnabled(!o->isReadOnly());
setDisabledPalette(m_dialog->osAdvanced);
// snmpCommunity->setEnabled(!o->isReadOnly());
// setDisabledPalette(snmpCommunity);
m_dialog->inactive->setEnabled(!o->isReadOnly());
setDisabledPalette(m_dialog->inactive);
} catch (FWException &ex)
{
qDebug() << "Caught FWException:" << ex.toString().c_str();
}
init=false;
}
示例6: fillCompileSelectList
void instDialog::fillCompileSelectList()
{
if (fwbdebug) qDebug("instDialog::fillCompileSelectList");
Firewall *fw;
Cluster *cl;
QDateTime dt;
creatingTable = true;
m_dialog->selectTable->clear();
list<Firewall*> working_list_of_firewalls = firewalls;
for (list<Cluster *>::iterator i=clusters.begin(); i!=clusters.end(); ++i)
{
cl = *i;
QTreeWidgetItem* cluster_item = createTreeItem(NULL, cl);
m_dialog->selectTable->addTopLevelItem(cluster_item);
list<Firewall*> members;
cl->getMembersList(members);
for (list<Firewall*>::iterator member=members.begin();
member!=members.end(); ++member)
{
createTreeItem(cluster_item, *member);
working_list_of_firewalls.remove(*member);
}
cluster_item->setExpanded(true);
}
for (list<Firewall *>::iterator i=working_list_of_firewalls.begin();
i!=working_list_of_firewalls.end(); ++i)
{
fw = *i;
QTreeWidgetItem* fw_item = createTreeItem(NULL, fw);
m_dialog->selectTable->addTopLevelItem(fw_item);
}
QTreeWidgetItemIterator it(m_dialog->selectTable);
while (*it)
{
setFlags(*it);
++it;
}
/* ticket #1305
* check if any of the firewall objects are members of clusters but
* the clusters are not requested for compile
*/
QString warn1(
tr("<b>You are trying to compile policy for a firewall object that is "
"a member of a cluster, however you requested compilation of only "
"this member firewall and not the cluster it belongs to. Assuming "
"firewall is standalone and not cluster member. Rules and parts of "
"the script specific for the cluster configuration will not be "
"generated.</b>"));
QStringList warn2;
list<FWObject*> all_libs = project->db()->getByType(Library::TYPENAME);
foreach(FWObject *lib, all_libs)
{
if (lib->getId() == FWObjectDatabase::DELETED_OBJECTS_ID) continue;
list<FWObject*> all_clusters = lib->getByTypeDeep(Cluster::TYPENAME);
foreach(FWObject *_cl, all_clusters)
{
if (std::find(clusters.begin(), clusters.end(), _cl) == clusters.end())
{
Cluster *cluster = Cluster::cast(_cl);
assert(cluster);
foreach(FWObject *fw, firewalls)
{
if (cluster->hasMember(Firewall::cast(fw)))
{
warn2 <<
QString(tr("Firewall '%1' is member of cluster '%2'")
.arg(QString::fromUtf8(fw->getName().c_str()))
.arg(QString::fromUtf8(cluster->getPath().c_str())));
}
}
}
}
}