本文整理汇总了C++中FWObject::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ FWObject::getName方法的具体用法?C++ FWObject::getName怎么用?C++ FWObject::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FWObject
的用法示例。
在下文中一共展示了FWObject::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
// the IP address of the gateway RGtw has to be in a network of the interface RItf
bool RoutingCompiler::contradictionRGtwAndRItf::processNext()
{
RoutingRule *rule=getNext(); if (rule==NULL) return false;
tmp_queue.push_back(rule);
RuleElementRGtw *gtwrel=rule->getRGtw();
RuleElementRItf *itfrel=rule->getRItf();
FWObject *oRGtw = FWReference::cast(gtwrel->front())->getPointer();
FWObject *oRItf = FWReference::cast(itfrel->front())->getPointer();
if (oRItf->getName() == "Any") { return true; }
if (Host::cast(oRGtw) != NULL ||
Interface::cast(oRGtw) != NULL ||
Address::cast(oRGtw)->dimension()==1)
{
const InetAddr* ip_interface = NULL;
if ( Host::cast(oRGtw) != NULL)
{
Host *host=Host::cast(oRGtw);
ip_interface = host->getAddressPtr();
} else if (Interface::cast(oRGtw) != NULL)
{
Interface *intf=Interface::cast(oRGtw);
ip_interface = intf->getAddressPtr();
} else if (Address::cast(oRGtw)->dimension()==1)
{
Address *ipv4 = Address::cast(oRGtw);
ip_interface = ipv4->getAddressPtr();
}
if (ip_interface)
{
list<FWObject*> obj_list = oRItf->getByType(IPv4::TYPENAME);
for (list<FWObject*>::iterator i=obj_list.begin();
i!=obj_list.end(); ++i)
{
Address *addr = Address::cast(*i);
if (addr->belongs(*ip_interface))
return true;
}
}
string msg;
msg = "Object \"" + oRGtw->getName() +
"\" used as gateway in the routing rule " +
rule->getLabel() +
" is not in the same local network as interface " +
oRItf->getName();
compiler->abort(rule, msg.c_str());
}
return true;
}
示例2: debugPrintRule
string RoutingCompiler::debugPrintRule(Rule *r)
{
RoutingRule *rule = RoutingRule::cast(r);
RuleElementRDst *dstrel = rule->getRDst();
RuleElementRItf *itfrel = rule->getRItf();
RuleElementRGtw *gtwrel = rule->getRGtw();
ostringstream str;
// str << setw(70) << setfill('-') << "-";
string dst, itf, gtw;
FWObject *obj = FWReference::getObject(itfrel->front());
itf = (obj) ? obj->getName() : "NULL";
obj = FWReference::getObject(gtwrel->front());
gtw = (obj) ? obj->getName() : "NULL";
int no = 0;
FWObject::iterator i1 = dstrel->begin();
while ( i1!=dstrel->end())
{
str << endl;
dst = " ";
if (i1 != dstrel->end())
{
FWObject *o = FWReference::getObject(*i1);
dst = (o) ? o->getName() : "NULL";
}
int w = 0;
if (no==0)
{
str << rule->getLabel();
w = rule->getLabel().length();
}
str << setw(10-w) << setfill(' ') << " ";
str << setw(18) << setfill(' ') << dst.c_str() << " ";
str << setw(18) << setfill(' ') << itf.c_str() << " ";
str << setw(18) << setfill(' ') << gtw.c_str() << " ";
str << setw(18) << setfill(' ') << " ";
++no;
if ( i1 != dstrel->end() ) ++i1;
}
return str.str();
}
示例3: unlockObject
void ObjectManipulator::unlockObject()
{
if (fwbdebug)
qDebug() << "ObjectManipulator::unlockObject selected:"
<< getCurrentObjectTree()->getNumSelected();
if (getCurrentObjectTree()->getNumSelected()==0) return;
try
{
FWObject *obj;
vector<FWObject*> so = getCurrentObjectTree()->getSimplifiedSelection();
for (vector<FWObject*>::iterator i=so.begin(); i!=so.end(); ++i)
{
obj= *i;
FWObject *lib = obj->getLibrary();
if (lib->getId()!=FWObjectDatabase::STANDARD_LIB_ID)
{
std::auto_ptr<FWCmdLockObject> cmd(
new FWCmdLockObject(m_project, obj, tr("Unlock object ") +
QString::fromUtf8(obj->getName().c_str())));
FWObject* new_state = cmd->getNewState();
new_state->setReadOnly(false);
if (!cmd->getOldState()->cmp(new_state, true))
m_project->undoStack->push(cmd.release());
}
}
} catch (FWException &ex)
{
qDebug() << ex.toString().c_str();
}
}
示例4: string
/*
* checks if one of the children of RuleElement is a host, IPv4 or
* network object with address 0.0.0.0 and netmask 0.0.0.0.
*
* Exceptions:
* - object 'any'
* - interface with dynamic address.
*
* In addition check for address A.B.C.D/0 which is most likely a
* mistake if A.B.C.D != 0.0.0.0. See #475
*/
Address* PolicyCompiler::checkForZeroAddr::findZeroAddress(RuleElement *re)
{
Address *a=NULL;
for (FWObject::iterator i=re->begin(); i!=re->end(); i++)
{
FWObject *o = FWReference::getObject(*i);
assert(o!=NULL);
MultiAddress *maddr = MultiAddress::cast(o);
if (maddr && maddr->isRunTime()) continue;
Address *addr = Address::cast(o);
if (addr==NULL && o!=NULL)
compiler->warning(
re->getParent(),
string("findZeroAddress: Unknown object in rule element: ") +
o->getName() +
" type=" + o->getTypeName());
if (addr && addr->hasInetAddress())
{
if (Interface::cast(o)!=NULL &&
(Interface::cast(o)->isDyn() ||
Interface::cast(o)->isUnnumbered() ||
Interface::cast(o)->isBridgePort()))
continue;
if ( ! addr->isAny())
{
const InetAddr *ad = addr->getAddressPtr();
const InetAddr *nm = addr->getNetmaskPtr();
// AddressRange has address but not netmask
// AddressRange with address 0.0.0.0 is acceptable
// (not equivalent to "any")
if (ad->isAny() && nm!=NULL && nm->isAny())
{
a = addr;
break;
}
// Address A.B.C.D/0 is most likely a mistake if
// A.B.C.D != 0.0.0.0
if ((Network::cast(addr) || NetworkIPv6::cast(addr)) &&
!ad->isAny() && nm!=NULL && nm->isAny())
{
a = addr;
break;
}
}
}
}
return a;
}
示例5: fileExport
void ProjectPanel::fileExport()
{
LibExportDialog ed;
list<FWObject*> selectedLibs;
map<int,FWObject*>::iterator i;
int lib_idx = -1;
do
{
if (ed.exec()!=QDialog::Accepted) return;
QList<QListWidgetItem*> selitems = ed.m_dialog->libs->selectedItems();
for (i=ed.mapOfLibs.begin(); i!=ed.mapOfLibs.end(); i++)
if (selitems.contains(ed.m_dialog->libs->item(i->first)))
selectedLibs.push_back(i->second);
lib_idx=ed.m_dialog->libs->currentRow ();
if (lib_idx<0 || selectedLibs.size()==0)
{
QMessageBox::critical(
this,"Firewall Builder",
tr("Please select a library you want to export."),
"&Continue", QString::null,QString::null,
0, 1 );
return;
}
} while (!exportLibraryTest(selectedLibs));
FWObject *selLib = ed.mapOfLibs[ lib_idx ];
QString path = st->getOpenFileDir() + QString::fromUtf8(selLib->getName().c_str()) + ".fwl";
resetFD();
QString fname = QFileDialog::getSaveFileName(
this,
"Choose a filename to save under",
path,
"Firewall Builder library files (*.fwl)");
if (fname.isEmpty()) return;
if (QFile::exists(fname) &&
QMessageBox::warning(
this,"Firewall Builder",
tr("The file %1 already exists.\nDo you want to overwrite it ?")
.arg(fname),
tr("&Yes"), tr("&No"), QString::null,
0, 1 )==1 ) return;
st->setOpenFileDir(path);
exportLibraryTo(fname,selectedLibs,ed.m_dialog->exportRO->isChecked());
}
示例6: getNext
bool PolicyCompiler::InterfacePolicyRules::processNext()
{
PolicyRule *rule = getNext(); if (rule==NULL) return false;
RuleElementItf *itfre = rule->getItf(); assert(itfre);
if (itfre->isAny())
{
// rule->setInterfaceId(-1);
tmp_queue.push_back(rule);
return true;
}
for (FWObject::iterator i=itfre->begin(); i!=itfre->end(); ++i)
{
FWObject *o = FWReference::getObject(*i);
if (ObjectGroup::isA(o))
{
// a group in "interface" rule element. GUI checks that only
// interfaces are allowed in such group, but we should check anyway.
for (FWObject::iterator i=o->begin(); i!=o->end(); ++i)
{
FWObject *o1 = FWReference::getObject(*i);
if (!Interface::isA(o1))
{
compiler->warning(
"Object '" + o1->getName() +
"', which is not an interface, is a member of the group '" +
o->getName() +
"' used in 'Interface' element of a rule.");
continue;
}
PolicyRule *r= compiler->dbcopy->createPolicyRule();
compiler->temp_ruleset->add(r);
r->duplicate(rule);
RuleElementItf *nitf = r->getItf();
nitf->clearChildren();
nitf->setAnyElement();
nitf->addRef(o1);
tmp_queue.push_back(r);
}
} else
{
PolicyRule *r= compiler->dbcopy->createPolicyRule();
compiler->temp_ruleset->add(r);
r->duplicate(rule);
RuleElementItf *nitf = r->getItf();
nitf->clearChildren();
nitf->setAnyElement();
nitf->addRef(o);
tmp_queue.push_back(r);
}
}
return true;
}
示例7: autorenameVlans
void ObjectManipulator::autorenameVlans(list<FWObject*> &obj_list)
{
for (list<FWObject*>::iterator j=obj_list.begin(); j!=obj_list.end(); ++j)
{
FWObject *obj = *j;
FWObject *parent = obj->getParent();
FWObject *fw = parent;
while (fw && Firewall::cast(fw)==NULL) fw = fw->getParent();
assert(fw);
QString obj_name = QString::fromUtf8(obj->getName().c_str());
std::auto_ptr<interfaceProperties> int_prop(
interfacePropertiesObjectFactory::getInterfacePropertiesObject(fw));
if (int_prop->looksLikeVlanInterface(obj_name))
{
// even though we only call this function if the type of
// this interface is 8021q, need to check its naming
// schema as well. We can't automatically rename
// interfaces that do not follow known naming convention.
QString base_name;
int vlan_id;
int_prop->parseVlan(obj_name, &base_name, &vlan_id);
if (base_name != "vlan")
{
QString new_name = QString("%1.%2")
.arg(QString::fromUtf8(
parent->getName().c_str()))
.arg(vlan_id);
if (new_name != QString::fromUtf8(obj->getName().c_str()))
{
FWCmdChange* cmd = new FWCmdChangeName(m_project, obj);
FWObject* new_state = cmd->getNewState();
new_state->setName(string(new_name.toUtf8()));
m_project->undoStack->push(cmd);
}
}
}
}
}
示例8: updateFirewallName
void ProjectPanel::updateFirewallName()
{
if (visibleRuleSet==NULL) return ;
QString name;
// mw->buildEditorTitleAndIcon(visibleRuleSet, ObjectEditor::optNone,
// &name, NULL, false);
// name = "<b>" + name + "</b>";
FWObject *fw = visibleRuleSet->getParent();
name = QString("%1 / %2")
.arg(QString::fromUtf8(fw->getName().c_str()))
.arg(QString::fromUtf8(visibleRuleSet->getName().c_str()));
m_panel->rulesetname->setText(name );
}
示例9: fillInterfaces
void RuleOptionsDialog::fillInterfaces(QComboBox* cb)
{
QSet<QString> deduplicated_interface_names;
list<FWObject*> interfaces = firewall->getByTypeDeep(Interface::TYPENAME);
for (list<FWObject*>::iterator i=interfaces.begin(); i!=interfaces.end(); ++i)
{
Interface *iface = Interface::cast(*i);
assert(iface);
if (iface->isLoopback()) continue;
deduplicated_interface_names.insert(iface->getName().c_str());
if (Cluster::isA(firewall))
{
FailoverClusterGroup *failover_group =
FailoverClusterGroup::cast(
iface->getFirstByType(FailoverClusterGroup::TYPENAME));
if (failover_group)
{
for (FWObject::iterator it=failover_group->begin();
it!=failover_group->end(); ++it)
{
FWObject *mi = FWReference::getObject(*it);
if (Interface::isA(mi) && ! iface->isLoopback())
{
deduplicated_interface_names.insert(mi->getName().c_str());
}
}
}
}
}
QStringList sorted_interfaces;
QSetIterator<QString> it(deduplicated_interface_names);
while (it.hasNext())
{
sorted_interfaces << it.next();
}
sorted_interfaces.sort();
cb->clear();
cb->addItem("");
cb->addItems(sorted_interfaces);
}
示例10: findAllGroups
void PrintingController::findAllGroups(list<FWObject*> &objects,
list<FWObject*> &groups)
{
if (fwbdebug) qDebug("findAllGroups: arg1 size %d", int(objects.size()));
for (FWObject::iterator obj=objects.begin(); obj!=objects.end(); ++obj)
{
if (fwbdebug) qDebug(" %s",(*obj)->getName().c_str());
FWObject *o = *obj;
if (FWReference::cast(o)!=NULL) o=FWReference::cast(o)->getPointer();
if (Group::cast(o)!=NULL &&
std::find(groups.begin(),groups.end(),o)==groups.end())
{
groups.push_back(o);
if (fwbdebug) qDebug("Add group %s to groups",o->getName().c_str());
findAllGroups(*o,groups);
}
}
}
示例11: autorename
void ObjectManipulator::autorename(list<FWObject*> &obj_list,
const string &objtype,
const string &namesuffix)
{
for (list<FWObject*>::iterator j=obj_list.begin(); j!=obj_list.end(); ++j)
{
FWObject *obj = *j;
QString old_name = obj->getName().c_str();
FWObject *parent = obj->getParent();
QString name = getStandardName(parent, objtype, namesuffix);
name = makeNameUnique(parent, name, objtype.c_str());
if (name != old_name)
{
FWCmdChange* cmd = new FWCmdChangeName(m_project, obj);
FWObject* new_state = cmd->getNewState();
new_state->setName(string(name.toUtf8()));
m_project->undoStack->push(cmd);
}
}
}
示例12: lockObject
void ObjectManipulator::lockObject()
{
if (fwbdebug)
qDebug() << "ObjectManipulator::lockObject selected:"
<< getCurrentObjectTree()->getNumSelected();
if (getCurrentObjectTree()->getNumSelected()==0) return;
try
{
FWObject *obj;
vector<FWObject*> so = getCurrentObjectTree()->getSimplifiedSelection();
for (vector<FWObject*>::iterator i=so.begin(); i!=so.end(); ++i)
{
obj= *i;
FWObject *lib = obj->getLibrary();
// these lbraries are locked anyway, do not let the user
// lock objects inside because they won't be able to unlock them.
if (lib->getId()!=FWObjectDatabase::STANDARD_LIB_ID)
{
std::auto_ptr<FWCmdLockObject> cmd(
new FWCmdLockObject(m_project, obj, tr("Lock object ") +
QString::fromUtf8(obj->getName().c_str())));
FWObject* new_state = cmd->getNewState();
new_state->setReadOnly(true);
if (!cmd->getOldState()->cmp(new_state, true))
m_project->undoStack->push(cmd.release());
}
}
// Arguably, locking an object should not change lastModified timestamp
// because none of the attributes that affect generated policy change.
//QCoreApplication::postEvent(
// mw, new dataModifiedEvent(m_project->getFileName(), 0));
} catch (FWException &ex)
{
qDebug() << ex.toString().c_str();
}
}
示例13: debugPrintRule
string PolicyCompiler_ipf::debugPrintRule(Rule *r)
{
PolicyRule *rule=PolicyRule::cast(r);
// FWOptions *ruleopt =rule->getOptionsObject();
ostringstream s;
s << PolicyCompiler::debugPrintRule(rule) << " ";
RuleElementItf *intf_re = rule->getItf();
string rule_interfaces;
int intf_count = 0;
for (FWObject::iterator it=intf_re->begin(); it!=intf_re->end(); ++it)
{
FWObject *o = *it;
if (FWReference::cast(o)!=NULL) o = FWReference::cast(o)->getPointer();
rule_interfaces += " " + o->getName();
intf_count++;
}
if (intf_count > 0)
{
s << " intf: ";
if (intf_count > 1) s << "{ ";
s << rule_interfaces;
if (intf_count > 1) s << " }";
}
else
s << " intf: ?";
s << " ";
if (r->getBool("skip_check_for_duplicates")) s << "skip_check_for_duplicates ";
if (r->getStr("skip_label")!="") s << "skip_label: " << r->getStr("skip_label") << " ";
if (r->getStr("skip_to")!="") s << "skip_to: " << r->getStr("skip_to") << " ";
if (r->getInt("no_to_skip")!=-1) s << "no_to_skip: " << r->getInt("no_to_skip");
s << " " << FWObjectDatabase::getStringId(r->getId()) << " (" << r->getId() << ")";
return s.str();
}
示例14: string
void NATCompiler_pf::PrintRule::_printInterface(NATRule *rule)
{
RuleElementItf *intf_re = rule->getItfOutb();
QStringList rule_interfaces;
if ( ! intf_re->isAny())
{
for (FWObject::iterator it=intf_re->begin(); it!=intf_re->end(); ++it)
{
FWObject *o = FWObjectReference::getObject(*it);
rule_interfaces << o->getName().c_str();
}
if (rule_interfaces.size() > 1)
{
rule_interfaces.push_front("{");
rule_interfaces.push_back("}");
}
compiler->output << "on "
<< string((intf_re->getBool("single_object_negation")) ? "! " : " ")
<< rule_interfaces.join(" ").toStdString()
<< " ";
}
}
示例15: actuallyPasteTo
FWObject* ObjectManipulator::actuallyPasteTo(FWObject *target,
FWObject *obj,
std::map<int,int> &map_ids)
{
//FWObject *res = NULL;
FWObject *ta = prepareForInsertion(target, obj);
if (ta == NULL) return NULL;
if (!isObjectAllowed(ta, obj)) return NULL;
// we disable copy/cut/paste/duplicate menu items for objects that
// can't be copied or duplicated in
// ObjectManipulator::getMenuState() but will check here just in
// case
if (AttachedNetworks::isA(obj)) return NULL;
if (fwbdebug)
qDebug() << "ObjectManipulator::actuallyPasteTo"
<< "target=" << target->getPath().c_str()
<< "ta=" << ta->getPath().c_str();
QString new_name = makeNameUnique(
ta, obj->getName().c_str(), obj->getTypeName().c_str());
try
{
/* clipboard holds a copy of the object */
if (obj->getRoot() != ta->getRoot())
{
if (fwbdebug) qDebug("Copy object %s (%d) to a different object tree",
obj->getName().c_str(), obj->getId());
FWCmdAddObject *cmd = new FWCmdAddObject(m_project, target, NULL,
QObject::tr("Paste object"));
FWObject *new_state = cmd->getNewState();
cmd->setNeedTreeReload(true);
// recursivelyCopySubtree() needs access to the target tree root
// when it copies subtree, so have to copy into the actual target
// tree.
FWObject *nobj = m_project->db()->recursivelyCopySubtree(target, obj, map_ids);
if (new_name != nobj->getName().c_str())
nobj->setName(string(new_name.toUtf8()));
target->remove(nobj, false);
new_state->add(nobj);
m_project->undoStack->push(cmd);
return nobj;
}
Group *grp = Group::cast(ta);
if (grp!=NULL && !FWBTree().isSystem(ta))
{
if (fwbdebug) qDebug("Copy object %s (%d) to a regular group",
obj->getName().c_str(), obj->getId());
/* check for duplicates. We just won't add an object if it is already there */
int cp_id = obj->getId();
list<FWObject*>::iterator j;
for (j=grp->begin(); j!=grp->end(); ++j)
{
FWObject *o1=*j;
if(cp_id==o1->getId()) return o1;
FWReference *ref;
if( (ref=FWReference::cast(o1))!=NULL &&
cp_id==ref->getPointerId()) return o1;
}
FWCmdChange *cmd = new FWCmdChange(
m_project, grp,
QObject::tr("Paste object"));
//cmd->setNeedTreeReload(false);
FWObject *new_state = cmd->getNewState();
new_state->addRef(obj);
m_project->undoStack->push(cmd);
return obj;
} else
{
/* add a copy of the object to system group , or
* add ruleset object to a firewall.
*/
if (fwbdebug)
qDebug("Copy object %s (%d) to a system group, "
"a ruleset to a firewall or an address to an interface",
obj->getName().c_str(), obj->getId());
FWObject *nobj = m_project->db()->create(obj->getTypeName());
assert(nobj!=NULL);
//nobj->ref();
nobj->duplicate(obj, true);
if (new_name != nobj->getName().c_str())
nobj->setName(string(new_name.toUtf8()));
// If we paste interface, reset the type of the copy
// See #299
if (Interface::isA(obj) && Interface::isA(ta))
{
Interface *new_intf = Interface::cast(nobj);
new_intf->getOptionsObject()->setStr("type", "ethernet");
// see #391 : need to reset "mamagement" flag in the copy
// to make sure we do not end up with two management interfaces
new_intf->setManagement(false);
//.........这里部分代码省略.........