diff --git a/src/cisco_lib/CompilerDriver_pix_run.cpp b/src/cisco_lib/CompilerDriver_pix_run.cpp index e39f92c20..2315b273b 100644 --- a/src/cisco_lib/CompilerDriver_pix_run.cpp +++ b/src/cisco_lib/CompilerDriver_pix_run.cpp @@ -941,7 +941,8 @@ void CompilerDriver_pix::pixClusterGroupChecks(ClusterGroup *cluster_group) { Interface *member_iface = Interface::cast(FWObjectReference::getObject(*it)); assert(member_iface); - FWObject *member = member_iface->getParentHost(); + FWObject *member = Host::getParentHost(member_iface); + //FWObject *member = member_iface->getParentHost(); if (cluster_interface) { diff --git a/src/compiler_lib/interfaceProperties.cpp b/src/compiler_lib/interfaceProperties.cpp index b55b6ebb6..4b0689b89 100644 --- a/src/compiler_lib/interfaceProperties.cpp +++ b/src/compiler_lib/interfaceProperties.cpp @@ -170,7 +170,8 @@ bool interfaceProperties::manageIpAddresses(Interface *intf, update_addresses.clear(); ignore_addresses.clear(); - FWObject *fw = intf->getParentHost(); + FWObject *fw = Host::getParentHost(intf); + //FWObject *fw = intf->getParentHost(); Resources *os_res = Resources::os_res[fw->getStr("host_OS")]; assert(os_res != NULL); @@ -270,7 +271,8 @@ bool interfaceProperties::validateInterface(FWObject *target, Interface::cast(target)->getOptionsObject()->getStr("type"); if (target_interface_type.empty()) target_interface_type = "ethernet"; - FWObject *fw = Interface::cast(target)->getParentHost(); + FWObject *fw = Host::getParentHost(target); + //FWObject *fw = Interface::cast(target)->getParentHost(); QString host_os = fw->getStr("host_OS").c_str(); Resources* os_res = Resources::os_res[host_os.toStdString()]; list interface_type_pairs; @@ -437,7 +439,8 @@ bool interfaceProperties::isEligibleForCluster(Interface *intf) parent_iface->getOptionsObject()->getStr("type") == "bridge") return false; - FWObject *fw = intf->getParentHost(); + FWObject *fw = Host::getParentHost(intf); + //FWObject *fw = intf->getParentHost(); list interfaces = fw->getByTypeDeep(Interface::TYPENAME); list::iterator i; for (i=interfaces.begin(); i!=interfaces.end(); ++i ) @@ -469,7 +472,8 @@ void interfaceProperties::guessSubInterfaceTypeAndAttributes(Interface *intf) if (parent_intf == NULL) return; - FWObject *f = intf->getParentHost(); + FWObject *f = Host::getParentHost(intf); + //FWObject *f = intf->getParentHost(); // Resources* os_res = Resources::os_res[f->getStr("host_OS")]; // string os_family = f->getStr("host_OS"); diff --git a/src/iptlib/NATCompiler_ipt.cpp b/src/iptlib/NATCompiler_ipt.cpp index bd4e170c0..04a73a331 100644 --- a/src/iptlib/NATCompiler_ipt.cpp +++ b/src/iptlib/NATCompiler_ipt.cpp @@ -2128,7 +2128,8 @@ bool NATCompiler_ipt::AssignInterface::processNext() if (iface) { - if (Cluster::isA(iface->getParentHost())) + FWObject *parent_host = Host::getParentHost(iface); + if (Cluster::isA(parent_host)) { if (iface->isFailoverInterface()) diff --git a/src/iptlib/utils.cpp b/src/iptlib/utils.cpp index b675b4be4..c7b9cd72d 100644 --- a/src/iptlib/utils.cpp +++ b/src/iptlib/utils.cpp @@ -159,7 +159,8 @@ void expand_interface_with_phys_address(Compiler *compiler, * we use physAddress only if Host option "use_mac_addr_filter" of the * parent Host object is true */ - FWObject *p = iface->getParentHost(); + FWObject *p = Host::getParentHost(iface); + //FWObject *p = iface->getParentHost(); assert(p!=NULL); FWOptions *hopt = Host::cast(p)->getOptionsObject(); diff --git a/src/libfwbuilder/src/fwbuilder/AttachedNetworks.cpp b/src/libfwbuilder/src/fwbuilder/AttachedNetworks.cpp index 499f819ca..4de067f9c 100644 --- a/src/libfwbuilder/src/fwbuilder/AttachedNetworks.cpp +++ b/src/libfwbuilder/src/fwbuilder/AttachedNetworks.cpp @@ -73,7 +73,7 @@ xmlNodePtr AttachedNetworks::toXML(xmlNodePtr parent) throw(FWException) void AttachedNetworks::addNetworkObject(const InetAddr *ip_addr, const InetAddr *ip_netm) { - FWObject *new_obj; + FWObject *new_obj = NULL; if (ip_addr->isV4()) { diff --git a/src/libfwbuilder/src/fwbuilder/Cluster.cpp b/src/libfwbuilder/src/fwbuilder/Cluster.cpp index 66b88c847..3f141b301 100644 --- a/src/libfwbuilder/src/fwbuilder/Cluster.cpp +++ b/src/libfwbuilder/src/fwbuilder/Cluster.cpp @@ -254,7 +254,7 @@ void Cluster::getMembersList(list &members) // as of 05/04 members of StateSyncClusterGroup are interfaces. See // tickets #10 and #11 if (Interface::cast(member)) - fw = Firewall::cast(Interface::cast(member)->getParentHost()); + fw = Firewall::cast(Host::getParentHost(member)); else fw = Firewall::cast(member); members_ids.insert(fw->getId()); @@ -288,7 +288,7 @@ bool Cluster::hasMember(Firewall *fw) // as of 05/04/2009 members of StateSyncClusterGroup are // interfaces. See tickets #10 and #11 if (Interface::cast(member)) - member_fw = Firewall::cast(Interface::cast(member)->getParentHost()); + member_fw = Firewall::cast(Host::getParentHost(member)); else member_fw = Firewall::cast(member); if (fw == member_fw) return true; diff --git a/src/libfwbuilder/src/fwbuilder/FWObject.cpp b/src/libfwbuilder/src/fwbuilder/FWObject.cpp index d7487ca8e..d52121d4c 100644 --- a/src/libfwbuilder/src/fwbuilder/FWObject.cpp +++ b/src/libfwbuilder/src/fwbuilder/FWObject.cpp @@ -1593,3 +1593,5 @@ bool FWObjectNameCmpPredicate::operator()(FWObject *a, FWObject *b) FWObject *o2 = (follow_references) ? FWReference::getObject(b) : b; return o1->getName() < o2->getName(); } + + diff --git a/src/libfwbuilder/src/fwbuilder/Host.cpp b/src/libfwbuilder/src/fwbuilder/Host.cpp index 4afded325..bddbd5435 100644 --- a/src/libfwbuilder/src/fwbuilder/Host.cpp +++ b/src/libfwbuilder/src/fwbuilder/Host.cpp @@ -168,3 +168,16 @@ int Host::countInetAddresses(bool skip_loopback) const return res; } +/* + * This function will find parent host, firewall or cluster object of + * a given object. If object is not a child of host, firewall or + * cluster, it returns NULL + */ +FWObject* Host::getParentHost(FWObject *obj) +{ + FWObject *parent_h = obj; + while (parent_h != NULL && Host::cast(parent_h) == NULL) + parent_h = parent_h->getParent(); + return parent_h; +} + diff --git a/src/libfwbuilder/src/fwbuilder/Host.h b/src/libfwbuilder/src/fwbuilder/Host.h index 0b5b33c66..c425c7be6 100644 --- a/src/libfwbuilder/src/fwbuilder/Host.h +++ b/src/libfwbuilder/src/fwbuilder/Host.h @@ -97,6 +97,15 @@ class Host : public Address virtual bool isPrimaryObject() const { return true; } + /** + * helper-function, needed when dealing with sub-interfaces: + * function returns the parent host (or firewall) of an interface + * or rule set. This is just a convenience function that performs + * operation we often need. + */ + static FWObject* getParentHost(FWObject *obj); + + protected: Management *mgmt; diff --git a/src/libfwbuilder/src/fwbuilder/Interface.cpp b/src/libfwbuilder/src/fwbuilder/Interface.cpp index 1e0ad0cb6..14aa454d9 100644 --- a/src/libfwbuilder/src/fwbuilder/Interface.cpp +++ b/src/libfwbuilder/src/fwbuilder/Interface.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -283,9 +284,10 @@ FWOptions* Interface::getOptionsObject() add(iface_opt); // set default interface options - if (this->getParentHost() != NULL) + const FWObject *parent_host = Host::getParentHost(this); + if (parent_host != NULL) { - const string host_OS = this->getParentHost()->getStr("host_OS"); + const string host_OS = parent_host->getStr("host_OS"); try { Resources::setDefaultIfaceOptions(host_OS, this); @@ -426,17 +428,6 @@ bool Interface::isLoopback() const return false; } -FWObject* Interface::getParentHost() const -{ - FWObject *p = this->getParent(); - if (!Interface::isA(p)) { - return p; - } else { - p = p->getParent(); - } - return p; -} - physAddress* Interface::getPhysicalAddress () const { return physAddress::cast( getFirstByType( physAddress::TYPENAME ) ); diff --git a/src/libfwbuilder/src/fwbuilder/Interface.h b/src/libfwbuilder/src/fwbuilder/Interface.h index fe028b67f..4ab03e1e2 100644 --- a/src/libfwbuilder/src/fwbuilder/Interface.h +++ b/src/libfwbuilder/src/fwbuilder/Interface.h @@ -100,12 +100,6 @@ public: DECLARE_DISPATCH_METHODS(Interface); - /** - * helper-function, needed when dealing with sub-interfaces: function - * returns the parent host (or firewall) of an interface. - */ - FWObject* getParentHost() const; - /** * each interface must be associated with some security level. Level * is described by interger number between 0 and 100, with 0 being diff --git a/src/libfwbuilder/src/fwcompiler/Compiler.cpp b/src/libfwbuilder/src/fwcompiler/Compiler.cpp index 1a5e70327..b4b856330 100644 --- a/src/libfwbuilder/src/fwcompiler/Compiler.cpp +++ b/src/libfwbuilder/src/fwcompiler/Compiler.cpp @@ -461,7 +461,8 @@ void Compiler::_expand_interface(Rule *rule, * we use physAddress only if Host option "use_mac_addr_filter" of the * parent Host object is true */ - FWObject *p = iface->getParentHost(); + FWObject *p = Host::getParentHost(iface); + //FWObject *p = iface->getParentHost(); Host *hp = Host::cast(p); if (hp==NULL) return; // something is very broken FWOptions *hopt = hp->getOptionsObject(); diff --git a/src/libfwbuilder/src/fwcompiler/RoutingCompiler.cpp b/src/libfwbuilder/src/fwcompiler/RoutingCompiler.cpp index 519dc5f9c..d739fcb77 100644 --- a/src/libfwbuilder/src/fwcompiler/RoutingCompiler.cpp +++ b/src/libfwbuilder/src/fwcompiler/RoutingCompiler.cpp @@ -519,7 +519,8 @@ bool RoutingCompiler::rItfChildOfFw::processNext() Interface *iface = Interface::cast(o); if (iface) { - FWObject *parent = iface->getParentHost(); + FWObject *parent = Host::getParentHost(iface); + //FWObject *parent = iface->getParentHost(); if (parent->getId() == compiler->fw->getId()) return true; Cluster *cluster = Cluster::cast(parent); diff --git a/src/libgui/ClusterGroupDialog.cpp b/src/libgui/ClusterGroupDialog.cpp index 396e24646..fe8f98c9a 100644 --- a/src/libgui/ClusterGroupDialog.cpp +++ b/src/libgui/ClusterGroupDialog.cpp @@ -205,7 +205,8 @@ void ClusterGroupDialog::addIcon(FWObject *o, bool master) { FWObject *iface = o; assert(Interface::cast(iface)!=NULL); - FWObject *fw = Interface::cast(iface)->getParentHost(); // because iface can be subinterface + FWObject *fw = Host::getParentHost(iface); +// FWObject *fw = Interface::cast(iface)->getParentHost(); // because iface can be subinterface bool valid = cluster->validateMember(Firewall::cast(fw)); QString iface_name = QString::fromUtf8(iface->getName().c_str()); QString fw_name = QString::fromUtf8(fw->getName().c_str()); diff --git a/src/libgui/ClusterInterfaceWidget.cpp b/src/libgui/ClusterInterfaceWidget.cpp index f1460e61b..9df5f892d 100644 --- a/src/libgui/ClusterInterfaceWidget.cpp +++ b/src/libgui/ClusterInterfaceWidget.cpp @@ -181,8 +181,8 @@ ClusterInterfaceData ClusterInterfaceWidget::getInterfaceData() { QTreeWidgetItem *item = ifacelist.list->selectedItems().first(); Interface* iface = item->data(0, Qt::UserRole).value(); - res.interfaces.append( - qMakePair(Firewall::cast(iface->getParentHost()), iface)); + FWObject *parent_fw = Host::getParentHost(iface); + res.interfaces.append(qMakePair(Firewall::cast(parent_fw), iface)); } return res; } diff --git a/src/libgui/DialogFactory.cpp b/src/libgui/DialogFactory.cpp index dfb676292..100b97546 100644 --- a/src/libgui/DialogFactory.cpp +++ b/src/libgui/DialogFactory.cpp @@ -290,7 +290,8 @@ QWidget *DialogFactory::createOSDialog(QWidget *parent,FWObject *o) QWidget *DialogFactory::createIfaceDialog(QWidget *parent,FWObject *o) throw(FWException) { - FWObject *h = Interface::cast(o)->getParentHost(); + FWObject *h = Host::getParentHost(o); + //FWObject *h = Interface::cast(o)->getParentHost(); string host_OS = h->getStr("host_OS"); Resources *os = Resources::os_res[host_OS]; diff --git a/src/libgui/FWObjectPropertiesFactory.cpp b/src/libgui/FWObjectPropertiesFactory.cpp index 75a1a9054..5b4bc788c 100644 --- a/src/libgui/FWObjectPropertiesFactory.cpp +++ b/src/libgui/FWObjectPropertiesFactory.cpp @@ -176,44 +176,49 @@ QString FWObjectPropertiesFactory::getObjectPropertiesBrief(FWObject *obj) if (!obj->isReadOnly()) intf->getOptionsObject(); str << intf->getLabel().c_str() << " "; - FWObject *parent = intf->getParentHost(); - - bool supports_security_levels = false; - bool supports_network_zones = false; - try - { - supports_security_levels = - (!parent->getStr("platform").empty() && - Resources::getTargetCapabilityBool( - parent->getStr("platform"), "security_levels")); - supports_network_zones = - (!parent->getStr("platform").empty() && - Resources::getTargetCapabilityBool( - parent->getStr("platform"), "network_zones")); - } catch (FWException &ex) { } - QStringList q; - if (supports_security_levels) - { - QString str; - str.setNum(intf->getSecurityLevel()); - q.push_back(QString("sec level: %1").arg(str)); - } - if (supports_network_zones) - { - int id = FWObjectDatabase::getIntId(intf->getStr("network_zone")); - if (id > 0) - { - FWObject *nz_obj = obj->getRoot()->findInIndex(id); - if (nz_obj) - q.push_back( - QString("network zone: %1") - .arg(nz_obj->getName().c_str())); - else - q.push_back(QString("network zone: not configured")); + FWObject *parent = Host::getParentHost(intf); + //FWObject *parent = intf->getParentHost(); + if (parent) + { + bool supports_security_levels = false; + bool supports_network_zones = false; + try + { + supports_security_levels = + (!parent->getStr("platform").empty() && + Resources::getTargetCapabilityBool( + parent->getStr("platform"), "security_levels")); + supports_network_zones = + (!parent->getStr("platform").empty() && + Resources::getTargetCapabilityBool( + parent->getStr("platform"), "network_zones")); + } catch (FWException &ex) { } + + if (supports_security_levels) + { + QString str; + str.setNum(intf->getSecurityLevel()); + q.push_back(QString("sec level: %1").arg(str)); + } + if (supports_network_zones) + { + int id = FWObjectDatabase::getIntId(intf->getStr("network_zone")); + if (id > 0) + { + FWObject *nz_obj = obj->getRoot()->findInIndex(id); + if (nz_obj) + q.push_back( + QString("network zone: %1") + .arg(nz_obj->getName().c_str())); + else + q.push_back(QString("network zone: not configured")); + + } } } + if (intf->isDyn()) q.push_back("dyn"); if (intf->isUnnumbered()) q.push_back("unnum"); if (intf->isDedicatedFailover()) q.push_back("failover"); diff --git a/src/libgui/FWWindow_editor.cpp b/src/libgui/FWWindow_editor.cpp index decf7c121..a017deab0 100644 --- a/src/libgui/FWWindow_editor.cpp +++ b/src/libgui/FWWindow_editor.cpp @@ -176,7 +176,10 @@ void FWWindow::openEditor(FWObject *obj) // firewall and if a ruleset visible in RuleSetView belongs to // another firewall, switch ruleset to the ruleset of the new // firewall which we looked at last time. - if (Firewall::cast(obj) != NULL) // this includes Cluster + // + FWObject *parent_fw = Host::getParentHost(obj); + + if (parent_fw != NULL) // this includes Cluster { RuleSetView* rsv = activeProject()->getCurrentRuleSetView(); if (rsv) @@ -191,7 +194,8 @@ void FWWindow::openEditor(FWObject *obj) if (obj != current_ruleset->getParent()) { FWObject *old_rs = - activeProject()->m_panel->om->findInHistoryByParent(obj); + activeProject()->m_panel->om->findRuleSetInHistoryByParentFw( + parent_fw); if (old_rs == NULL) old_rs = obj->getFirstByType(Policy::TYPENAME); diff --git a/src/libgui/InterfaceDialog.cpp b/src/libgui/InterfaceDialog.cpp index 710a2fa90..4d49d8c69 100644 --- a/src/libgui/InterfaceDialog.cpp +++ b/src/libgui/InterfaceDialog.cpp @@ -122,9 +122,10 @@ void InterfaceDialog::loadFWObject(FWObject *o) * something relevant in the interface to complement their changes * and right after the interface has been created. */ + FWObject *parent_host = Host::getParentHost(s); interfaceProperties *int_prop = interfacePropertiesObjectFactory::getInterfacePropertiesObject( - s->getParentHost()); + parent_host); int_prop->guessSubInterfaceTypeAndAttributes(s); delete int_prop; } @@ -197,7 +198,8 @@ void InterfaceDialog::loadFWObject(FWObject *o) m_dialog->bridge_port_label->hide(); } - FWObject *f = s->getParentHost(); + FWObject *f = Host::getParentHost(s); + //FWObject *f = s->getParentHost(); m_dialog->advancedconfig->setEnabled(true); @@ -329,9 +331,10 @@ void InterfaceDialog::validate(bool *res) return; } + FWObject *parent_host = Host::getParentHost(obj); interfaceProperties *int_prop = interfacePropertiesObjectFactory::getInterfacePropertiesObject( - Interface::cast(obj)->getParentHost()); + parent_host); QString err; /* @@ -448,7 +451,8 @@ void InterfaceDialog::applyChanges() // NOTE: new_state is a copy of the interface but it is not attached to // the tree and therefore has no parent. Need to use original object obj // to get the pointer to the parent firewall. - FWObject *f = Interface::cast(obj)->getParentHost(); + FWObject *f = Host::getParentHost(obj); + //FWObject *f = Interface::cast(obj)->getParentHost(); bool supports_security_levels = false; bool supports_network_zones = false; bool supports_unprotected = false; @@ -503,9 +507,10 @@ void InterfaceDialog::applyChanges() { // ticket #328: automatically assign vlan id to interface based on // interface name + FWObject *parent_host = Host::getParentHost(obj); interfaceProperties *int_prop = interfacePropertiesObjectFactory::getInterfacePropertiesObject( - Interface::cast(obj)->getParentHost()); + parent_host); int_prop->setPerformVlanChecks(true); int_prop->guessSubInterfaceTypeAndAttributes(intf); delete int_prop; diff --git a/src/libgui/ObjectManipulator.cpp b/src/libgui/ObjectManipulator.cpp index f95c5bb84..069d16cea 100644 --- a/src/libgui/ObjectManipulator.cpp +++ b/src/libgui/ObjectManipulator.cpp @@ -489,7 +489,8 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos) if (Interface::isA(currentObj) && ! currentObj->isReadOnly()) { Interface *iface = Interface::cast(currentObj); - FWObject *h = iface->getParentHost(); + FWObject *h = Host::getParentHost(iface); + //FWObject *h = iface->getParentHost(); bool supports_advanced_ifaces = false; try { diff --git a/src/libgui/ObjectManipulator.h b/src/libgui/ObjectManipulator.h index 0a81894a2..1ec236025 100644 --- a/src/libgui/ObjectManipulator.h +++ b/src/libgui/ObjectManipulator.h @@ -87,15 +87,6 @@ public: }; -class FindHistoryItemByParentObjectId -{ - int id; -public: - FindHistoryItemByParentObjectId(int i) { id = i; } - bool operator()(const HistoryItem &itm); -}; - - class ObjectManipulator : public QWidget { Q_OBJECT; @@ -334,7 +325,8 @@ public: * parent. Used to find which rule set of the firewall user * looked at last. */ - libfwbuilder::FWObject* findInHistoryByParent(libfwbuilder::FWObject* parent); + libfwbuilder::FWObject* findRuleSetInHistoryByParentFw( + libfwbuilder::FWObject* parent); void expandObjectInTree(libfwbuilder::FWObject *obj); diff --git a/src/libgui/ObjectManipulator_create_new.cpp b/src/libgui/ObjectManipulator_create_new.cpp index 1f07b0231..4c7507dc9 100644 --- a/src/libgui/ObjectManipulator_create_new.cpp +++ b/src/libgui/ObjectManipulator_create_new.cpp @@ -667,7 +667,8 @@ FWObject* ObjectManipulator::newAttachedNetworks(QUndoCommand* macro) { FWObject *no = createObject(currentObj, AttachedNetworks::TYPENAME, tr("Attached Networks"), NULL, macro); - string name = Interface::cast(currentObj)->getParentHost()->getName() + + FWObject *parent_host = Host::getParentHost(currentObj); + string name = parent_host->getName() + ":" + currentObj->getName() + ":attached"; no->setName(name); return no; @@ -734,7 +735,8 @@ FWObject* ObjectManipulator::newInterface(QUndoCommand* macro) if (Interface::isA(currentObj)) { - FWObject *h = Interface::cast(currentObj)->getParentHost(); + FWObject *h = Host::getParentHost(currentObj); + //FWObject *h = Interface::cast(currentObj)->getParentHost(); bool supports_advanced_ifaces = false; supports_advanced_ifaces = @@ -764,9 +766,10 @@ FWObject* ObjectManipulator::newInterface(QUndoCommand* macro) if (Interface::isA(parent)) { + FWObject *parent_host = Host::getParentHost(parent); interfaceProperties *int_prop = interfacePropertiesObjectFactory::getInterfacePropertiesObject( - Interface::cast(parent)->getParentHost()); + parent_host); int_prop->guessSubInterfaceTypeAndAttributes(new_interface); delete int_prop; //guessSubInterfaceTypeAndAttributes(new_interface); diff --git a/src/libgui/ObjectManipulator_tree_ops.cpp b/src/libgui/ObjectManipulator_tree_ops.cpp index 62137e861..613f8adaa 100644 --- a/src/libgui/ObjectManipulator_tree_ops.cpp +++ b/src/libgui/ObjectManipulator_tree_ops.cpp @@ -351,22 +351,17 @@ bool FindHistoryItemByObjectId::operator()(const HistoryItem &itm) return (itm.id() == id); } -bool FindHistoryItemByParentObjectId::operator()(const HistoryItem &itm) +FWObject* ObjectManipulator::findRuleSetInHistoryByParentFw(FWObject* parent) { - FWObject *obj = mw->activeProject()->db()->findInIndex(itm.id()); - FWObject *parent = obj->getParent(); - return (parent != NULL && parent->getId() == id); -} - -FWObject* ObjectManipulator::findInHistoryByParent(FWObject* parent) -{ - FindHistoryItemByParentObjectId pred(parent->getId()); - list::reverse_iterator it = - std::find_if(history.rbegin(), history.rend(), pred); - - if (it != history.rend()) + list::reverse_iterator it = history.rbegin(); + for (; it!=history.rend(); ++it) { - return m_project->db()->findInIndex(it->id()); + FWObject *obj = mw->activeProject()->db()->findInIndex(it->id()); + if (RuleSet::cast(obj)) + { + FWObject *parent_fw = Host::getParentHost(obj); + if (parent_fw != NULL && parent_fw == parent) return obj; + } } return NULL; diff --git a/src/libgui/clusterMembersDialog.cpp b/src/libgui/clusterMembersDialog.cpp index 91e40d8dd..9675dcd6d 100644 --- a/src/libgui/clusterMembersDialog.cpp +++ b/src/libgui/clusterMembersDialog.cpp @@ -122,7 +122,8 @@ void clusterMembersDialog::getSelectedMembers() Interface *iface = NULL; iface = Interface::cast(FWReference::cast((*it))->getPointer()); assert(iface != NULL); - Firewall *fw = Firewall::cast(iface->getParentHost()); + Firewall *fw = Firewall::cast(Host::getParentHost(iface)); + //Firewall *fw = Firewall::cast(iface->getParentHost()); // determine master std::string iface_id = FWObjectDatabase::getStringId(iface->getId()); diff --git a/src/libgui/platforms.cpp b/src/libgui/platforms.cpp index 2fc0209f2..f0286a276 100644 --- a/src/libgui/platforms.cpp +++ b/src/libgui/platforms.cpp @@ -541,7 +541,8 @@ void getInterfaceTypes(Interface *iface, list &res) */ void getSubInterfaceTypes(Interface *iface, list &res) { - FWObject *p = iface->getParentHost(); + FWObject *p = Host::getParentHost(iface); + //FWObject *p = iface->getParentHost(); assert(p!=NULL); QString host_os = p->getStr("host_OS").c_str(); @@ -583,7 +584,8 @@ void setInterfaceTypes(QComboBox *iface_type, // Note that if resource file says this subint can not be vlan, we // dan't return vlan type on the list even if its name looks like // it could be one. - FWObject *p = iface->getParentHost(); + FWObject *p = Host::getParentHost(iface); + //FWObject *p = iface->getParentHost(); assert(p!=NULL); QString host_os = p->getStr("host_OS").c_str(); QString obj_name = iface->getName().c_str(); diff --git a/src/unit_tests/compilerLibTest/interfacePropertiesTest.cpp b/src/unit_tests/compilerLibTest/interfacePropertiesTest.cpp index 472539042..d834bd705 100644 --- a/src/unit_tests/compilerLibTest/interfacePropertiesTest.cpp +++ b/src/unit_tests/compilerLibTest/interfacePropertiesTest.cpp @@ -365,9 +365,15 @@ void interfacePropertiesTest::isEligibleForCluster() CPPUNIT_ASSERT(int_prop != NULL); + Firewall *fw1 = Firewall::cast(db->create(Firewall::TYPENAME)); + fw1->setName("iface"); + fw1->setStr("host_OS", "unknown"); + db->add(fw1); + Interface *parent1 = Interface::cast(db->create(Interface::TYPENAME)); Interface *iface1 = Interface::cast(db->create(Interface::TYPENAME)); - db->add(parent1); + + fw1->add(parent1); parent1->add(iface1); iface1->getOptionsObject()->setStr("type", "ethernet"); diff --git a/src/unit_tests/genericDialogTest/genericDialogTest.cpp b/src/unit_tests/genericDialogTest/genericDialogTest.cpp index eccad5bbd..567036a4b 100644 --- a/src/unit_tests/genericDialogTest/genericDialogTest.cpp +++ b/src/unit_tests/genericDialogTest/genericDialogTest.cpp @@ -239,11 +239,14 @@ void genericDialogTest::testDialog(QWidget *dialog, FWObject *object) //qDebug() << "testing control" << widgets.at(i); old->duplicate(object); QWidget *widget = widgets.at(i); + // Skipping QSpinBox (which inherits QLineEdit) with QLineEdit type // there should be another one with right type in list if (widget->objectName() == "qt_spinbox_lineedit") continue; + if (dynamic_cast(dialog) != NULL) dynamic_cast(dialog)->open(); + activateTab(widget); if (!widget->isVisible() || !widget->isEnabled()) continue; @@ -285,6 +288,12 @@ void genericDialogTest::testHostOSSettingsDialog_linux24() testDialog(dialog, firewall); } +#if 0 +// rule options dialog uses stacked widget with only one page visible, +// depending on the firewall platform. Some widgets in invisible pages +// are not even initialized, also depending on the platform. Need to +// devise better test that would take this into account. + void genericDialogTest::testRuleOptionsDialog() { Firewall *firewall = Firewall::cast(om->createObject(FWBTree().getStandardSlotForObject(findUserLibrary(), Firewall::TYPENAME), Firewall::TYPENAME, "TestFirewall")); @@ -342,6 +351,8 @@ void genericDialogTest::testNATRuleOptionsDialog() testDialog(dynamic_cast(dialog), FWObject::cast(rule)); } } +#endif + Library* genericDialogTest::findUserLibrary() { diff --git a/src/unit_tests/genericDialogTest/genericDialogTest.h b/src/unit_tests/genericDialogTest/genericDialogTest.h index 49164d34b..cd8ef5df9 100644 --- a/src/unit_tests/genericDialogTest/genericDialogTest.h +++ b/src/unit_tests/genericDialogTest/genericDialogTest.h @@ -45,9 +45,9 @@ class genericDialogTest : public QObject private slots: void initTestCase(); void testFirewallSettingsDialog_iptables(); - void testRuleOptionsDialog(); - void testRoutingRuleOptionsDialog(); - void testNATRuleOptionsDialog(); + /* void testRuleOptionsDialog(); */ + /* void testRoutingRuleOptionsDialog(); */ + /* void testNATRuleOptionsDialog(); */ void testHostOSSettingsDialog_linux24(); diff --git a/src/unit_tests/tests_common.pri b/src/unit_tests/tests_common.pri index 290624660..b8ddf5335 100644 --- a/src/unit_tests/tests_common.pri +++ b/src/unit_tests/tests_common.pri @@ -2,6 +2,8 @@ # include(../../qmake.inc) +QT += network + OBJECTS_DIR = .obj MOC_DIR = .moc diff --git a/test/ipt/rc.firewall.local b/test/ipt/rc.firewall.local index e181846b8..b515af668 100755 --- a/test/ipt/rc.firewall.local +++ b/test/ipt/rc.firewall.local @@ -4,7 +4,7 @@ # # Firewall Builder fwb_ipt v5.0.0.3547 # -# Generated Fri Jun 3 17:29:42 2011 PDT by vadim +# Generated Sun Jun 5 20:10:11 2011 PDT by vadim # # files: * rc.firewall.local /etc/rc.d//rc.firewall.local # diff --git a/test/pf/pf_cluster_4_rc.conf.local b/test/pf/pf_cluster_4_rc.conf.local index e9e4c94d4..d4cdc63e2 100755 --- a/test/pf/pf_cluster_4_rc.conf.local +++ b/test/pf/pf_cluster_4_rc.conf.local @@ -3,7 +3,7 @@ # # Firewall Builder fwb_pf v5.0.0.3547 # -# Generated Fri Jun 3 18:57:45 2011 PDT by vadim +# Generated Sun Jun 5 20:10:47 2011 PDT by vadim # # files: * pf_cluster_4_rc.conf.local /etc/pf_cluster_4_rc.conf.local # files: pf_cluster_4_pf.conf /etc/pf_cluster_4_pf.conf