diff --git a/src/libgui/ObjectSelectorWidget.cpp b/src/libgui/ObjectSelectorWidget.cpp index ffc377293..3f826516e 100644 --- a/src/libgui/ObjectSelectorWidget.cpp +++ b/src/libgui/ObjectSelectorWidget.cpp @@ -54,7 +54,7 @@ ObjectSelectorWidget::~ObjectSelectorWidget() delete flt_obj_d; } -void ObjectSelectorWidget::init(const list &objects) +void ObjectSelectorWidget::init(const QList &objects) { this->objects = objects; fillListOfObjects(); diff --git a/src/libgui/ObjectSelectorWidget.h b/src/libgui/ObjectSelectorWidget.h index 977955f25..1c180ced4 100644 --- a/src/libgui/ObjectSelectorWidget.h +++ b/src/libgui/ObjectSelectorWidget.h @@ -44,7 +44,7 @@ class ObjectSelectorWidget : public QWidget Filter * flt_obj; FilterDialog * flt_obj_d; - std::list objects; + QList objects; QStringList objects_to_use; // configure this as a proprty so it can be accessed as a field after @@ -56,7 +56,7 @@ public: ObjectSelectorWidget(QWidget *parent); virtual ~ObjectSelectorWidget(); - void init(const std::list &objects); + void init(const QList &objects); int count() { return objects_to_use.count(); } diff --git a/src/libgui/importAddressListWizard/ChooseObjectsPage.cpp b/src/libgui/importAddressListWizard/ChooseObjectsPage.cpp index 97c0ea380..f545d4001 100644 --- a/src/libgui/importAddressListWizard/ChooseObjectsPage.cpp +++ b/src/libgui/importAddressListWizard/ChooseObjectsPage.cpp @@ -58,7 +58,7 @@ void ChooseObjectsPage::initializePage() importer.parse(); map imported_hosts_info = importer.getAll(); - list objects; + QList objects; map::iterator i; for (i=imported_hosts_info.begin(); i!=imported_hosts_info.end(); ++i) { diff --git a/src/libgui/snmpNetworkDiscoveryWizard/ND_ChooseNetworksPage.cpp b/src/libgui/snmpNetworkDiscoveryWizard/ND_ChooseNetworksPage.cpp index b46c2ea23..dd16de2a1 100644 --- a/src/libgui/snmpNetworkDiscoveryWizard/ND_ChooseNetworksPage.cpp +++ b/src/libgui/snmpNetworkDiscoveryWizard/ND_ChooseNetworksPage.cpp @@ -26,7 +26,7 @@ #include "FWWindow.h" #include "ND_ChooseNetworksPage.h" -#include "ND_ProgressPage.h" +#include "SNMPNetworkDiscoveryWizard.h" #include @@ -49,15 +49,10 @@ void ND_ChooseNetworksPage::initializePage() if (fwbdebug) qDebug() << "ND_ChooseNetworksPage::initializePage()"; - ND_ProgressPage *progress_page = NULL; - foreach(int page_id, wizard()->pageIds()) - { - progress_page = dynamic_cast(wizard()->page(page_id)); - if (progress_page != NULL) break; - } - assert(progress_page != NULL); + ObjectDescriptorList *networks = + dynamic_cast(wizard())->getNetworks(); - m_dialog->objectSelector->init(progress_page->getNetworks()); + m_dialog->objectSelector->init(*networks); /* list objects; diff --git a/src/libgui/snmpNetworkDiscoveryWizard/ND_ChooseObjectTypePage.cpp b/src/libgui/snmpNetworkDiscoveryWizard/ND_ChooseObjectTypePage.cpp index d7ae9ca12..efa6cca44 100644 --- a/src/libgui/snmpNetworkDiscoveryWizard/ND_ChooseObjectTypePage.cpp +++ b/src/libgui/snmpNetworkDiscoveryWizard/ND_ChooseObjectTypePage.cpp @@ -26,12 +26,13 @@ #include "FWWindow.h" #include "ND_ChooseObjectTypePage.h" +#include "SNMPNetworkDiscoveryWizard.h" #include using namespace std; -//using namespace libfwbuilder; +using namespace libfwbuilder; ND_ChooseObjectTypePage::ND_ChooseObjectTypePage(QWidget *parent) : QWizardPage(parent) @@ -45,4 +46,70 @@ void ND_ChooseObjectTypePage::initializePage() { if (fwbdebug) qDebug() << "ND_ChooseObjectTypePage::initializePage()"; + + objects = dynamic_cast(wizard())->getObjects(); + objectsToUse = dynamic_cast(wizard())->getObjectsToUse(); + + fillTypeChangingList(); } + +void ND_ChooseObjectTypePage::fillTypeChangingList() +{ + m_dialog->typeChangingList->clear(); + + qDebug() << objectsToUse; + + int idx = 0; + foreach(ObjectDescriptor od, *objects) + { + if (objectsToUse->contains(QString::fromUtf8(od.sysname.c_str()))) + { + QString ins; + ins = (od.interfaces.size()) ? + QString("%1").arg(od.interfaces.size()) : ""; + QStringList sl; + sl << QString::fromUtf8(od.toString().c_str()) + << ins << od.type.c_str(); + QTreeWidgetItem *itm = new QTreeWidgetItem( + m_dialog->typeChangingList, sl ); + itm->setData(0, Qt::UserRole, idx); + } + idx++; + } + + m_dialog->typeChangingList->resizeColumnToContents(0); + m_dialog->typeChangingList->resizeColumnToContents(1); +} + +void ND_ChooseObjectTypePage::typeAddress() +{ + changeTargetObject(IPv4::TYPENAME); +} + +void ND_ChooseObjectTypePage::typeHost() +{ + changeTargetObject(Host::TYPENAME); +} + +void ND_ChooseObjectTypePage::typeFirewall() +{ + changeTargetObject(Firewall::TYPENAME); +} + +void ND_ChooseObjectTypePage::changeTargetObject(const QString &buf) +{ + QTreeWidgetItem* item = m_dialog->typeChangingList->topLevelItem(0); + + while (item!=0) + { + if (item->isSelected()) + { + int idx = item->data(0, Qt::UserRole).toInt(); + (*objects)[idx].type = buf.toStdString(); + item->setText(2, buf); + } + item = m_dialog->typeChangingList->topLevelItem( + m_dialog->typeChangingList->indexOfTopLevelItem(item)+1); + } +} + diff --git a/src/libgui/snmpNetworkDiscoveryWizard/ND_ChooseObjectTypePage.h b/src/libgui/snmpNetworkDiscoveryWizard/ND_ChooseObjectTypePage.h index 87065ca38..3c8b40df2 100644 --- a/src/libgui/snmpNetworkDiscoveryWizard/ND_ChooseObjectTypePage.h +++ b/src/libgui/snmpNetworkDiscoveryWizard/ND_ChooseObjectTypePage.h @@ -24,6 +24,8 @@ #ifndef __ND_CHOOSEOBJECTTYPEPAGE_H_ #define __ND_CHOOSEOBJECTTYPEPAGE_H_ +#include "SNMPNetworkDiscoveryWizard.h" + #include "ui_nd_chooseobjecttypepage_q.h" @@ -32,6 +34,8 @@ class ND_ChooseObjectTypePage : public QWizardPage Q_OBJECT; Ui::ND_ChooseObjectTypePage_q *m_dialog; + ObjectDescriptorList *objects; + QStringList *objectsToUse; public: ND_ChooseObjectTypePage(QWidget *parent); @@ -39,8 +43,14 @@ public: virtual void initializePage(); + void fillTypeChangingList(); + + void changeTargetObject(const QString &buf); public slots: + void typeAddress(); + void typeHost(); + void typeFirewall(); }; diff --git a/src/libgui/snmpNetworkDiscoveryWizard/ND_ChooseObjectsPage.cpp b/src/libgui/snmpNetworkDiscoveryWizard/ND_ChooseObjectsPage.cpp index f4b2bace0..dcaab0676 100644 --- a/src/libgui/snmpNetworkDiscoveryWizard/ND_ChooseObjectsPage.cpp +++ b/src/libgui/snmpNetworkDiscoveryWizard/ND_ChooseObjectsPage.cpp @@ -26,7 +26,7 @@ #include "FWWindow.h" #include "ND_ChooseObjectsPage.h" -#include "ND_ProgressPage.h" +#include "SNMPNetworkDiscoveryWizard.h" #include @@ -51,15 +51,10 @@ void ND_ChooseObjectsPage::initializePage() if (fwbdebug) qDebug() << "ND_ChooseObjectsPage::initializePage()"; - ND_ProgressPage *progress_page = NULL; - foreach(int page_id, wizard()->pageIds()) - { - progress_page = dynamic_cast(wizard()->page(page_id)); - if (progress_page != NULL) break; - } - assert(progress_page != NULL); + ObjectDescriptorList *objects = + dynamic_cast(wizard())->getObjects(); - m_dialog->objectSelector->init(progress_page->getObjects()); + m_dialog->objectSelector->init(*objects); /* list objects; @@ -74,6 +69,12 @@ void ND_ChooseObjectsPage::initializePage() bool ND_ChooseObjectsPage::validatePage() { if (fwbdebug) qDebug() << "ND_ChooseObjectsPage::validatePage()"; + + QStringList *objectsToUse = + dynamic_cast(wizard())->getObjectsToUse(); + + *objectsToUse = m_dialog->objectSelector->getObjectsToUse(); + return true; } diff --git a/src/libgui/snmpNetworkDiscoveryWizard/ND_CreateObjectsPage.cpp b/src/libgui/snmpNetworkDiscoveryWizard/ND_CreateObjectsPage.cpp index 840a33ad4..d2169937a 100644 --- a/src/libgui/snmpNetworkDiscoveryWizard/ND_CreateObjectsPage.cpp +++ b/src/libgui/snmpNetworkDiscoveryWizard/ND_CreateObjectsPage.cpp @@ -26,15 +26,27 @@ #include "events.h" #include "FWWindow.h" #include "ProjectPanel.h" +#include "platforms.h" #include "ND_CreateObjectsPage.h" +#include "SNMPNetworkDiscoveryWizard.h" + +#include "interfaceProperties.h" +#include "interfacePropertiesObjectFactory.h" #include "fwbuilder/IPv4.h" #include "fwbuilder/IPv6.h" +#include "fwbuilder/Network.h" +#include "fwbuilder/NetworkIPv6.h" +#include "fwbuilder/Resources.h" +#include "fwbuilder/InterfaceData.h" +#include "fwbuilder/Firewall.h" #include +#include #include +#include using namespace std; using namespace libfwbuilder; @@ -51,58 +63,43 @@ void ND_CreateObjectsPage::initializePage() { if (fwbdebug) qDebug() << "ND_CreateObjectsPage::initializePage()"; + ObjectDescriptorList *objects = + dynamic_cast(wizard())->getObjects(); + QStringList *objectsToUse = + dynamic_cast(wizard())->getObjectsToUse(); + ObjectDescriptorList *networks = + dynamic_cast(wizard())->getNetworks(); + int lib_index = field("libIndex").toInt(); QStringList libraries = field("libraries").toStringList(); - QStringList objects = field("objectsToUse").toStringList(); if (fwbdebug) - { qDebug() << "libraries=" << libraries; - qDebug() << "objects=" << objects; - } m_dialog->progressBar->setFormat("%v / %m"); - m_dialog->progressBar->setMaximum(objects.size() / 2); - + m_dialog->progressBar->setMaximum(objectsToUse->size() / 2 + networks->size()); FWObject *last_object = NULL; - QString name; - QString addr; - int counter = 1; - while (objects.size() > 0) + string type, name, a; + int counter = 0; + + foreach(ObjectDescriptor od, *networks) { - name = objects.front(); objects.pop_front(); - addr = objects.front(); objects.pop_front(); + type = od.type; // Network or NetworkIPv6 + name = od.sysname; + a = od.addr.toString().c_str(); + + Address *net = Address::cast( + mw->createObject(type.c_str(), name.c_str())); - QString type; - try - { - InetAddr(AF_INET6, addr.toLatin1().constData() ); - type = IPv6::TYPENAME; - } catch (FWException &ex) - { - } + assert(net!=NULL); - if (type.isEmpty()) - { - try - { - InetAddr(AF_INET, addr.toLatin1().constData() ); - type = IPv4::TYPENAME; - } catch (FWException &ex) - { - } - } + net->setName(name); + net->setAddress(od.addr); + net->setNetmask(od.netmask); + + mw->moveObject(libraries[lib_index], net); - if (! type.isEmpty()) - { - Address *obj = Address::cast(mw->createObject(type, name)); - assert(obj!=NULL); - obj->setName(name.toUtf8().constData()); - obj->setAddress(InetAddr(addr.toStdString())); - obj->setNetmask(InetAddr(InetAddr::getAllOnes())); - mw->moveObject(libraries[lib_index], obj); - last_object = obj; - } + last_object = net; m_dialog->progressBar->setValue(counter); qApp->processEvents(); @@ -110,6 +107,205 @@ void ND_CreateObjectsPage::initializePage() counter++; } + foreach(ObjectDescriptor od, *objects) + { + if (objectsToUse->contains(QString::fromUtf8(od.sysname.c_str()))) + { + type = od.type; + + name = od.sysname; + + QString platform; + QString os; + QString version; + guessOSAndPlatformFromSysDescr(od.descr.c_str(), platform, os, version); + + a = od.addr.toString(); + + if (type==Host::TYPENAME || type==Firewall::TYPENAME) + { + FWObject *o=NULL; + + o = mw->createObject(type.c_str(), name.c_str()); + o->setName(name); + + if (type==Firewall::TYPENAME) + { + if (os == "linux") + { + o->setStr("platform", "iptables"); + o->setStr("host_OS", "linux24"); + } + if (os == "freebsd") + { + o->setStr("platform", "pf"); + o->setStr("host_OS", "freebsd"); + } + if (os == "openbsd") + { + o->setStr("platform", "pf"); + o->setStr("host_OS", "openbsd"); + } + if (os == "ios") + { + o->setStr("platform", "iosacl"); + o->setStr("host_OS", "ios"); + } + if (os == "pix" || os == "fwsm") + { + o->setStr("platform", "pix"); + o->setStr("host_OS", "pix_os"); + } + if (os == "apple") + { + o->setStr("platform", "ipfw"); + o->setStr("host_OS", "macosx"); + } + if (os == "solaris") + { + o->setStr("platform", "ipf"); + o->setStr("host_OS", "solaris"); + } + + Resources::setDefaultTargetOptions( o->getStr("platform"), + Firewall::cast(o) ); + Resources::setDefaultTargetOptions( o->getStr("host_OS"), + Firewall::cast(o) ); + } + + if (od.interfaces.size()==0) + { + Interface *itf= Interface::cast( + mw->createObject(o,Interface::TYPENAME,"nic1") + ); + + if (od.addr.isV4()) + { + IPv4 *ipv4= IPv4::cast( + mw->createObject(itf, IPv4::TYPENAME, a.c_str()) + ); + ipv4->setAddress(od.addr); + ipv4->setNetmask(InetAddr()); + } + + if (od.addr.isV6()) + { + IPv6 *ipv6 = IPv6::cast( + mw->createObject(itf, IPv6::TYPENAME, a.c_str()) + ); + ipv6->setAddress(od.addr); + ipv6->setNetmask(InetAddr()); + } + + } else + { + if (fwbdebug) + { + map::iterator i; + for (i=od.interfaces.begin(); i!=od.interfaces.end(); ++i) + { + InterfaceData *intf = &(i->second); + QString str("Discovered interface %1: %2"); + qDebug() << + str.arg(intf->name.c_str()).arg(intf->mac_addr.c_str()); + + } + } + + list interface_tree; + std::auto_ptr int_prop( + interfacePropertiesObjectFactory::getInterfacePropertiesObject(o)); + int_prop->rearrangeInterfaces(od.interfaces, interface_tree); + + if (interface_tree.size() != od.interfaces.size()) + { + // Some interfaces have been converted to subinterfaces + // Show warning + + QMessageBox::warning( + this, "Firewall Builder", + tr( +"Some discovered interfaces have been rearranged in " +"fwbuilder objects and recreated as subinterfaces to " +"reflect VLANs, bonding and bridging configurations. " +"The algorithm used to guess correct relationship " +"between interfaces and subinterfaces is imperfect " +"because of the limited information provided by SNMP " +"daemon. Pelase review created objects to make sure " +"generated configuration is accurate. " +"\n" +"\n" +"The program expects MAC addresses of bonding, bridge " +"and vlan interfaces to be the same. It is especially " +"important to review and fix generated objects if you " +"use MAC address spoofing." +), + tr("&Continue"), 0, 0, + 0 ); + + + } + + list::iterator it; + for (it=interface_tree.begin(); it!=interface_tree.end(); ++it) + { + InterfaceData *in = *it; + // if this interface has subinterfaces, add even if it + // has no ip address (last arg) + + FWObject *intf = addInterface( + o, in, in->subinterfaces.size()!=0); + if (intf == NULL) continue; + + list::iterator sit; + for (sit=in->subinterfaces.begin(); + sit!=in->subinterfaces.end(); ++sit) + { + InterfaceData *subint = *sit; + addInterface(intf, subint, true); + } + } + } + + if (!od.descr.empty()) + { + FWOptions* opt=(dynamic_cast(o))->getOptionsObject(); + opt->setStr("snmp_description",od.descr); + opt->setStr("snmp_location", od.location); + opt->setStr("snmp_contact", od.contact); + } + + mw->moveObject(libraries[lib_index], o); + + } else if (type==Network::TYPENAME) + { + Network *net=dynamic_cast( + mw->createObject(type.c_str(),name.c_str()) + ); + assert(net!=NULL); + net->setName(name); + net->setAddress(InetAddr(a)); + net->setNetmask(InetAddr(InetAddr(a))); + mw->moveObject(libraries[lib_index], net); + } else if (type==IPv4::TYPENAME) + { + IPv4 *obj=dynamic_cast( + mw->createObject(type.c_str(),name.c_str()) + ); + assert(obj!=NULL); + obj->setName(name); + obj->setAddress(InetAddr(a)); + obj->setNetmask(InetAddr(InetAddr::getAllOnes())); + mw->moveObject(libraries[lib_index], obj); + } + + m_dialog->progressBar->setValue(counter); + qApp->processEvents(); + + counter++; + } + } + ProjectPanel *pp = mw->activeProject(); QString filename = pp->getFileName(); QCoreApplication::postEvent(mw, new reloadObjectTreeEvent(filename)); @@ -118,3 +314,110 @@ void ND_CreateObjectsPage::initializePage() filename, last_object->getId())); } +FWObject* ND_CreateObjectsPage::addInterface(FWObject *parent, InterfaceData *in, + bool skip_ip_address_check) +{ + ObjectManipulator *om = mw->activeProject()->m_panel->om; + + bool includeUnnumbered = field("snmpIncludeUnnumbered").toBool(); + + if ( ! includeUnnumbered && ! skip_ip_address_check) + { + if (in->addr_mask.size()==0) return NULL; + if (in->addr_mask.front()->getAddressPtr()->isAny()) + return NULL; + } + + QString obj_name = in->name.c_str(); + Interface *itf = NULL; + itf = Interface::cast( + mw->createObject(parent, + QString(Interface::TYPENAME), obj_name)); + + QString iname = om->getStandardName(itf, physAddress::TYPENAME, "mac"); + iname = om->makeNameUnique(itf, iname, physAddress::TYPENAME); + + physAddress *paddr = physAddress::cast( + mw->createObject(itf, physAddress::TYPENAME, iname) + ); + paddr->setPhysAddress(in->mac_addr); + + itf->setLabel(in->label); + itf->setSecurityLevel(in->securityLevel); + + if (fwbdebug) + qDebug() << "Interface=" << obj_name + << "type=" << in->interface_type.c_str(); + + if (!in->interface_type.empty()) + { + itf->getOptionsObject()->setStr("type", in->interface_type); + if (in->interface_type == "8021q") + itf->getOptionsObject()->setInt("vlan_id", in->vlan_id); + } else + { + std::auto_ptr int_prop( + interfacePropertiesObjectFactory::getInterfacePropertiesObject(parent)); + if (int_prop->looksLikeVlanInterface(obj_name)) + { + QString base_name; + int vlan_id; + int_prop->parseVlan(obj_name, &base_name, &vlan_id); + + itf->getOptionsObject()->setStr("type", "8021q"); + itf->getOptionsObject()->setInt("vlan_id", vlan_id); + } + } + + if (in->addr_mask.size()==0 || + in->addr_mask.front()->getAddressPtr()->isAny()) + { + itf->setUnnumbered(true); + } else + { + list::iterator n; + for (n=in->addr_mask.begin(); n!=in->addr_mask.end(); ++n) + { + const InetAddr *addr = (*n)->getAddressPtr(); + const InetAddr *netm = (*n)->getNetmaskPtr(); + + if (addr->isV4()) + { + try + { + QString iname = om->getStandardName(itf, IPv4::TYPENAME, "ip"); + iname = om->makeNameUnique(itf, iname, IPv4::TYPENAME); + + IPv4 *ipv4= IPv4::cast( + om->createObject(itf, IPv4::TYPENAME, iname) + ); + ipv4->setAddress(*addr); + ipv4->setNetmask(*netm); + } catch (FWException &ex) + { + cerr << "FWException: " << ex.toString() << endl; + } + } + + if (addr->isV6()) + { + try + { + QString iname = om->getStandardName(itf, IPv6::TYPENAME, "ip"); + iname = om->makeNameUnique(itf, iname, IPv6::TYPENAME); + + IPv6 *ipv6 = IPv6::cast( + om->createObject(itf, IPv6::TYPENAME, iname) + ); + ipv6->setAddress(*addr); + ipv6->setNetmask(*netm); + } catch (FWException &ex) + { + cerr << "FWException: " << ex.toString() << endl; + } + } + } + } + return itf; +} + diff --git a/src/libgui/snmpNetworkDiscoveryWizard/ND_CreateObjectsPage.h b/src/libgui/snmpNetworkDiscoveryWizard/ND_CreateObjectsPage.h index 18f419496..a4269df60 100644 --- a/src/libgui/snmpNetworkDiscoveryWizard/ND_CreateObjectsPage.h +++ b/src/libgui/snmpNetworkDiscoveryWizard/ND_CreateObjectsPage.h @@ -26,13 +26,22 @@ #include "ui_nd_createobjectspage_q.h" +namespace libfwbuilder +{ + class InterfaceData; + class FWObject; +}; class ND_CreateObjectsPage : public QWizardPage { Q_OBJECT; Ui::ND_CreateObjectsPage_q *m_dialog; - + + libfwbuilder::FWObject* addInterface(libfwbuilder::FWObject *parent, + libfwbuilder::InterfaceData *in, + bool skip_ip_address_check); + public: ND_CreateObjectsPage(QWidget *parent); virtual ~ND_CreateObjectsPage() {} diff --git a/src/libgui/snmpNetworkDiscoveryWizard/ND_ProgressPage.cpp b/src/libgui/snmpNetworkDiscoveryWizard/ND_ProgressPage.cpp index 39919edb8..d496b3a6c 100644 --- a/src/libgui/snmpNetworkDiscoveryWizard/ND_ProgressPage.cpp +++ b/src/libgui/snmpNetworkDiscoveryWizard/ND_ProgressPage.cpp @@ -29,6 +29,7 @@ #include "ND_ProgressPage.h" #include "SNMPCrawlerThread.h" +#include "SNMPNetworkDiscoveryWizard.h" #include "fwbuilder/snmp.h" #include "fwbuilder/NetworkIPv6.h" @@ -97,14 +98,17 @@ ND_ProgressPage::~ND_ProgressPage() bool ND_ProgressPage::validatePage() { + ObjectDescriptorList *objects = + dynamic_cast(wizard())->getObjects(); + if (fwbdebug_nd) qDebug() << "ND_ProgressPage::validatePage()" << "crawler=" << crawler << "isRunning=" << ((crawler) ? crawler->isRunning() : 0) - << "objects.size()=" << objects.size(); + << "objects->size()=" << objects->size(); if (crawler != NULL && crawler->isRunning()) return false; - return (objects.size() > 0); + return (objects->size() > 0); } void ND_ProgressPage::crawlerDestroyed(QObject *obj) @@ -118,6 +122,14 @@ void ND_ProgressPage::initializePage() if (fwbdebug_nd) qDebug() << "ND_ProgressPage::initializePage()"; #ifdef HAVE_LIBSNMP + + ObjectDescriptorList *objects = + dynamic_cast(wizard())->getObjects(); + + ObjectDescriptorList *networks = + dynamic_cast(wizard())->getNetworks(); + + QString seedHostName = field("seedHostName").toString(); QString snmpInclAddr = field("snmpInAddr").toString(); QString snmpInclMask = field("snmpInMask").toString(); @@ -163,8 +175,8 @@ void ND_ProgressPage::initializePage() delete crawler; } - objects.clear(); - networks.clear(); + objects->clear(); + networks->clear(); emit completeChanged(); @@ -215,6 +227,13 @@ void ND_ProgressPage::crawlerFinished() { if (fwbdebug_nd) qDebug() << "ND_ProgressPage::crawlerFinished()"; + ObjectDescriptorList *networks = + dynamic_cast(wizard())->getNetworks(); + + ObjectDescriptorList *objects = + dynamic_cast(wizard())->getObjects(); + + logLine("\n"); logLine(tr("Network crawler stopped")); @@ -252,7 +271,7 @@ void ND_ProgressPage::crawlerFinished() od.netmask = *(net->getNetmaskPtr()); od.isSelected = false; - networks.push_back(od); + networks->push_back(od); } logLine(tr("Discovered %1 addresses").arg(discovered_addresses.size())); @@ -288,10 +307,10 @@ void ND_ProgressPage::crawlerFinished() for(si=od.dns_info.aliases.begin(); si!=od.dns_info.aliases.end(); ++si) { od.sysname = (*si); - objects.push_back(od);; + objects->push_back(od);; } } else - objects.push_back(od); + objects->push_back(od); } diff --git a/src/libgui/snmpNetworkDiscoveryWizard/ND_ProgressPage.h b/src/libgui/snmpNetworkDiscoveryWizard/ND_ProgressPage.h index 112ae7936..039486572 100644 --- a/src/libgui/snmpNetworkDiscoveryWizard/ND_ProgressPage.h +++ b/src/libgui/snmpNetworkDiscoveryWizard/ND_ProgressPage.h @@ -25,15 +25,12 @@ #define __ND_PROGRESSPAGE_H_ #include "ui_nd_progresspage_q.h" -#include "ObjectDescriptor.h" #include class SNMPCrawlerThread; -typedef std::list ObjectDescriptorMap; - class ND_ProgressPage : public QWizardPage { Q_OBJECT; @@ -43,8 +40,6 @@ class ND_ProgressPage : public QWizardPage QTextCharFormat error_format; QTextCharFormat warning_format; SNMPCrawlerThread *crawler; - ObjectDescriptorMap networks; - ObjectDescriptorMap objects; public: ND_ProgressPage(QWidget *parent); @@ -54,9 +49,6 @@ public: virtual void cleanupPage(); virtual bool validatePage(); - ObjectDescriptorMap getNetworks() { return networks; } - ObjectDescriptorMap getObjects() { return objects; } - public slots: void stop(); void saveLog(); diff --git a/src/libgui/snmpNetworkDiscoveryWizard/SNMPNetworkDiscoveryWizard.h b/src/libgui/snmpNetworkDiscoveryWizard/SNMPNetworkDiscoveryWizard.h index d1d5277b7..06f9625b2 100644 --- a/src/libgui/snmpNetworkDiscoveryWizard/SNMPNetworkDiscoveryWizard.h +++ b/src/libgui/snmpNetworkDiscoveryWizard/SNMPNetworkDiscoveryWizard.h @@ -24,16 +24,28 @@ #ifndef __SNMPNETWORKDISCOVERYWIZARD_H_ #define __SNMPNETWORKDISCOVERYWIZARD_H_ +#include "ObjectDescriptor.h" + +#include #include +typedef QList ObjectDescriptorList; class SNMPNetworkDiscoveryWizard : public QWizard { Q_OBJECT; + ObjectDescriptorList networks; + ObjectDescriptorList objects; + QStringList objectsToUse; + public: SNMPNetworkDiscoveryWizard(QWidget *parent); virtual ~SNMPNetworkDiscoveryWizard() {} + + ObjectDescriptorList* getNetworks() { return &networks; } + ObjectDescriptorList* getObjects() { return &objects; } + QStringList* getObjectsToUse() { return &objectsToUse; } public slots: diff --git a/src/libgui/snmpNetworkDiscoveryWizard/nd_chooseobjecttypepage_q.ui b/src/libgui/snmpNetworkDiscoveryWizard/nd_chooseobjecttypepage_q.ui index 516625a7d..776e13426 100644 --- a/src/libgui/snmpNetworkDiscoveryWizard/nd_chooseobjecttypepage_q.ui +++ b/src/libgui/snmpNetworkDiscoveryWizard/nd_chooseobjecttypepage_q.ui @@ -14,6 +14,43 @@ WizardPage + + + + + + Change type of selected objects: + + + + 6 + + + + + Address + + + + + + + Host + + + + + + + Firewall + + + + + + + + @@ -52,109 +89,62 @@ - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 30 - 20 - - - - - - - - Unselect All - - - - - - - Remove Filter - - - - - - - Filter ... - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 20 - 20 - - - - - - - - Select All - - - - - - - Change type of selected objects: - - - - 6 - - - - - Address - - - - - - - Host - - - - - - - Firewall - - - - - - - - - textLabel1_6 - layoutWidget - typeChangingList - groupBox4 - + + + addresTypeButton + clicked() + ND_ChooseObjectTypePage_q + typeAddress() + + + 104 + 487 + + + 288 + 259 + + + + + hostTypeButton + clicked() + ND_ChooseObjectTypePage_q + typeHost() + + + 288 + 487 + + + 288 + 259 + + + + + firewallTypeButton + clicked() + ND_ChooseObjectTypePage_q + typeFirewall() + + + 472 + 487 + + + 288 + 259 + + + + + + typeAddress() + typeHost() + typeFirewall() +