本文整理汇总了C++中PolicyRule::getItf方法的典型用法代码示例。如果您正苦于以下问题:C++ PolicyRule::getItf方法的具体用法?C++ PolicyRule::getItf怎么用?C++ PolicyRule::getItf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PolicyRule
的用法示例。
在下文中一共展示了PolicyRule::getItf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkInterfacesForShadowing
/**
* compare interfaces of rules r1 and r2.
*
* Return true if r2 shadows r1 (only inetrface rule element is
* checked)
*
* If interface element is "all" (empty), it shadows any specific
* interface in the other rule, also "all" shadows "all". If neither
* is "all", return true if both rules refer the same interface,
* otherwise return false.
*/
bool PolicyCompiler::checkInterfacesForShadowing(PolicyRule &r1, PolicyRule &r2)
{
RuleElementItf *intf1_re = r1.getItf();
FWObject *rule1_iface = FWObjectReference::getObject(intf1_re->front());
RuleElementItf *intf2_re = r2.getItf();
FWObject *rule2_iface = FWObjectReference::getObject(intf2_re->front());
int intf1_id = rule1_iface->getId();
int intf2_id = rule2_iface->getId();
if (intf2_re->isAny()) return true; // "eth0" -- "all" or "all" -- "all"
return (intf1_id == intf2_id);
}
示例2: getNext
bool PolicyCompiler::expandGroupsInItf::processNext()
{
PolicyRule *rule = getNext(); if (rule==NULL) return false;
RuleElementItf *itf = rule->getItf();
compiler->expandGroupsInRuleElement(itf);
tmp_queue.push_back(rule);
return true;
}
示例3: getNext
bool PolicyCompiler_junosacl::mirrorRule::processNext()
{
//PolicyCompiler_iosacl *iosacl_comp=dynamic_cast<PolicyCompiler_iosacl*>(compiler);
PolicyRule *rule = getNext(); if (rule==NULL) return false;
if (rule->getOptionsObject()->getBool("iosacl_add_mirror_rule"))
{
PolicyRule *r= compiler->dbcopy->createPolicyRule();
compiler->temp_ruleset->add(r);
r->duplicate(rule);
r->setAction(rule->getAction());
switch (rule->getDirection())
{
case PolicyRule::Inbound: r->setDirection(PolicyRule::Outbound); break;
case PolicyRule::Outbound: r->setDirection(PolicyRule::Inbound); break;
default: r->setDirection(PolicyRule::Both); break;
}
RuleElementSrc *osrc = rule->getSrc();
RuleElementDst *odst = rule->getDst();
RuleElementSrv *osrv = rule->getSrv();
RuleElementItf *oitf = rule->getItf();
RuleElementSrc *nsrc = r->getSrc();
RuleElementDst *ndst = r->getDst();
RuleElementSrv *nsrv = r->getSrv();
RuleElementItf *nitf = r->getItf();
duplicateRuleElement(osrc, ndst);
duplicateRuleElement(odst, nsrc);
duplicateRuleElement(oitf, nitf);
if (!osrv->isAny())
{
ObjectMirror mirror;
nsrv->clearChildren();
for (list<FWObject*>::iterator i1=osrv->begin(); i1!=osrv->end(); ++i1)
{
Service *nobj = mirror.getMirroredService(
Service::cast(FWReference::getObject(*i1)));
if (nobj->getParent() == NULL)
compiler->persistent_objects->add(nobj, false);
nsrv->addRef(nobj);
}
}
tmp_queue.push_back(r);
}
tmp_queue.push_back(rule);
return true;
}
示例4: prolog
int PolicyCompiler::prolog()
{
Compiler::prolog();
Policy *policy = Policy::cast(fw->getFirstByType(Policy::TYPENAME));
assert(policy);
if (source_ruleset == NULL) source_ruleset = policy;
source_ruleset->renumberRules();
temp_ruleset = new Policy(); // working copy of the policy
fw->add( temp_ruleset );
temp_ruleset->setName(source_ruleset->getName());
int global_num = 0;
string label_prefix = "";
if (source_ruleset->getName() != "Policy") label_prefix = source_ruleset->getName();
int rule_counter = 0;
for (FWObject::iterator i=source_ruleset->begin(); i!=source_ruleset->end(); i++)
{
PolicyRule *r = PolicyRule::cast(*i);
if (r == NULL) continue; // skip RuleSetOptions object
/*
* do not remove disabled rules just yet because some
* compilers might use RuleSet::insertRuleAtTop() and other
* similar methods from prolog() or
* addPredefinedPolicyRules()() and these methods renumber
* rules (labels stop matching rule positions when this is
* done because labels are configured in prolog() method of
* the base class. See fwbuilder ticket 1173)
*/
//if (r->isDisabled()) continue;
if (r->getLabel().empty())
{
RuleElementItf *itfre = r->getItf();
assert(itfre);
if (itfre->isAny())
{
r->setLabel( createRuleLabel(label_prefix,
"global", r->getPosition()) );
} else
{
string interfaces = "";
for (FWObject::iterator i=itfre->begin(); i!=itfre->end(); ++i)
{
FWObject *o = FWReference::getObject(*i);
if (interfaces!="") interfaces += ",";
interfaces += o->getName();
}
r->setLabel( createRuleLabel(label_prefix,
interfaces, r->getPosition()) );
}
}
r->setAbsRuleNumber(global_num);
global_num++;
rule_counter++;
}
initialized = true;
return rule_counter;
}