mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-09-11 15:41:41 +02:00
merging id-experimemt r233:HEAD
This commit is contained in:
@@ -1,3 +1,12 @@
|
|||||||
|
|
||||||
|
2008-06-08 Vadim Kurland <vadim@vk.crocodile.org>
|
||||||
|
|
||||||
|
* merged branch "id-experiment" r233:HEAD
|
||||||
|
|
||||||
|
2008-06-07 Vadim Kurland <vadim@vk.crocodile.org>
|
||||||
|
|
||||||
|
* main.cpp (main): support for integer object ids
|
||||||
|
|
||||||
2008-06-06 Vadim Kurland <vadim@vk.crocodile.org>
|
2008-06-06 Vadim Kurland <vadim@vk.crocodile.org>
|
||||||
|
|
||||||
* PolicyCompiler_pf_writers.cpp (PrintRule::_printUser): Support
|
* PolicyCompiler_pf_writers.cpp (PrintRule::_printUser): Support
|
||||||
|
|||||||
@@ -124,7 +124,8 @@ public:
|
|||||||
/** called by the generated lexer to do error recovery, override to
|
/** called by the generated lexer to do error recovery, override to
|
||||||
* customize the behaviour.
|
* customize the behaviour.
|
||||||
*/
|
*/
|
||||||
virtual void recover(const RecognitionException& ex, const BitSet& tokenSet)
|
virtual void recover(const RecognitionException& ,
|
||||||
|
const BitSet& tokenSet)
|
||||||
{
|
{
|
||||||
consume();
|
consume();
|
||||||
consumeUntil(tokenSet);
|
consumeUntil(tokenSet);
|
||||||
|
|||||||
@@ -239,7 +239,8 @@ public:
|
|||||||
/** called by the generated parser to do error recovery, override to
|
/** called by the generated parser to do error recovery, override to
|
||||||
* customize the behaviour.
|
* customize the behaviour.
|
||||||
*/
|
*/
|
||||||
virtual void recover(const RecognitionException& ex, const BitSet& tokenSet)
|
virtual void recover(const RecognitionException& ,
|
||||||
|
const BitSet& tokenSet)
|
||||||
{
|
{
|
||||||
consume();
|
consume();
|
||||||
consumeUntil(tokenSet);
|
consumeUntil(tokenSet);
|
||||||
|
|||||||
+13
-11
@@ -150,7 +150,7 @@ int fwbdebug = 0;
|
|||||||
class UpgradePredicate: public XMLTools::UpgradePredicate
|
class UpgradePredicate: public XMLTools::UpgradePredicate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool operator()(const string &msg) const
|
virtual bool operator()(const string&) const
|
||||||
{
|
{
|
||||||
bool res=false;
|
bool res=false;
|
||||||
cout << _("Data file has been created in the old version of Firewall Builder.") << endl << flush;
|
cout << _("Data file has been created in the old version of Firewall Builder.") << endl << flush;
|
||||||
@@ -280,7 +280,7 @@ FWObject *getObject(const char *objstr) throw (FWException)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* got object ID */
|
/* got object ID */
|
||||||
obj=objdb->getById(objstr,true);
|
obj=objdb->getById(FWObjectDatabase::getIntId(objstr), true);
|
||||||
if (obj==NULL)
|
if (obj==NULL)
|
||||||
{
|
{
|
||||||
SNPRINTF(errstr,sizeof(errstr),_("Object with ID='%s' not found"),objstr );
|
SNPRINTF(errstr,sizeof(errstr),_("Object with ID='%s' not found"),objstr );
|
||||||
@@ -601,7 +601,7 @@ int main(int argc, char * const *argv)
|
|||||||
{
|
{
|
||||||
nlib=*i;
|
nlib=*i;
|
||||||
lib=nlib->getName();
|
lib=nlib->getName();
|
||||||
if (nlib->getId()!="sysid99")
|
if (nlib->getId()!=FWObjectDatabase::DELETED_OBJECTS_ID)
|
||||||
{
|
{
|
||||||
ro_flag=nlib->isReadOnly();
|
ro_flag=nlib->isReadOnly();
|
||||||
cout << _("Library: ") << lib << ((ro_flag)?"(Read only)":" ") << endl;
|
cout << _("Library: ") << lib << ((ro_flag)?"(Read only)":" ") << endl;
|
||||||
@@ -880,10 +880,11 @@ int main(int argc, char * const *argv)
|
|||||||
FWObject *nobj=createObject(objtype,"/"+lib+"/"+systemGroupPaths[objtype]);
|
FWObject *nobj=createObject(objtype,"/"+lib+"/"+systemGroupPaths[objtype]);
|
||||||
TCPService *o=TCPService::cast(nobj);
|
TCPService *o=TCPService::cast(nobj);
|
||||||
o->setName(name);
|
o->setName(name);
|
||||||
o->setInt("src_range_start",atoi(addr1.c_str()));
|
|
||||||
o->setInt("src_range_end",atoi(addr2.c_str()));
|
o->setSrcRangeStart(atoi(addr1.c_str()));
|
||||||
o->setInt("dst_range_start",atoi(addr3.c_str()));
|
o->setSrcRangeEnd( atoi(addr2.c_str()));
|
||||||
o->setInt("dst_range_end",atoi(addr4.c_str()));
|
o->setDstRangeStart(atoi(addr3.c_str()));
|
||||||
|
o->setDstRangeEnd( atoi(addr4.c_str()));
|
||||||
|
|
||||||
o->setBool("urg_flag_mask",mask.find('u')!=string::npos || mask.find('U')!=string::npos);
|
o->setBool("urg_flag_mask",mask.find('u')!=string::npos || mask.find('U')!=string::npos);
|
||||||
o->setBool("ack_flag_mask",mask.find('a')!=string::npos || mask.find('A')!=string::npos);
|
o->setBool("ack_flag_mask",mask.find('a')!=string::npos || mask.find('A')!=string::npos);
|
||||||
@@ -910,10 +911,11 @@ int main(int argc, char * const *argv)
|
|||||||
FWObject *nobj=createObject(objtype,"/"+lib+"/"+systemGroupPaths[objtype]);
|
FWObject *nobj=createObject(objtype,"/"+lib+"/"+systemGroupPaths[objtype]);
|
||||||
UDPService *o=UDPService::cast(nobj);
|
UDPService *o=UDPService::cast(nobj);
|
||||||
o->setName(name);
|
o->setName(name);
|
||||||
o->setInt("src_range_start",atoi(addr1.c_str()));
|
|
||||||
o->setInt("src_range_end",atoi(addr2.c_str()));
|
o->setSrcRangeStart(atoi(addr1.c_str()));
|
||||||
o->setInt("dst_range_start",atoi(addr3.c_str()));
|
o->setSrcRangeEnd( atoi(addr2.c_str()));
|
||||||
o->setInt("dst_range_end",atoi(addr4.c_str()));
|
o->setDstRangeStart(atoi(addr3.c_str()));
|
||||||
|
o->setDstRangeEnd( atoi(addr4.c_str()));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (objtype==ICMPService::TYPENAME)
|
else if (objtype==ICMPService::TYPENAME)
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ int main(int argc, char * const *argv)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* got object ID */
|
/* got object ID */
|
||||||
obj=objdb->getById(object,true);
|
obj=objdb->getById(FWObjectDatabase::getIntId(object), true);
|
||||||
if (obj==NULL)
|
if (obj==NULL)
|
||||||
{
|
{
|
||||||
SNPRINTF(errstr,sizeof(errstr),_("Object with ID='%s' not found"),object );
|
SNPRINTF(errstr,sizeof(errstr),_("Object with ID='%s' not found"),object );
|
||||||
@@ -255,7 +255,7 @@ int main(int argc, char * const *argv)
|
|||||||
SNPRINTF(errstr,sizeof(errstr),
|
SNPRINTF(errstr,sizeof(errstr),
|
||||||
_("Object %s (ID='%s') does not have attribute %s"),
|
_("Object %s (ID='%s') does not have attribute %s"),
|
||||||
obj->getName().c_str(),
|
obj->getName().c_str(),
|
||||||
obj->getId().c_str(),
|
FWObjectDatabase::getStringId(obj->getId()).c_str(),
|
||||||
attr );
|
attr );
|
||||||
throw FWException(errstr);
|
throw FWException(errstr);
|
||||||
}
|
}
|
||||||
@@ -275,7 +275,7 @@ int main(int argc, char * const *argv)
|
|||||||
SNPRINTF(errstr,sizeof(errstr),
|
SNPRINTF(errstr,sizeof(errstr),
|
||||||
_("Object %s (ID='%s') has no options"),
|
_("Object %s (ID='%s') has no options"),
|
||||||
obj->getName().c_str(),
|
obj->getName().c_str(),
|
||||||
obj->getId().c_str() );
|
FWObjectDatabase::getStringId(obj->getId()).c_str() );
|
||||||
throw FWException(errstr);
|
throw FWException(errstr);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@@ -283,7 +283,7 @@ int main(int argc, char * const *argv)
|
|||||||
SNPRINTF(errstr,sizeof(errstr),
|
SNPRINTF(errstr,sizeof(errstr),
|
||||||
_("Can not print management address for %s (ID='%s'): only Host and Firewall objects have management interface"),
|
_("Can not print management address for %s (ID='%s'): only Host and Firewall objects have management interface"),
|
||||||
obj->getName().c_str(),
|
obj->getName().c_str(),
|
||||||
obj->getId().c_str() );
|
FWObjectDatabase::getStringId(obj->getId()).c_str() );
|
||||||
throw FWException(errstr);
|
throw FWException(errstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,7 +297,7 @@ int main(int argc, char * const *argv)
|
|||||||
SNPRINTF(errstr,sizeof(errstr),
|
SNPRINTF(errstr,sizeof(errstr),
|
||||||
_("Can not print address for %s (ID='%s'): objects of this type do not have address"),
|
_("Can not print address for %s (ID='%s'): objects of this type do not have address"),
|
||||||
obj->getName().c_str(),
|
obj->getName().c_str(),
|
||||||
obj->getId().c_str() );
|
FWObjectDatabase::getStringId(obj->getId()).c_str() );
|
||||||
throw FWException(errstr);
|
throw FWException(errstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -309,7 +309,7 @@ int main(int argc, char * const *argv)
|
|||||||
SNPRINTF(errstr,sizeof(errstr),
|
SNPRINTF(errstr,sizeof(errstr),
|
||||||
_("Can not print label for %s (ID='%s'): only Interface object has label"),
|
_("Can not print label for %s (ID='%s'): only Interface object has label"),
|
||||||
obj->getName().c_str(),
|
obj->getName().c_str(),
|
||||||
obj->getId().c_str() );
|
FWObjectDatabase::getStringId(obj->getId()).c_str() );
|
||||||
throw FWException(errstr);
|
throw FWException(errstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -326,14 +326,14 @@ int main(int argc, char * const *argv)
|
|||||||
SNPRINTF(errstr,sizeof(errstr),
|
SNPRINTF(errstr,sizeof(errstr),
|
||||||
_("Object %s (ID='%s') does not have management interface"),
|
_("Object %s (ID='%s') does not have management interface"),
|
||||||
obj->getName().c_str(),
|
obj->getName().c_str(),
|
||||||
obj->getId().c_str() );
|
FWObjectDatabase::getStringId(obj->getId()).c_str() );
|
||||||
throw FWException(errstr);
|
throw FWException(errstr);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SNPRINTF(errstr,sizeof(errstr),
|
SNPRINTF(errstr,sizeof(errstr),
|
||||||
_("Can not print management address for %s (ID='%s'): only Host and Firewall objects have management interface"),
|
_("Can not print management address for %s (ID='%s'): only Host and Firewall objects have management interface"),
|
||||||
obj->getName().c_str(),
|
obj->getName().c_str(),
|
||||||
obj->getId().c_str() );
|
FWObjectDatabase::getStringId(obj->getId()).c_str() );
|
||||||
throw FWException(errstr);
|
throw FWException(errstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ void AddressRangeDialog::validate(bool *res)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressRangeDialog::isChanged(bool *res)
|
void AddressRangeDialog::isChanged(bool *)
|
||||||
{
|
{
|
||||||
//*res=(!init && apply->isEnabled());
|
//*res=(!init && apply->isEnabled());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ void AddressTableDialog::validate(bool *res)
|
|||||||
if (!validateName(this,obj,m_dialog->obj_name->text())) { *res=false; return; }
|
if (!validateName(this,obj,m_dialog->obj_name->text())) { *res=false; return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressTableDialog::isChanged(bool *res)
|
void AddressTableDialog::isChanged(bool *)
|
||||||
{
|
{
|
||||||
//*res=(!init && apply->isEnabled());
|
//*res=(!init && apply->isEnabled());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,10 +61,10 @@ void AskLibForCopyDialog::loadObjects()
|
|||||||
{
|
{
|
||||||
FWObject *lib = (*i);
|
FWObject *lib = (*i);
|
||||||
|
|
||||||
if ((lib->getId()==DELETED_LIB &&
|
if ((lib->getId()==FWObjectDatabase::DELETED_OBJECTS_ID &&
|
||||||
! st->getBool("UI/ShowDeletedObjects"))||
|
! st->getBool("UI/ShowDeletedObjects"))||
|
||||||
lib->getId() == STANDARD_LIB ||
|
lib->getId() == FWObjectDatabase::STANDARD_LIB_ID ||
|
||||||
lib->getId() == TEMPLATE_LIB)
|
lib->getId() == FWObjectDatabase::TEMPLATE_LIB_ID)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int ind = addLib( lib );
|
int ind = addLib( lib );
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ void DialogData::loadToWidget( DialogOption &dopt , bool override)
|
|||||||
*/
|
*/
|
||||||
slist.clear();
|
slist.clear();
|
||||||
|
|
||||||
unsigned idx = 0;
|
int idx = 0;
|
||||||
QStringList::iterator i1 = dopt.mapping.begin();
|
QStringList::iterator i1 = dopt.mapping.begin();
|
||||||
QStringList::iterator i2 = dopt.mapping.begin();
|
QStringList::iterator i2 = dopt.mapping.begin();
|
||||||
++i2;
|
++i2;
|
||||||
|
|||||||
+3
-2
@@ -331,7 +331,8 @@ FWBTree::FWBTree()
|
|||||||
bool FWBTree::isSystem(FWObject *obj)
|
bool FWBTree::isSystem(FWObject *obj)
|
||||||
{
|
{
|
||||||
if (Library::isA(obj))
|
if (Library::isA(obj))
|
||||||
return (obj->getId()==STANDARD_LIB || obj->getId()==DELETED_LIB);
|
return (obj->getId()==FWObjectDatabase::STANDARD_LIB_ID ||
|
||||||
|
obj->getId()==FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||||
|
|
||||||
if (FWObjectDatabase::isA(obj)) return true;
|
if (FWObjectDatabase::isA(obj)) return true;
|
||||||
|
|
||||||
@@ -346,7 +347,7 @@ bool FWBTree::isSystem(FWObject *obj)
|
|||||||
|
|
||||||
bool FWBTree::isStandardId(FWObject *obj)
|
bool FWBTree::isStandardId(FWObject *obj)
|
||||||
{
|
{
|
||||||
return standardIDs[ obj->getId() ];
|
return standardIDs[ FWObjectDatabase::getStringId(obj->getId()).c_str() ];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FWBTree::validateForInsertion(FWObject *target, FWObject *obj)
|
bool FWBTree::validateForInsertion(FWObject *target, FWObject *obj)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ FWObjectClipboard::~FWObjectClipboard()
|
|||||||
|
|
||||||
void FWObjectClipboard::clear()
|
void FWObjectClipboard::clear()
|
||||||
{
|
{
|
||||||
for (vector<string>::iterator i=ids.begin(); i!=ids.end(); ++i)
|
for (vector<int>::iterator i=ids.begin(); i!=ids.end(); ++i)
|
||||||
{
|
{
|
||||||
FWObject *obj = mw->db()->findInIndex(*i);
|
FWObject *obj = mw->db()->findInIndex(*i);
|
||||||
if (obj) obj->unref();
|
if (obj) obj->unref();
|
||||||
@@ -70,7 +70,9 @@ void FWObjectClipboard::add(FWObject *_obj, ProjectPanel * fww)
|
|||||||
if (fwbdebug)
|
if (fwbdebug)
|
||||||
{
|
{
|
||||||
qDebug("FWObjectClipboard::add adding _obj=%p (id=%s)",
|
qDebug("FWObjectClipboard::add adding _obj=%p (id=%s)",
|
||||||
_obj,_obj->getId().c_str());
|
_obj,
|
||||||
|
FWObjectDatabase::getStringId(_obj->getId()).c_str()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_obj->ref();
|
_obj->ref();
|
||||||
@@ -90,20 +92,26 @@ FWObject* FWObjectClipboard::getObject()
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t FWObjectClipboard::windowsCount (){return windows.size();}
|
size_t FWObjectClipboard::windowsCount ()
|
||||||
|
{
|
||||||
|
return windows.size();
|
||||||
|
}
|
||||||
|
|
||||||
ProjectPanel * FWObjectClipboard::getWindowByIdx (int idx)
|
ProjectPanel * FWObjectClipboard::getWindowByIdx (int idx)
|
||||||
{
|
{
|
||||||
if (idx<windowsCount ())
|
if (idx < int(windowsCount()))
|
||||||
{
|
{
|
||||||
return windows[idx];
|
return windows[idx];
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
libfwbuilder::FWObject* FWObjectClipboard::getObjectByIdx (int idx)
|
|
||||||
|
FWObject* FWObjectClipboard::getObjectByIdx (int idx)
|
||||||
{
|
{
|
||||||
std::string s1 = ids[idx];
|
int s1 = ids[idx];
|
||||||
ProjectPanel * w1 = windows[idx];
|
ProjectPanel * w1 = windows[idx];
|
||||||
FWObject *co= w1->db()->findInIndex(s1);
|
FWObject *co= w1->db()->findInIndex(s1);
|
||||||
return co;
|
return co;
|
||||||
//w1->db()->FWObject *co= win->db()->findInIndex(*i);
|
//w1->db()->FWObject *co= win->db()->findInIndex(*i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class libfwbuilder::FWObject;
|
|||||||
class ProjectPanel ;
|
class ProjectPanel ;
|
||||||
class FWObjectClipboard {
|
class FWObjectClipboard {
|
||||||
|
|
||||||
std::vector<std::string> ids;
|
std::vector<int> ids;
|
||||||
std::vector<ProjectPanel*> windows;
|
std::vector<ProjectPanel*> windows;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -58,13 +58,16 @@ public:
|
|||||||
* clear the clipboard
|
* clear the clipboard
|
||||||
*/
|
*/
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
size_t windowsCount ();
|
size_t windowsCount ();
|
||||||
|
|
||||||
ProjectPanel * getWindowByIdx (int idx);
|
ProjectPanel * getWindowByIdx (int idx);
|
||||||
libfwbuilder::FWObject* getObjectByIdx (int idx);
|
libfwbuilder::FWObject* getObjectByIdx (int idx);
|
||||||
std::vector<std::string>::iterator begin() { return ids.begin(); }
|
|
||||||
std::vector<std::string>::iterator end() { return ids.end(); }
|
std::vector<int>::iterator begin() { return ids.begin(); }
|
||||||
std::vector<std::string>::reverse_iterator rbegin() { return ids.rbegin(); }
|
std::vector<int>::iterator end() { return ids.end(); }
|
||||||
std::vector<std::string>::reverse_iterator rend() { return ids.rend(); }
|
std::vector<int>::reverse_iterator rbegin() { return ids.rbegin(); }
|
||||||
|
std::vector<int>::reverse_iterator rend() { return ids.rend(); }
|
||||||
int size() { return ids.size(); }
|
int size() { return ids.size(); }
|
||||||
|
|
||||||
static FWObjectClipboard *obj_clipboard;
|
static FWObjectClipboard *obj_clipboard;
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ FWObjectDropArea::FWObjectDropArea(QWidget*p, const char * n, Qt::WFlags f):
|
|||||||
helperText =tr("Drop object here.");
|
helperText =tr("Drop object here.");
|
||||||
|
|
||||||
}
|
}
|
||||||
void FWObjectDropArea::paintEvent(QPaintEvent *ev)
|
void FWObjectDropArea::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
int w=width();
|
int w=width();
|
||||||
int h=height();
|
int h=height();
|
||||||
@@ -215,7 +215,7 @@ void FWObjectDropArea::dragEnterEvent( QDragEnterEvent *ev)
|
|||||||
|
|
||||||
void FWObjectDropArea::pasteObject()
|
void FWObjectDropArea::pasteObject()
|
||||||
{
|
{
|
||||||
vector<string>::iterator i;
|
vector<int>::iterator i;
|
||||||
for( i= FWObjectClipboard::obj_clipboard->begin();
|
for( i= FWObjectClipboard::obj_clipboard->begin();
|
||||||
i!=FWObjectClipboard::obj_clipboard->end(); ++i)
|
i!=FWObjectClipboard::obj_clipboard->end(); ++i)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -202,10 +202,10 @@ QString FWObjectPropertiesFactory::getObjectProperties(FWObject *obj)
|
|||||||
{
|
{
|
||||||
int sps,spe,dps,dpe;
|
int sps,spe,dps,dpe;
|
||||||
|
|
||||||
sps=obj->getInt("src_range_start");
|
sps=TCPUDPService::cast(obj)->getSrcRangeStart();
|
||||||
spe=obj->getInt("src_range_end");
|
spe=TCPUDPService::cast(obj)->getSrcRangeEnd();
|
||||||
dps=obj->getInt("dst_range_start");
|
dps=TCPUDPService::cast(obj)->getDstRangeStart();
|
||||||
dpe=obj->getInt("dst_range_end");
|
dpe=TCPUDPService::cast(obj)->getDstRangeEnd();
|
||||||
|
|
||||||
str << sps << ":" << spe << " / ";
|
str << sps << ":" << spe << " / ";
|
||||||
str << dps << ":" << dpe;
|
str << dps << ":" << dpe;
|
||||||
@@ -265,7 +265,7 @@ QString FWObjectPropertiesFactory::getObjectPropertiesDetailed(FWObject *obj,
|
|||||||
if (!tooltip)
|
if (!tooltip)
|
||||||
{
|
{
|
||||||
str += QObject::tr("<b>Object Id:</b> ");
|
str += QObject::tr("<b>Object Id:</b> ");
|
||||||
str += QString(obj->getId().c_str()) + "<br>\n";
|
str += QString(FWObjectDatabase::getStringId(obj->getId()).c_str()) + "<br>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,10 +497,10 @@ QString FWObjectPropertiesFactory::getObjectPropertiesDetailed(FWObject *obj,
|
|||||||
{
|
{
|
||||||
int sps,spe,dps,dpe;
|
int sps,spe,dps,dpe;
|
||||||
|
|
||||||
sps=obj->getInt("src_range_start");
|
sps=TCPUDPService::cast(obj)->getSrcRangeStart();
|
||||||
spe=obj->getInt("src_range_end");
|
spe=TCPUDPService::cast(obj)->getSrcRangeEnd();
|
||||||
dps=obj->getInt("dst_range_start");
|
dps=TCPUDPService::cast(obj)->getDstRangeStart();
|
||||||
dpe=obj->getInt("dst_range_end");
|
dpe=TCPUDPService::cast(obj)->getDstRangeEnd();
|
||||||
|
|
||||||
if (showPath && !tooltip) str += "<b>Path: </b>" + path + "<br>\n";
|
if (showPath && !tooltip) str += "<b>Path: </b>" + path + "<br>\n";
|
||||||
str += "<table cellspacing=\"0\" cellpadding=\"0\">";
|
str += "<table cellspacing=\"0\" cellpadding=\"0\">";
|
||||||
|
|||||||
@@ -153,13 +153,13 @@ void FindObjectWidget::find()
|
|||||||
findNext();
|
findNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FindObjectWidget::matchID(const QString &id)
|
bool FindObjectWidget::matchID(int id)
|
||||||
{
|
{
|
||||||
if (m_widget->findDropArea->isEmpty()) return true;
|
if (m_widget->findDropArea->isEmpty()) return true;
|
||||||
QString s=QString::fromUtf8(m_widget->findDropArea->getObject()->getId().c_str() );
|
int s_id = m_widget->findDropArea->getObject()->getId();
|
||||||
|
return s_id==id;
|
||||||
return s==id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FindObjectWidget::matchAttr(libfwbuilder::FWObject *obj)
|
bool FindObjectWidget::matchAttr(libfwbuilder::FWObject *obj)
|
||||||
{
|
{
|
||||||
if (!m_widget->findDropArea->isEmpty()) return true;
|
if (!m_widget->findDropArea->isEmpty()) return true;
|
||||||
@@ -206,22 +206,26 @@ bool FindObjectWidget::matchAttr(libfwbuilder::FWObject *obj)
|
|||||||
if (m_widget->useRegexp->isChecked())
|
if (m_widget->useRegexp->isChecked())
|
||||||
{
|
{
|
||||||
QString port;
|
QString port;
|
||||||
port.setNum(obj->getInt("src_range_start"));
|
port.setNum(TCPUDPService::cast(obj)->getSrcRangeStart());
|
||||||
res |= ( port.indexOf( QRegExp(s) )!=-1 );
|
res |= ( port.indexOf( QRegExp(s) )!=-1 );
|
||||||
port.setNum(obj->getInt("src_range_end"));
|
port.setNum(TCPUDPService::cast(obj)->getSrcRangeEnd());
|
||||||
res |= ( port.indexOf( QRegExp(s) )!=-1 );
|
res |= ( port.indexOf( QRegExp(s) )!=-1 );
|
||||||
port.setNum(obj->getInt("dst_range_start"));
|
port.setNum(TCPUDPService::cast(obj)->getDstRangeStart());
|
||||||
res |= ( port.indexOf( QRegExp(s) )!=-1 );
|
res |= ( port.indexOf( QRegExp(s) )!=-1 );
|
||||||
port.setNum(obj->getInt("dst_range_end"));
|
port.setNum(TCPUDPService::cast(obj)->getDstRangeEnd());
|
||||||
res |= ( port.indexOf( QRegExp(s) )!=-1 );
|
res |= ( port.indexOf( QRegExp(s) )!=-1 );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
bool conversion_status = false;
|
bool conversion_status = false;
|
||||||
int port = s.toInt(&conversion_status);
|
int port = s.toInt(&conversion_status);
|
||||||
res |= (conversion_status && (port == obj->getInt("src_range_start")));
|
res |= (conversion_status &&
|
||||||
res |= (conversion_status && (port == obj->getInt("src_range_end")));
|
(port == TCPUDPService::cast(obj)->getSrcRangeStart()));
|
||||||
res |= (conversion_status && (port == obj->getInt("dst_range_start")));
|
res |= (conversion_status &&
|
||||||
res |= (conversion_status && (port == obj->getInt("dst_range_end")));
|
(port == TCPUDPService::cast(obj)->getSrcRangeEnd()));
|
||||||
|
res |= (conversion_status &&
|
||||||
|
(port == TCPUDPService::cast(obj)->getDstRangeStart()));
|
||||||
|
res |= (conversion_status &&
|
||||||
|
(port == TCPUDPService::cast(obj)->getDstRangeEnd()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -304,14 +308,12 @@ loop:
|
|||||||
if (FWReference::cast(o)!=NULL)
|
if (FWReference::cast(o)!=NULL)
|
||||||
{
|
{
|
||||||
FWReference *r=FWReference::cast(o);
|
FWReference *r=FWReference::cast(o);
|
||||||
if (
|
if (matchAttr( r->getPointer() ) &&
|
||||||
matchAttr( r->getPointer() ) &&
|
matchID( r->getPointer()->getId() )) break;
|
||||||
matchID( QString::fromUtf8(r->getPointer()->getId().c_str()) )) break;
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
if (
|
if (matchAttr( o ) &&
|
||||||
matchAttr( o ) &&
|
matchID( o->getId() )) break;
|
||||||
matchID( QString::fromUtf8(o->getId().c_str()) )) break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +354,9 @@ loop:
|
|||||||
if (fwbdebug)
|
if (fwbdebug)
|
||||||
{
|
{
|
||||||
qDebug("Found object: o=%p id=%s name=%s type=%s",
|
qDebug("Found object: o=%p id=%s name=%s type=%s",
|
||||||
o, o->getId().c_str(),o->getName().c_str(),o->getTypeName().c_str());
|
o,
|
||||||
|
FWObjectDatabase::getStringId(o->getId()).c_str(),
|
||||||
|
o->getName().c_str(),o->getTypeName().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,14 +451,12 @@ void FindObjectWidget::replaceAll()
|
|||||||
if (FWReference::cast(o)!=NULL)
|
if (FWReference::cast(o)!=NULL)
|
||||||
{
|
{
|
||||||
FWReference *r=FWReference::cast(o);
|
FWReference *r=FWReference::cast(o);
|
||||||
if (
|
if (matchAttr( r->getPointer() ) &&
|
||||||
matchAttr( r->getPointer() ) &&
|
matchID( r->getPointer()->getId() )) break;
|
||||||
matchID( QString::fromUtf8(r->getPointer()->getId().c_str()) )) break;
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
if (
|
if (matchAttr( o ) &&
|
||||||
matchAttr( o ) &&
|
matchID( o->getId() )) break;
|
||||||
matchID( QString::fromUtf8(o->getId().c_str()) )) break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (treeSeeker==mw->db()->tree_end())
|
if (treeSeeker==mw->db()->tree_end())
|
||||||
@@ -492,7 +494,7 @@ FWObject* FindObjectWidget::_replaceCurrent()
|
|||||||
if (RuleElement::cast(p)==NULL || !RuleElement::cast(p)->isAny())
|
if (RuleElement::cast(p)==NULL || !RuleElement::cast(p)->isAny())
|
||||||
{
|
{
|
||||||
/* avoid duplicates */
|
/* avoid duplicates */
|
||||||
string cp_id=ro->getId();
|
int cp_id = ro->getId();
|
||||||
FWObject *oo;
|
FWObject *oo;
|
||||||
FWReference *ref;
|
FWReference *ref;
|
||||||
|
|
||||||
@@ -511,7 +513,7 @@ FWObject* FindObjectWidget::_replaceCurrent()
|
|||||||
FWObject *to;
|
FWObject *to;
|
||||||
FWReference *ref;
|
FWReference *ref;
|
||||||
list<FWObject*>::iterator i;
|
list<FWObject*>::iterator i;
|
||||||
string id=m_widget->replaceDropArea->getObject()->getId();
|
int id = m_widget->replaceDropArea->getObject()->getId();
|
||||||
for (i=p->begin();i!=p->end();++i)
|
for (i=p->begin();i!=p->end();++i)
|
||||||
{
|
{
|
||||||
to=*i;
|
to=*i;
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class FindObjectWidget : public QWidget
|
|||||||
libfwbuilder::Firewall* selectedFirewall;
|
libfwbuilder::Firewall* selectedFirewall;
|
||||||
|
|
||||||
bool matchName(const QString &name);
|
bool matchName(const QString &name);
|
||||||
bool matchID(const QString &name);
|
bool matchID(int id);
|
||||||
bool matchAttr(libfwbuilder::FWObject* obj);
|
bool matchAttr(libfwbuilder::FWObject* obj);
|
||||||
bool validateReplaceObject();
|
bool validateReplaceObject();
|
||||||
libfwbuilder::FWObject* _replaceCurrent();
|
libfwbuilder::FWObject* _replaceCurrent();
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ void FirewallDialog::validate(bool *res)
|
|||||||
if (!validateName(this,obj,m_dialog->obj_name->text())) { *res=false; return; }
|
if (!validateName(this,obj,m_dialog->obj_name->text())) { *res=false; return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
void FirewallDialog::isChanged(bool *res)
|
void FirewallDialog::isChanged(bool*)
|
||||||
{
|
{
|
||||||
if (fwbdebug)
|
if (fwbdebug)
|
||||||
qDebug("FirewallDialog::isChanged");
|
qDebug("FirewallDialog::isChanged");
|
||||||
|
|||||||
@@ -263,12 +263,12 @@ void GroupObjectDialog::insertObject(FWObject *o)
|
|||||||
o->getName().c_str(), g->getName().c_str());
|
o->getName().c_str(), g->getName().c_str());
|
||||||
|
|
||||||
/* avoid duplicates */
|
/* avoid duplicates */
|
||||||
string cp_id=o->getId();
|
int cp_id = o->getId();
|
||||||
|
|
||||||
map<string, ObjectListViewItem*>::iterator i;
|
map<int, ObjectListViewItem*>::iterator i;
|
||||||
for (i=allListViewItems.begin(); i!=allListViewItems.end(); ++i)
|
for (i=allListViewItems.begin(); i!=allListViewItems.end(); ++i)
|
||||||
{
|
{
|
||||||
string go=(*i).first;
|
int go = (*i).first;
|
||||||
//if (FWReference::cast(go)!=NULL) go=FWReference::cast(go)->getPointer();
|
//if (FWReference::cast(go)!=NULL) go=FWReference::cast(go)->getPointer();
|
||||||
//if (o==go || o->getId()==go->getId()) return;
|
//if (o==go || o->getId()==go->getId()) return;
|
||||||
if(go==cp_id) return;
|
if(go==cp_id) return;
|
||||||
@@ -312,7 +312,7 @@ void GroupObjectDialog::addIcon(FWObject *o,bool ref)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ObjectIconViewItem *ivitm = new ObjectIconViewItem(iconView,obj_name,pm );
|
ObjectIconViewItem *ivitm = new ObjectIconViewItem(iconView,obj_name,pm );
|
||||||
ivitm->setProperty("id", o->getId().c_str() );
|
//ivitm->setProperty("id", o->getId().c_str() );
|
||||||
ivitm->setProperty("type", o->getTypeName().c_str() );
|
ivitm->setProperty("type", o->getTypeName().c_str() );
|
||||||
ivitm->setFWObject( o );
|
ivitm->setFWObject( o );
|
||||||
|
|
||||||
@@ -325,7 +325,7 @@ void GroupObjectDialog::addIcon(FWObject *o,bool ref)
|
|||||||
tvitm->setText( 1, FWObjectPropertiesFactory::getObjectProperties(o) );
|
tvitm->setText( 1, FWObjectPropertiesFactory::getObjectProperties(o) );
|
||||||
tvitm->setIcon( 0, QIcon(pm) );
|
tvitm->setIcon( 0, QIcon(pm) );
|
||||||
|
|
||||||
tvitm->setProperty("id", o->getId().c_str() );
|
//tvitm->setProperty("id", o->getId().c_str() );
|
||||||
tvitm->setProperty("type", o->getTypeName().c_str() );
|
tvitm->setProperty("type", o->getTypeName().c_str() );
|
||||||
tvitm->setFWObject( o );
|
tvitm->setFWObject( o );
|
||||||
|
|
||||||
@@ -428,7 +428,7 @@ void GroupObjectDialog::applyChanges()
|
|||||||
|
|
||||||
set<FWObject*> oldobj;
|
set<FWObject*> oldobj;
|
||||||
set<FWObject*> newobj;
|
set<FWObject*> newobj;
|
||||||
map<string, ObjectListViewItem*>::iterator i;
|
map<int, ObjectListViewItem*>::iterator i;
|
||||||
for (i=allListViewItems.begin(); i!=allListViewItems.end(); ++i)
|
for (i=allListViewItems.begin(); i!=allListViewItems.end(); ++i)
|
||||||
{
|
{
|
||||||
newobj.insert( mw->db()->findInIndex((*i).first) );
|
newobj.insert( mw->db()->findInIndex((*i).first) );
|
||||||
@@ -647,7 +647,7 @@ void GroupObjectDialog::cutObj()
|
|||||||
|
|
||||||
void GroupObjectDialog::pasteObj()
|
void GroupObjectDialog::pasteObj()
|
||||||
{
|
{
|
||||||
vector<string>::iterator i;
|
vector<int>::iterator i;
|
||||||
|
|
||||||
for (i= FWObjectClipboard::obj_clipboard->begin();
|
for (i= FWObjectClipboard::obj_clipboard->begin();
|
||||||
i!=FWObjectClipboard::obj_clipboard->end(); ++i)
|
i!=FWObjectClipboard::obj_clipboard->end(); ++i)
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ class GroupObjectDialog : public QWidget
|
|||||||
std::vector<libfwbuilder::FWObject*> selectedObjects;
|
std::vector<libfwbuilder::FWObject*> selectedObjects;
|
||||||
|
|
||||||
libfwbuilder::FWObject *selectedObject;
|
libfwbuilder::FWObject *selectedObject;
|
||||||
std::map<std::string, ObjectIconViewItem*> allIconViewItems;
|
std::map<int, ObjectIconViewItem*> allIconViewItems;
|
||||||
std::map<std::string, ObjectListViewItem*> allListViewItems;
|
std::map<int, ObjectListViewItem*> allListViewItems;
|
||||||
|
|
||||||
bool init;
|
bool init;
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ void HostDialog::validate(bool *res)
|
|||||||
if (!validateName(this,obj,m_dialog->obj_name->text())) { *res=false; return; }
|
if (!validateName(this,obj,m_dialog->obj_name->text())) { *res=false; return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostDialog::isChanged(bool *res)
|
void HostDialog::isChanged(bool*)
|
||||||
{
|
{
|
||||||
//*res=(!init && apply->isEnabled());
|
//*res=(!init && apply->isEnabled());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ void IPv4Dialog::validate(bool *res)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPv4Dialog::isChanged(bool *res)
|
void IPv4Dialog::isChanged(bool *)
|
||||||
{
|
{
|
||||||
//*res=(!init && apply->isEnabled());
|
//*res=(!init && apply->isEnabled());
|
||||||
|
|
||||||
|
|||||||
@@ -587,10 +587,11 @@ FWObject* Importer::getTCPService(int srs, int sre,
|
|||||||
|
|
||||||
TCPService* s = TCPService::cast(
|
TCPService* s = TCPService::cast(
|
||||||
createObject(TCPService::TYPENAME, nstr.str()));
|
createObject(TCPService::TYPENAME, nstr.str()));
|
||||||
s->setInt("src_range_start", srs);
|
s->setSrcRangeStart(srs);
|
||||||
s->setInt("src_range_end", sre);
|
s->setSrcRangeEnd(sre);
|
||||||
s->setInt("dst_range_start", drs);
|
s->setDstRangeStart(drs);
|
||||||
s->setInt("dst_range_end", dre);
|
s->setDstRangeEnd(dre);
|
||||||
|
|
||||||
|
|
||||||
if (!flags_mask.empty() && !flags_comp.empty())
|
if (!flags_mask.empty() && !flags_comp.empty())
|
||||||
{
|
{
|
||||||
@@ -652,10 +653,10 @@ FWObject* Importer::getUDPService(int srs, int sre, int drs, int dre)
|
|||||||
<< srs << "-" << sre << ":" << drs << "-" << dre;
|
<< srs << "-" << sre << ":" << drs << "-" << dre;
|
||||||
|
|
||||||
UDPService* s = UDPService::cast(createObject(UDPService::TYPENAME, nstr.str()));
|
UDPService* s = UDPService::cast(createObject(UDPService::TYPENAME, nstr.str()));
|
||||||
s->setInt("src_range_start", srs);
|
s->setSrcRangeStart(srs);
|
||||||
s->setInt("src_range_end", sre);
|
s->setSrcRangeEnd(sre);
|
||||||
s->setInt("dst_range_start", drs);
|
s->setDstRangeStart(drs);
|
||||||
s->setInt("dst_range_end", dre);
|
s->setDstRangeEnd(dre);
|
||||||
|
|
||||||
s->setComment(cstr.str());
|
s->setComment(cstr.str());
|
||||||
all_objects[sstr.str()] = s;
|
all_objects[sstr.str()] = s;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ InterfaceData::InterfaceData(const libfwbuilder::Interface &iface)
|
|||||||
networkZone = iface.getStr("network_zone");
|
networkZone = iface.getStr("network_zone");
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterfaceData::guessLabel(const string &platform)
|
void InterfaceData::guessLabel(const string&)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* some firewalls report fairly regular names for interfaces through
|
* some firewalls report fairly regular names for interfaces through
|
||||||
@@ -88,7 +88,7 @@ void InterfaceData::guessLabel(const string &platform)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void InterfaceData::guessSecurityLevel(const string &platform)
|
void InterfaceData::guessSecurityLevel(const string&)
|
||||||
{
|
{
|
||||||
InetAddrMask n10(InetAddr("10.0.0.0"), InetAddr("255.0.0.0"));
|
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 n172(InetAddr("172.16.0.0"), InetAddr("255.240.0.0"));
|
||||||
|
|||||||
+16
-13
@@ -163,8 +163,8 @@ void InterfaceDialog::loadFWObject(FWObject *o)
|
|||||||
|
|
||||||
int n=0;
|
int n=0;
|
||||||
|
|
||||||
netzoneObjectIDs["sysid0"]=n;
|
netzoneObjectIDs[FWObjectDatabase::ANY_ADDRESS_ID] = n;
|
||||||
netzoneObjectNos[n]="sysid0";
|
netzoneObjectNos[n] = FWObjectDatabase::ANY_ADDRESS_ID;
|
||||||
netzoneObjectNames.push_back(" Any ");
|
netzoneObjectNames.push_back(" Any ");
|
||||||
|
|
||||||
++n;
|
++n;
|
||||||
@@ -177,7 +177,7 @@ void InterfaceDialog::loadFWObject(FWObject *o)
|
|||||||
FWObject *library= *l;
|
FWObject *library= *l;
|
||||||
FWObject *o1,*o2;
|
FWObject *o1,*o2;
|
||||||
|
|
||||||
if ( library->getId()==DELETED_LIB ) continue;
|
if ( library->getId()==FWObjectDatabase::DELETED_OBJECTS_ID ) continue;
|
||||||
|
|
||||||
o1=library->findObjectByName(ObjectGroup::TYPENAME,"Objects");
|
o1=library->findObjectByName(ObjectGroup::TYPENAME,"Objects");
|
||||||
assert(o1!=NULL);
|
assert(o1!=NULL);
|
||||||
@@ -185,15 +185,15 @@ void InterfaceDialog::loadFWObject(FWObject *o)
|
|||||||
if (o2==NULL)
|
if (o2==NULL)
|
||||||
{
|
{
|
||||||
if (fwbdebug)
|
if (fwbdebug)
|
||||||
qDebug("InterfaceDialog::loadFWObject missing Groups group in %s",o1->getId().c_str());
|
qDebug("InterfaceDialog::loadFWObject missing Groups group in %s", FWObjectDatabase::getStringId(o1->getId()).c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// assert(o2!=NULL);
|
// assert(o2!=NULL);
|
||||||
|
|
||||||
for (FWObject::iterator i=o2->begin(); i!=o2->end(); ++i)
|
for (FWObject::iterator i=o2->begin(); i!=o2->end(); ++i)
|
||||||
{
|
{
|
||||||
netzoneObjectIDs[ (*i)->getId().c_str() ]=n;
|
netzoneObjectIDs[(*i)->getId()] = n;
|
||||||
netzoneObjectNos[n]= (*i)->getId().c_str();
|
netzoneObjectNos[n] =(*i)->getId();
|
||||||
netzoneObjectNames.push_back(
|
netzoneObjectNames.push_back(
|
||||||
tr("Group: ")+ (*i)->getName().c_str() );
|
tr("Group: ")+ (*i)->getName().c_str() );
|
||||||
++n;
|
++n;
|
||||||
@@ -203,15 +203,16 @@ void InterfaceDialog::loadFWObject(FWObject *o)
|
|||||||
if (o2==NULL)
|
if (o2==NULL)
|
||||||
{
|
{
|
||||||
if (fwbdebug)
|
if (fwbdebug)
|
||||||
qDebug("InterfaceDialog::loadFWObject missing Networks group in %s",o1->getId().c_str());
|
qDebug("InterfaceDialog::loadFWObject missing Networks group in %s",
|
||||||
|
FWObjectDatabase::getStringId(o1->getId()).c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// assert(o2!=NULL);
|
// assert(o2!=NULL);
|
||||||
|
|
||||||
for (FWObject::iterator i1=o2->begin(); i1!=o2->end(); ++i1)
|
for (FWObject::iterator i1=o2->begin(); i1!=o2->end(); ++i1)
|
||||||
{
|
{
|
||||||
netzoneObjectIDs[ (*i1)->getId().c_str() ]=n;
|
netzoneObjectIDs[(*i1)->getId()] = n;
|
||||||
netzoneObjectNos[n]= (*i1)->getId().c_str();
|
netzoneObjectNos[n] = (*i1)->getId();
|
||||||
netzoneObjectNames.push_back(
|
netzoneObjectNames.push_back(
|
||||||
tr("Network: ")+ (*i1)->getName().c_str() );
|
tr("Network: ")+ (*i1)->getName().c_str() );
|
||||||
++n;
|
++n;
|
||||||
@@ -221,8 +222,8 @@ void InterfaceDialog::loadFWObject(FWObject *o)
|
|||||||
m_dialog->netzone->clear();
|
m_dialog->netzone->clear();
|
||||||
m_dialog->netzone->addItems( netzoneObjectNames );
|
m_dialog->netzone->addItems( netzoneObjectNames );
|
||||||
|
|
||||||
QString id=obj->getStr("network_zone").c_str();
|
int id = FWObjectDatabase::getIntId(obj->getStr("network_zone"));
|
||||||
if (id=="") id="sysid0"; // any network
|
if (id==-1) id = FWObjectDatabase::ANY_ADDRESS_ID; // any network
|
||||||
m_dialog->netzone->setCurrentIndex( netzoneObjectIDs[id] );
|
m_dialog->netzone->setCurrentIndex( netzoneObjectIDs[id] );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -290,7 +291,7 @@ void InterfaceDialog::validate(bool *res)
|
|||||||
if (!validateName(this,obj,m_dialog->obj_name->text())) *res=false;
|
if (!validateName(this,obj,m_dialog->obj_name->text())) *res=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterfaceDialog::isChanged(bool *res)
|
void InterfaceDialog::isChanged(bool*)
|
||||||
{
|
{
|
||||||
//*res=(!init && apply->isEnabled());
|
//*res=(!init && apply->isEnabled());
|
||||||
}
|
}
|
||||||
@@ -342,7 +343,9 @@ void InterfaceDialog::applyChanges()
|
|||||||
|
|
||||||
if (supports_network_zones)
|
if (supports_network_zones)
|
||||||
obj->setStr("network_zone",
|
obj->setStr("network_zone",
|
||||||
netzoneObjectNos[ m_dialog->netzone->currentIndex() ].toLatin1().constData() );
|
FWObjectDatabase::getStringId(
|
||||||
|
netzoneObjectNos[
|
||||||
|
m_dialog->netzone->currentIndex() ]));
|
||||||
|
|
||||||
s->setManagement( m_dialog->management->isChecked() );
|
s->setManagement( m_dialog->management->isChecked() );
|
||||||
|
|
||||||
|
|||||||
@@ -43,8 +43,12 @@ class InterfaceDialog : public QWidget
|
|||||||
|
|
||||||
libfwbuilder::FWObject *obj;
|
libfwbuilder::FWObject *obj;
|
||||||
bool init;
|
bool init;
|
||||||
QMap<QString,int> netzoneObjectIDs;
|
|
||||||
QMap<int,QString> netzoneObjectNos;
|
// netzoneObjectIDs : key - object id, value - number in the list
|
||||||
|
QMap<int,int> netzoneObjectIDs;
|
||||||
|
|
||||||
|
// netzoneObjectNos : key - number in the list, value - obj id
|
||||||
|
QMap<int,int> netzoneObjectNos;
|
||||||
|
|
||||||
Ui::InterfaceDialog_q *m_dialog;
|
Ui::InterfaceDialog_q *m_dialog;
|
||||||
ProjectPanel *m_project;
|
ProjectPanel *m_project;
|
||||||
|
|||||||
@@ -80,7 +80,8 @@ void LibraryDialog::loadFWObject(FWObject *o)
|
|||||||
m_dialog->obj_name->setText( QString::fromUtf8(s->getName().c_str()) );
|
m_dialog->obj_name->setText( QString::fromUtf8(s->getName().c_str()) );
|
||||||
m_dialog->comment->setText( QString::fromUtf8(s->getComment().c_str()) );
|
m_dialog->comment->setText( QString::fromUtf8(s->getComment().c_str()) );
|
||||||
|
|
||||||
m_dialog->obj_name->setEnabled( obj->getId() != "syslib000" );
|
m_dialog->obj_name->setEnabled(
|
||||||
|
obj->getId() != FWObjectDatabase::STANDARD_LIB_ID);
|
||||||
// apply->setEnabled( obj->getId() != "syslib000" );
|
// apply->setEnabled( obj->getId() != "syslib000" );
|
||||||
// comment->setEnabled( !m_project->isSystem(obj) );
|
// comment->setEnabled( !m_project->isSystem(obj) );
|
||||||
|
|
||||||
@@ -124,7 +125,8 @@ void LibraryDialog::applyChanges()
|
|||||||
obj->setStr("color", color.toLatin1().constData());
|
obj->setStr("color", color.toLatin1().constData());
|
||||||
|
|
||||||
/* just for fool-proof'ness, do not allow changing name of the 'Standard' lib */
|
/* just for fool-proof'ness, do not allow changing name of the 'Standard' lib */
|
||||||
if (oldname!=obj->getName() && obj->getId()=="syslib000")
|
if (oldname!=obj->getName() &&
|
||||||
|
obj->getId()==FWObjectDatabase::STANDARD_LIB_ID)
|
||||||
{
|
{
|
||||||
obj->setName( oldname );
|
obj->setName( oldname );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,8 +107,10 @@ int ObjConflictResolutionDialog::run( FWObject *o1,
|
|||||||
|
|
||||||
QString p1, p2;
|
QString p1, p2;
|
||||||
|
|
||||||
FWObject *delObjLib1 = o1->getRoot()->getById( DELETED_LIB );
|
FWObject *delObjLib1 = o1->getRoot()->getById(
|
||||||
FWObject *delObjLib2 = o2->getRoot()->getById( DELETED_LIB );
|
FWObjectDatabase::DELETED_OBJECTS_ID );
|
||||||
|
FWObject *delObjLib2 = o2->getRoot()->getById(
|
||||||
|
FWObjectDatabase::DELETED_OBJECTS_ID );
|
||||||
|
|
||||||
if (delObjLib1!=NULL && o1->isChildOf(delObjLib1))
|
if (delObjLib1!=NULL && o1->isChildOf(delObjLib1))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -561,7 +561,7 @@ void ObjectEditor::selectObject(FWObject *o)
|
|||||||
((GroupObjectDialog *) dialogs[ visible ])->selectObject(o);
|
((GroupObjectDialog *) dialogs[ visible ])->selectObject(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectEditor::selectionChanged(FWObject *o)
|
void ObjectEditor::selectionChanged(FWObject*)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
if (visible==-1) return;
|
if (visible==-1) return;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ using namespace libfwbuilder;
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
ObjectIconView::ObjectIconView(QWidget* parent, const char * name, Qt::WindowFlags f) :
|
ObjectIconView::ObjectIconView(QWidget* parent, const char*, Qt::WindowFlags) :
|
||||||
QListWidget(parent)
|
QListWidget(parent)
|
||||||
{
|
{
|
||||||
//setWindowFlags(f);
|
//setWindowFlags(f);
|
||||||
|
|||||||
@@ -42,14 +42,14 @@ class ObjectIconViewItem : public QListWidgetItem {
|
|||||||
|
|
||||||
libfwbuilder::FWObject *objptr;
|
libfwbuilder::FWObject *objptr;
|
||||||
QMap<QString, QString> props;
|
QMap<QString, QString> props;
|
||||||
std::string ID;
|
int ID;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ObjectIconViewItem(QListWidget *parent) : QListWidgetItem(parent) {
|
ObjectIconViewItem(QListWidget *parent) : QListWidgetItem(parent) {
|
||||||
objptr=NULL;
|
objptr=NULL;
|
||||||
// setDropEnabled(false);
|
// setDropEnabled(false);
|
||||||
ID="";
|
ID=-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectIconViewItem(QListWidget *parent, const QString &text, const QPixmap &icon ) : QListWidgetItem(parent)
|
ObjectIconViewItem(QListWidget *parent, const QString &text, const QPixmap &icon ) : QListWidgetItem(parent)
|
||||||
@@ -58,11 +58,11 @@ class ObjectIconViewItem : public QListWidgetItem {
|
|||||||
setText(text);
|
setText(text);
|
||||||
setIcon(QIcon(icon));
|
setIcon(QIcon(icon));
|
||||||
// setDropEnabled(false);
|
// setDropEnabled(false);
|
||||||
ID="";
|
ID=-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
libfwbuilder::FWObject *getFWObject() { return mw->db()->getById(ID,true); }
|
libfwbuilder::FWObject *getFWObject() { return mw->db()->getById(ID,true); }
|
||||||
std::string getFWObjectID() {return ID; }
|
int getFWObjectID() {return ID; }
|
||||||
void setFWObject(libfwbuilder::FWObject *obj) {ID=obj->getId(); }
|
void setFWObject(libfwbuilder::FWObject *obj) {ID=obj->getId(); }
|
||||||
|
|
||||||
QString getProperty(const QString &name) { return props[name]; }
|
QString getProperty(const QString &name) { return props[name]; }
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ using namespace libfwbuilder;
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
ObjectListView::ObjectListView(QWidget* parent, const char * name, Qt::WindowFlags f) :
|
ObjectListView::ObjectListView(QWidget* parent, const char*,
|
||||||
|
Qt::WindowFlags f) :
|
||||||
QTreeWidget(parent)
|
QTreeWidget(parent)
|
||||||
{
|
{
|
||||||
setWindowFlags(f);
|
setWindowFlags(f);
|
||||||
|
|||||||
@@ -44,22 +44,22 @@ class ObjectListViewItem : public QTreeWidgetItem {
|
|||||||
libfwbuilder::FWObject *objptr;
|
libfwbuilder::FWObject *objptr;
|
||||||
QMap<QString, QString> props;
|
QMap<QString, QString> props;
|
||||||
QString lib;
|
QString lib;
|
||||||
std::string ID;
|
int ID;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ObjectListViewItem(QTreeWidget *parent) : QTreeWidgetItem(parent) {
|
ObjectListViewItem(QTreeWidget *parent) : QTreeWidgetItem(parent) {
|
||||||
objptr=NULL;
|
objptr=NULL;
|
||||||
ID="";
|
ID=-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectListViewItem(QTreeWidgetItem *parent) : QTreeWidgetItem(parent){
|
ObjectListViewItem(QTreeWidgetItem *parent) : QTreeWidgetItem(parent){
|
||||||
objptr=NULL;
|
objptr=NULL;
|
||||||
ID="";
|
ID=-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
libfwbuilder::FWObject *getFWObject() {return mw->db()->getById(ID,true); }
|
libfwbuilder::FWObject *getFWObject() {return mw->db()->getById(ID,true); }
|
||||||
std::string getFWObjectID() {return ID; }
|
int getFWObjectID() {return ID; }
|
||||||
void setFWObject(libfwbuilder::FWObject *obj) { ID=obj->getId(); }
|
void setFWObject(libfwbuilder::FWObject *obj) { ID=obj->getId(); }
|
||||||
|
|
||||||
ObjectTreeView* getTree();
|
ObjectTreeView* getTree();
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ ObjectTreeViewItem* ObjectManipulator::insertObject( ObjectTreeViewItem *itm,
|
|||||||
nitm->setIcon( 1, QIcon(pm) );
|
nitm->setIcon( 1, QIcon(pm) );
|
||||||
nitm->setFlags(nitm->flags() | Qt::ItemIsDragEnabled);
|
nitm->setFlags(nitm->flags() | Qt::ItemIsDragEnabled);
|
||||||
|
|
||||||
nitm->setProperty("id", obj->getId().c_str() );
|
//nitm->setProperty("id", obj->getId().c_str() );
|
||||||
nitm->setProperty("type", obj->getTypeName().c_str() );
|
nitm->setProperty("type", obj->getTypeName().c_str() );
|
||||||
nitm->setFWObject( obj );
|
nitm->setFWObject( obj );
|
||||||
|
|
||||||
@@ -349,7 +349,8 @@ void ObjectManipulator::showDeletedObjects(bool f)
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FWObject *dobj = m_project->db()->findInIndex( FWObjectDatabase::getDeletedObjectsId());
|
FWObject *dobj = m_project->db()->findInIndex(
|
||||||
|
FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||||
|
|
||||||
if (fwbdebug)
|
if (fwbdebug)
|
||||||
qDebug("ObjectManipulator::showDeletedObjects f=%d dobj=%p",f, dobj);
|
qDebug("ObjectManipulator::showDeletedObjects f=%d dobj=%p",f, dobj);
|
||||||
@@ -357,7 +358,7 @@ void ObjectManipulator::showDeletedObjects(bool f)
|
|||||||
if (dobj==NULL)
|
if (dobj==NULL)
|
||||||
{
|
{
|
||||||
dobj=m_project->db()->create(Library::TYPENAME);
|
dobj=m_project->db()->create(Library::TYPENAME);
|
||||||
dobj->setId(m_project->db()->getDeletedObjectsId());
|
dobj->setId(FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||||
dobj->setName("Deleted Objects");
|
dobj->setName("Deleted Objects");
|
||||||
dobj->setReadOnly(false);
|
dobj->setReadOnly(false);
|
||||||
m_project->db()->add(dobj);
|
m_project->db()->add(dobj);
|
||||||
@@ -721,13 +722,15 @@ void ObjectManipulator::loadObjects(FWObjectDatabase *)
|
|||||||
|
|
||||||
if (fwbdebug)
|
if (fwbdebug)
|
||||||
qDebug("ObjectManipulator::loadObjects lib %p %s %s",
|
qDebug("ObjectManipulator::loadObjects lib %p %s %s",
|
||||||
lib, lib->getId().c_str(), lib->getName().c_str() );
|
lib,
|
||||||
|
FWObjectDatabase::getStringId(lib->getId()).c_str(),
|
||||||
|
lib->getName().c_str() );
|
||||||
|
|
||||||
if ( lib->getId()==DELETED_LIB &&
|
if ( lib->getId()==FWObjectDatabase::DELETED_OBJECTS_ID &&
|
||||||
! st->getBool("UI/ShowDeletedObjects")) continue;
|
! st->getBool("UI/ShowDeletedObjects")) continue;
|
||||||
|
|
||||||
if ( lib->getId()!=STANDARD_LIB &&
|
if ( lib->getId()!=FWObjectDatabase::STANDARD_LIB_ID &&
|
||||||
lib->getId()!=TEMPLATE_LIB &&
|
lib->getId()!=FWObjectDatabase::TEMPLATE_LIB_ID &&
|
||||||
firstUserLib==NULL) firstUserLib=*i;
|
firstUserLib==NULL) firstUserLib=*i;
|
||||||
|
|
||||||
addTreePage( lib );
|
addTreePage( lib );
|
||||||
@@ -858,7 +861,7 @@ void ObjectManipulator::addTreePage( FWObject *lib)
|
|||||||
itm1->setIcon( 0, pm);
|
itm1->setIcon( 0, pm);
|
||||||
}
|
}
|
||||||
|
|
||||||
itm1->setProperty("id", lib->getId().c_str() );
|
//itm1->setProperty("id", lib->getId().c_str() );
|
||||||
itm1->setProperty("type", lib->getTypeName().c_str() );
|
itm1->setProperty("type", lib->getTypeName().c_str() );
|
||||||
itm1->setFWObject( lib );
|
itm1->setFWObject( lib );
|
||||||
allItems[lib] = itm1;
|
allItems[lib] = itm1;
|
||||||
@@ -1001,9 +1004,9 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
|
|||||||
*/
|
*/
|
||||||
if (lib==cl) continue;
|
if (lib==cl) continue;
|
||||||
|
|
||||||
if ( lib->getId()==STANDARD_LIB ||
|
if ( lib->getId()==FWObjectDatabase::STANDARD_LIB_ID ||
|
||||||
lib->getId()==TEMPLATE_LIB ||
|
lib->getId()==FWObjectDatabase::TEMPLATE_LIB_ID ||
|
||||||
lib->getId()==DELETED_LIB ||
|
lib->getId()==FWObjectDatabase::DELETED_OBJECTS_ID ||
|
||||||
lib->isReadOnly())
|
lib->isReadOnly())
|
||||||
continue;
|
continue;
|
||||||
QAction* dact=duptargets->addAction(
|
QAction* dact=duptargets->addAction(
|
||||||
@@ -1255,7 +1258,7 @@ void ObjectManipulator::getMenuState(bool haveMoveTargets,
|
|||||||
inDeletedObjects = false;
|
inDeletedObjects = false;
|
||||||
|
|
||||||
FWObject *delObjLib =
|
FWObject *delObjLib =
|
||||||
m_project->db()->findInIndex( FWObjectDatabase::getDeletedObjectsId());
|
m_project->db()->findInIndex( FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||||
|
|
||||||
vector<FWObject*> so = getCurrentObjectTree()->getSelectedObjects();
|
vector<FWObject*> so = getCurrentObjectTree()->getSelectedObjects();
|
||||||
for (vector<FWObject*>::iterator i=so.begin(); i!=so.end(); ++i)
|
for (vector<FWObject*>::iterator i=so.begin(); i!=so.end(); ++i)
|
||||||
@@ -1275,7 +1278,7 @@ void ObjectManipulator::getMenuState(bool haveMoveTargets,
|
|||||||
/*
|
/*
|
||||||
* enable Paste menu item only if object can be pasted
|
* enable Paste menu item only if object can be pasted
|
||||||
*/
|
*/
|
||||||
vector<string>::iterator i;
|
vector<int>::iterator i;
|
||||||
for (i= FWObjectClipboard::obj_clipboard->begin();
|
for (i= FWObjectClipboard::obj_clipboard->begin();
|
||||||
i!=FWObjectClipboard::obj_clipboard->end(); ++i)
|
i!=FWObjectClipboard::obj_clipboard->end(); ++i)
|
||||||
{
|
{
|
||||||
@@ -1531,7 +1534,7 @@ void ObjectManipulator::moveObject(FWObject *targetLib, FWObject *obj)
|
|||||||
FWObject *cl=pom->getCurrentLib();
|
FWObject *cl=pom->getCurrentLib();
|
||||||
if (cl==targetLib) return;
|
if (cl==targetLib) return;
|
||||||
|
|
||||||
// bool inDeletedObjects = (obj->getParent()->getId()==FWObjectDatabase::getDeletedObjectsId());
|
// bool inDeletedObjects = (obj->getParent()->getId()==FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||||
|
|
||||||
// QString parentType;
|
// QString parentType;
|
||||||
// QString parentName;
|
// QString parentName;
|
||||||
@@ -1713,7 +1716,7 @@ void ObjectManipulator::pasteObj()
|
|||||||
if (pom->getCurrentObjectTree()->getNumSelected()==0) return;
|
if (pom->getCurrentObjectTree()->getNumSelected()==0) return;
|
||||||
FWObject *obj=pom->getCurrentObjectTree()->getSelectedObjects().front();
|
FWObject *obj=pom->getCurrentObjectTree()->getSelectedObjects().front();
|
||||||
if (obj==NULL) return;
|
if (obj==NULL) return;
|
||||||
vector<string>::iterator i;
|
vector<int>::iterator i;
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for (i= FWObjectClipboard::obj_clipboard->begin();
|
for (i= FWObjectClipboard::obj_clipboard->begin();
|
||||||
i!=FWObjectClipboard::obj_clipboard->end(); ++i)
|
i!=FWObjectClipboard::obj_clipboard->end(); ++i)
|
||||||
@@ -1722,7 +1725,7 @@ void ObjectManipulator::pasteObj()
|
|||||||
FWObjectClipboard::obj_clipboard->getObjectByIdx(idx);
|
FWObjectClipboard::obj_clipboard->getObjectByIdx(idx);
|
||||||
if (Interface::isA(co) && Firewall::isA(obj))
|
if (Interface::isA(co) && Firewall::isA(obj))
|
||||||
{
|
{
|
||||||
FWObject *no = pasteTo (obj, co, false, false, true);
|
pasteTo (obj, co, false, false, true);
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
pom->copyObjWithDeep(co);
|
pom->copyObjWithDeep(co);
|
||||||
@@ -1799,7 +1802,7 @@ FWObject* ObjectManipulator::pasteTo(FWObject *target, FWObject *obj,
|
|||||||
if (validateOnly) return obj;
|
if (validateOnly) return obj;
|
||||||
|
|
||||||
/* check for duplicates. We just won't add an object if it is already there */
|
/* check for duplicates. We just won't add an object if it is already there */
|
||||||
string cp_id=obj->getId();
|
int cp_id = obj->getId();
|
||||||
list<FWObject*>::iterator j;
|
list<FWObject*>::iterator j;
|
||||||
for(j=grp->begin(); j!=grp->end(); ++j)
|
for(j=grp->begin(); j!=grp->end(); ++j)
|
||||||
{
|
{
|
||||||
@@ -1856,7 +1859,7 @@ void ObjectManipulator::lockObject()
|
|||||||
FWObject *lib = obj->getLibrary();
|
FWObject *lib = obj->getLibrary();
|
||||||
// these lbraries are locked anyway, do not let the user
|
// these lbraries are locked anyway, do not let the user
|
||||||
// lock objects inside because they won't be able to unlock them.
|
// lock objects inside because they won't be able to unlock them.
|
||||||
if (lib->getId()!=STANDARD_LIB && lib->getId()!=TEMPLATE_LIB)
|
if (lib->getId()!=FWObjectDatabase::STANDARD_LIB_ID && lib->getId()!=FWObjectDatabase::TEMPLATE_LIB_ID)
|
||||||
obj->setReadOnly(true);
|
obj->setReadOnly(true);
|
||||||
}
|
}
|
||||||
pom->getCurrentObjectTree()->setLockFlags();
|
pom->getCurrentObjectTree()->setLockFlags();
|
||||||
@@ -1884,7 +1887,7 @@ void ObjectManipulator::unlockObject()
|
|||||||
{
|
{
|
||||||
obj= *i;
|
obj= *i;
|
||||||
FWObject *lib = obj->getLibrary();
|
FWObject *lib = obj->getLibrary();
|
||||||
if (lib->getId()!=STANDARD_LIB && lib->getId()!=TEMPLATE_LIB)
|
if (lib->getId()!=FWObjectDatabase::STANDARD_LIB_ID && lib->getId()!=FWObjectDatabase::TEMPLATE_LIB_ID)
|
||||||
obj->setReadOnly(false);
|
obj->setReadOnly(false);
|
||||||
}
|
}
|
||||||
pom->getCurrentObjectTree()->setLockFlags();
|
pom->getCurrentObjectTree()->setLockFlags();
|
||||||
@@ -1905,7 +1908,7 @@ void ObjectManipulator::deleteObj()
|
|||||||
bool emptyingTrash = false;
|
bool emptyingTrash = false;
|
||||||
bool emptyingTrashInLib = false;
|
bool emptyingTrashInLib = false;
|
||||||
|
|
||||||
FWObject *delObjLib = m_project->db()->findInIndex(FWObjectDatabase::getDeletedObjectsId());
|
FWObject *delObjLib = m_project->db()->findInIndex(FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||||
if (fwbdebug)
|
if (fwbdebug)
|
||||||
qDebug("ObjectManipulator::deleteObj delObjLib=%p",delObjLib);
|
qDebug("ObjectManipulator::deleteObj delObjLib=%p",delObjLib);
|
||||||
|
|
||||||
@@ -2052,7 +2055,7 @@ void ObjectManipulator::delObj(FWObject *obj,bool openobj)
|
|||||||
obj,obj->getName().c_str(),openobj);
|
obj,obj->getName().c_str(),openobj);
|
||||||
|
|
||||||
FWObject *parent=obj->getParent();
|
FWObject *parent=obj->getParent();
|
||||||
FWObject *delObjLib = m_project->db()->findInIndex( DELETED_LIB );
|
FWObject *delObjLib = m_project->db()->findInIndex( FWObjectDatabase::DELETED_OBJECTS_ID );
|
||||||
|
|
||||||
if (fwbdebug)
|
if (fwbdebug)
|
||||||
qDebug("ObjectManipulator::delObj deleted obj lib %p",
|
qDebug("ObjectManipulator::delObj deleted obj lib %p",
|
||||||
@@ -2067,13 +2070,13 @@ void ObjectManipulator::delObj(FWObject *obj,bool openobj)
|
|||||||
for (int i = 0 ; i < oms.size(); i++)
|
for (int i = 0 ; i < oms.size(); i++)
|
||||||
{
|
{
|
||||||
ObjectManipulator* pom = oms[i] ;
|
ObjectManipulator* pom = oms[i] ;
|
||||||
if (obj->getId()==STANDARD_LIB || obj->getId()==DELETED_LIB) return;
|
if (obj->getId()==FWObjectDatabase::STANDARD_LIB_ID || obj->getId()==FWObjectDatabase::DELETED_OBJECTS_ID) return;
|
||||||
|
|
||||||
pom->m_project->findObjectWidget->reset();
|
pom->m_project->findObjectWidget->reset();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!islib && !isDelObj && obj->getId()!=TEMPLATE_LIB)
|
if (!islib && !isDelObj && obj->getId()!=FWObjectDatabase::TEMPLATE_LIB_ID)
|
||||||
pom->updateLastModifiedTimestampForAllFirewalls(obj);
|
pom->updateLastModifiedTimestampForAllFirewalls(obj);
|
||||||
|
|
||||||
if (fwbdebug)
|
if (fwbdebug)
|
||||||
@@ -2112,7 +2115,7 @@ void ObjectManipulator::delObj(FWObject *obj,bool openobj)
|
|||||||
if (islib && obj->isReadOnly()) obj->setReadOnly(false);
|
if (islib && obj->isReadOnly()) obj->setReadOnly(false);
|
||||||
// if (firstAction)
|
// if (firstAction)
|
||||||
// {
|
// {
|
||||||
if (obj->getId()==TEMPLATE_LIB) // special case
|
if (obj->getId()==FWObjectDatabase::TEMPLATE_LIB_ID) // special case
|
||||||
{
|
{
|
||||||
if (fwbdebug)
|
if (fwbdebug)
|
||||||
qDebug("ObjectManipulator::delObj: "
|
qDebug("ObjectManipulator::delObj: "
|
||||||
@@ -2410,7 +2413,7 @@ void ObjectManipulator::selectionChanged(QTreeWidgetItem *cur)
|
|||||||
if (history.empty() || otvi!=history.top().item() )
|
if (history.empty() || otvi!=history.top().item() )
|
||||||
{
|
{
|
||||||
mw->m_mainWindow->backAction->setEnabled( true );
|
mw->m_mainWindow->backAction->setEnabled( true );
|
||||||
history.push( HistoryItem(otvi,o->getId().c_str()) );
|
history.push( HistoryItem(otvi, o->getId()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
currentObj = obj;
|
currentObj = obj;
|
||||||
@@ -2508,9 +2511,9 @@ void ObjectManipulator::libChanged(int ln)
|
|||||||
void ObjectManipulator::updateCreateObjectMenu(FWObject* lib)
|
void ObjectManipulator::updateCreateObjectMenu(FWObject* lib)
|
||||||
{
|
{
|
||||||
bool f =
|
bool f =
|
||||||
lib->getId()==STANDARD_LIB ||
|
lib->getId()==FWObjectDatabase::STANDARD_LIB_ID ||
|
||||||
lib->getId()==TEMPLATE_LIB ||
|
lib->getId()==FWObjectDatabase::TEMPLATE_LIB_ID ||
|
||||||
lib->getId()==DELETED_LIB ||
|
lib->getId()==FWObjectDatabase::DELETED_OBJECTS_ID ||
|
||||||
lib->isReadOnly();
|
lib->isReadOnly();
|
||||||
|
|
||||||
m_objectManipulator->newButton->setEnabled( !f );
|
m_objectManipulator->newButton->setEnabled( !f );
|
||||||
@@ -2529,7 +2532,7 @@ void ObjectManipulator::back()
|
|||||||
/* skip objects that have been deleted */
|
/* skip objects that have been deleted */
|
||||||
while ( ! history.empty())
|
while ( ! history.empty())
|
||||||
{
|
{
|
||||||
if (m_project->db()->findInIndex( history.top().id().toLatin1().constData() )!=NULL) break;
|
if (m_project->db()->findInIndex( history.top().id() )!=NULL) break;
|
||||||
history.pop();
|
history.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2584,15 +2587,17 @@ FWObject* ObjectManipulator::createObject(const QString &objType,
|
|||||||
|
|
||||||
if (fwbdebug)
|
if (fwbdebug)
|
||||||
{
|
{
|
||||||
qDebug("lib: %s %s",lib->getName().c_str(), lib->getId().c_str());
|
qDebug("lib: %s %s",
|
||||||
|
lib->getName().c_str(),
|
||||||
|
FWObjectDatabase::getStringId(lib->getId()).c_str());
|
||||||
qDebug("lib: isReadOnly=%d isLoaded=%d",
|
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() ) );
|
||||||
qDebug("libs->count()=%d", m_objectManipulator->libs->count() );
|
qDebug("libs->count()=%d", m_objectManipulator->libs->count() );
|
||||||
}
|
}
|
||||||
|
|
||||||
while ( lib->getId()==STANDARD_LIB ||
|
while ( lib->getId()==FWObjectDatabase::STANDARD_LIB_ID ||
|
||||||
lib->getId()==TEMPLATE_LIB ||
|
lib->getId()==FWObjectDatabase::TEMPLATE_LIB_ID ||
|
||||||
lib->getId()==DELETED_LIB ||
|
lib->getId()==FWObjectDatabase::DELETED_OBJECTS_ID ||
|
||||||
lib->isReadOnly() )
|
lib->isReadOnly() )
|
||||||
{
|
{
|
||||||
if (i>=m_objectManipulator->libs->count())
|
if (i>=m_objectManipulator->libs->count())
|
||||||
@@ -2609,7 +2614,9 @@ FWObject* ObjectManipulator::createObject(const QString &objType,
|
|||||||
if (fwbdebug)
|
if (fwbdebug)
|
||||||
{
|
{
|
||||||
qDebug("i=%d",i);
|
qDebug("i=%d",i);
|
||||||
qDebug("lib: %s %s",lib->getName().c_str(), lib->getId().c_str());
|
qDebug("lib: %s %s",
|
||||||
|
lib->getName().c_str(),
|
||||||
|
FWObjectDatabase::getStringId(lib->getId()).c_str());
|
||||||
qDebug("lib: isReadOnly=%d isLoaded=%d",
|
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() ) );
|
||||||
}
|
}
|
||||||
@@ -2657,9 +2664,9 @@ FWObject* ObjectManipulator::createObject(FWObject *parent,
|
|||||||
objType.toLatin1().constData(), objName.toLatin1().constData());
|
objType.toLatin1().constData(), objName.toLatin1().constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
while ( lib->getId()==STANDARD_LIB ||
|
while ( lib->getId()==FWObjectDatabase::STANDARD_LIB_ID ||
|
||||||
lib->getId()==TEMPLATE_LIB ||
|
lib->getId()==FWObjectDatabase::TEMPLATE_LIB_ID ||
|
||||||
lib->getId()==DELETED_LIB ||
|
lib->getId()==FWObjectDatabase::DELETED_OBJECTS_ID ||
|
||||||
lib->isReadOnly() )
|
lib->isReadOnly() )
|
||||||
{
|
{
|
||||||
if (i >= m_objectManipulator->libs->count())
|
if (i >= m_objectManipulator->libs->count())
|
||||||
@@ -2678,8 +2685,9 @@ FWObject* ObjectManipulator::createObject(FWObject *parent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FWObject* ObjectManipulator::copyObj2Tree(const QString &/*objType*/, const QString &/*objName*/,
|
FWObject* ObjectManipulator::copyObj2Tree(
|
||||||
libfwbuilder::FWObject *copyFrom, FWObject *parent, bool /*askLib*/)
|
const QString &/*objType*/, const QString &/*objName*/,
|
||||||
|
FWObject *copyFrom, FWObject *parent, bool /*askLib*/)
|
||||||
{
|
{
|
||||||
if (!validateDialog()) return NULL;
|
if (!validateDialog()) return NULL;
|
||||||
ids.clear();
|
ids.clear();
|
||||||
@@ -2691,22 +2699,21 @@ FWObject* ObjectManipulator::copyObj2Tree(const QString &/*objType*/, const QStr
|
|||||||
return copyObjWithDeep(copyFrom);
|
return copyObjWithDeep(copyFrom);
|
||||||
}
|
}
|
||||||
|
|
||||||
libfwbuilder::FWObject * ObjectManipulator::copyObjWithDeep(libfwbuilder::FWObject *copyFrom)
|
FWObject * ObjectManipulator::copyObjWithDeep(FWObject *copyFrom)
|
||||||
{
|
{
|
||||||
|
if (copyFrom==NULL) return NULL;
|
||||||
|
|
||||||
if (copyFrom==NULL)
|
|
||||||
return NULL;
|
|
||||||
FWObject *nobj= copyFrom;
|
FWObject *nobj= copyFrom;
|
||||||
if (nobj->getId()!="")
|
if (nobj->getId() > -1)
|
||||||
{
|
{
|
||||||
if (ids.contains(nobj->getId().c_str()))
|
if (ids.contains(nobj->getId()))
|
||||||
{
|
{
|
||||||
|
|
||||||
return nobj;
|
return nobj;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ids.insert(nobj->getId().c_str());
|
ids.insert(nobj->getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//nobj->duplicate(copyFrom,false);
|
//nobj->duplicate(copyFrom,false);
|
||||||
|
|||||||
@@ -59,13 +59,13 @@ namespace libfwbuilder
|
|||||||
|
|
||||||
class HistoryItem {
|
class HistoryItem {
|
||||||
ObjectTreeViewItem *itm;
|
ObjectTreeViewItem *itm;
|
||||||
QString objId;
|
int objId;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HistoryItem(ObjectTreeViewItem *oi,const QString &id) { itm=oi; objId=id; }
|
HistoryItem(ObjectTreeViewItem *oi, int id) { itm=oi; objId=id; }
|
||||||
~HistoryItem();
|
~HistoryItem();
|
||||||
ObjectTreeViewItem* item() { return itm; }
|
ObjectTreeViewItem* item() { return itm; }
|
||||||
QString id() { return objId; }
|
int id() { return objId; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/*class ObjToolTip : public QToolTip {
|
/*class ObjToolTip : public QToolTip {
|
||||||
@@ -83,7 +83,7 @@ class ObjectManipulator : public QWidget/*ObjectManipulator_q*/ {
|
|||||||
|
|
||||||
std::vector<libfwbuilder::FWObject*> idxToLibs;
|
std::vector<libfwbuilder::FWObject*> idxToLibs;
|
||||||
std::vector<QTreeWidget*> idxToTrees;
|
std::vector<QTreeWidget*> idxToTrees;
|
||||||
QSet <QString> ids ;
|
QSet<int> ids ;
|
||||||
std::stack<HistoryItem> history;
|
std::stack<HistoryItem> history;
|
||||||
int cacheHits;
|
int cacheHits;
|
||||||
|
|
||||||
|
|||||||
@@ -512,13 +512,15 @@ void ObjectTreeView::dropEvent(QDropEvent *ev)
|
|||||||
if (otvsource!=NULL)
|
if (otvsource!=NULL)
|
||||||
{
|
{
|
||||||
FWObjectDatabase* root = otvsource->getCurrentObject()->getRoot();
|
FWObjectDatabase* root = otvsource->getCurrentObject()->getRoot();
|
||||||
QString id = dragobj->getId().c_str();
|
int id = dragobj->getId();
|
||||||
FWObject * item = root->getById(id.toAscii().data(),true);
|
FWObject * item = root->getById(id, true);
|
||||||
qDebug(item->getId().c_str());
|
if (fwbdebug)
|
||||||
|
{
|
||||||
|
qDebug("%d", item->getId());
|
||||||
qDebug(item->getTypeName().c_str());
|
qDebug(item->getTypeName().c_str());
|
||||||
qDebug(dragobj->getId().c_str());
|
qDebug("%d", dragobj->getId());
|
||||||
qDebug(dragobj->getTypeName().c_str());
|
qDebug(dragobj->getTypeName().c_str());
|
||||||
|
}
|
||||||
//ProjectPanel * ppsource = otvsource->m_project ;
|
//ProjectPanel * ppsource = otvsource->m_project ;
|
||||||
}
|
}
|
||||||
QString n=QString::fromUtf8(dragobj->getName().c_str());
|
QString n=QString::fromUtf8(dragobj->getName().c_str());
|
||||||
@@ -819,7 +821,8 @@ void ObjectTreeView::setLockFlags()
|
|||||||
FWObject *lib = otvi->getFWObject()->getLibrary();
|
FWObject *lib = otvi->getFWObject()->getLibrary();
|
||||||
// these lbraries are locked anyway, do not let the user
|
// these lbraries are locked anyway, do not let the user
|
||||||
// lock objects inside because they won't be able to unlock them.
|
// lock objects inside because they won't be able to unlock them.
|
||||||
if (lib->getId()!=STANDARD_LIB && lib->getId()!=TEMPLATE_LIB)
|
if (lib->getId()!=FWObjectDatabase::STANDARD_LIB_ID &&
|
||||||
|
lib->getId()!=FWObjectDatabase::TEMPLATE_LIB_ID)
|
||||||
{
|
{
|
||||||
if (otvi->getFWObject()->getBool("ro")) Unlockable=true;
|
if (otvi->getFWObject()->getBool("ro")) Unlockable=true;
|
||||||
else Lockable=true;
|
else Lockable=true;
|
||||||
|
|||||||
@@ -92,8 +92,5 @@ bool ObjectTreeViewItem::operator< ( const QTreeWidgetItem & other ) const
|
|||||||
{
|
{
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
if (rank1<rank2)
|
|
||||||
{
|
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ void PhysicalAddressDialog::validate(bool *res)
|
|||||||
if (!validateName(this,obj,m_dialog->obj_name->text())) { *res=false; return; }
|
if (!validateName(this,obj,m_dialog->obj_name->text())) { *res=false; return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicalAddressDialog::isChanged(bool *res)
|
void PhysicalAddressDialog::isChanged(bool *)
|
||||||
{
|
{
|
||||||
//*res=(!init && apply->isEnabled());
|
//*res=(!init && apply->isEnabled());
|
||||||
}
|
}
|
||||||
|
|||||||
+42
-32
@@ -312,8 +312,8 @@ void ProjectPanel::findIntersectRefs(FWObject *lib,
|
|||||||
if (ref!=NULL)
|
if (ref!=NULL)
|
||||||
{
|
{
|
||||||
FWObject *plib = ref->getPointer()->getLibrary();
|
FWObject *plib = ref->getPointer()->getLibrary();
|
||||||
if ( plib->getId()!=STANDARD_LIB &&
|
if ( plib->getId()!=FWObjectDatabase::STANDARD_LIB_ID &&
|
||||||
plib->getId()!=DELETED_LIB &&
|
plib->getId()!=FWObjectDatabase::DELETED_OBJECTS_ID &&
|
||||||
plib!=lib )
|
plib!=lib )
|
||||||
{
|
{
|
||||||
FWObject* ptr=ref->getPointer();
|
FWObject* ptr=ref->getPointer();
|
||||||
@@ -392,7 +392,7 @@ void ProjectPanel::findIntersectRefs(FWObject *lib,
|
|||||||
|
|
||||||
|
|
||||||
void ProjectPanel::restoreDepends(FWObject *obj_old, FWObject *obj,
|
void ProjectPanel::restoreDepends(FWObject *obj_old, FWObject *obj,
|
||||||
const std::map<const std::string, FWObject *> &objByIds)
|
const std::map<int, FWObject *> &objByIds)
|
||||||
{
|
{
|
||||||
Firewall *fw = Firewall::cast(obj);
|
Firewall *fw = Firewall::cast(obj);
|
||||||
Firewall *fw_old = Firewall::cast(obj_old);
|
Firewall *fw_old = Firewall::cast(obj_old);
|
||||||
@@ -405,7 +405,7 @@ void ProjectPanel::restoreDepends(FWObject *obj_old, FWObject *obj,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ProjectPanel::restorePolicyRefs(Policy *pol, Policy *pol_old,
|
void ProjectPanel::restorePolicyRefs(Policy *pol, Policy *pol_old,
|
||||||
const std::map<const std::string, FWObject *> &objByIds)
|
const std::map<int, FWObject *> &objByIds)
|
||||||
{
|
{
|
||||||
if (!pol || !pol_old)
|
if (!pol || !pol_old)
|
||||||
return;
|
return;
|
||||||
@@ -420,7 +420,7 @@ void ProjectPanel::restorePolicyRefs(Policy *pol, Policy *pol_old,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ProjectPanel::restorePolicyRuleRefs(PolicyRule *rule, PolicyRule *rule_old,
|
void ProjectPanel::restorePolicyRuleRefs(PolicyRule *rule, PolicyRule *rule_old,
|
||||||
const std::map<const std::string, FWObject *> &objByIds)
|
const std::map<int, FWObject *> &objByIds)
|
||||||
{
|
{
|
||||||
if (!rule || !rule_old) return;
|
if (!rule || !rule_old) return;
|
||||||
for (int col =0; col < 5; col++)
|
for (int col =0; col < 5; col++)
|
||||||
@@ -433,7 +433,7 @@ void ProjectPanel::restorePolicyRuleRefs(PolicyRule *rule, PolicyRule *rule_old,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ProjectPanel::restoreRERefs(RuleElement *re_new, RuleElement *re_old,
|
void ProjectPanel::restoreRERefs(RuleElement *re_new, RuleElement *re_old,
|
||||||
const std::map<const std::string, FWObject *> &objByIds)
|
const std::map<int, FWObject *> &objByIds)
|
||||||
{
|
{
|
||||||
if (!re_new || ! re_old) return;
|
if (!re_new || ! re_old) return;
|
||||||
while((re_new->begin() != re_new->end()) &&
|
while((re_new->begin() != re_new->end()) &&
|
||||||
@@ -449,7 +449,7 @@ void ProjectPanel::restoreRERefs(RuleElement *re_new, RuleElement *re_old,
|
|||||||
//qDebug("o_old->getId() = (%s)", o_old->getId().c_str());//).toAscii().constData());// !!!!!
|
//qDebug("o_old->getId() = (%s)", o_old->getId().c_str());//).toAscii().constData());// !!!!!
|
||||||
//for (std::map<const std::string, FWObject *>::const_iterator i = objByIds.begin(); i != objByIds.end(); i++)
|
//for (std::map<const std::string, FWObject *>::const_iterator i = objByIds.begin(); i != objByIds.end(); i++)
|
||||||
//qDebug("i->first.c_str() = (%s)", i->first.c_str());// !!!!!
|
//qDebug("i->first.c_str() = (%s)", i->first.c_str());// !!!!!
|
||||||
std::map<const std::string, FWObject *>::const_iterator it = objByIds.find(o_old->getId());
|
std::map<int, FWObject *>::const_iterator it = objByIds.find(o_old->getId());
|
||||||
if (objByIds.end() != it)
|
if (objByIds.end() != it)
|
||||||
{
|
{
|
||||||
FWObject *o = it->second;
|
FWObject *o = it->second;
|
||||||
@@ -1978,12 +1978,14 @@ void ProjectPanel::startupLoad()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString id = st->getStr("UI/visibleFirewall");
|
QString id = st->getStr("UI/visibleFirewall");
|
||||||
|
int i_id = FWObjectDatabase::getIntId(id.toLatin1().constData());
|
||||||
FWObject *show_fw=NULL;
|
FWObject *show_fw=NULL;
|
||||||
if ( !id.isEmpty() ) show_fw = db()->getById(id.toLatin1().constData(),true);
|
if ( !id.isEmpty() ) show_fw = db()->getById(i_id, true);
|
||||||
|
|
||||||
id = st->getStr("UI/visibleObject");
|
id = st->getStr("UI/visibleObject");
|
||||||
|
i_id = FWObjectDatabase::getIntId(id.toLatin1().constData());
|
||||||
FWObject *show_obj=NULL;
|
FWObject *show_obj=NULL;
|
||||||
if ( !id.isEmpty() ) show_obj = db()->getById(id.toLatin1().constData(),true);
|
if ( !id.isEmpty() ) show_obj = db()->getById(i_id, true);
|
||||||
|
|
||||||
showFirewalls( show_fw==NULL );
|
showFirewalls( show_fw==NULL );
|
||||||
|
|
||||||
@@ -2078,7 +2080,7 @@ void ProjectPanel::load(QWidget *dialogs_parent)
|
|||||||
FWObjectDatabase *ndb = new FWObjectDatabase();
|
FWObjectDatabase *ndb = new FWObjectDatabase();
|
||||||
ndb->load(libfname, &upgrade_predicate,librespath);
|
ndb->load(libfname, &upgrade_predicate,librespath);
|
||||||
FWObject *dobj =
|
FWObject *dobj =
|
||||||
ndb->findInIndex( FWObjectDatabase::getDeletedObjectsId());
|
ndb->findInIndex( FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||||
if (dobj) ndb->remove(dobj, false);
|
if (dobj) ndb->remove(dobj, false);
|
||||||
|
|
||||||
MergeConflictRes mcr(dlgp);
|
MergeConflictRes mcr(dlgp);
|
||||||
@@ -2274,7 +2276,8 @@ void ProjectPanel::load(QWidget *dialogs_parent,RCS *_rcs,libfwbuilder::FWObject
|
|||||||
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
|
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
|
||||||
{
|
{
|
||||||
qDebug("* Library %s %s in the data file",
|
qDebug("* Library %s %s in the data file",
|
||||||
(*i)->getId().c_str(),(*i)->getName().c_str() );
|
FWObjectDatabase::getStringId((*i)->getId()).c_str(),
|
||||||
|
(*i)->getName().c_str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2285,7 +2288,7 @@ void ProjectPanel::load(QWidget *dialogs_parent,RCS *_rcs,libfwbuilder::FWObject
|
|||||||
*
|
*
|
||||||
* However, if I am editing standard library, it should not be read-only.
|
* However, if I am editing standard library, it should not be read-only.
|
||||||
*/
|
*/
|
||||||
FWObject *slib = objdb->findInIndex("syslib000");
|
FWObject *slib = objdb->findInIndex(FWObjectDatabase::STANDARD_LIB_ID);
|
||||||
if (fwbdebug)
|
if (fwbdebug)
|
||||||
qDebug("standard library read-only status: %d, editingStandardLib: %d",
|
qDebug("standard library read-only status: %d, editingStandardLib: %d",
|
||||||
slib->isReadOnly(), editingStandardLib);
|
slib->isReadOnly(), editingStandardLib);
|
||||||
@@ -2528,7 +2531,8 @@ void ProjectPanel::load(QWidget *dialogs_parent,RCS *_rcs)
|
|||||||
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
|
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
|
||||||
{
|
{
|
||||||
qDebug("* Found library %s %s in the data file",
|
qDebug("* Found library %s %s in the data file",
|
||||||
(*i)->getId().c_str(),(*i)->getName().c_str() );
|
FWObjectDatabase::getStringId((*i)->getId()).c_str(),
|
||||||
|
(*i)->getName().c_str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2538,8 +2542,10 @@ void ProjectPanel::load(QWidget *dialogs_parent,RCS *_rcs)
|
|||||||
list<FWObject*> ll = ndb->getByType(Library::TYPENAME);
|
list<FWObject*> ll = ndb->getByType(Library::TYPENAME);
|
||||||
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
|
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
|
||||||
{
|
{
|
||||||
if ((*i)->getId()==STANDARD_LIB) editingStandardLib=true;
|
if ((*i)->getId()==FWObjectDatabase::STANDARD_LIB_ID)
|
||||||
if ((*i)->getId()==TEMPLATE_LIB) editingTemplateLib=true;
|
editingStandardLib=true;
|
||||||
|
if ((*i)->getId()==FWObjectDatabase::TEMPLATE_LIB_ID)
|
||||||
|
editingTemplateLib=true;
|
||||||
(*i)->setReadOnly( false );
|
(*i)->setReadOnly( false );
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@@ -2563,9 +2569,9 @@ void ProjectPanel::load(QWidget *dialogs_parent,RCS *_rcs)
|
|||||||
libfname.c_str());
|
libfname.c_str());
|
||||||
assert(nlib1!=NULL);
|
assert(nlib1!=NULL);
|
||||||
}
|
}
|
||||||
string nlib1ID = nlib1->getId();
|
int nlib1ID = nlib1->getId();
|
||||||
FWObject *dobj =
|
FWObject *dobj =
|
||||||
ndb1->findInIndex(FWObjectDatabase::getDeletedObjectsId());
|
ndb1->findInIndex(FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||||
if (dobj) ndb1->remove(dobj, false);
|
if (dobj) ndb1->remove(dobj, false);
|
||||||
|
|
||||||
MergeConflictRes mcr(dlgp);
|
MergeConflictRes mcr(dlgp);
|
||||||
@@ -2609,7 +2615,8 @@ void ProjectPanel::load(QWidget *dialogs_parent,RCS *_rcs)
|
|||||||
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
|
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
|
||||||
{
|
{
|
||||||
qDebug("* Library %s %s in the data file",
|
qDebug("* Library %s %s in the data file",
|
||||||
(*i)->getId().c_str(),(*i)->getName().c_str() );
|
FWObjectDatabase::getStringId((*i)->getId()).c_str(),
|
||||||
|
(*i)->getName().c_str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2620,12 +2627,15 @@ void ProjectPanel::load(QWidget *dialogs_parent,RCS *_rcs)
|
|||||||
*
|
*
|
||||||
* However, if I am editing standard library, it should not be read-only.
|
* However, if I am editing standard library, it should not be read-only.
|
||||||
*/
|
*/
|
||||||
FWObject *slib = objdb->findInIndex("syslib000");
|
FWObject *slib = objdb->findInIndex(FWObjectDatabase::STANDARD_LIB_ID);
|
||||||
|
if (slib!=NULL )
|
||||||
|
{
|
||||||
if (fwbdebug)
|
if (fwbdebug)
|
||||||
qDebug("standard library read-only status: %d, editingStandardLib: %d",
|
qDebug("standard library read-only status: %d, editingStandardLib: %d",
|
||||||
slib->isReadOnly(), editingStandardLib);
|
slib->isReadOnly(), editingStandardLib);
|
||||||
|
|
||||||
if (slib!=NULL ) slib->setReadOnly(! editingStandardLib);
|
slib->setReadOnly(! editingStandardLib);
|
||||||
|
}
|
||||||
|
|
||||||
/* if the file name has an old extension .xml, change it to .fwb and
|
/* if the file name has an old extension .xml, change it to .fwb and
|
||||||
* warn the user
|
* warn the user
|
||||||
@@ -2869,9 +2879,9 @@ void ProjectPanel::save()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* skip standard and template libraries unless we edit them */
|
/* skip standard and template libraries unless we edit them */
|
||||||
QString s=(*i)->getId().c_str();
|
int id = (*i)->getId();
|
||||||
if (s==STANDARD_LIB && !editingStandardLib) continue;
|
if (id==FWObjectDatabase::STANDARD_LIB_ID && !editingStandardLib) continue;
|
||||||
if (s==TEMPLATE_LIB && !editingTemplateLib) continue;
|
if (id==FWObjectDatabase::TEMPLATE_LIB_ID && !editingTemplateLib) continue;
|
||||||
|
|
||||||
if (fwbdebug) qDebug(" add");
|
if (fwbdebug) qDebug(" add");
|
||||||
userLibs.push_back( *i );
|
userLibs.push_back( *i );
|
||||||
@@ -2886,8 +2896,8 @@ void ProjectPanel::save()
|
|||||||
/* exported libraries are always read-only */
|
/* exported libraries are always read-only */
|
||||||
list<FWObject*> ll = ndb->getByType(Library::TYPENAME);
|
list<FWObject*> ll = ndb->getByType(Library::TYPENAME);
|
||||||
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
|
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
|
||||||
if ((*i)->getId()!=STANDARD_LIB &&
|
if ((*i)->getId()!=FWObjectDatabase::STANDARD_LIB_ID &&
|
||||||
(*i)->getId()!=DELETED_LIB) (*i)->setReadOnly( true );
|
(*i)->getId()!=FWObjectDatabase::DELETED_OBJECTS_ID) (*i)->setReadOnly( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
ndb->resetTimeLastModified( db()->getTimeLastModified() );
|
ndb->resetTimeLastModified( db()->getTimeLastModified() );
|
||||||
@@ -2938,7 +2948,7 @@ void ProjectPanel::loadLibrary(const string &libfpath)
|
|||||||
FWObjectDatabase *ndb = new FWObjectDatabase();
|
FWObjectDatabase *ndb = new FWObjectDatabase();
|
||||||
ndb->load(libfpath, &upgrade_predicate, librespath);
|
ndb->load(libfpath, &upgrade_predicate, librespath);
|
||||||
|
|
||||||
FWObject *dobj = ndb->findInIndex(FWObjectDatabase::getDeletedObjectsId());
|
FWObject *dobj = ndb->findInIndex(FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||||
if (dobj) ndb->remove(dobj, false);
|
if (dobj) ndb->remove(dobj, false);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@@ -3050,7 +3060,7 @@ void ProjectPanel::fileCompare()
|
|||||||
db1 = new FWObjectDatabase();
|
db1 = new FWObjectDatabase();
|
||||||
db1->load(fname1.toLatin1().constData(), &upgrade_predicate, librespath);
|
db1->load(fname1.toLatin1().constData(), &upgrade_predicate, librespath);
|
||||||
|
|
||||||
dobj = db1->findInIndex(FWObjectDatabase::getDeletedObjectsId());
|
dobj = db1->findInIndex(FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||||
if (dobj) db1->remove(dobj, false);
|
if (dobj) db1->remove(dobj, false);
|
||||||
} catch(FWException &ex)
|
} catch(FWException &ex)
|
||||||
{
|
{
|
||||||
@@ -3068,7 +3078,7 @@ void ProjectPanel::fileCompare()
|
|||||||
db2 = new FWObjectDatabase();
|
db2 = new FWObjectDatabase();
|
||||||
db2->load(fname2.toLatin1().constData(), &upgrade_predicate, librespath);
|
db2->load(fname2.toLatin1().constData(), &upgrade_predicate, librespath);
|
||||||
|
|
||||||
dobj = db2->findInIndex(FWObjectDatabase::getDeletedObjectsId());
|
dobj = db2->findInIndex(FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||||
if (dobj) db2->remove(dobj, false);
|
if (dobj) db2->remove(dobj, false);
|
||||||
} catch(FWException &ex)
|
} catch(FWException &ex)
|
||||||
{
|
{
|
||||||
@@ -3162,8 +3172,8 @@ void ProjectPanel::findExternalRefs(FWObject *lib,
|
|||||||
if (ref!=NULL)
|
if (ref!=NULL)
|
||||||
{
|
{
|
||||||
FWObject *plib = ref->getPointer()->getLibrary();
|
FWObject *plib = ref->getPointer()->getLibrary();
|
||||||
if ( plib->getId()!=STANDARD_LIB &&
|
if ( plib->getId()!=FWObjectDatabase::STANDARD_LIB_ID &&
|
||||||
plib->getId()!=DELETED_LIB &&
|
plib->getId()!=FWObjectDatabase::DELETED_OBJECTS_ID &&
|
||||||
plib!=lib )
|
plib!=lib )
|
||||||
extRefs.push_back(ref);
|
extRefs.push_back(ref);
|
||||||
return;
|
return;
|
||||||
@@ -3333,7 +3343,7 @@ void ProjectPanel::exportLibraryTo(QString fname,list<FWObject*> &selectedLibs,
|
|||||||
for (list<FWObject*>::iterator i=selectedLibs.begin(); i!=selectedLibs.end(); ++i)
|
for (list<FWObject*>::iterator i=selectedLibs.begin(); i!=selectedLibs.end(); ++i)
|
||||||
{
|
{
|
||||||
FWObject *nlib= ndb->findInIndex( (*i)->getId() );
|
FWObject *nlib= ndb->findInIndex( (*i)->getId() );
|
||||||
if (nlib && nlib->getId()!=DELETED_LIB)
|
if (nlib && nlib->getId()!=FWObjectDatabase::DELETED_OBJECTS_ID)
|
||||||
nlib->setReadOnly( true );
|
nlib->setReadOnly( true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3834,7 +3844,7 @@ void ProjectPanel::loadState (QString filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectPanel::splitterMoved ( int pos, int index )
|
void ProjectPanel::splitterMoved ( int , int )
|
||||||
{
|
{
|
||||||
saveState();
|
saveState();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,13 +103,13 @@ class ProjectPanel: public QWidget {
|
|||||||
const std::list<libfwbuilder::FWObject*> &objList,std::list<libfwbuilder::FWReference*> & refLinfs);
|
const std::list<libfwbuilder::FWObject*> &objList,std::list<libfwbuilder::FWReference*> & refLinfs);
|
||||||
|
|
||||||
void restorePolicyRefs(libfwbuilder::Policy *pol, libfwbuilder::Policy *pol_old,
|
void restorePolicyRefs(libfwbuilder::Policy *pol, libfwbuilder::Policy *pol_old,
|
||||||
const std::map<const std::string, libfwbuilder::FWObject *> &objByIds);
|
const std::map<int, libfwbuilder::FWObject *> &objByIds);
|
||||||
void restorePolicyRuleRefs(libfwbuilder::PolicyRule *rule,
|
void restorePolicyRuleRefs(libfwbuilder::PolicyRule *rule,
|
||||||
libfwbuilder::PolicyRule *rule_old,
|
libfwbuilder::PolicyRule *rule_old,
|
||||||
const std::map<const std::string, libfwbuilder::FWObject *> &objByIds);
|
const std::map<int, libfwbuilder::FWObject *> &objByIds);
|
||||||
void restoreRERefs(libfwbuilder::RuleElement *re_new,
|
void restoreRERefs(libfwbuilder::RuleElement *re_new,
|
||||||
libfwbuilder::RuleElement *re_old,
|
libfwbuilder::RuleElement *re_old,
|
||||||
const std::map<const std::string, libfwbuilder::FWObject *> &objByIds);
|
const std::map<int, libfwbuilder::FWObject *> &objByIds);
|
||||||
public:
|
public:
|
||||||
libfwbuilder::RuleSet* getCurrentRuleSet () {return visibleRuleSet;};
|
libfwbuilder::RuleSet* getCurrentRuleSet () {return visibleRuleSet;};
|
||||||
RuleSetView * getCurrentRuleSetView () ;
|
RuleSetView * getCurrentRuleSetView () ;
|
||||||
@@ -279,7 +279,7 @@ public:
|
|||||||
std::list<libfwbuilder::FWObject*> & objList, std::list<libfwbuilder::FWReference*> & refLinfs,
|
std::list<libfwbuilder::FWObject*> & objList, std::list<libfwbuilder::FWReference*> & refLinfs,
|
||||||
libfwbuilder::FWObject *lib);
|
libfwbuilder::FWObject *lib);
|
||||||
void restoreDepends(libfwbuilder::FWObject *obj_old, libfwbuilder::FWObject *nobj,
|
void restoreDepends(libfwbuilder::FWObject *obj_old, libfwbuilder::FWObject *nobj,
|
||||||
const std::map<const std::string, libfwbuilder::FWObject *> &objByIds);
|
const std::map<int, libfwbuilder::FWObject *> &objByIds);
|
||||||
public slots:
|
public slots:
|
||||||
void newObject();
|
void newObject();
|
||||||
void info();
|
void info();
|
||||||
|
|||||||
+1
-1
@@ -973,7 +973,7 @@ QString RCS::rlog() throw(libfwbuilder::FWException)
|
|||||||
throw( FWException( msg.toLatin1().constData() ) );
|
throw( FWException( msg.toLatin1().constData() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList RCS::rcsdiff(const QString &rev) throw(libfwbuilder::FWException)
|
QStringList RCS::rcsdiff(const QString&) throw(libfwbuilder::FWException)
|
||||||
{
|
{
|
||||||
isDiff();
|
isDiff();
|
||||||
QString temp = stdoutBuffer;
|
QString temp = stdoutBuffer;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
RCSFileDialog::RCSFileDialog( const QString& dirName, const QString& filter,
|
RCSFileDialog::RCSFileDialog( const QString& dirName, const QString& filter,
|
||||||
QWidget* parent, const char* name, bool modal )
|
QWidget* parent, const char* name, bool )
|
||||||
: QFileDialog( parent, name, dirName, filter )
|
: QFileDialog( parent, name, dirName, filter )
|
||||||
{
|
{
|
||||||
if (fwbdebug) qDebug("RCSFileDialog: constructor 1");
|
if (fwbdebug) qDebug("RCSFileDialog: constructor 1");
|
||||||
@@ -68,7 +68,7 @@ RCSFileDialog::RCSFileDialog( const QString& dirName, const QString& filter,
|
|||||||
if (fwbdebug) qDebug("RCSFileDialog: constructor done");
|
if (fwbdebug) qDebug("RCSFileDialog: constructor done");
|
||||||
}
|
}
|
||||||
|
|
||||||
RCSFileDialog::RCSFileDialog( QWidget* parent, const char* name, bool modal )
|
RCSFileDialog::RCSFileDialog( QWidget* parent, const char* , bool )
|
||||||
: QFileDialog(parent, "Open file")// name
|
: QFileDialog(parent, "Open file")// name
|
||||||
{
|
{
|
||||||
if (fwbdebug) qDebug("RCSFileDialog: constructor 2");
|
if (fwbdebug) qDebug("RCSFileDialog: constructor 2");
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace libfwbuilder;
|
using namespace libfwbuilder;
|
||||||
|
|
||||||
int RCSViewItem::compare(QTreeWidgetItem *itm, int col, bool ascending) const
|
int RCSViewItem::compare(QTreeWidgetItem *itm, int col, bool ) const
|
||||||
{
|
{
|
||||||
QString rev1 = text(col);
|
QString rev1 = text(col);
|
||||||
QString rev2 = itm->text(col);
|
QString rev2 = itm->text(col);
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ void RuleSetDialog::validate(bool *res)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RuleSetDialog::isChanged(bool *res)
|
void RuleSetDialog::isChanged(bool *)
|
||||||
{
|
{
|
||||||
//*res=(!init && apply->isEnabled());
|
//*res=(!init && apply->isEnabled());
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -1625,9 +1625,9 @@ void RuleSetView::paintCell(QPainter *pntr,
|
|||||||
|
|
||||||
if ( (!sel) &&
|
if ( (!sel) &&
|
||||||
mwSelObj!= NULL &&
|
mwSelObj!= NULL &&
|
||||||
mwSelObj->getId() != "sysid0" &&
|
mwSelObj->getId() != FWObjectDatabase::ANY_ADDRESS_ID &&
|
||||||
mwSelObj->getId() != "sysid1" &&
|
mwSelObj->getId() != FWObjectDatabase::ANY_SERVICE_ID &&
|
||||||
mwSelObj->getId() != "sysid2" &&
|
mwSelObj->getId() != FWObjectDatabase::ANY_INTERVAL_ID &&
|
||||||
mwSelObj == o1)
|
mwSelObj == o1)
|
||||||
{
|
{
|
||||||
p.setPen(Qt::red);
|
p.setPen(Qt::red);
|
||||||
@@ -2196,7 +2196,7 @@ FWObject* RuleSetView::getSelectedObject()
|
|||||||
|
|
||||||
void RuleSetView::copyRuleContent(Rule *dst, Rule *src)
|
void RuleSetView::copyRuleContent(Rule *dst, Rule *src)
|
||||||
{
|
{
|
||||||
string id=dst->getId();
|
int id = dst->getId();
|
||||||
int p = dst->getPosition();
|
int p = dst->getPosition();
|
||||||
|
|
||||||
if ( src->isDisabled() ) dst->disable();
|
if ( src->isDisabled() ) dst->disable();
|
||||||
@@ -2221,7 +2221,7 @@ void RuleSetView::copyRuleContent(Rule *dst, Rule *src)
|
|||||||
(*j)->duplicate(selem);
|
(*j)->duplicate(selem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id!="") dst->setId(id);
|
if (id > -1) dst->setId(id);
|
||||||
dst->setPosition(p);
|
dst->setPosition(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3343,12 +3343,12 @@ void RuleSetView::deleteObject(int row, int col, FWObject *obj)
|
|||||||
{
|
{
|
||||||
RuleElement *re = getRE(row,col);
|
RuleElement *re = getRE(row,col);
|
||||||
if (re==NULL || re->isAny()) return;
|
if (re==NULL || re->isAny()) return;
|
||||||
string id = obj->getId();
|
int id = obj->getId();
|
||||||
|
|
||||||
if (fwbdebug)
|
if (fwbdebug)
|
||||||
{
|
{
|
||||||
qDebug("RuleSetView::deleteObject row=%d col=%d id=%s",
|
qDebug("RuleSetView::deleteObject row=%d col=%d id=%s",
|
||||||
row,col,id.c_str());
|
row, col, FWObjectDatabase::getStringId(id).c_str());
|
||||||
qDebug("obj = %p", re->getRoot()->findInIndex(id));
|
qDebug("obj = %p", re->getRoot()->findInIndex(id));
|
||||||
int rc = obj->ref()-1; obj->unref();
|
int rc = obj->ref()-1; obj->unref();
|
||||||
qDebug("obj->ref_counter=%d",rc);
|
qDebug("obj->ref_counter=%d",rc);
|
||||||
@@ -3430,7 +3430,7 @@ bool RuleSetView::insertObject(int row, int col, FWObject *obj)
|
|||||||
if (! re->isAny())
|
if (! re->isAny())
|
||||||
{
|
{
|
||||||
/* avoid duplicates */
|
/* avoid duplicates */
|
||||||
string cp_id=obj->getId();
|
int cp_id = obj->getId();
|
||||||
list<FWObject*>::iterator j;
|
list<FWObject*>::iterator j;
|
||||||
for(j=re->begin(); j!=re->end(); ++j)
|
for(j=re->begin(); j!=re->end(); ++j)
|
||||||
{
|
{
|
||||||
@@ -3465,7 +3465,7 @@ void RuleSetView::pasteObject()
|
|||||||
{
|
{
|
||||||
if (!isTreeReadWrite(this,ruleset)) return;
|
if (!isTreeReadWrite(this,ruleset)) return;
|
||||||
|
|
||||||
vector<string>::iterator i;
|
vector<int>::iterator i;
|
||||||
for (i= FWObjectClipboard::obj_clipboard->begin();
|
for (i= FWObjectClipboard::obj_clipboard->begin();
|
||||||
i!=FWObjectClipboard::obj_clipboard->end(); ++i)
|
i!=FWObjectClipboard::obj_clipboard->end(); ++i)
|
||||||
{
|
{
|
||||||
@@ -4204,7 +4204,7 @@ void RuleSetView::pasteRuleAbove()
|
|||||||
if (fwbdebug) qDebug("Firewall: pasteRuleAbove");
|
if (fwbdebug) qDebug("Firewall: pasteRuleAbove");
|
||||||
|
|
||||||
/* pick rules in reverse order */
|
/* pick rules in reverse order */
|
||||||
vector<string>::reverse_iterator i;
|
vector<int>::reverse_iterator i;
|
||||||
for (i= FWObjectClipboard::obj_clipboard->rbegin();
|
for (i= FWObjectClipboard::obj_clipboard->rbegin();
|
||||||
i!=FWObjectClipboard::obj_clipboard->rend(); ++i)
|
i!=FWObjectClipboard::obj_clipboard->rend(); ++i)
|
||||||
{
|
{
|
||||||
@@ -4248,7 +4248,7 @@ void RuleSetView::pasteRuleBelow()
|
|||||||
position = currentRow();
|
position = currentRow();
|
||||||
|
|
||||||
int n=0;
|
int n=0;
|
||||||
vector<string>::iterator i;
|
vector<int>::iterator i;
|
||||||
for (i= FWObjectClipboard::obj_clipboard->begin();
|
for (i= FWObjectClipboard::obj_clipboard->begin();
|
||||||
i!=FWObjectClipboard::obj_clipboard->end(); ++i,++n)
|
i!=FWObjectClipboard::obj_clipboard->end(); ++i,++n)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -74,10 +74,10 @@ void TCPServiceDialog::loadFWObject(FWObject *o)
|
|||||||
init=true;
|
init=true;
|
||||||
|
|
||||||
m_dialog->obj_name->setText( QString::fromUtf8(s->getName().c_str()) );
|
m_dialog->obj_name->setText( QString::fromUtf8(s->getName().c_str()) );
|
||||||
m_dialog->ss->setValue( s->getInt("src_range_start") );
|
m_dialog->ss->setValue( TCPUDPService::cast(s)->getSrcRangeStart() );
|
||||||
m_dialog->se->setValue( s->getInt("src_range_end") );
|
m_dialog->se->setValue( TCPUDPService::cast(s)->getSrcRangeEnd() );
|
||||||
m_dialog->ds->setValue( s->getInt("dst_range_start") );
|
m_dialog->ds->setValue( TCPUDPService::cast(s)->getDstRangeStart() );
|
||||||
m_dialog->de->setValue( s->getInt("dst_range_end") );
|
m_dialog->de->setValue( TCPUDPService::cast(s)->getDstRangeEnd() );
|
||||||
|
|
||||||
m_dialog->urg_m->setChecked( s->getBool("urg_flag_mask") );
|
m_dialog->urg_m->setChecked( s->getBool("urg_flag_mask") );
|
||||||
m_dialog->ack_m->setChecked( s->getBool("ack_flag_mask") );
|
m_dialog->ack_m->setChecked( s->getBool("ack_flag_mask") );
|
||||||
@@ -220,10 +220,11 @@ void TCPServiceDialog::applyChanges()
|
|||||||
if (m_dialog->ss->value()!=0 && m_dialog->se->value()==0) m_dialog->se->setValue( m_dialog->ss->value() );
|
if (m_dialog->ss->value()!=0 && m_dialog->se->value()==0) m_dialog->se->setValue( m_dialog->ss->value() );
|
||||||
if (m_dialog->ds->value()!=0 && m_dialog->de->value()==0) m_dialog->de->setValue( m_dialog->ds->value() );
|
if (m_dialog->ds->value()!=0 && m_dialog->de->value()==0) m_dialog->de->setValue( m_dialog->ds->value() );
|
||||||
|
|
||||||
obj->setInt("src_range_start", m_dialog->ss->value() );
|
|
||||||
obj->setInt("src_range_end", m_dialog->se->value() );
|
TCPUDPService::cast(obj)->setSrcRangeStart(m_dialog->ss->value());
|
||||||
obj->setInt("dst_range_start", m_dialog->ds->value() );
|
TCPUDPService::cast(obj)->setSrcRangeEnd(m_dialog->se->value());
|
||||||
obj->setInt("dst_range_end", m_dialog->de->value() );
|
TCPUDPService::cast(obj)->setDstRangeStart(m_dialog->ds->value());
|
||||||
|
TCPUDPService::cast(obj)->setDstRangeEnd(m_dialog->de->value());
|
||||||
|
|
||||||
obj->setBool("urg_flag_mask", m_dialog->urg_m->isChecked() );
|
obj->setBool("urg_flag_mask", m_dialog->urg_m->isChecked() );
|
||||||
obj->setBool("ack_flag_mask", m_dialog->ack_m->isChecked() );
|
obj->setBool("ack_flag_mask", m_dialog->ack_m->isChecked() );
|
||||||
|
|||||||
@@ -73,10 +73,10 @@ void UDPServiceDialog::loadFWObject(FWObject *o)
|
|||||||
init=true;
|
init=true;
|
||||||
|
|
||||||
m_dialog->obj_name->setText( QString::fromUtf8(s->getName().c_str()) );
|
m_dialog->obj_name->setText( QString::fromUtf8(s->getName().c_str()) );
|
||||||
m_dialog->ss->setValue( s->getInt("src_range_start") );
|
m_dialog->ss->setValue( TCPUDPService::cast(s)->getSrcRangeStart() );
|
||||||
m_dialog->se->setValue( s->getInt("src_range_end") );
|
m_dialog->se->setValue( TCPUDPService::cast(s)->getSrcRangeEnd() );
|
||||||
m_dialog->ds->setValue( s->getInt("dst_range_start") );
|
m_dialog->ds->setValue( TCPUDPService::cast(s)->getDstRangeStart() );
|
||||||
m_dialog->de->setValue( s->getInt("dst_range_end") );
|
m_dialog->de->setValue( TCPUDPService::cast(s)->getDstRangeEnd() );
|
||||||
|
|
||||||
m_dialog->comment->setText( QString::fromUtf8(s->getComment().c_str()) );
|
m_dialog->comment->setText( QString::fromUtf8(s->getComment().c_str()) );
|
||||||
|
|
||||||
@@ -162,10 +162,10 @@ void UDPServiceDialog::applyChanges()
|
|||||||
if (m_dialog->ss->value()!=0 && m_dialog->se->value()==0) m_dialog->se->setValue( m_dialog->ss->value() );
|
if (m_dialog->ss->value()!=0 && m_dialog->se->value()==0) m_dialog->se->setValue( m_dialog->ss->value() );
|
||||||
if (m_dialog->ds->value()!=0 && m_dialog->de->value()==0) m_dialog->de->setValue( m_dialog->ds->value() );
|
if (m_dialog->ds->value()!=0 && m_dialog->de->value()==0) m_dialog->de->setValue( m_dialog->ds->value() );
|
||||||
|
|
||||||
obj->setInt("src_range_start", m_dialog->ss->value() );
|
TCPUDPService::cast(obj)->setSrcRangeStart(m_dialog->ss->value());
|
||||||
obj->setInt("src_range_end", m_dialog->se->value() );
|
TCPUDPService::cast(obj)->setSrcRangeEnd(m_dialog->se->value());
|
||||||
obj->setInt("dst_range_start", m_dialog->ds->value() );
|
TCPUDPService::cast(obj)->setDstRangeStart(m_dialog->ds->value());
|
||||||
obj->setInt("dst_range_end", m_dialog->de->value() );
|
TCPUDPService::cast(obj)->setDstRangeEnd(m_dialog->de->value());
|
||||||
|
|
||||||
mw->updateObjName(obj,QString::fromUtf8(oldname.c_str()));
|
mw->updateObjName(obj,QString::fromUtf8(oldname.c_str()));
|
||||||
|
|
||||||
|
|||||||
+12
-9
@@ -171,21 +171,21 @@ bool findDialog::matchAttr(libfwbuilder::FWObject *obj)
|
|||||||
if (m_dialog->useRegexp->isChecked())
|
if (m_dialog->useRegexp->isChecked())
|
||||||
{
|
{
|
||||||
QString port;
|
QString port;
|
||||||
port.setNum(obj->getInt("src_range_start"));
|
port.setNum(TCPUDPService::cast(obj)->getSrcRangeStart());
|
||||||
res |= ( port.indexOf( QRegExp(s) )!=-1 );
|
res |= ( port.indexOf( QRegExp(s) )!=-1 );
|
||||||
port.setNum(obj->getInt("src_range_end"));
|
port.setNum(TCPUDPService::cast(obj)->getSrcRangeEnd());
|
||||||
res |= ( port.indexOf( QRegExp(s) )!=-1 );
|
res |= ( port.indexOf( QRegExp(s) )!=-1 );
|
||||||
port.setNum(obj->getInt("dst_range_start"));
|
port.setNum(TCPUDPService::cast(obj)->getDstRangeStart());
|
||||||
res |= ( port.indexOf( QRegExp(s) )!=-1 );
|
res |= ( port.indexOf( QRegExp(s) )!=-1 );
|
||||||
port.setNum(obj->getInt("dst_range_end"));
|
port.setNum(TCPUDPService::cast(obj)->getDstRangeEnd());
|
||||||
res |= ( port.indexOf( QRegExp(s) )!=-1 );
|
res |= ( port.indexOf( QRegExp(s) )!=-1 );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
int port = s.toInt();
|
int port = s.toInt();
|
||||||
res |= (port == obj->getInt("src_range_start"));
|
res |= (port == TCPUDPService::cast(obj)->getSrcRangeStart());
|
||||||
res |= (port == obj->getInt("src_range_end"));
|
res |= (port == TCPUDPService::cast(obj)->getSrcRangeEnd());
|
||||||
res |= (port == obj->getInt("dst_range_start"));
|
res |= (port == TCPUDPService::cast(obj)->getDstRangeStart());
|
||||||
res |= (port == obj->getInt("dst_range_end"));
|
res |= (port == TCPUDPService::cast(obj)->getDstRangeEnd());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -302,7 +302,10 @@ loop:
|
|||||||
if (fwbdebug)
|
if (fwbdebug)
|
||||||
{
|
{
|
||||||
qDebug("Found object: o=%p id=%s name=%s type=%s",
|
qDebug("Found object: o=%p id=%s name=%s type=%s",
|
||||||
o, o->getId().c_str(),o->getName().c_str(),o->getTypeName().c_str());
|
o,
|
||||||
|
FWObjectDatabase::getStringId(o->getId()).c_str(),
|
||||||
|
o->getName().c_str(),
|
||||||
|
o->getTypeName().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_project->openObject( o );
|
m_project->openObject( o );
|
||||||
|
|||||||
+4
-4
@@ -54,10 +54,10 @@ extern int fwbdebug;
|
|||||||
extern bool registered;
|
extern bool registered;
|
||||||
extern bool gui_experiment1;
|
extern bool gui_experiment1;
|
||||||
|
|
||||||
#define STANDARD_LIB "syslib000"
|
//#define STANDARD_LIB "syslib000"
|
||||||
#define USER_LIB "syslib001"
|
//#define USER_LIB "syslib001"
|
||||||
#define TEMPLATE_LIB "syslib100"
|
//#define TEMPLATE_LIB "syslib100"
|
||||||
#define DELETED_LIB "sysid99"
|
//#define DELETED_LIB "sysid99"
|
||||||
|
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
|
|||||||
+12
-12
@@ -124,9 +124,9 @@ class findNamePredicate {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class findIdPredicate {
|
class findIdPredicate {
|
||||||
QString p;
|
int p;
|
||||||
public:
|
public:
|
||||||
findIdPredicate(const QString &_p):p(_p){}
|
findIdPredicate(int _p):p(_p){}
|
||||||
bool operator()(const libData &ld) { return ld.id==p; }
|
bool operator()(const libData &ld) { return ld.id==p; }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ Builder GUI and save back to file again."
|
|||||||
list<libData>::iterator listOfLibraries::add(const QString &path, bool load)
|
list<libData>::iterator listOfLibraries::add(const QString &path, bool load)
|
||||||
{
|
{
|
||||||
QString name;
|
QString name;
|
||||||
QString id;
|
int id = -1;
|
||||||
|
|
||||||
if ( ! QFile::exists(path) ) return end();
|
if ( ! QFile::exists(path) ) return end();
|
||||||
|
|
||||||
@@ -172,10 +172,10 @@ list<libData>::iterator listOfLibraries::add(const QString &path, bool load)
|
|||||||
for (list<FWObject*>::iterator i=libs.begin(); i!=libs.end(); i++)
|
for (list<FWObject*>::iterator i=libs.begin(); i!=libs.end(); i++)
|
||||||
{
|
{
|
||||||
name = (*i)->getName().c_str();
|
name = (*i)->getName().c_str();
|
||||||
id = (*i)->getId().c_str();
|
id = (*i)->getId();
|
||||||
if ((*i)->getId() == STANDARD_LIB) continue;
|
if (id == FWObjectDatabase::STANDARD_LIB_ID) continue;
|
||||||
if ((*i)->getId() == DELETED_LIB) continue;
|
if (id == FWObjectDatabase::DELETED_OBJECTS_ID) continue;
|
||||||
if ((*i)->getId() == TEMPLATE_LIB) continue;
|
if (id == FWObjectDatabase::TEMPLATE_LIB_ID) continue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ list<libData>::iterator listOfLibraries::add(const QString &path, bool load)
|
|||||||
return end();
|
return end();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id.isEmpty()) return end();
|
if (id == -1) return end();
|
||||||
if (name.isEmpty()) return end();
|
if (name.isEmpty()) return end();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@@ -220,9 +220,9 @@ list<libData>::iterator listOfLibraries::add(const QString &path, bool load)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (id == STANDARD_LIB) return end();
|
if (id == FWObjectDatabase::STANDARD_LIB_ID) return end();
|
||||||
if (id == DELETED_LIB) return end();
|
if (id == FWObjectDatabase::DELETED_OBJECTS_ID) return end();
|
||||||
if (id == TEMPLATE_LIB) return end();
|
if (id == FWObjectDatabase::TEMPLATE_LIB_ID) return end();
|
||||||
|
|
||||||
list<libData>::iterator i1=insert(end(),libData( id, name, path, false) );
|
list<libData>::iterator i1=insert(end(),libData( id, name, path, false) );
|
||||||
i1->load=load;
|
i1->load=load;
|
||||||
@@ -255,7 +255,7 @@ bool listOfLibraries::isLoaded(const QString &libName)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool listOfLibraries::isKnown(const QString &id)
|
bool listOfLibraries::isKnown(int id)
|
||||||
{
|
{
|
||||||
list<libData>::iterator it;
|
list<libData>::iterator it;
|
||||||
if ( (it=std::find_if(begin(),end(),findIdPredicate(id)))!=end())
|
if ( (it=std::find_if(begin(),end(),findIdPredicate(id)))!=end())
|
||||||
|
|||||||
@@ -39,13 +39,13 @@
|
|||||||
class libData
|
class libData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString id;
|
int id;
|
||||||
QString name;
|
QString name;
|
||||||
QString path;
|
QString path;
|
||||||
bool mandatory;
|
bool mandatory;
|
||||||
bool load;
|
bool load;
|
||||||
|
|
||||||
libData(const QString &i,const QString &n,const QString &p,bool f)
|
libData(int i, const QString &n, const QString &p, bool f)
|
||||||
{ id=i; name=n; path=p; mandatory=f; load=false; }
|
{ id=i; name=n; path=p; mandatory=f; load=false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ class listOfLibraries : public std::list<libData>
|
|||||||
bool getLoad(const QString &libPath);
|
bool getLoad(const QString &libPath);
|
||||||
|
|
||||||
bool isLoaded(const QString &libName);
|
bool isLoaded(const QString &libName);
|
||||||
bool isKnown(const QString &id);
|
bool isKnown(int id);
|
||||||
|
|
||||||
void load();
|
void load();
|
||||||
void save();
|
void save();
|
||||||
|
|||||||
+4
-2
@@ -697,10 +697,12 @@ int main( int argc, char ** argv )
|
|||||||
if (fwbdebug)
|
if (fwbdebug)
|
||||||
qDebug("Main: closing. VisibleFirewall = %p",o);
|
qDebug("Main: closing. VisibleFirewall = %p",o);
|
||||||
|
|
||||||
if (o) st->setStr("UI/visibleFirewall", o->getId().c_str() );
|
if (o) st->setStr("UI/visibleFirewall",
|
||||||
|
FWObjectDatabase::getStringId(o->getId()).c_str());
|
||||||
|
|
||||||
o=mw->getOpened();
|
o=mw->getOpened();
|
||||||
if (o) st->setStr("UI/visibleObject", o->getId().c_str() );
|
if (o) st->setStr("UI/visibleObject",
|
||||||
|
FWObjectDatabase::getStringId(o->getId()).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -908,7 +908,7 @@ void newFirewallDialog::finishClicked()
|
|||||||
* TODO: need to add flags to the API to be able to delete objects
|
* TODO: need to add flags to the API to be able to delete objects
|
||||||
* without placing them in "Deleted objects" automatically
|
* without placing them in "Deleted objects" automatically
|
||||||
*/
|
*/
|
||||||
FWObject *delObjLib = mw->db()->getById( DELETED_LIB );
|
FWObject *delObjLib = mw->db()->getById( FWObjectDatabase::DELETED_OBJECTS_ID );
|
||||||
if (delObjLib!=NULL && delObjLib->getById(tlibID)!=NULL)
|
if (delObjLib!=NULL && delObjLib->getById(tlibID)!=NULL)
|
||||||
{
|
{
|
||||||
if (fwbdebug) qDebug("newFirewallDialog::accept Delete library of templates from 'Deleted objects'");
|
if (fwbdebug) qDebug("newFirewallDialog::accept Delete library of templates from 'Deleted objects'");
|
||||||
|
|||||||
@@ -721,7 +721,7 @@ void newHostDialog::finishClicked()
|
|||||||
if (unloadTemplatesLib)
|
if (unloadTemplatesLib)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
FWObject *tlib = mw->db()->getById(TEMPLATE_LIB);
|
FWObject *tlib = mw->db()->getById(FWObjectDatabase::TEMPLATE_LIB_ID);
|
||||||
assert (tlib!=NULL);
|
assert (tlib!=NULL);
|
||||||
string tlibID = tlib->getId();
|
string tlibID = tlib->getId();
|
||||||
if (fwbdebug) qDebug(" Delete library of templates");
|
if (fwbdebug) qDebug(" Delete library of templates");
|
||||||
@@ -734,7 +734,7 @@ void newHostDialog::finishClicked()
|
|||||||
* TODO: need to add flags to the API to be able to delete objects
|
* TODO: need to add flags to the API to be able to delete objects
|
||||||
* without placing them in "Deleted objects" automatically
|
* without placing them in "Deleted objects" automatically
|
||||||
*/
|
*/
|
||||||
FWObject *delObjLib = mw->db()->getById( DELETED_LIB );
|
FWObject *delObjLib = mw->db()->getById( FWObjectDatabase::DELETED_OBJECTS_ID );
|
||||||
if (delObjLib!=NULL && delObjLib->getById(tlibID)!=NULL)
|
if (delObjLib!=NULL && delObjLib->getById(tlibID)!=NULL)
|
||||||
{
|
{
|
||||||
if (fwbdebug) qDebug(" Delete library of templates from 'Deleted objects'");
|
if (fwbdebug) qDebug(" Delete library of templates from 'Deleted objects'");
|
||||||
|
|||||||
+15
-12
@@ -122,9 +122,9 @@ void fillLibraries(QComboBox *libs, libfwbuilder::FWObject *obj, bool rw)
|
|||||||
FWObject *libobj = obj->getLibrary();
|
FWObject *libobj = obj->getLibrary();
|
||||||
assert(libobj!=NULL);
|
assert(libobj!=NULL);
|
||||||
lib = libobj->getName().c_str();
|
lib = libobj->getName().c_str();
|
||||||
standardObj = (libobj->getId()==STANDARD_LIB);
|
standardObj = (libobj->getId()==FWObjectDatabase::STANDARD_LIB_ID);
|
||||||
templateObj = (libobj->getId()==TEMPLATE_LIB);
|
templateObj = (libobj->getId()==FWObjectDatabase::TEMPLATE_LIB_ID);
|
||||||
deletedObj = (libobj->getId()==DELETED_LIB);
|
deletedObj = (libobj->getId()==FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
libs->clear();
|
libs->clear();
|
||||||
@@ -138,9 +138,12 @@ void fillLibraries(QComboBox *libs, libfwbuilder::FWObject *obj, bool rw)
|
|||||||
if (libicn.empty())
|
if (libicn.empty())
|
||||||
libicn=(":/Icons/"+(*i)->getTypeName()+"/icon-tree").c_str();
|
libicn=(":/Icons/"+(*i)->getTypeName()+"/icon-tree").c_str();
|
||||||
|
|
||||||
if ( (*i)->getId()==STANDARD_LIB && !standardObj) continue;
|
if ( (*i)->getId()==FWObjectDatabase::STANDARD_LIB_ID &&
|
||||||
if ( (*i)->getId()==TEMPLATE_LIB && !templateObj) continue;
|
!standardObj) continue;
|
||||||
if ( (*i)->getId()==DELETED_LIB && !deletedObj ) continue;
|
if ( (*i)->getId()==FWObjectDatabase::TEMPLATE_LIB_ID &&
|
||||||
|
!templateObj) continue;
|
||||||
|
if ( (*i)->getId()==FWObjectDatabase::DELETED_OBJECTS_ID &&
|
||||||
|
!deletedObj ) continue;
|
||||||
|
|
||||||
if (rw && (*i)->isReadOnly()) continue;
|
if (rw && (*i)->isReadOnly()) continue;
|
||||||
if (lib==QString((*i)->getName().c_str())) cn=n;
|
if (lib==QString((*i)->getName().c_str())) cn=n;
|
||||||
@@ -167,9 +170,9 @@ void fillLibraries(QListWidget *libs, libfwbuilder::FWObject *obj, bool rw)
|
|||||||
FWObject *libobj = obj->getLibrary();
|
FWObject *libobj = obj->getLibrary();
|
||||||
assert(libobj!=NULL);
|
assert(libobj!=NULL);
|
||||||
lib = libobj->getName().c_str();
|
lib = libobj->getName().c_str();
|
||||||
standardObj = (libobj->getId()==STANDARD_LIB);
|
standardObj = (libobj->getId()==FWObjectDatabase::STANDARD_LIB_ID);
|
||||||
templateObj = (libobj->getId()==TEMPLATE_LIB);
|
templateObj = (libobj->getId()==FWObjectDatabase::TEMPLATE_LIB_ID);
|
||||||
deletedObj = (libobj->getId()==DELETED_LIB);
|
deletedObj = (libobj->getId()==FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
libs->clear();
|
libs->clear();
|
||||||
@@ -183,9 +186,9 @@ void fillLibraries(QListWidget *libs, libfwbuilder::FWObject *obj, bool rw)
|
|||||||
if (libicn.empty())
|
if (libicn.empty())
|
||||||
libicn=Resources::global_res->getObjResourceStr(*i,"icon-tree").c_str();
|
libicn=Resources::global_res->getObjResourceStr(*i,"icon-tree").c_str();
|
||||||
|
|
||||||
if ( (*i)->getId()==STANDARD_LIB && !standardObj) continue;
|
if ( (*i)->getId()==FWObjectDatabase::STANDARD_LIB_ID && !standardObj) continue;
|
||||||
if ( (*i)->getId()==TEMPLATE_LIB && !templateObj) continue;
|
if ( (*i)->getId()==FWObjectDatabase::TEMPLATE_LIB_ID && !templateObj) continue;
|
||||||
if ( (*i)->getId()==DELETED_LIB && !deletedObj ) continue;
|
if ( (*i)->getId()==FWObjectDatabase::DELETED_OBJECTS_ID && !deletedObj ) continue;
|
||||||
|
|
||||||
if (rw && (*i)->isReadOnly()) continue;
|
if (rw && (*i)->isReadOnly()) continue;
|
||||||
if (lib==QString((*i)->getName().c_str())) cn=n;
|
if (lib==QString((*i)->getName().c_str())) cn=n;
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ void findByObjectType(FWObject *o,
|
|||||||
{
|
{
|
||||||
if (skip_system_libs)
|
if (skip_system_libs)
|
||||||
{
|
{
|
||||||
if (o->getId()==DELETED_LIB) return;
|
if (o->getId()==FWObjectDatabase::DELETED_OBJECTS_ID) return;
|
||||||
if (o->getId()==TEMPLATE_LIB) return;
|
if (o->getId()==FWObjectDatabase::TEMPLATE_LIB_ID) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (list<FWObject*>::iterator m=o->begin(); m!=o->end(); m++)
|
for (list<FWObject*>::iterator m=o->begin(); m!=o->end(); m++)
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ struct FWObjectNameCmpPredicate :
|
|||||||
|
|
||||||
class findFWObjectIDPredicate : public std::unary_function<libfwbuilder::FWObject*, bool>
|
class findFWObjectIDPredicate : public std::unary_function<libfwbuilder::FWObject*, bool>
|
||||||
{
|
{
|
||||||
std::string _id;
|
int _id;
|
||||||
public:
|
public:
|
||||||
findFWObjectIDPredicate(const std::string &id):_id(id) {}
|
findFWObjectIDPredicate(int id):_id(id) {}
|
||||||
bool operator()(const libfwbuilder::FWObject *o) const
|
bool operator()(const libfwbuilder::FWObject *o) const
|
||||||
{return o->getId()==_id;}
|
{return o->getId()==_id;}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -310,8 +310,8 @@ string PolicyCompiler_iosacl::PrintRule::_printSrcService(libfwbuilder::Service
|
|||||||
|
|
||||||
if (TCPService::isA(srv) || UDPService::isA(srv))
|
if (TCPService::isA(srv) || UDPService::isA(srv))
|
||||||
{
|
{
|
||||||
int rs=srv->getInt("src_range_start");
|
int rs=TCPUDPService::cast(srv)->getSrcRangeStart();
|
||||||
int re=srv->getInt("src_range_end");
|
int re=TCPUDPService::cast(srv)->getSrcRangeEnd();
|
||||||
|
|
||||||
if (rs<0) rs=0;
|
if (rs<0) rs=0;
|
||||||
if (re<0) re=0;
|
if (re<0) re=0;
|
||||||
@@ -343,8 +343,8 @@ string PolicyCompiler_iosacl::PrintRule::_printDstService(Service *srv)
|
|||||||
|
|
||||||
if (TCPService::isA(srv) || UDPService::isA(srv))
|
if (TCPService::isA(srv) || UDPService::isA(srv))
|
||||||
{
|
{
|
||||||
int rs=srv->getInt("dst_range_start");
|
int rs=TCPUDPService::cast(srv)->getDstRangeStart();
|
||||||
int re=srv->getInt("dst_range_end");
|
int re=TCPUDPService::cast(srv)->getDstRangeEnd();
|
||||||
|
|
||||||
if (rs<0) rs=0;
|
if (rs<0) rs=0;
|
||||||
if (re<0) re=0;
|
if (re<0) re=0;
|
||||||
|
|||||||
@@ -267,8 +267,8 @@ string NATCompiler_ipt::PrintRule::_printSrcPorts(Service *srv)
|
|||||||
{
|
{
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
if (TCPService::isA(srv) || UDPService::isA(srv)) {
|
if (TCPService::isA(srv) || UDPService::isA(srv)) {
|
||||||
int rs=srv->getInt("src_range_start");
|
int rs=TCPUDPService::cast(srv)->getSrcRangeStart();
|
||||||
int re=srv->getInt("src_range_end");
|
int re=TCPUDPService::cast(srv)->getSrcRangeEnd();
|
||||||
ostr << _printOPorts(rs,re);
|
ostr << _printOPorts(rs,re);
|
||||||
}
|
}
|
||||||
return ostr.str();
|
return ostr.str();
|
||||||
@@ -278,8 +278,8 @@ string NATCompiler_ipt::PrintRule::_printDstPorts(Service *srv)
|
|||||||
{
|
{
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
if (TCPService::isA(srv) || UDPService::isA(srv)) {
|
if (TCPService::isA(srv) || UDPService::isA(srv)) {
|
||||||
int rs=srv->getInt("dst_range_start");
|
int rs=TCPUDPService::cast(srv)->getDstRangeStart();
|
||||||
int re=srv->getInt("dst_range_end");
|
int re=TCPUDPService::cast(srv)->getDstRangeEnd();
|
||||||
ostr << _printOPorts(rs,re);
|
ostr << _printOPorts(rs,re);
|
||||||
}
|
}
|
||||||
return ostr.str();
|
return ostr.str();
|
||||||
@@ -289,8 +289,8 @@ string NATCompiler_ipt::PrintRule::_printSNATPorts(Service *srv)
|
|||||||
{
|
{
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
if (TCPService::isA(srv) || UDPService::isA(srv)) {
|
if (TCPService::isA(srv) || UDPService::isA(srv)) {
|
||||||
int rs=srv->getInt("src_range_start");
|
int rs=TCPUDPService::cast(srv)->getSrcRangeStart();
|
||||||
int re=srv->getInt("src_range_end");
|
int re=TCPUDPService::cast(srv)->getSrcRangeEnd();
|
||||||
ostr << _printTPorts(rs,re);
|
ostr << _printTPorts(rs,re);
|
||||||
}
|
}
|
||||||
return ostr.str();
|
return ostr.str();
|
||||||
@@ -300,8 +300,8 @@ string NATCompiler_ipt::PrintRule::_printDNATPorts(Service *srv)
|
|||||||
{
|
{
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
if (TCPService::isA(srv) || UDPService::isA(srv)) {
|
if (TCPService::isA(srv) || UDPService::isA(srv)) {
|
||||||
int rs=srv->getInt("dst_range_start");
|
int rs=TCPUDPService::cast(srv)->getDstRangeStart();
|
||||||
int re=srv->getInt("dst_range_end");
|
int re=TCPUDPService::cast(srv)->getDstRangeEnd();
|
||||||
ostr << _printTPorts(rs,re);
|
ostr << _printTPorts(rs,re);
|
||||||
}
|
}
|
||||||
return ostr.str();
|
return ostr.str();
|
||||||
|
|||||||
+11
-11
@@ -154,7 +154,7 @@ string NATCompiler_ipt::debugPrintRule(Rule *r)
|
|||||||
NATRule *rule=NATRule::cast(r);
|
NATRule *rule=NATRule::cast(r);
|
||||||
|
|
||||||
return NATCompiler::debugPrintRule(rule)+
|
return NATCompiler::debugPrintRule(rule)+
|
||||||
" "+rule->getInterfaceId()+
|
" " + FWObjectDatabase::getStringId(rule->getInterfaceId()) +
|
||||||
" " + rule->getStr("ipt_chain") +
|
" " + rule->getStr("ipt_chain") +
|
||||||
" " + rule->getStr("ipt_target") +
|
" " + rule->getStr("ipt_target") +
|
||||||
" (type="+rule->getRuleTypeAsString()+")";
|
" (type="+rule->getRuleTypeAsString()+")";
|
||||||
@@ -1209,10 +1209,10 @@ bool NATCompiler_ipt::separatePortRanges::processNext()
|
|||||||
assert(s!=NULL);
|
assert(s!=NULL);
|
||||||
|
|
||||||
if ( TCPService::isA(s) || UDPService::isA(s) ) {
|
if ( TCPService::isA(s) || UDPService::isA(s) ) {
|
||||||
int srs=s->getInt("src_range_start");
|
int srs=TCPUDPService::cast(s)->getSrcRangeStart();
|
||||||
int sre=s->getInt("src_range_end");
|
int sre=TCPUDPService::cast(s)->getSrcRangeEnd();
|
||||||
int drs=s->getInt("dst_range_start");
|
int drs=TCPUDPService::cast(s)->getDstRangeStart();
|
||||||
int dre=s->getInt("dst_range_end");
|
int dre=TCPUDPService::cast(s)->getDstRangeEnd();
|
||||||
|
|
||||||
compiler->normalizePortRange(srs,sre);
|
compiler->normalizePortRange(srs,sre);
|
||||||
compiler->normalizePortRange(drs,dre);
|
compiler->normalizePortRange(drs,dre);
|
||||||
@@ -1262,8 +1262,8 @@ bool NATCompiler_ipt::separateSourcePorts::processNext()
|
|||||||
assert(s!=NULL);
|
assert(s!=NULL);
|
||||||
|
|
||||||
if ( TCPService::isA(s) || UDPService::isA(s) ) {
|
if ( TCPService::isA(s) || UDPService::isA(s) ) {
|
||||||
int srs=s->getInt("src_range_start");
|
int srs=TCPUDPService::cast(s)->getSrcRangeStart();
|
||||||
int sre=s->getInt("src_range_end");
|
int sre=TCPUDPService::cast(s)->getSrcRangeEnd();
|
||||||
|
|
||||||
compiler->normalizePortRange(srs,sre);
|
compiler->normalizePortRange(srs,sre);
|
||||||
|
|
||||||
@@ -1317,10 +1317,10 @@ bool NATCompiler_ipt::separateSourceAndDestinationPorts::processNext()
|
|||||||
assert(s!=NULL);
|
assert(s!=NULL);
|
||||||
|
|
||||||
if ( TCPService::isA(s) || UDPService::isA(s) ) {
|
if ( TCPService::isA(s) || UDPService::isA(s) ) {
|
||||||
int srs=s->getInt("src_range_start");
|
int srs=TCPUDPService::cast(s)->getSrcRangeStart();
|
||||||
int sre=s->getInt("src_range_end");
|
int sre=TCPUDPService::cast(s)->getSrcRangeEnd();
|
||||||
int drs=s->getInt("dst_range_start");
|
int drs=TCPUDPService::cast(s)->getDstRangeStart();
|
||||||
int dre=s->getInt("dst_range_end");
|
int dre=TCPUDPService::cast(s)->getDstRangeEnd();
|
||||||
|
|
||||||
compiler->normalizePortRange(srs,sre);
|
compiler->normalizePortRange(srs,sre);
|
||||||
compiler->normalizePortRange(drs,dre);
|
compiler->normalizePortRange(drs,dre);
|
||||||
|
|||||||
@@ -640,8 +640,8 @@ string PolicyCompiler_ipt::PrintRule::_printSrcPorts(Service *srv)
|
|||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
if (TCPService::isA(srv) || UDPService::isA(srv))
|
if (TCPService::isA(srv) || UDPService::isA(srv))
|
||||||
{
|
{
|
||||||
int rs=srv->getInt("src_range_start");
|
int rs=TCPUDPService::cast(srv)->getSrcRangeStart();
|
||||||
int re=srv->getInt("src_range_end");
|
int re=TCPUDPService::cast(srv)->getSrcRangeEnd();
|
||||||
str << _printPorts(rs,re);
|
str << _printPorts(rs,re);
|
||||||
}
|
}
|
||||||
return str.str();
|
return str.str();
|
||||||
@@ -652,8 +652,8 @@ string PolicyCompiler_ipt::PrintRule::_printDstPorts(Service *srv)
|
|||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
if (TCPService::isA(srv) || UDPService::isA(srv))
|
if (TCPService::isA(srv) || UDPService::isA(srv))
|
||||||
{
|
{
|
||||||
int rs=srv->getInt("dst_range_start");
|
int rs=TCPUDPService::cast(srv)->getDstRangeStart();
|
||||||
int re=srv->getInt("dst_range_end");
|
int re=TCPUDPService::cast(srv)->getDstRangeEnd();
|
||||||
str << _printPorts(rs,re);
|
str << _printPorts(rs,re);
|
||||||
}
|
}
|
||||||
return str.str();
|
return str.str();
|
||||||
@@ -941,7 +941,7 @@ string PolicyCompiler_ipt::PrintRule::_printAddr(Address *o)
|
|||||||
{
|
{
|
||||||
compiler->warning(
|
compiler->warning(
|
||||||
string("Empty inet address in object ") +
|
string("Empty inet address in object ") +
|
||||||
o->getId());
|
FWObjectDatabase::getStringId(o->getId()));
|
||||||
return ostr.str();
|
return ostr.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -346,13 +346,13 @@ int PolicyCompiler_ipt::prolog()
|
|||||||
TCPService *tcpsyn;
|
TCPService *tcpsyn;
|
||||||
|
|
||||||
anytcp=Service::cast(dbcopy->create(TCPService::TYPENAME) );
|
anytcp=Service::cast(dbcopy->create(TCPService::TYPENAME) );
|
||||||
anytcp->setId(ANY_TCP_OBJ_ID);
|
anytcp->setId(FWObjectDatabase::registerStringId(ANY_TCP_OBJ_ID));
|
||||||
anytcp->setName("AnyTCP");
|
anytcp->setName("AnyTCP");
|
||||||
dbcopy->add(anytcp);
|
dbcopy->add(anytcp);
|
||||||
cacheObj(anytcp); // to keep cache consistent
|
cacheObj(anytcp); // to keep cache consistent
|
||||||
|
|
||||||
tcpsyn=TCPService::cast(dbcopy->create(TCPService::TYPENAME) );
|
tcpsyn=TCPService::cast(dbcopy->create(TCPService::TYPENAME) );
|
||||||
tcpsyn->setId(TCP_SYN_OBJ_ID);
|
tcpsyn->setId(FWObjectDatabase::registerStringId(TCP_SYN_OBJ_ID));
|
||||||
tcpsyn->setName("tcpSYN");
|
tcpsyn->setName("tcpSYN");
|
||||||
tcpsyn->setTCPFlag(TCPService::SYN,true);
|
tcpsyn->setTCPFlag(TCPService::SYN,true);
|
||||||
tcpsyn->setAllTCPFlagMasks();
|
tcpsyn->setAllTCPFlagMasks();
|
||||||
@@ -360,25 +360,25 @@ int PolicyCompiler_ipt::prolog()
|
|||||||
cacheObj(tcpsyn); // to keep cache consistent
|
cacheObj(tcpsyn); // to keep cache consistent
|
||||||
|
|
||||||
anyudp=Service::cast(dbcopy->create(UDPService::TYPENAME) );
|
anyudp=Service::cast(dbcopy->create(UDPService::TYPENAME) );
|
||||||
anyudp->setId(ANY_UDP_OBJ_ID);
|
anyudp->setId(FWObjectDatabase::registerStringId(ANY_UDP_OBJ_ID));
|
||||||
anyudp->setName("AnyUDP");
|
anyudp->setName("AnyUDP");
|
||||||
dbcopy->add(anyudp);
|
dbcopy->add(anyudp);
|
||||||
cacheObj(anyudp); // to keep cache consistent
|
cacheObj(anyudp); // to keep cache consistent
|
||||||
|
|
||||||
anyicmp=Service::cast(dbcopy->create(ICMPService::TYPENAME) );
|
anyicmp=Service::cast(dbcopy->create(ICMPService::TYPENAME) );
|
||||||
anyicmp->setId(ANY_ICMP_OBJ_ID);
|
anyicmp->setId(FWObjectDatabase::registerStringId(ANY_ICMP_OBJ_ID));
|
||||||
anyicmp->setName("AnyICMP");
|
anyicmp->setName("AnyICMP");
|
||||||
dbcopy->add(anyicmp);
|
dbcopy->add(anyicmp);
|
||||||
cacheObj(anyicmp); // to keep cache consistent
|
cacheObj(anyicmp); // to keep cache consistent
|
||||||
|
|
||||||
anyip=Service::cast(dbcopy->create(IPService::TYPENAME) );
|
anyip=Service::cast(dbcopy->create(IPService::TYPENAME) );
|
||||||
anyip->setId(ANY_IP_OBJ_ID);
|
anyip->setId(FWObjectDatabase::registerStringId(ANY_IP_OBJ_ID));
|
||||||
anyip->setName("AnyIP");
|
anyip->setName("AnyIP");
|
||||||
dbcopy->add(anyip);
|
dbcopy->add(anyip);
|
||||||
cacheObj(anyip); // to keep cache consistent
|
cacheObj(anyip); // to keep cache consistent
|
||||||
|
|
||||||
bcast255=Address::cast(dbcopy->create(IPv4::TYPENAME) );
|
bcast255=Address::cast(dbcopy->create(IPv4::TYPENAME) );
|
||||||
bcast255->setId(BCAST_255_OBJ_ID);
|
bcast255->setId(FWObjectDatabase::registerStringId(BCAST_255_OBJ_ID));
|
||||||
bcast255->setName("Broadcast_addr");
|
bcast255->setName("Broadcast_addr");
|
||||||
bcast255->setAddress(InetAddr::getAllOnes());
|
bcast255->setAddress(InetAddr::getAllOnes());
|
||||||
bcast255->setNetmask(InetAddr(InetAddr::getAllOnes()));
|
bcast255->setNetmask(InetAddr(InetAddr::getAllOnes()));
|
||||||
@@ -577,7 +577,7 @@ bool PolicyCompiler_ipt::splitNonTerminatingTargets::processNext()
|
|||||||
ndst = r->getDst(); ndst->reset();
|
ndst = r->getDst(); ndst->reset();
|
||||||
nsrv = r->getSrv(); nsrv->reset();
|
nsrv = r->getSrv(); nsrv->reset();
|
||||||
nitfre = r->getItf(); nitfre->reset();
|
nitfre = r->getItf(); nitfre->reset();
|
||||||
r->setInterfaceId("");
|
r->setInterfaceId(-1);
|
||||||
ruleopt = r->getOptionsObject();
|
ruleopt = r->getOptionsObject();
|
||||||
ruleopt->setInt("limit_value",-1);
|
ruleopt->setInt("limit_value",-1);
|
||||||
ruleopt->setInt("limit_value",-1);
|
ruleopt->setInt("limit_value",-1);
|
||||||
@@ -615,7 +615,7 @@ bool PolicyCompiler_ipt::InterfacePolicyRulesWithOptimization::processNext()
|
|||||||
RuleElementItf *itfre=rule->getItf(); assert(itfre);
|
RuleElementItf *itfre=rule->getItf(); assert(itfre);
|
||||||
if (itfre->isAny())
|
if (itfre->isAny())
|
||||||
{
|
{
|
||||||
rule->setInterfaceId("");
|
rule->setInterfaceId(-1);
|
||||||
tmp_queue.push_back(rule);
|
tmp_queue.push_back(rule);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -864,7 +864,8 @@ bool PolicyCompiler_ipt::Logging2::processNext()
|
|||||||
if (TCPService::isA(srv))
|
if (TCPService::isA(srv))
|
||||||
{
|
{
|
||||||
nsrv->clearChildren();
|
nsrv->clearChildren();
|
||||||
nsrv->addRef(compiler->dbcopy->findInIndex(ANY_TCP_OBJ_ID));
|
nsrv->addRef(compiler->dbcopy->findInIndex(
|
||||||
|
FWObjectDatabase::getIntId(ANY_TCP_OBJ_ID)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1040,7 +1041,8 @@ bool PolicyCompiler_ipt::SrcNegation::processNext()
|
|||||||
if (TCPService::isA(srv))
|
if (TCPService::isA(srv))
|
||||||
{
|
{
|
||||||
nsrv->clearChildren();
|
nsrv->clearChildren();
|
||||||
nsrv->addRef(compiler->dbcopy->findInIndex(ANY_TCP_OBJ_ID));
|
nsrv->addRef(compiler->dbcopy->findInIndex(
|
||||||
|
FWObjectDatabase::getIntId(ANY_TCP_OBJ_ID)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1157,7 +1159,8 @@ bool PolicyCompiler_ipt::DstNegation::processNext()
|
|||||||
if (TCPService::isA(srv))
|
if (TCPService::isA(srv))
|
||||||
{
|
{
|
||||||
nsrv->clearChildren();
|
nsrv->clearChildren();
|
||||||
nsrv->addRef(compiler->dbcopy->findInIndex(ANY_TCP_OBJ_ID));
|
nsrv->addRef(compiler->dbcopy->findInIndex(
|
||||||
|
FWObjectDatabase::getIntId(ANY_TCP_OBJ_ID)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1381,7 +1384,8 @@ bool PolicyCompiler_ipt::TimeNegation::processNext()
|
|||||||
if (TCPService::isA(srv))
|
if (TCPService::isA(srv))
|
||||||
{
|
{
|
||||||
nsrv->clearChildren();
|
nsrv->clearChildren();
|
||||||
nsrv->addRef(compiler->dbcopy->findInIndex(ANY_TCP_OBJ_ID));
|
nsrv->addRef(compiler->dbcopy->findInIndex(
|
||||||
|
FWObjectDatabase::getIntId(ANY_TCP_OBJ_ID)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1480,7 +1484,7 @@ bool PolicyCompiler_ipt::setChainPreroutingForTag::processNext()
|
|||||||
rule->getStr("ipt_chain").empty() &&
|
rule->getStr("ipt_chain").empty() &&
|
||||||
(rule->getDirection()==PolicyRule::Both ||
|
(rule->getDirection()==PolicyRule::Both ||
|
||||||
rule->getDirection()==PolicyRule::Inbound) &&
|
rule->getDirection()==PolicyRule::Inbound) &&
|
||||||
rule->getInterfaceId().empty() )
|
rule->getInterfaceId()==-1 )
|
||||||
rule->setStr("ipt_chain","PREROUTING");
|
rule->setStr("ipt_chain","PREROUTING");
|
||||||
|
|
||||||
tmp_queue.push_back(rule);
|
tmp_queue.push_back(rule);
|
||||||
@@ -1498,7 +1502,7 @@ bool PolicyCompiler_ipt::setChainPostroutingForTag::processNext()
|
|||||||
rule->getStr("ipt_chain").empty() &&
|
rule->getStr("ipt_chain").empty() &&
|
||||||
(rule->getDirection()==PolicyRule::Both ||
|
(rule->getDirection()==PolicyRule::Both ||
|
||||||
rule->getDirection()==PolicyRule::Outbound) &&
|
rule->getDirection()==PolicyRule::Outbound) &&
|
||||||
rule->getInterfaceId().empty() )
|
rule->getInterfaceId()==-1 )
|
||||||
rule->setStr("ipt_chain","POSTROUTING");
|
rule->setStr("ipt_chain","POSTROUTING");
|
||||||
|
|
||||||
tmp_queue.push_back(rule);
|
tmp_queue.push_back(rule);
|
||||||
@@ -3066,10 +3070,10 @@ bool PolicyCompiler_ipt::separatePortRanges::processNext()
|
|||||||
|
|
||||||
if ( TCPService::isA(s) || UDPService::isA(s) )
|
if ( TCPService::isA(s) || UDPService::isA(s) )
|
||||||
{
|
{
|
||||||
unsigned srs=s->getInt("src_range_start");
|
unsigned srs=TCPUDPService::cast(s)->getSrcRangeStart();
|
||||||
unsigned sre=s->getInt("src_range_end");
|
unsigned sre=TCPUDPService::cast(s)->getSrcRangeEnd();
|
||||||
unsigned drs=s->getInt("dst_range_start");
|
unsigned drs=TCPUDPService::cast(s)->getDstRangeStart();
|
||||||
unsigned dre=s->getInt("dst_range_end");
|
unsigned dre=TCPUDPService::cast(s)->getDstRangeEnd();
|
||||||
|
|
||||||
if (srs!=0 && sre==0) sre=srs;
|
if (srs!=0 && sre==0) sre=srs;
|
||||||
if (drs!=0 && dre==0) dre=drs;
|
if (drs!=0 && dre==0) dre=drs;
|
||||||
@@ -3127,9 +3131,10 @@ bool PolicyCompiler_ipt::separateSrcPort::processNext()
|
|||||||
Service *s=Service::cast(o);
|
Service *s=Service::cast(o);
|
||||||
assert(s!=NULL);
|
assert(s!=NULL);
|
||||||
|
|
||||||
if ( TCPService::isA(s) || UDPService::isA(s) ) {
|
if ( TCPService::isA(s) || UDPService::isA(s) )
|
||||||
int srs=s->getInt("src_range_start");
|
{
|
||||||
int sre=s->getInt("src_range_end");
|
int srs=TCPUDPService::cast(s)->getSrcRangeStart();
|
||||||
|
int sre=TCPUDPService::cast(s)->getSrcRangeEnd();
|
||||||
|
|
||||||
compiler->normalizePortRange(srs,sre);
|
compiler->normalizePortRange(srs,sre);
|
||||||
|
|
||||||
@@ -3200,7 +3205,8 @@ bool PolicyCompiler_ipt::splitRuleIfSrvAnyActionReject::processNext()
|
|||||||
compiler->temp_ruleset->add(r);
|
compiler->temp_ruleset->add(r);
|
||||||
r->duplicate(rule);
|
r->duplicate(rule);
|
||||||
nsrv=r->getSrv();
|
nsrv=r->getSrv();
|
||||||
nsrv->addRef(compiler->dbcopy->findInIndex(ANY_TCP_OBJ_ID));
|
nsrv->addRef(compiler->dbcopy->findInIndex(
|
||||||
|
FWObjectDatabase::getIntId(ANY_TCP_OBJ_ID)));
|
||||||
|
|
||||||
FWOptions *ruleopt =r->getOptionsObject();
|
FWOptions *ruleopt =r->getOptionsObject();
|
||||||
ruleopt->setStr("action_on_reject","TCP RST");
|
ruleopt->setStr("action_on_reject","TCP RST");
|
||||||
@@ -4020,7 +4026,7 @@ string PolicyCompiler_ipt::debugPrintRule(Rule *r)
|
|||||||
RuleElementInterval *intrel=rule->getWhen();
|
RuleElementInterval *intrel=rule->getWhen();
|
||||||
RuleElementItf *itfrel=rule->getItf();
|
RuleElementItf *itfrel=rule->getItf();
|
||||||
|
|
||||||
string iface_id = rule->getInterfaceId();
|
int iface_id = rule->getInterfaceId();
|
||||||
// Interface *rule_iface = fw_interfaces[iface_id];
|
// Interface *rule_iface = fw_interfaces[iface_id];
|
||||||
|
|
||||||
ostringstream str;
|
ostringstream str;
|
||||||
|
|||||||
@@ -102,7 +102,8 @@ void PolicyCompiler_ipt::optimize1::optimizeForRuleElement(PolicyRule *rule,
|
|||||||
if (TCPService::isA(srv))
|
if (TCPService::isA(srv))
|
||||||
{
|
{
|
||||||
re->clearChildren();
|
re->clearChildren();
|
||||||
re->addRef(compiler->dbcopy->findInIndex(ANY_TCP_OBJ_ID));
|
re->addRef(compiler->dbcopy->findInIndex(
|
||||||
|
FWObjectDatabase::getIntId(ANY_TCP_OBJ_ID)));
|
||||||
/* also leave a flag indicating that further optimization by service
|
/* also leave a flag indicating that further optimization by service
|
||||||
* is not needed */
|
* is not needed */
|
||||||
rule->setBool("do_not_optimize_by_srv",true);
|
rule->setBool("do_not_optimize_by_srv",true);
|
||||||
|
|||||||
+6
-5
@@ -151,12 +151,12 @@ void assignRuleSetChain(RuleSet *ruleset)
|
|||||||
|
|
||||||
if (!Compiler::isRootRuleSet(ruleset))
|
if (!Compiler::isRootRuleSet(ruleset))
|
||||||
rule->setStr("ipt_chain", branch_name);
|
rule->setStr("ipt_chain", branch_name);
|
||||||
rule->setUniqueId( rule->getId() );
|
rule->setUniqueId( FWObjectDatabase::getStringId(rule->getId()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void findBranchesInMangleTable(Firewall *fw, list<FWObject*> &all_policies)
|
void findBranchesInMangleTable(Firewall*, list<FWObject*> &all_policies)
|
||||||
{
|
{
|
||||||
// special but common case: if we only have one policy, there is
|
// special but common case: if we only have one policy, there is
|
||||||
// no need to check if we have to do branching in mangle table
|
// no need to check if we have to do branching in mangle table
|
||||||
@@ -406,8 +406,8 @@ int main(int argc, char * const *argv)
|
|||||||
|
|
||||||
//objdb->dump(true,true);
|
//objdb->dump(true,true);
|
||||||
|
|
||||||
FWObject *slib = objdb->findInIndex("syslib000");
|
FWObject *slib = objdb->findInIndex(FWObjectDatabase::STANDARD_LIB_ID);
|
||||||
if ( slib->isReadOnly()) slib->setReadOnly(false);
|
if (slib && slib->isReadOnly()) slib->setReadOnly(false);
|
||||||
|
|
||||||
/* Review firewall and OS options and generate commands */
|
/* Review firewall and OS options and generate commands */
|
||||||
Firewall* fw=objdb->findFirewallByName(fwobjectname);
|
Firewall* fw=objdb->findFirewallByName(fwobjectname);
|
||||||
@@ -512,7 +512,8 @@ _("Dynamic interface %s should not have an IP address object attached to it. Thi
|
|||||||
sprintf(errstr,
|
sprintf(errstr,
|
||||||
"Interface %s (id=%s) has IP address %s.\n",
|
"Interface %s (id=%s) has IP address %s.\n",
|
||||||
iface->getName().c_str(),
|
iface->getName().c_str(),
|
||||||
iface->getId().c_str(),
|
FWObjectDatabase::getStringId(
|
||||||
|
iface->getId()).c_str(),
|
||||||
ip_addr->toString().c_str());
|
ip_addr->toString().c_str());
|
||||||
throw FWException(errstr);
|
throw FWException(errstr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -270,10 +270,10 @@ bool PolicyCompiler_ipfw::separatePortRanges::processNext()
|
|||||||
|
|
||||||
if ( TCPService::isA(s) || UDPService::isA(s) )
|
if ( TCPService::isA(s) || UDPService::isA(s) )
|
||||||
{
|
{
|
||||||
unsigned srs=s->getInt("src_range_start");
|
unsigned srs=TCPUDPService::cast(s)->getSrcRangeStart();
|
||||||
unsigned sre=s->getInt("src_range_end");
|
unsigned sre=TCPUDPService::cast(s)->getSrcRangeEnd();
|
||||||
unsigned drs=s->getInt("dst_range_start");
|
unsigned drs=TCPUDPService::cast(s)->getDstRangeStart();
|
||||||
unsigned dre=s->getInt("dst_range_end");
|
unsigned dre=TCPUDPService::cast(s)->getDstRangeEnd();
|
||||||
|
|
||||||
if (srs!=0 && sre==0) sre=srs;
|
if (srs!=0 && sre==0) sre=srs;
|
||||||
if (drs!=0 && dre==0) dre=drs;
|
if (drs!=0 && dre==0) dre=drs;
|
||||||
@@ -343,10 +343,10 @@ bool PolicyCompiler_ipfw::sortTCPUDPServices::processNext()
|
|||||||
Service *s=Service::cast(o);
|
Service *s=Service::cast(o);
|
||||||
assert(s!=NULL);
|
assert(s!=NULL);
|
||||||
|
|
||||||
unsigned srs=s->getInt("src_range_start");
|
unsigned srs=TCPUDPService::cast(s)->getSrcRangeStart();
|
||||||
unsigned sre=s->getInt("src_range_end");
|
unsigned sre=TCPUDPService::cast(s)->getSrcRangeEnd();
|
||||||
unsigned drs=s->getInt("dst_range_start");
|
unsigned drs=TCPUDPService::cast(s)->getDstRangeStart();
|
||||||
unsigned dre=s->getInt("dst_range_end");
|
unsigned dre=TCPUDPService::cast(s)->getDstRangeEnd();
|
||||||
|
|
||||||
if (srs!=0 && sre==0) sre=srs;
|
if (srs!=0 && sre==0) sre=srs;
|
||||||
if (drs!=0 && dre==0) dre=drs;
|
if (drs!=0 && dre==0) dre=drs;
|
||||||
|
|||||||
@@ -388,8 +388,8 @@ string PolicyCompiler_ipfw::PrintRule::_printSrcService(Service *srv,bool neg)
|
|||||||
|
|
||||||
if (TCPService::isA(srv) || UDPService::isA(srv))
|
if (TCPService::isA(srv) || UDPService::isA(srv))
|
||||||
{
|
{
|
||||||
int rs=srv->getInt("src_range_start");
|
int rs=TCPUDPService::cast(srv)->getSrcRangeStart();
|
||||||
int re=srv->getInt("src_range_end");
|
int re=TCPUDPService::cast(srv)->getSrcRangeEnd();
|
||||||
string s1= _printPort(rs,re,neg);
|
string s1= _printPort(rs,re,neg);
|
||||||
if (!s1.empty()) res= s1;
|
if (!s1.empty()) res= s1;
|
||||||
}
|
}
|
||||||
@@ -454,8 +454,8 @@ string PolicyCompiler_ipfw::PrintRule::_printDstService(Service *srv,bool neg)
|
|||||||
|
|
||||||
if (TCPService::isA(srv) || UDPService::isA(srv))
|
if (TCPService::isA(srv) || UDPService::isA(srv))
|
||||||
{
|
{
|
||||||
int rs=srv->getInt("dst_range_start");
|
int rs=TCPUDPService::cast(srv)->getDstRangeStart();
|
||||||
int re=srv->getInt("dst_range_end");
|
int re=TCPUDPService::cast(srv)->getDstRangeEnd();
|
||||||
string s1=_printPort(rs,re,neg);;
|
string s1=_printPort(rs,re,neg);;
|
||||||
if (!s1.empty()) res= s1;
|
if (!s1.empty()) res= s1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -383,8 +383,9 @@ void PolicyCompiler_pf::addDefaultPolicyRule()
|
|||||||
PolicyRule *r;
|
PolicyRule *r;
|
||||||
TCPService *ssh =
|
TCPService *ssh =
|
||||||
TCPService::cast(dbcopy->create(TCPService::TYPENAME) );
|
TCPService::cast(dbcopy->create(TCPService::TYPENAME) );
|
||||||
ssh->setInt("dst_range_start",22);
|
ssh->setDstRangeStart(22);
|
||||||
ssh->setInt("dst_range_end",22);
|
ssh->setDstRangeEnd(22);
|
||||||
|
|
||||||
ssh->setName("mgmt_ssh");
|
ssh->setName("mgmt_ssh");
|
||||||
dbcopy->add(ssh,false);
|
dbcopy->add(ssh,false);
|
||||||
cacheObj(ssh); // to keep cache consistent
|
cacheObj(ssh); // to keep cache consistent
|
||||||
@@ -887,8 +888,8 @@ bool PolicyCompiler_pf::separateSrcPort::processNext()
|
|||||||
assert(s!=NULL);
|
assert(s!=NULL);
|
||||||
|
|
||||||
if ( TCPService::isA(s) || UDPService::isA(s) ) {
|
if ( TCPService::isA(s) || UDPService::isA(s) ) {
|
||||||
int srs=s->getInt("src_range_start");
|
int srs=TCPUDPService::cast(s)->getSrcRangeStart();
|
||||||
int sre=s->getInt("src_range_end");
|
int sre=TCPUDPService::cast(s)->getSrcRangeEnd();
|
||||||
|
|
||||||
compiler->normalizePortRange(srs,sre);
|
compiler->normalizePortRange(srs,sre);
|
||||||
|
|
||||||
|
|||||||
@@ -518,8 +518,8 @@ string PolicyCompiler_pf::PrintRule::_printSrcService(Service *srv, bool neg)
|
|||||||
ostringstream str;
|
ostringstream str;
|
||||||
if (TCPService::isA(srv) || UDPService::isA(srv))
|
if (TCPService::isA(srv) || UDPService::isA(srv))
|
||||||
{
|
{
|
||||||
int rs=srv->getInt("src_range_start");
|
int rs=TCPUDPService::cast(srv)->getSrcRangeStart();
|
||||||
int re=srv->getInt("src_range_end");
|
int re=TCPUDPService::cast(srv)->getSrcRangeEnd();
|
||||||
str << _printPort(rs,re,neg);
|
str << _printPort(rs,re,neg);
|
||||||
}
|
}
|
||||||
return str.str();
|
return str.str();
|
||||||
@@ -589,8 +589,8 @@ string PolicyCompiler_pf::PrintRule::_printDstService(Service *srv, bool neg)
|
|||||||
ostringstream str;
|
ostringstream str;
|
||||||
if (TCPService::isA(srv) || UDPService::isA(srv))
|
if (TCPService::isA(srv) || UDPService::isA(srv))
|
||||||
{
|
{
|
||||||
int rs=srv->getInt("dst_range_start");
|
int rs=TCPUDPService::cast(srv)->getDstRangeStart();
|
||||||
int re=srv->getInt("dst_range_end");
|
int re=TCPUDPService::cast(srv)->getDstRangeEnd();
|
||||||
str << _printPort(rs,re,neg);
|
str << _printPort(rs,re,neg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+25
-19
@@ -455,8 +455,8 @@ bool NATCompiler_pix::verifyRuleElements::processNext()
|
|||||||
|
|
||||||
if (TCPService::isA(osrv) || UDPService::isA(osrv))
|
if (TCPService::isA(osrv) || UDPService::isA(osrv))
|
||||||
{
|
{
|
||||||
int drs=osrv->getInt("dst_range_start");
|
int drs=TCPUDPService::cast(osrv)->getDstRangeStart();
|
||||||
int dre=osrv->getInt("dst_range_end");
|
int dre=TCPUDPService::cast(osrv)->getDstRangeEnd();
|
||||||
|
|
||||||
if (drs!=dre)
|
if (drs!=dre)
|
||||||
compiler->abort("TCP or UDP service with a port range is not "
|
compiler->abort("TCP or UDP service with a port range is not "
|
||||||
@@ -464,8 +464,8 @@ bool NATCompiler_pix::verifyRuleElements::processNext()
|
|||||||
}
|
}
|
||||||
if (TCPService::isA(tsrv) || UDPService::isA(tsrv))
|
if (TCPService::isA(tsrv) || UDPService::isA(tsrv))
|
||||||
{
|
{
|
||||||
int drs=tsrv->getInt("dst_range_start");
|
int drs=TCPUDPService::cast(tsrv)->getDstRangeStart();
|
||||||
int dre=tsrv->getInt("dst_range_end");
|
int dre=TCPUDPService::cast(tsrv)->getDstRangeEnd();
|
||||||
|
|
||||||
if (drs!=dre)
|
if (drs!=dre)
|
||||||
compiler->abort("TCP or UDP service with a port range is not "
|
compiler->abort("TCP or UDP service with a port range is not "
|
||||||
@@ -1346,21 +1346,27 @@ bool NATCompiler_pix::DetectDuplicateNAT::processNext()
|
|||||||
*(natcmd->o_srv)==*(nc->o_srv)
|
*(natcmd->o_srv)==*(nc->o_srv)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
compiler->abort("Duplicate NAT detected: rules "
|
ostringstream str;
|
||||||
+rule->getLabel()
|
str << "Duplicate NAT detected: rules "
|
||||||
+" and "+nc->rule_label
|
<< rule->getLabel()
|
||||||
+" : "+natcmd->o_src->getAddressPtr()->toString()
|
<< " and "<< nc->rule_label
|
||||||
+"/"+natcmd->o_src->getNetmaskPtr()->toString()
|
<< " : "<< natcmd->o_src->getAddressPtr()->toString()
|
||||||
+ " "
|
<< "/"<< natcmd->o_src->getNetmaskPtr()->toString()
|
||||||
+ natcmd->o_srv->getProtocolName()
|
<< " "
|
||||||
+ natcmd->o_srv->getStr("src_range_start")+":"
|
<< natcmd->o_srv->getProtocolName()
|
||||||
+ natcmd->o_srv->getStr("src_range_end")+":"
|
<< " "
|
||||||
+ " "
|
<< TCPUDPService::cast(natcmd->o_srv)->getSrcRangeStart()
|
||||||
+"->"+natcmd->o_dst->getAddressPtr()->toString()
|
<< ":"
|
||||||
+"/"+natcmd->o_dst->getNetmaskPtr()->toString()
|
<< TCPUDPService::cast(natcmd->o_srv)->getSrcRangeEnd()
|
||||||
+ " "
|
<< " "
|
||||||
+ natcmd->o_srv->getStr("dst_range_start")+"/"
|
<< "->"<< natcmd->o_dst->getAddressPtr()->toString()
|
||||||
+ natcmd->o_srv->getStr("dst_range_end"));
|
<< "/"<< natcmd->o_dst->getNetmaskPtr()->toString()
|
||||||
|
<< " "
|
||||||
|
<< TCPUDPService::cast(natcmd->o_srv)->getDstRangeStart()
|
||||||
|
<< "/"
|
||||||
|
<< TCPUDPService::cast(natcmd->o_srv)->getDstRangeEnd();
|
||||||
|
|
||||||
|
compiler->abort(str.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ void NATCompiler_pix::PrintRule::_printPort(Service *srv)
|
|||||||
{
|
{
|
||||||
if (TCPService::isA(srv) || UDPService::isA(srv))
|
if (TCPService::isA(srv) || UDPService::isA(srv))
|
||||||
{
|
{
|
||||||
int drs=srv->getInt("dst_range_start");
|
int drs=TCPUDPService::cast(srv)->getDstRangeStart();
|
||||||
|
|
||||||
if (drs!=0) compiler->output << drs << " ";
|
if (drs!=0) compiler->output << drs << " ";
|
||||||
}
|
}
|
||||||
@@ -214,8 +214,8 @@ string NATCompiler_pix::PrintRule::_printSrcService(Service *srv)
|
|||||||
|
|
||||||
if (TCPService::isA(srv) || UDPService::isA(srv))
|
if (TCPService::isA(srv) || UDPService::isA(srv))
|
||||||
{
|
{
|
||||||
int rs=srv->getInt("src_range_start");
|
int rs=TCPUDPService::cast(srv)->getSrcRangeStart();
|
||||||
int re=srv->getInt("src_range_end");
|
int re=TCPUDPService::cast(srv)->getSrcRangeEnd();
|
||||||
|
|
||||||
if (rs<0) rs=0;
|
if (rs<0) rs=0;
|
||||||
if (re<0) re=0;
|
if (re<0) re=0;
|
||||||
@@ -238,8 +238,8 @@ string NATCompiler_pix::PrintRule::_printDstService(Service *srv)
|
|||||||
ostringstream str;
|
ostringstream str;
|
||||||
|
|
||||||
if (TCPService::isA(srv) || UDPService::isA(srv)) {
|
if (TCPService::isA(srv) || UDPService::isA(srv)) {
|
||||||
int rs=srv->getInt("dst_range_start");
|
int rs=TCPUDPService::cast(srv)->getDstRangeStart();
|
||||||
int re=srv->getInt("dst_range_end");
|
int re=TCPUDPService::cast(srv)->getDstRangeEnd();
|
||||||
|
|
||||||
if (rs<0) rs=0;
|
if (rs<0) rs=0;
|
||||||
if (re<0) re=0;
|
if (re<0) re=0;
|
||||||
|
|||||||
@@ -203,8 +203,8 @@ bool PolicyCompiler_pix::PrintObjectGroupsAndClearCommands::processNext()
|
|||||||
Service *s=Service::cast(obj);
|
Service *s=Service::cast(obj);
|
||||||
assert(s!=NULL);
|
assert(s!=NULL);
|
||||||
|
|
||||||
int rs=s->getInt("dst_range_start");
|
int rs=TCPUDPService::cast(s)->getDstRangeStart();
|
||||||
int re=s->getInt("dst_range_end");
|
int re=TCPUDPService::cast(s)->getDstRangeEnd();
|
||||||
|
|
||||||
if (rs<0) rs=0;
|
if (rs<0) rs=0;
|
||||||
if (re<0) re=0;
|
if (re<0) re=0;
|
||||||
@@ -304,8 +304,8 @@ string PolicyCompiler_pix::PrintRule::_printSrcService(libfwbuilder::Service *sr
|
|||||||
|
|
||||||
if (TCPService::isA(srv) || UDPService::isA(srv))
|
if (TCPService::isA(srv) || UDPService::isA(srv))
|
||||||
{
|
{
|
||||||
int rs=srv->getInt("src_range_start");
|
int rs=TCPUDPService::cast(srv)->getSrcRangeStart();
|
||||||
int re=srv->getInt("src_range_end");
|
int re=TCPUDPService::cast(srv)->getSrcRangeEnd();
|
||||||
|
|
||||||
if (rs<0) rs=0;
|
if (rs<0) rs=0;
|
||||||
if (re<0) re=0;
|
if (re<0) re=0;
|
||||||
@@ -328,8 +328,8 @@ string PolicyCompiler_pix::PrintRule::_printDstService(libfwbuilder::Service *sr
|
|||||||
ostringstream str;
|
ostringstream str;
|
||||||
|
|
||||||
if (TCPService::isA(srv) || UDPService::isA(srv)) {
|
if (TCPService::isA(srv) || UDPService::isA(srv)) {
|
||||||
int rs=srv->getInt("dst_range_start");
|
int rs=TCPUDPService::cast(srv)->getDstRangeStart();
|
||||||
int re=srv->getInt("dst_range_end");
|
int re=TCPUDPService::cast(srv)->getDstRangeEnd();
|
||||||
|
|
||||||
if (rs<0) rs=0;
|
if (rs<0) rs=0;
|
||||||
if (re<0) re=0;
|
if (re<0) re=0;
|
||||||
@@ -472,7 +472,7 @@ string PolicyCompiler_pix::PrintRule::_printSSHTelnetCommand(PolicyRule *rule
|
|||||||
Interface *rule_iface = compiler->getCachedFwInterface(rule->getInterfaceId());
|
Interface *rule_iface = compiler->getCachedFwInterface(rule->getInterfaceId());
|
||||||
assert(rule_iface);
|
assert(rule_iface);
|
||||||
|
|
||||||
port=srv->getInt("dst_range_start");
|
port=TCPUDPService::cast(srv)->getDstRangeStart();
|
||||||
|
|
||||||
for (FWObject::iterator i=rel->begin(); i!=rel->end(); ++i)
|
for (FWObject::iterator i=rel->begin(); i!=rel->end(); ++i)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user