bool PolicyCompiler::ConvertToAtomicForAddresses::processNext() { PolicyRule *rule=getNext(); if (rule==NULL) return false; RuleElementSrc *src=rule->getSrc(); assert(src); RuleElementDst *dst=rule->getDst(); assert(dst); for (FWObject::iterator i1=src->begin(); i1!=src->end(); ++i1) { for (FWObject::iterator i2=dst->begin(); i2!=dst->end(); ++i2) { PolicyRule *r = compiler->dbcopy->createPolicyRule(); r->duplicate(rule); compiler->temp_ruleset->add(r); FWObject *s; s=r->getSrc(); assert(s); s->clearChildren(); s->addCopyOf( *i1 ); s=r->getDst(); assert(s); s->clearChildren(); s->addCopyOf( *i2 ); tmp_queue.push_back(r); } } return true; }
bool PolicyCompiler::ConvertToAtomicForIntervals::processNext() { PolicyRule *rule=getNext(); if (rule==NULL) return false; RuleElementInterval *ivl=rule->getWhen(); if (ivl==NULL || ivl->isAny()) { tmp_queue.push_back(rule); return true; } for (FWObject::iterator i1=ivl->begin(); i1!=ivl->end(); ++i1) { PolicyRule *r = compiler->dbcopy->createPolicyRule(); r->duplicate(rule); compiler->temp_ruleset->add(r); FWObject *s; s=r->getWhen(); assert(s); s->clearChildren(); s->addCopyOf( *i1 ); tmp_queue.push_back(r); } return true; }
Rule* PolicyCompiler::getDifference(PolicyRule &r1, PolicyRule &r2) { PolicyRule *r = new PolicyRule(); *r = r1; FWObject *nsrc = getFirstSrc(r); nsrc->clearChildren(); FWObject *ndst = getFirstDst(r); ndst->clearChildren(); Service *nsrv = getFirstSrv(r); nsrv->clearChildren(); RuleElementItf *intf_re = r1.getItf(); FWObject *rule1_iface = FWObjectReference::getObject(intf_re->front()); int iface1 = rule1_iface->getId(); intf_re = r2.getItf(); FWObject *rule2_iface = FWObjectReference::getObject(intf_re->front()); int iface2 = rule2_iface->getId(); if (iface1 != iface2) return r; /* vector<FWObject*> v1=_substract_obj( r1.getSrc() , r2.getSrc() ); vector<FWObject*> v2=_substract_obj( r1.getDst() , r2.getDst() ); vector<FWObject*> v3=_substract_srv( r1.getSrv() , r2.getSrv() ); for (vector<FWObject*>::iterator i=v1.begin(); i!=v1.end(); ++i) nsrc->addRef(*i); for (vector<FWObject*>::iterator i=v2.begin(); i!=v2.end(); ++i) ndst->addRef(*i); for (vector<FWObject*>::iterator i=v3.begin(); i!=v3.end(); ++i) nsrv->addRef(*i); */ return r; }
bool RoutingCompiler::ConvertToAtomicForDST::processNext() { RoutingRule *rule=getNext(); if (rule==NULL) return false; //RuleElementSrc *src=rule->getSrc(); assert(src); RuleElementRDst *dst=rule->getRDst(); assert(dst); for (FWObject::iterator it=dst->begin(); it!=dst->end(); ++it) { RoutingRule *r = compiler->dbcopy->createRoutingRule(); r->duplicate(rule); compiler->temp_ruleset->add(r); FWObject *s = r->getRDst(); assert(s); s->clearChildren(); s->addRef(FWReference::getObject(*it)); tmp_queue.push_back(r); } return true; }