fixed snmp discovery

This commit is contained in:
Vadim Kurland
2008-07-02 23:00:16 +00:00
parent aa2abe50b8
commit 579704a694
11 changed files with 245 additions and 505 deletions
+164 -139
View File
@@ -68,6 +68,7 @@
#include "fwbuilder/dns.h"
#include "fwbuilder/snmp.h"
#include "fwbuilder/Logger.h"
#include "FWBSettings.h"
#include "ObjectManipulator.h"
@@ -98,18 +99,23 @@ DiscoveryDruid::DiscoveryDruid(QWidget *parent, bool start_with_import) :
dm_method->addButton(m_dialog->dm_usesnmp,2);
dm_method->addButton(m_dialog->dm_import_config,3);
connect(dm_method, SIGNAL( buttonClicked(int) ), this, SLOT( changedDiscoveryMethod(int) ) );
connect(m_dialog->dnsfromlist, SIGNAL( clicked(bool) ), this, SLOT( changedNameServer() ) );
connect(m_dialog->dnscustom, SIGNAL( clicked(bool) ), this, SLOT( changedNameServer() ) );
connect(m_dialog->nameserverlist, SIGNAL( editTextChanged(QString) ), this, SLOT( changedNameServer() ) );
connect(m_dialog->nameserverline, SIGNAL( textChanged(QString) ), this, SLOT( changedNameServer() ) );
connect(dm_method, SIGNAL( buttonClicked(int) ),
this, SLOT( changedDiscoveryMethod(int) ) );
connect(m_dialog->dnsfromlist, SIGNAL( clicked(bool) ),
this, SLOT( changedNameServer() ) );
connect(m_dialog->dnscustom, SIGNAL( clicked(bool) ),
this, SLOT( changedNameServer() ) );
connect(m_dialog->nameserverlist, SIGNAL( editTextChanged(QString) ),
this, SLOT( changedNameServer() ) );
connect(m_dialog->nameserverline, SIGNAL( textChanged(QString) ),
this, SLOT( changedNameServer() ) );
thread=NULL;
thread = NULL;
timer=new QTimer(this);
prg_timer=new QTimer(this);
unBar=NULL;
unProg=0;
timer = new QTimer(this);
prg_timer = new QTimer(this);
unBar = NULL;
unProg = 0;
connect(prg_timer,SIGNAL(timeout()),this,SLOT(updatePrg()));
@@ -251,8 +257,9 @@ void DiscoveryDruid::restore()
m_dialog->dnstimeout->setValue((i)?i:2);
i=st->getInt(QString(DISCOVERY_DRUID_PREFIX) + DISCOVERY_DRUID_DNSRETRIES);
m_dialog->dnsretries->setValue((i)?i:1);
//m_dialog->seedhostname->setText(st->getStr(
// QString(DISCOVERY_DRUID_PREFIX) + DISCOVERY_DRUID_SEEDHOST));
m_dialog->seedhostname->setText(st->getStr(
QString(DISCOVERY_DRUID_PREFIX) + DISCOVERY_DRUID_SEEDHOST));
m_dialog->snmpinaddr->setText(st->getStr(
QString(DISCOVERY_DRUID_PREFIX) + DISCOVERY_DRUID_SNMPINADDR));
m_dialog->snmpinmask->setText(st->getStr(
@@ -309,9 +316,9 @@ void DiscoveryDruid::save()
QString(DISCOVERY_DRUID_PREFIX) + DISCOVERY_DRUID_SNMPDNSTIMEOUT,
m_dialog->snmpdnstimeout->value());
}
//st->setStr(
// QString(DISCOVERY_DRUID_PREFIX) + DISCOVERY_DRUID_SEEDHOST,
// m_dialog->seedhostname->text());
st->setStr(
QString(DISCOVERY_DRUID_PREFIX) + DISCOVERY_DRUID_SEEDHOST,
m_dialog->seedhostname->text());
st->setStr(
QString(DISCOVERY_DRUID_PREFIX) + DISCOVERY_DRUID_SNMPINADDR,
m_dialog->snmpinaddr->text());
@@ -472,11 +479,11 @@ void DiscoveryDruid::changedSelected( const int &page )
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents,100);
setNextEnabled(page,false);
setNextEnabled(page, false);
cancelButton->hide();
setBackEnabled(page,false);
disconnect(timer,SIGNAL(timeout()),0,0);
connect(timer,SIGNAL(timeout()),this,SLOT(updateLog()));
setBackEnabled(page, false);
disconnect(timer, SIGNAL(timeout()), 0, 0);
connect(timer, SIGNAL(timeout()), this, SLOT(updateLog()));
timer->setSingleShot(false);
timer->start(1000);
@@ -698,46 +705,6 @@ void DiscoveryDruid::changedDiscoveryMethod(int c)
}
}
void DiscoveryDruid::saveScanLog()
{
QString dir;
dir=st->getWDir();
if (dir.isEmpty()) dir=st->getOpenFileDir();
if (dir.isEmpty()) dir="~";
QString s = QFileDialog::getSaveFileName(
this,
"Choose a file",
dir,
"Text file (*.txt)");
if (!s.isEmpty())
{
if (s.endsWith(".txt"))
{
s+=".txt";
}
QFile f(s);
if (f.open(QIODevice::WriteOnly))
{
if (fwbdebug)
{
qDebug("Saving crawler log to file: %d chars",
m_dialog->discoverylog->toPlainText().length());
qDebug("--------------------------------");
}
QTextStream strm(&f);
QString txt = m_dialog->discoverylog->toPlainText();
strm << txt << endl;
if (fwbdebug) qDebug("%s",txt.toAscii().constData());
if (fwbdebug)
qDebug("--------------------------------");
f.close();
}
}
}
void DiscoveryDruid::startHostsScan()
{
if (thread!=NULL)
@@ -866,60 +833,6 @@ InetAddr DiscoveryDruid::getSeedHostAddress()
return seed_host_addr;
}
void DiscoveryDruid::startSNMPScan()
{
#ifdef HAVE_LIBSNMP
bool use_incl=!m_dialog->snmpinaddr->text().isEmpty() && !m_dialog->snmpinmask->text().isEmpty();
if (use_incl)
{
try
{
InetAddrMask in(
InetAddr(m_dialog->snmpinaddr->text().toLatin1().constData()),
InetAddr(m_dialog->snmpinmask->text().toLatin1().constData())
);
include_networks.push_back(in);
}
catch (const FWException &ex)
{
//TODO: to do something usefull
}
}
libfwbuilder::SNMPCrawler *q=new SNMPCrawler();
q->init(getSeedHostAddress(),
m_dialog->snmpcommunity->text().toLatin1().constData(),
m_dialog->snmprecursive->isChecked(),
! m_dialog->snmpincludevirt->isChecked(),
false,
m_dialog->snmpfollowp2p->isChecked(),
0,
m_dialog->snmpretries->value(),
1000000L*m_dialog->snmptimeout->value(),
0,
0,
(use_incl) ? &include_networks : NULL);
m_dialog->discoveryprogress->setMaximum(0);
unBar=m_dialog->discoveryprogress;
bop=q;
try
{
logger=bop->start_operation();
m_dialog->discoverylog->append("Collecting data ...");
} catch(const FWException &ex)
{
delete q;
q=NULL;
}
#endif
}
void DiscoveryDruid::changedDomainName()
{
if (m_dialog->domainname->text().isEmpty())
@@ -1387,6 +1300,106 @@ void DiscoveryDruid::loadDataFromImporter()
}
}
void DiscoveryDruid::saveScanLog()
{
QString dir;
dir=st->getWDir();
if (dir.isEmpty()) dir=st->getOpenFileDir();
if (dir.isEmpty()) dir="~";
QString s = QFileDialog::getSaveFileName(
this,
"Choose a file",
dir,
"Text file (*.txt)");
if (!s.isEmpty())
{
if (s.endsWith(".txt"))
{
s+=".txt";
}
QFile f(s);
if (f.open(QIODevice::WriteOnly))
{
if (fwbdebug)
{
qDebug("Saving crawler log to file: %d chars",
m_dialog->discoverylog->toPlainText().length());
qDebug("--------------------------------");
}
QTextStream strm(&f);
QString txt = m_dialog->discoverylog->toPlainText();
strm << txt << endl;
if (fwbdebug) qDebug("%s",txt.toAscii().constData());
if (fwbdebug)
qDebug("--------------------------------");
f.close();
}
}
}
void DiscoveryDruid::startSNMPScan()
{
#ifdef HAVE_LIBSNMP
bool use_incl=!m_dialog->snmpinaddr->text().isEmpty() && !m_dialog->snmpinmask->text().isEmpty();
if (use_incl)
{
try
{
InetAddrMask in(
InetAddr(m_dialog->snmpinaddr->text().toLatin1().constData()),
InetAddr(m_dialog->snmpinmask->text().toLatin1().constData())
);
include_networks.push_back(in);
}
catch (const FWException &ex)
{
//TODO: to do something usefull
}
}
libfwbuilder::SNMPCrawler *q = new SNMPCrawler();
q->init(getSeedHostAddress(),
m_dialog->snmpcommunity->text().toLatin1().constData(),
m_dialog->snmprecursive->isChecked(),
! m_dialog->snmpincludevirt->isChecked(),
false,
m_dialog->snmpfollowp2p->isChecked(),
0,
m_dialog->snmpretries->value(),
1000000L*m_dialog->snmptimeout->value(),
0,
0,
(use_incl) ? &include_networks : NULL);
m_dialog->discoveryprogress->setMaximum(0);
unBar = m_dialog->discoveryprogress;
bop=q;
try
{
logger = bop->start_operation();
if (fwbdebug) logger->copyToStderr();
m_dialog->discoverylog->append("Collecting data ...");
disconnect(timer, SIGNAL(timeout()), 0, 0);
connect(timer, SIGNAL(timeout()), this, SLOT(updateLog()));
timer->setSingleShot(false);
timer->start(100);
} catch(const FWException &ex)
{
delete q;
q=NULL;
}
#endif
}
void DiscoveryDruid::loadDataFromCrawler()
{
#ifdef HAVE_LIBSNMP
@@ -1615,6 +1628,8 @@ void DiscoveryDruid::customEvent(QEvent *event)
void DiscoveryDruid::updateLog()
{
if (fwbdebug) qDebug("DiscoveryDruid::updateLog");
if (current_task==BT_HOSTS || current_task==BT_IMPORT)
{
QString buf;
@@ -1981,9 +1996,7 @@ void DiscoveryDruid::createRealObjects()
m_dialog->lastprogress->setMaximum( Objects.size());
QMap<QString,ObjectDescriptor >::iterator i;
for(i=Networks.begin();
i!=Networks.end();
++i)
for(i=Networks.begin(); i!=Networks.end(); ++i)
{
od=i.value();
if (od.isSelected)
@@ -2003,15 +2016,13 @@ void DiscoveryDruid::createRealObjects()
}
}
for(i=Objects.begin();
i!=Objects.end();
++i)
for(i=Objects.begin(); i!=Objects.end(); ++i)
{
od=i.value();
type=od.type;
od = i.value();
type = od.type;
name=od.sysname;
a=od.addr.toString();
name = od.sysname;
a = od.addr.toString();
if(od.isSelected)
{
@@ -2019,7 +2030,7 @@ void DiscoveryDruid::createRealObjects()
{
FWObject *o=NULL;
o=mw->createObject(type.c_str(),name.c_str());
o = mw->createObject(type.c_str(), name.c_str());
o->setName(name);
if (od.interfaces.size()==0)
@@ -2036,18 +2047,32 @@ void DiscoveryDruid::createRealObjects()
ipv4->setNetmask(InetAddr());
} else
{
map<int,Interface>::const_iterator i;
map<int,InterfaceData>::const_iterator i;
for (i=od.interfaces.begin(); i!=od.interfaces.end(); ++i)
{
Interface in=i->second;
Interface *itf=
Interface::cast(mw->createObject(
o,
Interface::TYPENAME,
(i->second).getName().c_str(),
&in));
mw->autorename(itf,IPv4::TYPENAME,"ip");
mw->autorename(itf,physAddress::TYPENAME,"mac");
InterfaceData in = i->second;
if (in.addr_mask.getAddressPtr()->isAny()) continue;
Interface *itf = Interface::cast(
mw->createObject(o,
QString(Interface::TYPENAME),
QString(i->second.name.c_str())));
itf->setPhysicalAddress(in.mac_addr);
itf->setLabel(in.label);
itf->setExt(in.ext);
itf->setSecurityLevel(in.securityLevel);
const InetAddr *addr = in.addr_mask.getAddressPtr();
IPv4 *ipv4= IPv4::cast(
mw->createObject(itf, IPv4::TYPENAME,
addr->toString().c_str())
);
ipv4->setAddress(*addr);
ipv4->setNetmask(*(in.addr_mask.getNetmaskPtr()));
mw->autorename(itf, IPv4::TYPENAME, "ip");
mw->autorename(itf, physAddress::TYPENAME, "mac");
}
}
if (!od.descr.empty())
@@ -2101,14 +2126,14 @@ void DiscoveryDruid::createRealObjects()
}
void DiscoveryDruid::autorename(FWObject *obj,
const string &objtype,
const string &namesuffix)
const string &objtype,
const string &namesuffix)
{
FWObject *hst = obj->getParent();
list<FWObject*> ol = obj->getByType(objtype);
int sfxn = 1;
for (list<FWObject*>::iterator j=ol.begin(); j!=ol.end(); ++j,sfxn++)
for (list<FWObject*>::iterator j=ol.begin(); j!=ol.end(); ++j,++sfxn)
{
QString sfx;
if (ol.size()==1) sfx="";
@@ -2214,7 +2239,7 @@ ObjectDescriptor& ObjectDescriptor::operator=(const ObjectDescriptor& od) {
WorkerThread::WorkerThread() : QThread()
{
Log=new QueueLogger();
Log = new QueueLogger();
}
WorkerThread::~WorkerThread()
@@ -2224,7 +2249,7 @@ WorkerThread::~WorkerThread()
void WorkerThread::setProgress(int p)
{
ProgressEvent *event=new ProgressEvent();
ProgressEvent *event = new ProgressEvent();
event->value=p;
QApplication::postEvent(Widget,event);
+3 -2
View File
@@ -36,6 +36,7 @@
#include <qhostinfo.h>
#include "fwbuilder/Interface.h"
#include "fwbuilder/InterfaceData.h"
#include "fwbuilder/dns.h"
#include "fwbuilder/snmp.h"
#include "fwbuilder/InetAddr.h"
@@ -65,7 +66,7 @@ class ObjectDescriptor
bool isSelected;
map<int, libfwbuilder::Interface> interfaces ;
map<int, libfwbuilder::InterfaceData> interfaces ;
string MAC_addr ;
libfwbuilder::HostEnt dns_info ;
@@ -118,7 +119,7 @@ class DoneEvent : public QEvent
typedef enum {BT_NONE,BT_HOSTS,BT_DNS,BT_SNMP,BT_IMPORT} BackgroundTask;
class WorkerThread : public QThread, QObject
class WorkerThread : public QThread
{
QWidget *Widget;
-214
View File
@@ -1,214 +0,0 @@
/*
Firewall Builder
Copyright (C) 2001 NetCitadel, LLC
Author: Vadim Kurland vadim@vk.crocodile.org
$Id: InterfaceData.cpp,v 1.2 2006/03/06 03:02:57 vkurland Exp $
This program is free software which we release under the GNU General Public
License. You may redistribute and/or modify this program under the terms
of that license as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To get a copy of the GNU General Public License, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "fwbuilder_ph.h"
#include "InterfaceData.h"
#include "fwbuilder/Resources.h"
#include "fwbuilder/InetAddr.h"
using namespace libfwbuilder;
using namespace std;
InterfaceData::InterfaceData(const libfwbuilder::Interface &iface)
{
id = iface.getId();
name = iface.getName();
IPv4 *addr = IPv4::cast(iface.getFirstByType(IPv4::TYPENAME));
if (addr)
{
address = addr->getAddressPtr()->toString();
netmask = addr->getNetmaskPtr()->toString();
}
else
{
address = "";
netmask = "";
}
securityLevel = iface.getSecurityLevel();
isDyn = iface.isDyn();
isUnnumbered = iface.isUnnumbered();
isBridgePort = iface.isBridgePort();
libfwbuilder::physAddress *pa = iface.getPhysicalAddress();
if (pa!=NULL)
physicalAddress = pa->getPhysAddress();
label = iface.getLabel();
networkZone = iface.getStr("network_zone");
}
void InterfaceData::guessLabel(const string&)
{
/*
* some firewalls report fairly regular names for interfaces through
* their built-in SNMP agent. We can use this to assign labels
* automatically.
*
* in PIX interfaces have names like "PIX Firewall 'inside' interface"
*
*/
string pat1="PIX Firewall '";
string pat2="' interface";
string::size_type p2;
if ( name.find(pat1)==0 && (p2=name.find(pat2))!=string::npos )
label=name.substr( pat1.size() , p2-pat1.size() );
if (!isDyn &&
!isUnnumbered &&
!isBridgePort &&
address == InetAddr::getLoopbackAddr().toString())
label="loopback";
}
void InterfaceData::guessSecurityLevel(const string&)
{
InetAddrMask n10(InetAddr("10.0.0.0"), InetAddr("255.0.0.0"));
InetAddrMask n172(InetAddr("172.16.0.0"), InetAddr("255.240.0.0"));
InetAddrMask n192(InetAddr("192.168.0.0"), InetAddr("255.255.0.0"));
securityLevel=-1;
string llbl=label;
for (string::size_type i=0; i<llbl.length(); i++)
llbl[i]= tolower( llbl[i] );
if ( llbl=="outside" ||
llbl=="out" ||
llbl=="external" ||
llbl=="external net" ||
llbl=="ext" ||
llbl=="internet" ||
llbl=="wan" ||
llbl=="dsl" ||
llbl=="cable") securityLevel=0;
if ( llbl=="inside" ||
llbl=="lan" ||
llbl=="in" ||
llbl=="internal" ||
llbl=="internal_net" ||
llbl=="internal net" ) securityLevel=100;
if ( address==InetAddr::getLoopbackAddr().toString()) securityLevel=100;
if ( name=="Null0" ) securityLevel=100;
if (securityLevel==-1 && !isDyn && !isUnnumbered && !isBridgePort)
{
if (n10.belongs( InetAddr( address ) )) securityLevel=100;
if (n172.belongs( InetAddr( address ) )) securityLevel=100;
if (n192.belongs( InetAddr( address ) )) securityLevel=100;
}
if (isDyn || isUnnumbered || isBridgePort) securityLevel=0;
if (securityLevel==-1) securityLevel=50;
}
class sort_order_func_adaptor
{
public:
explicit sort_order_func_adaptor() {}
bool operator()(const InterfaceData &a, const InterfaceData &b)
{
if (a.label=="outside") return true;
if (b.label=="inside") return true;
return (a.securityLevel<b.securityLevel || a.label<b.label || a.name<b.name);
}
};
void InterfaceData::guessSecurityLevel(const string &platform,
list<InterfaceData> &ifaces)
{
// first pass - try to find internal and external interfaces and
// assign sec. levels and labels
// bool supports_security_levels=Resources::getTargetCapabilityBool(platform,
// "security_levels");
list<InterfaceData> res;
if (ifaces.size()==1)
{
ifaces.front().guessSecurityLevel(platform);
return;
}
if (ifaces.size()==2)
{
if (ifaces.front().address==InetAddr::getLoopbackAddr().toString())
{
ifaces.front().securityLevel=100;
ifaces.back().securityLevel=0;
} else
{
if (ifaces.back().address==InetAddr::getLoopbackAddr().toString())
{
ifaces.front().securityLevel=0;
ifaces.back().securityLevel=100;
} else
{
ifaces.front().guessSecurityLevel(platform);
ifaces.back().guessSecurityLevel(platform);
}
}
ifaces.sort(sort_order_func_adaptor());
return;
}
else
{
for (list<InterfaceData>::iterator i=ifaces.begin(); i!=ifaces.end(); i++)
{
i->guessSecurityLevel(platform);
}
}
ifaces.sort(sort_order_func_adaptor());
// second pass - Assign sec. levels evenly if it is pix, or all zeros in all other cases.
int sec_level_step= 100 / ( ifaces.size() - 1 );
int sec_level = 0;
for (list<InterfaceData>::iterator i=ifaces.begin(); i!=ifaces.end(); i++)
{
i->securityLevel=sec_level;
sec_level += sec_level_step;
}
}
-86
View File
@@ -1,86 +0,0 @@
/*
Firewall Builder
Copyright (C) 2001 NetCitadel, LLC
Author: Vadim Kurland vadim@vk.crocodile.org
$Id: InterfaceData.h,v 1.2 2006/03/06 03:02:57 vkurland Exp $
This program is free software which we release under the GNU General Public
License. You may redistribute and/or modify this program under the terms
of that license as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To get a copy of the GNU General Public License, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __INTERFACE_DATA_HH_
#define __INTERFACE_DATA_HH_
#include "fwbuilder/Interface.h"
#include "fwbuilder/physAddress.h"
struct InterfaceData
{
std::string id;
std::string name;
std::string address;
std::string netmask;
int securityLevel;
bool isDyn;
bool isUnnumbered;
bool isBridgePort;
std::string physicalAddress;
std::string label;
std::string networkZone;
InterfaceData()
{
isDyn = false;
isUnnumbered = false;
isBridgePort = false;
securityLevel = 0;
}
InterfaceData(const libfwbuilder::Interface &iface);
/**
* this method is a collection of heuristics that allow us to assign
* a reasonable label to the interface based on firewall platform,
* name of the interface, its label and other parameters.
*/
void guessLabel(const std::string &platform);
/**
* this method is a collection of heuristics that allow us to make an
* educated guess about interface's security level based on the
* firewall platform, name of the interface, its label and other
* parameters.
*/
void guessSecurityLevel(const std::string &platform);
/**
* This method is a collection of heuristics that allow us to assign
* a reasonable security level to many interfaces based on firewall
* platform, their names and labels and other parameters. This method
* compares parameters of many interfaces and in certain cases can
* guess their relative security levels.
*/
static void guessSecurityLevel(const std::string &platform,
std::list<InterfaceData> &interfaces);
};
#endif
+43 -40
View File
@@ -520,13 +520,15 @@ void ObjectManipulator::updateObjName(FWObject *obj,
itm->setText(0, pom->getTreeLabel( obj ) );
if (!Library::isA(obj)) itm->parent()->sortChildren(0, Qt::AscendingOrder);
if (!Library::isA(obj))
itm->parent()->sortChildren(0, Qt::AscendingOrder);
/* need to update name of the firewall in the drop-down list */
/* need to update name of the firewall in the drop-down list */
if (Firewall::isA(obj))
{
pom->m_project->updateFirewallName(obj,oldName);
}
if (RuleSet::cast(obj)!=NULL)
{
pom->m_project->updateFirewallName(obj,oldName);
@@ -571,7 +573,7 @@ void ObjectManipulator::updateObjName(FWObject *obj,
info(); // need to update info in case user edited comments and other attributes.
}
void ObjectManipulator::autorename(FWObject *obj,bool ask)
void ObjectManipulator::autorename(FWObject *obj, bool ask)
{
if (Host::isA(obj) || Firewall::isA(obj))
{
@@ -637,35 +639,36 @@ void ObjectManipulator::autorename(FWObject *obj,
const string &objtype,
const string &namesuffix)
{
QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators();
for (int i = 0 ; i < oms.size(); i++)
{
ObjectManipulator* pom = oms[i] ;
FWObject *hst = obj->getParent();
list<FWObject*> ol = obj->getByType(objtype);
int sfxn = 1;
for (list<FWObject*>::iterator j=ol.begin(); j!=ol.end(); ++j,sfxn++)
QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators();
for (int i = 0 ; i < oms.size(); i++)
{
QString sfx;
if (ol.size()==1) sfx="";
else sfx.setNum(sfxn);
QString nn = QString("%1:%2:%3%4")
.arg(QString::fromUtf8(hst->getName().c_str()))
.arg(QString::fromUtf8(obj->getName().c_str()))
.arg(namesuffix.c_str())
.arg(sfx);
ObjectManipulator* pom = oms[i] ;
(*j)->setName(string(nn.toUtf8()));
QTreeWidgetItem *itm1 = pom->allItems[ *j ];
assert(itm1!=NULL);
itm1->setText(0, getTreeLabel( *j ) );
itm1->parent()->sortChildren(0, Qt::AscendingOrder);//();
}
ol.clear();
}
FWObject *hst = obj->getParent();
list<FWObject*> ol = obj->getByType(objtype);
int sfxn = 1;
for (list<FWObject*>::iterator j=ol.begin(); j!=ol.end(); ++j,sfxn++)
{
QString sfx;
if (ol.size()==1) sfx="";
else sfx.setNum(sfxn);
QString nn = QString("%1:%2:%3%4")
.arg(QString::fromUtf8(hst->getName().c_str()))
.arg(QString::fromUtf8(obj->getName().c_str()))
.arg(namesuffix.c_str())
.arg(sfx);
(*j)->setName(string(nn.toUtf8()));
QTreeWidgetItem *itm1 = pom->allItems[ *j ];
if (itm1!=NULL)
{
itm1->setText(0, getTreeLabel( *j ) );
itm1->parent()->sortChildren(0, Qt::AscendingOrder);//();
}
}
ol.clear();
}
}
void ObjectManipulator::clearObjects()
@@ -2468,7 +2471,7 @@ void ObjectManipulator::invalidateDialog()
void ObjectManipulator::libChangedById(int id)
{
for (int i = 0 ; i < idxToLibs.size(); i++)
for (vector<FWObject*>::size_type i = 0 ; i < idxToLibs.size(); i++)
{
if (idxToLibs[i]->getId()==id)
{
@@ -2483,7 +2486,7 @@ void ObjectManipulator::changeFirstNotSystemLib()
{
QString sid2 = "syslib000";
QString sid3 = "syslib001";
for (int i = 0 ; i < idxToLibs.size(); i++)
for (vector<FWObject*>::size_type i = 0 ; i < idxToLibs.size(); i++)
{
QString sid1 = FWObjectDatabase::getStringId(idxToLibs[i]->getId()).c_str();
if ( sid1 != sid2)
@@ -2630,15 +2633,17 @@ FWObject* ObjectManipulator::createObject(const QString &objType,
lib->getName().c_str(),
FWObjectDatabase::getStringId(lib->getId()).c_str());
qDebug("lib: isReadOnly=%d isLoaded=%d",
lib->isReadOnly(), m_project->getAddOnLibs()->isLoaded( lib->getName().c_str() ) );
lib->isReadOnly(),
m_project->getAddOnLibs()->isLoaded(lib->getName().c_str()));
}
i++;
}
FWObject *parent=m_project->getFWTree()->getStandardSlotForObject(lib, objType);
FWObject *parent =
m_project->getFWTree()->getStandardSlotForObject(lib, objType);
if (parent==NULL)
{
QMessageBox::warning(this,"Firewall Builder",
QObject::tr(
"Type '%1': new object can not be created because\n"
@@ -2647,18 +2652,16 @@ FWObject* ObjectManipulator::createObject(const QString &objType,
.arg(objType),
"&Continue", QString::null, QString::null,
0, 1 );
return NULL;
}
return actuallyCreateObject(parent,objType,objName,copyFrom);
}
FWObject* ObjectManipulator::createObject(FWObject *parent,
const QString &objType,
const QString &objName,
FWObject *copyFrom)
const QString &objType,
const QString &objName,
FWObject *copyFrom)
{
if (!validateDialog()) return NULL;
-2
View File
@@ -36,7 +36,6 @@ HEADERS += ../../config.h \
newGroupDialog.h \
filePropDialog.h \
DialogData.h \
InterfaceData.h \
execDialog.h \
SimpleTextEditor.h \
SimpleIntEditor.h \
@@ -149,7 +148,6 @@ SOURCES += ProjectPanel.cpp \
newGroupDialog.cpp \
filePropDialog.cpp \
DialogData.cpp \
InterfaceData.cpp \
execDialog.cpp \
SimpleTextEditor.cpp \
SimpleIntEditor.cpp \
+11 -10
View File
@@ -32,7 +32,6 @@
#include "platforms.h"
#include "newFirewallDialog.h"
#include "InterfaceData.h"
#include "FWWindow.h"
#include "ObjConflictResolutionDialog.h"
#include "upgradePredicate.h"
@@ -230,10 +229,11 @@ void newFirewallDialog::monitor()
timer->stop();
const map<int, Interface> &intf = q->getInterfaces();
for(map<int, Interface>::const_iterator i=intf.begin();i!=intf.end(); ++i)
const map<int, InterfaceData> &intf = q->getInterfaces();
map<int, InterfaceData>::const_iterator i;
for(i=intf.begin();i!=intf.end(); ++i)
{
if ( i->second.isUp() )
if ( i->second.ostatus )
{
InterfaceData idata( i->second );
@@ -247,10 +247,10 @@ void newFirewallDialog::monitor()
QStringList qsl;
qsl << idata.name.c_str()
<< idata.label.c_str()
<< idata.address.c_str()
<< idata.netmask.c_str()
<< idata.addr_mask.getAddressPtr()->toString().c_str()
<< idata.addr_mask.getNetmaskPtr()->toString().c_str()
<< dn
<< idata.physicalAddress.c_str();
<< idata.mac_addr.c_str();
new QTreeWidgetItem(m_dialog->iface_list, qsl);
// cerr << "Added interface " << idata.name << endl;
@@ -485,9 +485,10 @@ void newFirewallDialog::fillInterfaceSLList()
idata.isBridgePort = itm->text(4).indexOf("Bridge")!=-1;
if (!idata.isDyn && !idata.isUnnumbered && !idata.isBridgePort)
idata.address = itm->text(2).toLatin1().constData();
idata.addr_mask.setAddress(itm->text(2).toLatin1().constData());
else
idata.address = QObject::tr("dynamic").toLatin1().constData();
idata.addr_mask.setAddress(
QObject::tr("dynamic").toLatin1().constData());
try
{
@@ -506,7 +507,7 @@ void newFirewallDialog::fillInterfaceSLList()
QStringList qsl;
qsl << idata.name.c_str()
<< idata.label.c_str()
<< idata.address.c_str()
<< idata.addr_mask.getAddressPtr()->toString().c_str()
<< QString::number(idata.securityLevel);
new QTreeWidgetItem(m_dialog->iface_sl_list, qsl);
+1 -1
View File
@@ -30,7 +30,7 @@
#include "../../config.h"
#include <ui_newfirewalldialog_q.h>
#include "InterfaceData.h"
#include "fwbuilder/InterfaceData.h"
#include "fakeWizard.h"
#include <map>
+7 -7
View File
@@ -33,7 +33,6 @@
#include "platforms.h"
#include "newHostDialog.h"
#include "InterfaceData.h"
#include "FWWindow.h"
#include "ObjConflictResolutionDialog.h"
#include "upgradePredicate.h"
@@ -224,10 +223,11 @@ void newHostDialog::monitor()
timer->stop();
const map<int, Interface> &intf = q->getInterfaces();
for(map<int, Interface>::const_iterator i=intf.begin();i!=intf.end(); ++i)
const map<int, InterfaceData> &intf = q->getInterfaces();
map<int, InterfaceData>::const_iterator i;
for(i=intf.begin();i!=intf.end(); ++i)
{
if ( i->second.isUp() )
if ( i->second.ostatus )
{
InterfaceData idata( i->second );
@@ -240,10 +240,10 @@ void newHostDialog::monitor()
QStringList qsl;
qsl << idata.name.c_str()
<< idata.label.c_str()
<< idata.address.c_str()
<< idata.netmask.c_str()
<< idata.addr_mask.getAddressPtr()->toString().c_str()
<< idata.addr_mask.getNetmaskPtr()->toString().c_str()
<< dn
<< idata.physicalAddress.c_str();
<< idata.mac_addr.c_str();
new QTreeWidgetItem(m_dialog->iface_list, qsl);
// cerr << "Added interface " << idata.name << endl;
+1 -1
View File
@@ -30,7 +30,7 @@
#include "../../config.h"
#include <ui_newhostdialog_q.h>
#include "InterfaceData.h"
#include "fwbuilder/InterfaceData.h"
#include "fakeWizard.h"
#include <QDialog>
+15 -3
View File
@@ -88,9 +88,15 @@
<bool>true</bool>
</property>
<widget class="QFrame" name="frame16" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>150</width>
<width>0</width>
<height>50</height>
</size>
</property>
@@ -121,6 +127,12 @@
</property>
<item row="1" column="0" >
<widget class="QFrame" name="frame21" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</property>
@@ -206,7 +218,7 @@
<item row="0" column="0" >
<widget class="QSplitter" name="objInfoSplitter" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<sizepolicy vsizetype="Expanding" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -266,7 +278,7 @@
</widget>
<widget class="QFrame" name="rightFrame" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
<sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>