From 58355d5aab06d370143e3db09fb6331867cbca42 Mon Sep 17 00:00:00 2001 From: Vadim Kurland Date: Sun, 13 Apr 2008 07:06:30 +0000 Subject: [PATCH] ******************************** Merge branch inet-addr-changes r61 ******************************** --- src/cisco_lib/Helper.cpp | 30 +- src/cisco_lib/Helper.h | 12 +- src/cisco_lib/PolicyCompiler_cisco.cpp | 4 +- src/fwbedit/fwbedit.cpp | 12 +- src/fwblookup/fwblookup.cpp | 9 +- src/gui/AddressRangeDialog.cpp | 8 +- src/gui/DiscoveryDruid.cpp | 99 +- src/gui/DiscoveryDruid.h | 18 +- src/gui/IOSImporter.cpp | 11 +- src/gui/IPTImporter.cpp | 8 +- src/gui/IPv4Dialog.cpp | 12 +- src/gui/Importer.cpp | 32 +- src/gui/InterfaceData.cpp | 25 +- src/gui/NetworkDialog.cpp | 10 +- src/gui/fwbuilder_ph.h | 3 +- src/gui/instDialog.cpp | 3 +- src/gui/newFirewallDialog.cpp | 18 +- src/gui/newHostDialog.cpp | 21 +- src/iosacl/PolicyCompiler_iosacl.cpp | 18 +- src/iosacl/PolicyCompiler_iosacl_writers.cpp | 20 +- src/ipf/ipf.cpp | 2 +- src/ipfw/ipfw.cpp | 2 +- src/ipt/NATCompiler_PrintRule.cpp | 58 +- src/ipt/NATCompiler_ipt.cpp | 27 +- src/ipt/OSConfigurator_linux24.cpp | 26 +- src/ipt/OSConfigurator_linux24.h | 6 +- src/ipt/PolicyCompiler_PrintRule.cpp | 39 +- src/ipt/PolicyCompiler_PrintRuleIptRst.cpp | 1 - .../PolicyCompiler_PrintRuleIptRstEcho.cpp | 1 - src/ipt/PolicyCompiler_ipt.cpp | 33 +- src/ipt/RoutingCompiler_ipt.cpp | 2 - src/ipt/RoutingCompiler_ipt_writers.cpp | 14 +- src/ipt/ipt.cpp | 9 +- src/pf/pf.cpp | 2 +- src/pflib/NATCompiler_ipf_writers.cpp | 28 +- src/pflib/NATCompiler_pf.cpp | 2 +- src/pflib/NATCompiler_pf_writers.cpp | 14 +- src/pflib/OSConfigurator_freebsd.cpp | 5 +- src/pflib/OSConfigurator_freebsd.h | 2 +- src/pflib/OSConfigurator_macosx.h | 2 +- src/pflib/OSConfigurator_openbsd.cpp | 5 +- src/pflib/OSConfigurator_openbsd.h | 2 +- src/pflib/OSConfigurator_solaris.cpp | 5 +- src/pflib/OSConfigurator_solaris.h | 4 +- src/pflib/PolicyCompiler_ipf_writers.cpp | 14 +- src/pflib/PolicyCompiler_ipfw_writers.cpp | 13 +- src/pflib/PolicyCompiler_pf.cpp | 12 +- src/pflib/PolicyCompiler_pf_writers.cpp | 22 +- src/pflib/TableFactory.cpp | 9 +- src/pix/NATCompiler_pix.cpp | 83 +- src/pix/NATCompiler_pix.h | 6 +- src/pix/NATCompiler_pix_writers.cpp | 6 +- src/pix/OSConfigurator_pix_os.cpp | 6 +- src/pix/PIXObjectGroup.h | 2 +- src/pix/PolicyCompiler_pix.cpp | 9 +- src/pix/PolicyCompiler_pix_writers.cpp | 16 +- test/ipf/objects-for-regression-tests.fwb | 2 +- test/ipfw/objects-for-regression-tests.fwb | 2 +- test/ipt/objects-for-regression-tests.fwb | 536 ++--- test/pf/objects-for-regression-tests.fwb | 1868 ++++++++--------- test/pix/quick-cmp.sh | 4 +- 61 files changed, 1657 insertions(+), 1617 deletions(-) diff --git a/src/cisco_lib/Helper.cpp b/src/cisco_lib/Helper.cpp index 481314dc9..cd0eaa316 100644 --- a/src/cisco_lib/Helper.cpp +++ b/src/cisco_lib/Helper.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include @@ -41,21 +41,6 @@ using namespace libfwbuilder; using namespace fwcompiler; using namespace std; -bool Helper::belongsTo(Address *obj, const IPAddress &a) -{ - const IPNetwork n1( obj->getAddress() , - (Interface::cast(obj))?Netmask("255.255.255.255"):obj->getNetmask() ); - - return n1.belongs(a); -} - - -bool Helper::belongsTo(Address *obj, Address *addr) -{ - return belongsTo(obj,addr->getAddress()); -} - - static unsigned long calculateDimension(FWObject* obj) { if (Group::cast(obj)!=NULL) { @@ -118,14 +103,13 @@ string Helper::findInterfaceByAddress(libfwbuilder::Address *obj) return findInterfaceByAddress(obj->getAddress()); } -string Helper::findInterfaceByAddress(const libfwbuilder::IPAddress &addr) +string Helper::findInterfaceByAddress(const libfwbuilder::InetAddr &addr) { Firewall *fw=compiler->fw; list l2=fw->getByType(Interface::TYPENAME); for (list::iterator i=l2.begin(); i!=l2.end(); ++i) { Interface *iface=Interface::cast(*i); - IPNetwork n( iface->getAddress() , iface->getNetmask() ); - if ( n.belongs( addr ) ) return iface->getId(); + if ( iface->belongs( addr ) ) return iface->getId(); } return ""; } @@ -135,7 +119,7 @@ string Helper::findInterfaceByNetzone(Address *obj) return findInterfaceByNetzone(obj->getAddress()); } -string Helper::findInterfaceByNetzone(const IPAddress &addr) throw(string) +string Helper::findInterfaceByNetzone(const InetAddr &addr) throw(string) { Firewall *fw=compiler->fw; map zones; @@ -150,7 +134,7 @@ string Helper::findInterfaceByNetzone(const IPAddress &addr) throw(string) j!=netzone->end(); ++j) { assert(Address::cast(*j)!=NULL); - if ( belongsTo( Address::cast(*j) , addr ) ) + if (Address::cast(*j)->belongs(addr)) zones[(*i)->getId()]=netzone; } } @@ -249,7 +233,7 @@ list Helper::findInterfaceByNetzoneOrAll(RuleElement *re) string triplet::hash() { - return string(src->getAddress()) + "." + - string(dst->getAddress()) + "." + + return src->getAddress().toString() + "." + + dst->getAddress().toString() + "." + srv->getId(); } diff --git a/src/cisco_lib/Helper.h b/src/cisco_lib/Helper.h index 551aececb..85af19513 100644 --- a/src/cisco_lib/Helper.h +++ b/src/cisco_lib/Helper.h @@ -40,14 +40,6 @@ namespace fwcompiler { { fwcompiler::Compiler *compiler; - /** - * this methods checks if object addr belongs to network or address obj - */ - bool belongsTo(libfwbuilder::Address *obj, - const libfwbuilder::IPAddress &a); - bool belongsTo(libfwbuilder::Address *obj, - libfwbuilder::Address *addr); - public: Helper(fwcompiler::Compiler *comp) { compiler=comp; } @@ -57,14 +49,14 @@ namespace fwcompiler { * finds interface of the firewall to whose subnet object * 'obj' belongs to. Returns interface ID */ - std::string findInterfaceByAddress(const libfwbuilder::IPAddress &a); + std::string findInterfaceByAddress(const libfwbuilder::InetAddr &a); std::string findInterfaceByAddress(libfwbuilder::Address *obj); /** * finds interface of the firewall associated with the netzone * that object 'obj' belongs to. Returns interface ID */ - std::string findInterfaceByNetzone(const libfwbuilder::IPAddress &a) + std::string findInterfaceByNetzone(const libfwbuilder::InetAddr &a) throw(std::string); std::string findInterfaceByNetzone(libfwbuilder::Address *obj); std::list findInterfaceByNetzoneOrAll( diff --git a/src/cisco_lib/PolicyCompiler_cisco.cpp b/src/cisco_lib/PolicyCompiler_cisco.cpp index a666a2c4c..9411f312b 100644 --- a/src/cisco_lib/PolicyCompiler_cisco.cpp +++ b/src/cisco_lib/PolicyCompiler_cisco.cpp @@ -409,7 +409,7 @@ bool PolicyCompiler_cisco::splitIfRuleElementMatchesFW::processNext() Address *a=Address::cast(obj); assert(a!=NULL); -// IPAddress obj_addr=a->getAddress(); +// InetAddr obj_addr=a->getAddress(); if (cisco_comp->complexMatch(a,cisco_comp->fw)) { @@ -697,7 +697,7 @@ bool PolicyCompiler_cisco::splitByNetworkZonesForRE::processNext() Address *a=Address::cast(obj); assert(a!=NULL); -// IPAddress obj_addr=a->getAddress(); +// InetAddr obj_addr=a->getAddress(); try { diff --git a/src/fwbedit/fwbedit.cpp b/src/fwbedit/fwbedit.cpp index 1ff821f2a..736d4cc78 100644 --- a/src/fwbedit/fwbedit.cpp +++ b/src/fwbedit/fwbedit.cpp @@ -251,7 +251,7 @@ bool testIPv4(string s) bool res=false; try { - IPAddress( s.c_str() ); + InetAddr( s.c_str() ); res=true; } catch (FWException &ex) { } @@ -682,7 +682,7 @@ int main(int argc, char * const *argv) { IPv4 *o=IPv4::cast(nobj); o->setName(name); - o->setAddress(addr1); + o->setAddress(InetAddr(addr1)); } } @@ -705,8 +705,8 @@ int main(int argc, char * const *argv) FWObject *nobj=createObject(objtype,"/"+lib+"/"+systemGroupPaths[objtype]); AddressRange *o=AddressRange::cast(nobj); o->setName(name); - o->setRangeStart(IPAddress(addr1)); - o->setRangeEnd(IPAddress(addr2)); + o->setRangeStart(InetAddr(addr1)); + o->setRangeEnd(InetAddr(addr2)); } else if (objtype==ObjectGroup::TYPENAME) @@ -723,8 +723,8 @@ int main(int argc, char * const *argv) FWObject *nobj=createObject(objtype,"/"+lib+"/"+systemGroupPaths[objtype]); Network *o=Network::cast(nobj); o->setName(name); - o->setAddress(addr1); - o->setNetmask(addr2); + o->setAddress(InetAddr(addr1)); + o->setNetmask(InetNetmask(addr2)); } else if (objtype==Firewall::TYPENAME) { diff --git a/src/fwblookup/fwblookup.cpp b/src/fwblookup/fwblookup.cpp index f2f74844a..9015575f0 100644 --- a/src/fwblookup/fwblookup.cpp +++ b/src/fwblookup/fwblookup.cpp @@ -316,9 +316,12 @@ int main(int argc, char * const *argv) { if (Host::isA(obj) || Firewall::isA(obj)) { - IPAddress ma=Host::cast(obj)->getManagementAddress(); - if (ma!=IPAddress("0.0.0.0")) cout << ma.toString() << endl; - else { + InetAddr ma = Host::cast(obj)->getManagementAddress(); + if (ma != InetAddr::getAny()) + { + cout << ma.toString() << endl; + } else + { SNPRINTF(errstr,sizeof(errstr), _("Object %s (ID='%s') does not have management interface"), obj->getName().c_str(), diff --git a/src/gui/AddressRangeDialog.cpp b/src/gui/AddressRangeDialog.cpp index 572ed927b..d33c75db3 100644 --- a/src/gui/AddressRangeDialog.cpp +++ b/src/gui/AddressRangeDialog.cpp @@ -118,7 +118,7 @@ void AddressRangeDialog::validate(bool *res) assert(s!=NULL); try { - IPAddress(m_dialog->rangeStart->text().toLatin1().constData()); + InetAddr(m_dialog->rangeStart->text().toLatin1().constData()); } catch (FWException &ex) { *res=false; @@ -129,7 +129,7 @@ void AddressRangeDialog::validate(bool *res) } try { - IPAddress(m_dialog->rangeEnd->text().toLatin1().constData()); + InetAddr(m_dialog->rangeEnd->text().toLatin1().constData()); } catch (FWException &ex) { *res=false; @@ -161,8 +161,8 @@ void AddressRangeDialog::applyChanges() obj->setComment( string(m_dialog->comment->toPlainText().toUtf8().constData()) ); try { - s->setRangeStart( IPAddress(m_dialog->rangeStart->text().toLatin1().constData()) ); - s->setRangeEnd( IPAddress(m_dialog->rangeEnd->text().toLatin1().constData()) ); + s->setRangeStart( InetAddr(m_dialog->rangeStart->text().toLatin1().constData()) ); + s->setRangeEnd( InetAddr(m_dialog->rangeEnd->text().toLatin1().constData()) ); } catch (FWException &ex) { diff --git a/src/gui/DiscoveryDruid.cpp b/src/gui/DiscoveryDruid.cpp index 8d1d3eafb..4001aefb3 100644 --- a/src/gui/DiscoveryDruid.cpp +++ b/src/gui/DiscoveryDruid.cpp @@ -64,7 +64,8 @@ #include "fwbuilder/IPv4.h" #include "fwbuilder/Host.h" #include "fwbuilder/Network.h" -#include "fwbuilder/IPAddress.h" +#include "fwbuilder/InetAddr.h" +#include "fwbuilder/InetAddrMask.h" #include "fwbuilder/Firewall.h" #include "fwbuilder/dns.h" @@ -620,7 +621,7 @@ void DiscoveryDruid::updatePrg() void DiscoveryDruid::getNameServers() { - multimap ns_records; + multimap ns_records; string domain_name=m_dialog->domainname->text().toLatin1().constData(); DNS_getNS_query *dns=new DNS_getNS_query(domain_name); @@ -642,7 +643,7 @@ void DiscoveryDruid::getNameServers() m_dialog->dnscustom->setChecked(true); return ; } - multimap::iterator i; + multimap::iterator i; m_dialog->nameserverlist->clear(); NameServers.clear(); @@ -653,7 +654,7 @@ void DiscoveryDruid::getNameServers() QString qs = s.c_str(); m_dialog->nameserverlist->addItem(qs); - IPAddress *na=new IPAddress( (*i).second ); + InetAddr *na=new InetAddr( (*i).second ); NameServers[qs] = *na; } } @@ -835,7 +836,7 @@ void DiscoveryDruid::startConfigImport() } } -IPAddress DiscoveryDruid::getNS() +InetAddr DiscoveryDruid::getNS() { string ns; if (m_dialog->dnscustom->isChecked()) @@ -844,17 +845,17 @@ IPAddress DiscoveryDruid::getNS() try { - return IPAddress(ns); + return InetAddr(ns); } catch (FWException &ex) { /* perhaps not address but host name */ - list addr; + list addr; try { addr=DNS::getHostByName(ns); } catch (FWException &ex) { - return IPAddress(); + return InetAddr(); } return addr.front(); @@ -866,7 +867,7 @@ IPAddress DiscoveryDruid::getNS() void DiscoveryDruid::startDNSScan() { - IPAddress ns=getNS(); + InetAddr ns=getNS(); string domain_name=m_dialog->domainname->text().toLatin1().constData(); DNS_findA_query *q=new DNS_findA_query(); @@ -893,14 +894,14 @@ void DiscoveryDruid::startDNSScan() } } -IPAddress DiscoveryDruid::getSeedHostAddress() +InetAddr DiscoveryDruid::getSeedHostAddress() { - libfwbuilder::IPAddress seed_host_addr; + libfwbuilder::InetAddr seed_host_addr; if (!m_dialog->seedhostname->text().isEmpty()) { try { - seed_host_addr=IPAddress(m_dialog->seedhostname->text().toLatin1().constData()); + seed_host_addr=InetAddr(m_dialog->seedhostname->text().toLatin1().constData()); return seed_host_addr; } catch(const FWException &ex) { @@ -909,9 +910,9 @@ IPAddress DiscoveryDruid::getSeedHostAddress() try { QString a = getAddrByName( m_dialog->seedhostname->text() ); - return IPAddress( a.toLatin1().constData() ); + return InetAddr( a.toLatin1().constData() ); #if 0 - list v=DNS::getHostByName( m_dialog->seedhostname->text().toLatin1().constData() ); + list v=DNS::getHostByName( m_dialog->seedhostname->text().toLatin1().constData() ); seed_host_addr = v.front(); return seed_host_addr; #endif @@ -932,10 +933,10 @@ void DiscoveryDruid::startSNMPScan() { try { - IPNetwork in( - IPAddress(m_dialog->snmpinaddr->text().toLatin1().constData()), - Netmask(m_dialog->snmpinmask->text().toLatin1().constData()) - ); + InetAddrMask in( + InetAddr(m_dialog->snmpinaddr->text().toLatin1().constData()), + InetNetmask(m_dialog->snmpinmask->text().toLatin1().constData()) + ); include_networks.push_back(in); } catch (const FWException &ex) @@ -1013,12 +1014,12 @@ void DiscoveryDruid::changedNameServer() return; } - if(isIPAddress(s)) + if(isInetAddr(s)) { timer->stop(); m_dialog->DNSprogress_2->hide(); - QString rs=testIPAddress(s); + QString rs=testInetAddr(s); if (rs.isEmpty()) { m_dialog->nameserver_error->setText(" "); @@ -1070,13 +1071,13 @@ void DiscoveryDruid::typedCustomNS() } } -bool DiscoveryDruid::isIPAddress(const QString s) +bool DiscoveryDruid::isInetAddr(const QString s) { QRegExp r=QRegExp("^(\\d|\\.)+$",Qt::CaseInsensitive); //non wildcard return r.exactMatch(s); } -QString DiscoveryDruid::testIPAddress(const QString s) +QString DiscoveryDruid::testInetAddr(const QString s) { QString res; QRegExp r=QRegExp("^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$",Qt::CaseInsensitive); //non wildcard @@ -1084,7 +1085,7 @@ QString DiscoveryDruid::testIPAddress(const QString s) { try { - IPAddress(s.toLatin1().constData()); + InetAddr(s.toLatin1().constData()); } catch(const FWException &ex) { res=ex.toString().c_str(); @@ -1388,9 +1389,9 @@ void DiscoveryDruid::loadDataFromDNS() DNS_findA_query *q=(DNS_findA_query*)bop; Objects.clear(); - map > t = q->getResult(); + map > t = q->getResult(); - for(map >::iterator j = t.begin(); j!=t.end(); ++j) + for(map >::iterator j = t.begin(); j!=t.end(); ++j) { ObjectDescriptor od; od.addr = *((*j).second.begin()); @@ -1476,8 +1477,8 @@ void DiscoveryDruid::loadDataFromCrawler() Objects.clear(); Networks.clear(); - set::iterator m; - set s = q->getNetworks(); + set::iterator m; + set s = q->getNetworks(); if (fwbdebug) qDebug(QString("got %1 networks").arg(s.size()).toAscii().constData()); @@ -1486,16 +1487,16 @@ void DiscoveryDruid::loadDataFromCrawler() { ObjectDescriptor od; - od.sysname=(string)*m; - od.addr=m->getAddress(); - od.netmask=m->getNetmask(); - od.type=Network::TYPENAME; - od.isSelected=false; + od.sysname = m->toString(); + od.addr = m->getAddress(); + od.netmask = m->getNetmask(); + od.type = Network::TYPENAME; + od.isSelected = false; Networks[od.sysname.c_str()]= od ; } - map t = q->getAllIPs(); + map t = q->getAllIPs(); if (fwbdebug) qDebug(QString("got %1 addresses").arg(t.size()).toAscii().constData()); @@ -1504,7 +1505,7 @@ void DiscoveryDruid::loadDataFromCrawler() m_dialog->discoveryprogress->setValue(0); int cntr = 0; - map::iterator j; + map::iterator j; for(j = t.begin(); j!=t.end(); ++j,++cntr) { m_dialog->discoveryprogress->setValue( cntr ); @@ -1823,7 +1824,7 @@ void DiscoveryDruid::changedSeedHost() } else { - if(isIPAddress(HostName)) + if(isInetAddr(HostName)) { // seems to be an IP Address m_dialog->DNSprogress->hide(); timer->stop(); @@ -1832,7 +1833,7 @@ void DiscoveryDruid::changedSeedHost() { try { - IPAddress(HostName.toLatin1().constData()); + InetAddr(HostName.toLatin1().constData()); QPalette palette = m_dialog->seedhosterror_message->palette(); palette.setColor(m_dialog->seedhosterror_message->foregroundRole(), Qt::darkGreen); @@ -1894,9 +1895,9 @@ void DiscoveryDruid::changedInclNet() try { - IPAddress a(m_dialog->snmpinaddr->text().toLatin1().constData()); - Netmask n(m_dialog->snmpinmask->text().toLatin1().constData()); - IPNetwork(a,n); + InetAddr a(m_dialog->snmpinaddr->text().toLatin1().constData()); + InetNetmask n(m_dialog->snmpinmask->text().toLatin1().constData()); + InetAddrMask(a,n); m_dialog->confineerror_message->setText(" "); isSNMPInclNetOK=true; @@ -2079,8 +2080,8 @@ void DiscoveryDruid::createRealObjects() ); assert(net!=NULL); net->setName(name); - net->setAddress(IPAddress(a)); - net->setNetmask(Netmask(IPAddress(a))); + net->setAddress(InetAddr(a)); + net->setNetmask(InetNetmask(InetAddr(a))); mw->moveObject(m_dialog->libs->currentText(), net); } } @@ -2114,8 +2115,8 @@ void DiscoveryDruid::createRealObjects() ); - ipv4->setAddress(a); - ipv4->setNetmask("255.255.255.255"); + ipv4->setAddress(InetAddr(a)); + ipv4->setNetmask(InetNetmask()); } else { map::const_iterator i; @@ -2162,8 +2163,8 @@ void DiscoveryDruid::createRealObjects() ); assert(net!=NULL); net->setName(name); - net->setAddress(IPAddress(a)); - net->setNetmask(Netmask(IPAddress(a))); + net->setAddress(InetAddr(a)); + net->setNetmask(InetNetmask(InetAddr(a))); mw->moveObject(m_dialog->libs->currentText(), net); }else if (type==IPv4::TYPENAME) { @@ -2172,8 +2173,8 @@ void DiscoveryDruid::createRealObjects() ); assert(obj!=NULL); obj->setName(name); - obj->setAddress(IPAddress(a)); - obj->setNetmask("255.255.255.255"); + obj->setAddress(InetAddr(a)); + obj->setNetmask(InetNetmask(InetAddr::getAllOnes())); mw->moveObject(m_dialog->libs->currentText(), obj); } } @@ -2343,7 +2344,7 @@ void HostsFileImport::run() *Log << "Discovery method:" << "Read file in hosts format. \n"; - map > reverse_hosts; + map > reverse_hosts; HostsFile *hf; /* * read hosts file here @@ -2377,7 +2378,7 @@ void HostsFileImport::run() */ hosts.clear(); - map >::iterator i; + map >::iterator i; int count=reverse_hosts.size(); int t=0; for (i=reverse_hosts.begin(); i!=reverse_hosts.end(); ++i) diff --git a/src/gui/DiscoveryDruid.h b/src/gui/DiscoveryDruid.h index 9a8ebc2bd..b47235bd6 100644 --- a/src/gui/DiscoveryDruid.h +++ b/src/gui/DiscoveryDruid.h @@ -38,7 +38,7 @@ #include "fwbuilder/Interface.h" #include "fwbuilder/dns.h" #include "fwbuilder/snmp.h" -#include "fwbuilder/IPAddress.h" +#include "fwbuilder/InetAddr.h" #include "fwbuilder/Logger.h" #include "FilterDialog.h" @@ -69,8 +69,8 @@ class ObjectDescriptor string MAC_addr ; libfwbuilder::HostEnt dns_info ; - libfwbuilder::IPAddress addr ; - libfwbuilder::Netmask netmask ; + libfwbuilder::InetAddr addr ; + libfwbuilder::InetNetmask netmask ; ObjectDescriptor(); @@ -194,8 +194,8 @@ private: int FromPage; QMap Objects; QMap Networks; - QMap NameServers; - vector include_networks; + QMap NameServers; + vector include_networks; QTimer* timer; QTimer* prg_timer; @@ -232,10 +232,10 @@ public: void createRealObjects(); // void stripObjects(); void getNameServers(); - IPAddress getNS(); - IPAddress getSeedHostAddress(); - bool isIPAddress(const QString s); - QString testIPAddress(const QString s); + InetAddr getNS(); + InetAddr getSeedHostAddress(); + bool isInetAddr(const QString s); + QString testInetAddr(const QString s); virtual void customEvent(QEvent *event); diff --git a/src/gui/IOSImporter.cpp b/src/gui/IOSImporter.cpp index 1b71f2329..9e08b49c0 100644 --- a/src/gui/IOSImporter.cpp +++ b/src/gui/IOSImporter.cpp @@ -40,7 +40,7 @@ #include "fwbuilder/Resources.h" #include "fwbuilder/Network.h" #include "fwbuilder/Address.h" -#include "fwbuilder/IPAddress.h" +#include "fwbuilder/InetAddr.h" #include "fwbuilder/IPService.h" #include "fwbuilder/ICMPService.h" #include "fwbuilder/TCPService.h" @@ -195,17 +195,14 @@ FWObject* IOSImporter::createAddress(const std::string &addr, // invert netmask (this is IOS) try { - IPAddress orig_nm(netmask); - long nm = orig_nm.to32BitInt(); - struct in_addr na; - na.s_addr = ~nm; - correct_nm = IPAddress(&na).toString(); + InetAddr orig_nm(netmask); + correct_nm = (~orig_nm).toString(); return Importer::createAddress(addr, correct_nm); } catch (FWException &ex) { markCurrentRuleBad( std::string("Error converting netmask '") + netmask + "' (address " + addr + ")"); - return Importer::createAddress(addr, "255.255.255.255"); + return Importer::createAddress(addr, InetAddr::getAllOnes().toString()); } } diff --git a/src/gui/IPTImporter.cpp b/src/gui/IPTImporter.cpp index 0cdfa4b96..6f3382e87 100644 --- a/src/gui/IPTImporter.cpp +++ b/src/gui/IPTImporter.cpp @@ -48,7 +48,7 @@ #include "fwbuilder/Network.h" #include "fwbuilder/Address.h" #include "fwbuilder/AddressRange.h" -#include "fwbuilder/IPAddress.h" +#include "fwbuilder/InetAddr.h" #include "fwbuilder/IPService.h" #include "fwbuilder/ICMPService.h" #include "fwbuilder/TCPService.h" @@ -727,9 +727,9 @@ void IPTImporter::pushNATRule() addODst(); addOSrv(); - if (src_nm.empty()) src_nm = "255.255.255.255"; - if (dst_nm.empty()) dst_nm = "255.255.255.255"; - if (nat_nm.empty()) nat_nm = "255.255.255.255"; + if (src_nm.empty()) src_nm = InetAddr::getAllOnes().toString(); + if (dst_nm.empty()) dst_nm = InetAddr::getAllOnes().toString(); + if (nat_nm.empty()) nat_nm = InetAddr::getAllOnes().toString(); if (target=="ACCEPT") { diff --git a/src/gui/IPv4Dialog.cpp b/src/gui/IPv4Dialog.cpp index c30f2553e..20254ef58 100644 --- a/src/gui/IPv4Dialog.cpp +++ b/src/gui/IPv4Dialog.cpp @@ -155,7 +155,7 @@ void IPv4Dialog::validate(bool *res) assert(s!=NULL); try { - IPAddress( m_dialog->address->text().toLatin1().constData() ); + InetAddr( m_dialog->address->text().toLatin1().constData() ); } catch (FWException &ex) { *res=false; @@ -169,7 +169,7 @@ void IPv4Dialog::validate(bool *res) { try { - Netmask( m_dialog->netmask->text().toLatin1().constData() ); + InetNetmask( m_dialog->netmask->text().toLatin1().constData() ); } catch (FWException &ex) { *res=false; @@ -203,17 +203,19 @@ void IPv4Dialog::applyChanges() try { - s->setAddress( m_dialog->address->text().toLatin1().constData() ); + s->setAddress( + InetAddr(m_dialog->address->text().toLatin1().constData()) ); } catch (FWException &ex) { } if ( showNetmask ) { try { - s->setNetmask( m_dialog->netmask->text().toLatin1().constData() ); + s->setNetmask( + InetNetmask(m_dialog->netmask->text().toLatin1().constData()) ); } catch (FWException &ex) { } } else - s->setNetmask( "255.255.255.255" ); + s->setNetmask(InetNetmask()); mw->updateObjName(obj,QString::fromUtf8(oldname.c_str())); diff --git a/src/gui/Importer.cpp b/src/gui/Importer.cpp index da8b7080f..e90b2baa1 100644 --- a/src/gui/Importer.cpp +++ b/src/gui/Importer.cpp @@ -246,8 +246,8 @@ void Importer::addInterfaceAddress(const std::string &a, IPv4::TYPENAME, aname); current_interface->setUnnumbered(false); - IPv4::cast(nobj)->setAddress( a ); - IPv4::cast(nobj)->setNetmask( nm ); + IPv4::cast(nobj)->setAddress( InetAddr(a) ); + IPv4::cast(nobj)->setNetmask( InetNetmask(nm) ); *logger << "Interface address: " << a << "/" << nm << "\n"; } @@ -395,17 +395,21 @@ void Importer::pushRule() FWObject* Importer::makeSrcObj() { - if ( (src_a=="" && src_nm=="") || (src_a=="0.0.0.0" && src_nm=="0.0.0.0")) + if ( (src_a=="" && src_nm=="") || + (src_a==InetAddr::getAny().toString() && + src_nm==InetAddr::getAny().toString())) return NULL; // this is 'any' - if (src_nm=="") src_nm="255.255.255.255"; + if (src_nm=="") src_nm=InetAddr::getAllOnes().toString(); return createAddress(src_a, src_nm); } FWObject* Importer::makeDstObj() { - if ( (dst_a=="" && dst_nm=="") || (dst_a=="0.0.0.0" && dst_nm=="0.0.0.0")) + if ( (dst_a=="" && dst_nm=="") || + (dst_a==InetAddr::getAny().toString() && + dst_nm==InetAddr::getAny().toString())) return NULL; // this is 'any' - if (dst_nm=="") dst_nm="255.255.255.255"; + if (dst_nm=="") dst_nm=InetAddr::getAllOnes().toString(); return createAddress(dst_a, dst_nm); } @@ -816,13 +820,13 @@ FWObject* Importer::createAddress(const std::string &addr, std::string sig = std::string("addr-") + addr + "/" + netmask; if (all_objects.count(sig)!=0) return all_objects[sig]; - if ( netmask == "255.255.255.255" ) + if ( netmask == InetAddr::getAllOnes().toString() ) { Address *a; std::string name = std::string("h-") + addr; a = Address::cast(createObject(IPv4::TYPENAME, name)); - a->setAddress( addr ); - a->setNetmask( "255.255.255.255" ); + a->setAddress(InetAddr(addr)); + a->setNetmask(InetNetmask(InetAddr::getAllOnes())); a->setComment(comment); all_objects[sig] = a; *logger << "Address object: " << name << "\n"; @@ -834,7 +838,7 @@ FWObject* Importer::createAddress(const std::string &addr, net = Network::cast(createObject(Network::TYPENAME, name)); try { - net->setAddress( addr ); + net->setAddress( InetAddr(addr) ); } catch (FWException &ex) { markCurrentRuleBad( @@ -843,7 +847,7 @@ FWObject* Importer::createAddress(const std::string &addr, try { - net->setNetmask( netmask ); + net->setNetmask( InetNetmask(netmask) ); } catch (FWException &ex) { if (netmask.find('.')!=std::string::npos) @@ -862,7 +866,7 @@ FWObject* Importer::createAddress(const std::string &addr, try { str >> nm_len; - net->setNetmask( Netmask(nm_len) ); + net->setNetmask( InetNetmask(nm_len) ); } catch (std::exception& e) { // could not convert netmask as simple integer @@ -894,7 +898,7 @@ FWObject* Importer::createAddressRange(const std::string &addr1, try { - ar->setRangeStart( IPAddress(addr1) ); + ar->setRangeStart( InetAddr(addr1) ); } catch (FWException &ex) { markCurrentRuleBad( @@ -903,7 +907,7 @@ FWObject* Importer::createAddressRange(const std::string &addr1, try { - ar->setRangeEnd( IPAddress(addr2) ); + ar->setRangeEnd( InetAddr(addr2) ); } catch (FWException &ex) { markCurrentRuleBad( diff --git a/src/gui/InterfaceData.cpp b/src/gui/InterfaceData.cpp index 7ed5b674b..3d66c23c0 100644 --- a/src/gui/InterfaceData.cpp +++ b/src/gui/InterfaceData.cpp @@ -30,7 +30,7 @@ #include "InterfaceData.h" #include "fwbuilder/Resources.h" -#include "fwbuilder/IPAddress.h" +#include "fwbuilder/InetAddr.h" using namespace libfwbuilder; using namespace std; @@ -54,16 +54,17 @@ void InterfaceData::guessLabel(const string &platform) if (!isDyn && !isUnnumbered && !isBridgePort && - address=="127.0.0.1") label="loopback"; + address == InetAddr::getLoopbackAddr().toString()) + label="loopback"; } void InterfaceData::guessSecurityLevel(const string &platform) { - IPNetwork n10(IPAddress("10.0.0.0"),Netmask("255.0.0.0")); - IPNetwork n172(IPAddress("172.16.0.0"),Netmask("255.240.0.0")); - IPNetwork n192(IPAddress("192.168.0.0"),Netmask("255.255.0.0")); + InetAddrMask n10(InetAddr("10.0.0.0"), InetNetmask("255.0.0.0")); + InetAddrMask n172(InetAddr("172.16.0.0"), InetNetmask("255.240.0.0")); + InetAddrMask n192(InetAddr("192.168.0.0"), InetNetmask("255.255.0.0")); securityLevel=-1; @@ -89,14 +90,14 @@ void InterfaceData::guessSecurityLevel(const string &platform) llbl=="internal_net" || llbl=="internal net" ) securityLevel=100; - if ( address=="127.0.0.1") securityLevel=100; - if ( name=="Null0" ) securityLevel=100; + if ( address==InetAddr::getLoopbackAddr().toString()) securityLevel=100; + if ( name=="Null0" ) securityLevel=100; if (securityLevel==-1 && !isDyn && !isUnnumbered && !isBridgePort) { - if (n10.belongs( IPAddress( address ) )) securityLevel=100; - if (n172.belongs( IPAddress( address ) )) securityLevel=100; - if (n192.belongs( IPAddress( address ) )) securityLevel=100; + if (n10.belongs( InetAddr( address ) )) securityLevel=100; + if (n172.belongs( InetAddr( address ) )) securityLevel=100; + if (n192.belongs( InetAddr( address ) )) securityLevel=100; } if (isDyn || isUnnumbered || isBridgePort) securityLevel=0; @@ -141,13 +142,13 @@ void InterfaceData::guessSecurityLevel(const string &platform, if (ifaces.size()==2) { - if (ifaces.front().address=="127.0.0.1") + if (ifaces.front().address==InetAddr::getLoopbackAddr().toString()) { ifaces.front().securityLevel=100; ifaces.back().securityLevel=0; } else { - if (ifaces.back().address=="127.0.0.1") + if (ifaces.back().address==InetAddr::getLoopbackAddr().toString()) { ifaces.front().securityLevel=0; ifaces.back().securityLevel=100; diff --git a/src/gui/NetworkDialog.cpp b/src/gui/NetworkDialog.cpp index af7138ce8..7d5a867b1 100644 --- a/src/gui/NetworkDialog.cpp +++ b/src/gui/NetworkDialog.cpp @@ -114,7 +114,7 @@ void NetworkDialog::validate(bool *res) assert(s!=NULL); try { - IPAddress( m_dialog->address->text().toLatin1().constData() ); + InetAddr( m_dialog->address->text().toLatin1().constData() ); } catch (FWException &ex) { *res=false; @@ -125,7 +125,7 @@ void NetworkDialog::validate(bool *res) } try { - Netmask( m_dialog->netmask->text().toLatin1().constData() ); + InetNetmask( m_dialog->netmask->text().toLatin1().constData() ); } catch (FWException &ex) { *res=false; @@ -156,8 +156,10 @@ void NetworkDialog::applyChanges() obj->setComment( string(m_dialog->comment->toPlainText().toUtf8().constData()) ); try { - s->setAddress( m_dialog->address->text().toLatin1().constData() ); - s->setNetmask( m_dialog->netmask->text().toLatin1().constData() ); + s->setAddress( + InetAddr(m_dialog->address->text().toLatin1().constData()) ); + s->setNetmask( + InetNetmask(m_dialog->netmask->text().toLatin1().constData()) ); } catch (FWException &ex) { /* exception thrown if user types illegal m_dialog->address or m_dialog->netmask */ diff --git a/src/gui/fwbuilder_ph.h b/src/gui/fwbuilder_ph.h index 96b3881a4..60f749f32 100755 --- a/src/gui/fwbuilder_ph.h +++ b/src/gui/fwbuilder_ph.h @@ -2,6 +2,8 @@ #include "utils.h" #include "config.h" #include +#include "fwbuilder/InetAddr.h" +#include "fwbuilder/InetAddrMask.h" #include "fwbuilder/Firewall.h" #include #include @@ -104,7 +106,6 @@ #include #include #include -#include "fwbuilder/IPAddress.h" #include #include #include diff --git a/src/gui/instDialog.cpp b/src/gui/instDialog.cpp index 3e9940c64..4134bbdf1 100644 --- a/src/gui/instDialog.cpp +++ b/src/gui/instDialog.cpp @@ -766,7 +766,8 @@ bool instDialog::doInstallPage(Firewall* f) .arg(cnf.fwobj->getName().c_str()).toLatin1().constData() ); return false; } - if ((cnf.maddr == "" || cnf.maddr == "0.0.0.0")) + if (cnf.maddr == "" || + cnf.maddr == QString(InetAddr::getAny().toString().c_str())) { addToLog( QObject::tr("Management interface does not have IP address, can not communicate with the firewall.") ); diff --git a/src/gui/newFirewallDialog.cpp b/src/gui/newFirewallDialog.cpp index 9ceae1683..8b80f727b 100644 --- a/src/gui/newFirewallDialog.cpp +++ b/src/gui/newFirewallDialog.cpp @@ -256,14 +256,14 @@ void newFirewallDialog::getInterfacesViaSNMP() getInterfacesBusy = true; - IPAddress addr; + InetAddr addr; QString name=m_dialog->obj_name->text().toLatin1().constData(); try { QApplication::setOverrideCursor( QCursor( Qt::WaitCursor) ); QString a = getAddrByName(name); QApplication::restoreOverrideCursor(); - addr = a.toAscii().constData(); + addr = InetAddr(a.toAscii().constData()); } catch (FWException &ex) { QMessageBox::warning( @@ -587,13 +587,15 @@ void newFirewallDialog::addInterface() addr = m_dialog->iface_addr->text(); netm = m_dialog->iface_netmask->text(); - if (addr.isEmpty()) addr="0.0.0.0"; - if (netm.isEmpty()) netm="0.0.0.0"; + if (addr.isEmpty()) + addr = QString(InetAddr::getAny().toString().c_str()); + if (netm.isEmpty()) + netm = QString(InetAddr::getAny().toString().c_str()); try { - IPAddress(addr.toLatin1().constData()); - Netmask(netm.toLatin1().constData()); + InetAddr(addr.toLatin1().constData()); + InetNetmask(netm.toLatin1().constData()); } catch (FWException &ex) { @@ -809,8 +811,8 @@ void newFirewallDialog::finishClicked() { QString addrname=QString("%1:%2:ip").arg(m_dialog->obj_name->text()).arg(name); IPv4 *oa = IPv4::cast(mw->createObject(oi, IPv4::TYPENAME,addrname)); - oa->setAddress( addr.toLatin1().constData() ); - oa->setNetmask( netmask.toLatin1().constData() ); + oa->setAddress( InetAddr(addr.toLatin1().constData()) ); + oa->setNetmask( InetNetmask(netmask.toLatin1().constData()) ); } // updateObjName has a side effect: it causes redraw of the ruleset // views in the main window diff --git a/src/gui/newHostDialog.cpp b/src/gui/newHostDialog.cpp index dc56035bb..5a51aa2ae 100644 --- a/src/gui/newHostDialog.cpp +++ b/src/gui/newHostDialog.cpp @@ -248,14 +248,14 @@ void newHostDialog::getInterfacesViaSNMP() getInterfacesBusy = true; - IPAddress addr; + InetAddr addr; QString name=m_dialog->obj_name->text().toLatin1().constData(); try { QApplication::setOverrideCursor( QCursor( Qt::WaitCursor) ); QString a = getAddrByName(name); QApplication::restoreOverrideCursor(); - addr = a.toAscii().constData(); + addr = InetAddr(a.toAscii().constData()); } catch (FWException &ex) { QMessageBox::warning( @@ -489,18 +489,21 @@ void newHostDialog::addInterface() QString addr; QString netm; - if (!m_dialog->iface_dyn->isChecked() && !m_dialog->iface_unnum->isChecked()) + if (!m_dialog->iface_dyn->isChecked() && + !m_dialog->iface_unnum->isChecked()) { addr = m_dialog->iface_addr->text(); netm = m_dialog->iface_netmask->text(); - if (addr.isEmpty()) addr="0.0.0.0"; - if (netm.isEmpty()) netm="0.0.0.0"; + if (addr.isEmpty()) + addr = QString(InetAddr::getAny().toString().c_str()); + if (netm.isEmpty()) + netm = QString(InetAddr::getAny().toString().c_str()); try { - IPAddress(addr.toLatin1().constData()); - Netmask(netm.toLatin1().constData()); + InetAddr(addr.toLatin1().constData()); + InetNetmask(netm.toLatin1().constData()); } catch (FWException &ex) { @@ -628,8 +631,8 @@ void newHostDialog::finishClicked() IPv4 *oa = IPv4::cast( mw->createObject(oi, IPv4::TYPENAME,addrname) ); - oa->setAddress( addr.toLatin1().constData() ); - oa->setNetmask( netmask.toLatin1().constData() ); + oa->setAddress( InetAddr(addr.toLatin1().constData()) ); + oa->setNetmask( InetNetmask(netmask.toLatin1().constData()) ); } mw->updateObjName(oi,"","",false); diff --git a/src/iosacl/PolicyCompiler_iosacl.cpp b/src/iosacl/PolicyCompiler_iosacl.cpp index 8503923bf..bd597dc00 100644 --- a/src/iosacl/PolicyCompiler_iosacl.cpp +++ b/src/iosacl/PolicyCompiler_iosacl.cpp @@ -109,14 +109,14 @@ int PolicyCompiler_iosacl::prolog() { if (netmask.find(".")!=string::npos) { - Netmask nm(netmask); - nm.to32BitInt(); // to avoid warning abt unused var + InetNetmask nm(netmask); + nm.getLength(); // to avoid warning abt unused var } else { int nm_length; istringstream str(netmask); str >> nm_length; - Netmask nm(nm_length); + InetNetmask nm(nm_length); netmask = nm.toString(); } } catch(FWException &ex) @@ -127,8 +127,8 @@ int PolicyCompiler_iosacl::prolog() try { - IPAddress a(addr); - a.to32BitInt(); + InetAddr a(addr); + a.isAny(); } catch(FWException &ex) { abort("Invalid address for management subnet: '"+addr+"'"); @@ -143,10 +143,10 @@ int PolicyCompiler_iosacl::prolog() // cisco uses "wildcards" instead of netmasks - long nm = Netmask(netmask).to32BitInt(); - struct in_addr na; - na.s_addr = ~nm; - IPAddress nnm(&na); + //long nm = InetNetmask(netmask).to32BitInt(); + //struct in_addr na; + //na.s_addr = ~nm; + InetAddr nnm( ~(InetNetmask(netmask)) ); output << clearACLcmd << " " << temp_acl << endl; output << "ip access-list extended " << temp_acl << endl; diff --git a/src/iosacl/PolicyCompiler_iosacl_writers.cpp b/src/iosacl/PolicyCompiler_iosacl_writers.cpp index 691abed95..3664befb2 100644 --- a/src/iosacl/PolicyCompiler_iosacl_writers.cpp +++ b/src/iosacl/PolicyCompiler_iosacl_writers.cpp @@ -371,8 +371,8 @@ string PolicyCompiler_iosacl::PrintRule::_printAddr(libfwbuilder::Address *o) { ostringstream str; - IPAddress srcaddr=o->getAddress(); - Netmask srcmask=o->getNetmask(); + InetAddr srcaddr=o->getAddress(); + InetNetmask srcmask=o->getNetmask(); if (Interface::cast(o)!=NULL) { @@ -382,18 +382,18 @@ string PolicyCompiler_iosacl::PrintRule::_printAddr(libfwbuilder::Address *o) return string("interface ") + interface_->getLabel() + " "; } - srcmask=Netmask("255.255.255.255"); + srcmask=InetNetmask(InetAddr::getAllOnes()); } if (IPv4::cast(o)!=NULL) - srcmask=Netmask("255.255.255.255"); + srcmask=InetNetmask(InetAddr::getAllOnes()); - if (srcaddr.toString()=="0.0.0.0" && srcmask.toString()=="0.0.0.0") + if (srcaddr.isAny() && srcmask.isAny()) { str << "any "; } else { - if (srcmask.toString()=="255.255.255.255") + if (srcmask.isHostMask()) { str << "host " << srcaddr.toString() << " "; } else @@ -402,10 +402,10 @@ string PolicyCompiler_iosacl::PrintRule::_printAddr(libfwbuilder::Address *o) // cisco uses "wildcards" instead of netmasks - long nm = srcmask.to32BitInt(); - struct in_addr na; - na.s_addr = ~nm; - IPAddress nnm(&na); + //long nm = srcmask.to32BitInt(); + //struct in_addr na; + //na.s_addr = ~nm; + InetAddr nnm( ~srcmask ); str << nnm.toString() << " "; } diff --git a/src/ipf/ipf.cpp b/src/ipf/ipf.cpp index 7a6a24664..a857e7f99 100644 --- a/src/ipf/ipf.cpp +++ b/src/ipf/ipf.cpp @@ -319,7 +319,7 @@ int main(int argc, char * const *argv) for (list::iterator j=la.begin(); j!=la.end(); ++j) { IPv4 *ipv4 = IPv4::cast(*j); - if ( ipv4->getAddress().toString()=="0.0.0.0") + if ( ipv4->getAddress() == InetAddr::getAny()) { char errstr[256]; sprintf(errstr, diff --git a/src/ipfw/ipfw.cpp b/src/ipfw/ipfw.cpp index 9a7d793b0..6bc4dbfaf 100644 --- a/src/ipfw/ipfw.cpp +++ b/src/ipfw/ipfw.cpp @@ -286,7 +286,7 @@ int main(int argc, char * const *argv) for (list::iterator j=la.begin(); j!=la.end(); ++j) { IPv4 *ipv4 = IPv4::cast(*j); - if ( ipv4->getAddress().toString()=="0.0.0.0") + if ( ipv4->getAddress() == InetAddr::getAny()) { char errstr[256]; sprintf(errstr, diff --git a/src/ipt/NATCompiler_PrintRule.cpp b/src/ipt/NATCompiler_PrintRule.cpp index 73e1e6dd1..cd1cbbe64 100644 --- a/src/ipt/NATCompiler_PrintRule.cpp +++ b/src/ipt/NATCompiler_PrintRule.cpp @@ -453,37 +453,39 @@ string NATCompiler_ipt::PrintRule::_printAddr(Address *o,bool print_mask,bool p assert(atrt==NULL); } - IPAddress addr=o->getAddress(); - Netmask mask=o->getNetmask(); - Interface *iface; - if ( (iface=Interface::cast(o))!=NULL ) + if (print_range && AddressRange::cast(o)!=NULL) { - if (iface->isDyn() && iface->getBool("use_var_address")) - { - ostr << "$" << ipt_comp->getInterfaceVarName(iface) << " "; - return ostr.str(); - } -// if (Interface::cast(o)->isDyn()) return; - mask=Netmask("255.255.255.255"); - } - - if (IPv4::cast(o)!=NULL) - { - mask=Netmask("255.255.255.255"); - } - - if (print_range && AddressRange::cast(o)!=NULL) { - IPAddress a1=AddressRange::cast(o)->getRangeStart(); - IPAddress a2=AddressRange::cast(o)->getRangeEnd(); + InetAddr a1 = AddressRange::cast(o)->getRangeStart(); + InetAddr a2 = AddressRange::cast(o)->getRangeEnd(); ostr << a1.toString() << "-" << a2.toString(); - } else { - if (addr.toString()=="0.0.0.0" && mask.toString()=="0.0.0.0") { + } else + { + const InetAddr& addr=o->getAddress(); + const InetNetmask& mask=o->getNetmask(); + + if (addr == InetAddr::getAny() && mask == InetAddr::getAny()) + { ostr << "0/0"; - } else { + } else + { + Interface *iface; + if ( (iface=Interface::cast(o))!=NULL ) + { + if (iface->isDyn() && iface->getBool("use_var_address")) + { + ostr << "$" << ipt_comp->getInterfaceVarName(iface) << " "; + return ostr.str(); + } + ostr << addr.toString(); + return ostr.str(); + } + ostr << addr.toString(); - if (print_mask && mask.toString()!="255.255.255.255") { - ostr << "/" << mask.getLength(); - } + + if (print_mask && IPv4::cast(o)==NULL && !mask.isHostMask()) + { + ostr << "/" << mask.getLength(); + } } } return ostr.str(); @@ -571,7 +573,7 @@ bool NATCompiler_ipt::PrintRule::processNext() * fool-proof: this is last resort check for situation when user created IPv4 object * for the interface but left it with empty address ( 0.0.0.0 ). */ - if ( ! physaddress.empty() && osrc->getAddress()==IPAddress("0.0.0.0")) + if ( ! physaddress.empty() && osrc->getAddress()==InetAddr()) { ; } else diff --git a/src/ipt/NATCompiler_ipt.cpp b/src/ipt/NATCompiler_ipt.cpp index 91ced98ee..e3d784602 100644 --- a/src/ipt/NATCompiler_ipt.cpp +++ b/src/ipt/NATCompiler_ipt.cpp @@ -221,21 +221,21 @@ bool NATCompiler_ipt::ConvertLoadBalancingRules::processNext() { RuleElementTDst *tdst=rule->getTDst(); assert(tdst); - list al; + list al; for(list::iterator i=tdst->begin(); i!=tdst->end(); i++) { FWObject *o= *i; FWObject *obj = NULL; if (FWReference::cast(o)!=NULL) obj=FWReference::cast(o)->getPointer(); - Address *a=Address::cast(obj); + Address *a = Address::cast(obj); - al.push_back( a->getAddress() ); + al.push_back( a->getAddressPtr() ); } al.sort(); - IPAddress a1=al.front(); - list::iterator j=al.begin(); + const InetAddr* a1 = al.front(); + list::iterator j=al.begin(); j++; for ( ; j!=al.end(); j++) @@ -244,21 +244,23 @@ bool NATCompiler_ipt::ConvertLoadBalancingRules::processNext() * big endian/little endian conversion for me */ AddressRange tar; - tar.setRangeStart( a1 ); - tar.setRangeEnd( *j ); + tar.setRangeStart( *a1 ); + tar.setRangeEnd( *(*j) ); if ( tar.dimension() != 2 ) { compiler->abort( string( _("Non-contiguous address range in Translated Destination in load balancing NAT rule ") )+ rule->getLabel()); } - a1= *j; + a1 = *j; } - AddressRange *ar= AddressRange::cast(compiler->dbcopy->create(AddressRange::TYPENAME) ); - ar->setRangeStart( al.front() ); - ar->setRangeEnd( al.back() ); - ar->setName(string("%")+al.front().toString()+"-"+al.back().toString()+"%" ); + AddressRange *ar = AddressRange::cast( + compiler->dbcopy->create(AddressRange::TYPENAME) ); + ar->setRangeStart( *(al.front()) ); + ar->setRangeEnd( *(al.back()) ); + ar->setName(string("%")+al.front()->toString() + +"-"+al.back()->toString()+"%" ); compiler->cacheObj(ar); // to keep cache consistent compiler->dbcopy->add(ar,false); tdst->clearChildren(); @@ -2023,7 +2025,6 @@ bool NATCompiler_ipt::processMultiAddressObjectsInRE::processNext() dynamic_cast(compiler->osconfigurator); RuleElement *re=RuleElement::cast( rule->getFirstByType(re_type) ); - bool neg = re->getNeg(); if (re->size()==1) { diff --git a/src/ipt/OSConfigurator_linux24.cpp b/src/ipt/OSConfigurator_linux24.cpp index 9630ecc5a..376c8fb45 100644 --- a/src/ipt/OSConfigurator_linux24.cpp +++ b/src/ipt/OSConfigurator_linux24.cpp @@ -28,6 +28,8 @@ #include "OSConfigurator_linux24.h" +#include "fwbuilder/InetAddr.h" + #include "fwbuilder/Firewall.h" #include "fwbuilder/FWOptions.h" #include "fwbuilder/Interface.h" @@ -199,29 +201,25 @@ void OSConfigurator_linux24::addVirtualAddressForNAT(const Network *nw) if ( options->getBool("manage_virtual_addr") ) { if (virtual_addresses.empty() || - find(virtual_addresses.begin(),virtual_addresses.end(),nw->getAddress())==virtual_addresses.end()) + find(virtual_addresses.begin(),virtual_addresses.end(), + nw->getAddress())==virtual_addresses.end()) { Interface *iface=findInterfaceFor( nw, fw ); if (iface!=NULL) { - IPNetwork n( nw->getAddress() , nw->getNetmask() ); - - IPAddress a; + const InetAddr& a = nw->getAddress(); string str, subnet, first, last; - a=nw->getAddress() +1; - first = a.toString(); - - a = n.getBroadcastAddress() -1; - last = a.toString(); + first = (a + 1).toString(); + last = (nw->getBroadcastAddress() -1).toString(); ostr << endl; ostr << "a=\"" << first << "\"" << endl; ostr << "while test \"$a\" != \"" << last << "\"; do" << endl; - ostr << " add_addr ${a} " << nw->getNetmask().getLength() << " " - << iface->getName() << endl; + ostr << " add_addr ${a} " << nw->getNetmask().getLength() + << " " << iface->getName() << endl; ostr << endl; ostr << " OIFS=$IFS" << endl; @@ -254,7 +252,8 @@ void OSConfigurator_linux24::addVirtualAddressForNAT(const Address *addr) if ( options->getBool("manage_virtual_addr") ) { if (virtual_addresses.empty() || - find(virtual_addresses.begin(),virtual_addresses.end(),addr->getAddress())==virtual_addresses.end()) + find(virtual_addresses.begin(),virtual_addresses.end(), + addr->getAddress())==virtual_addresses.end()) { IPv4 *iaddr=IPv4::cast( findAddressFor(addr, fw ) ); if (iaddr!=NULL) @@ -269,7 +268,8 @@ void OSConfigurator_linux24::addVirtualAddressForNAT(const Address *addr) virtual_addresses.push_back(addr->getAddress()); registerVirtualAddressForNat(); } else - warning(_("Can not add virtual address ") + addr->getAddress().toString() + + warning(_("Can not add virtual address ") + + addr->getAddress().toString() + _(" (object ") + addr->getName() + ")" ); } commands_to_add_virtual_addresses.push_back(ostr.str()); diff --git a/src/ipt/OSConfigurator_linux24.h b/src/ipt/OSConfigurator_linux24.h index f22100776..36c88d17f 100644 --- a/src/ipt/OSConfigurator_linux24.h +++ b/src/ipt/OSConfigurator_linux24.h @@ -42,9 +42,9 @@ namespace fwcompiler { class OSConfigurator_linux24 : public OSConfigurator { OSData os_data; - std::map address_table_objects; - std::vector virtual_addresses; - std::list commands_to_add_virtual_addresses; + std::map address_table_objects; + std::vector virtual_addresses; + std::list commands_to_add_virtual_addresses; std::string getInterfaceVarName(libfwbuilder::FWObject *iface); diff --git a/src/ipt/PolicyCompiler_PrintRule.cpp b/src/ipt/PolicyCompiler_PrintRule.cpp index ec49a60c4..7c625bbdc 100644 --- a/src/ipt/PolicyCompiler_PrintRule.cpp +++ b/src/ipt/PolicyCompiler_PrintRule.cpp @@ -906,40 +906,18 @@ string PolicyCompiler_ipt::PrintRule::_printAddr(Address *o) return ostr.str(); } - IPAddress addr; - Netmask mask; - try { - addr=o->getAddress(); + const InetAddr& addr = o->getAddress(); + const InetNetmask& mask = o->getNetmask(); - if (Interface::cast(o)!=NULL || IPv4::cast(o)!=NULL) mask=Netmask("255.255.255.255"); - else mask=o->getNetmask(); - } - catch (FWException ex) - { - FWObject *obj=o; -/* - * check if this is object of class Address. since we want to - * distinguish between Host, Interface and Address, and both Host and - * Interface are inherited from Address, we can't use cast. Use isA - * instead - */ - while (obj!=NULL && - !Host::isA(obj) && - !Firewall::isA(obj) && - !Network::isA(obj)) obj=obj->getParent(); - - compiler->error(_("Problem with address or netmask in the object or one of its interfaces: '")+obj->getName()+"'"); - throw; - } - - - if (addr.toString()=="0.0.0.0" && mask.toString()=="0.0.0.0") + if (addr.isAny() && mask.isAny()) { ostr << "0/0 "; } else { ostr << addr.toString(); - if (mask.toString()!="255.255.255.255") + + if (Interface::cast(o)==NULL && IPv4::cast(o)==NULL && + !mask.isHostMask()) { ostr << "/" << mask.getLength(); } @@ -1080,7 +1058,6 @@ PolicyCompiler_ipt::PrintRule::PrintRule(const std::string &name) : PolicyRulePr bool PolicyCompiler_ipt::PrintRule::processNext() { - PolicyCompiler_ipt *ipt_comp=dynamic_cast(compiler); PolicyRule *rule =getNext(); if (rule==NULL) return false; @@ -1147,7 +1124,7 @@ string PolicyCompiler_ipt::PrintRule::PolicyRuleToString(PolicyRule *rule) * fool-proof: this is last resort check for situation when user created IPv4 object * for the interface but left it with empty address ( 0.0.0.0 ). */ - if ( ! physaddress.empty() && src->getAddress()==IPAddress("0.0.0.0")) + if ( ! physaddress.empty() && src->getAddress()==InetAddr()) { ; } else @@ -1202,7 +1179,7 @@ string PolicyCompiler_ipt::PrintRule::_declareTable() string PolicyCompiler_ipt::PrintRule::_flushAndSetDefaultPolicy() { - PolicyCompiler_ipt *ipt_comp = dynamic_cast(compiler); +// PolicyCompiler_ipt *ipt_comp = dynamic_cast(compiler); FWOptions *fwopt = compiler->getCachedFwOpt(); ostringstream res; diff --git a/src/ipt/PolicyCompiler_PrintRuleIptRst.cpp b/src/ipt/PolicyCompiler_PrintRuleIptRst.cpp index 358de9457..40c25f42d 100644 --- a/src/ipt/PolicyCompiler_PrintRuleIptRst.cpp +++ b/src/ipt/PolicyCompiler_PrintRuleIptRst.cpp @@ -135,7 +135,6 @@ string PolicyCompiler_ipt::PrintRuleIptRst::_declareTable() string PolicyCompiler_ipt::PrintRuleIptRst::_flushAndSetDefaultPolicy() { - PolicyCompiler_ipt *ipt_comp=dynamic_cast(compiler); ostringstream res; res << ":INPUT DROP [0:0]" << endl; diff --git a/src/ipt/PolicyCompiler_PrintRuleIptRstEcho.cpp b/src/ipt/PolicyCompiler_PrintRuleIptRstEcho.cpp index 5a37266da..984e5d7af 100644 --- a/src/ipt/PolicyCompiler_PrintRuleIptRstEcho.cpp +++ b/src/ipt/PolicyCompiler_PrintRuleIptRstEcho.cpp @@ -101,7 +101,6 @@ string PolicyCompiler_ipt::PrintRuleIptRstEcho::_declareTable() string PolicyCompiler_ipt::PrintRuleIptRstEcho::_flushAndSetDefaultPolicy() { - PolicyCompiler_ipt *ipt_comp=dynamic_cast(compiler); ostringstream res; res << "echo :INPUT DROP [0:0]" << endl; diff --git a/src/ipt/PolicyCompiler_ipt.cpp b/src/ipt/PolicyCompiler_ipt.cpp index c46de46c6..c3e7f1596 100644 --- a/src/ipt/PolicyCompiler_ipt.cpp +++ b/src/ipt/PolicyCompiler_ipt.cpp @@ -340,8 +340,8 @@ int PolicyCompiler_ipt::prolog() bcast255=Address::cast(dbcopy->create(IPv4::TYPENAME) ); bcast255->setId(BCAST_255_OBJ_ID); bcast255->setName("Broadcast_addr"); - bcast255->setAddress("255.255.255.255"); - bcast255->setNetmask("255.255.255.255"); + bcast255->setAddress(InetAddr::getAllOnes()); + bcast255->setNetmask(InetNetmask(InetAddr::getAllOnes())); dbcopy->add(bcast255); cacheObj(bcast255); @@ -1707,23 +1707,25 @@ bool PolicyCompiler_ipt::splitIfIfaceAndDirectionBoth::processNext() return true; } -bool PolicyCompiler_ipt::bridgingFw::checkForMatchingBroadcastAndMulticast(Address *addr) +bool PolicyCompiler_ipt::bridgingFw::checkForMatchingBroadcastAndMulticast( + Address *addr) { - IPAddress obj1_addr=addr->getAddress(); - if (obj1_addr!=IPAddress("0.0.0.0") && + const InetAddr& obj1_addr = addr->getAddress(); + if (!obj1_addr.isAny() && (obj1_addr.isBroadcast() || obj1_addr.isMulticast()) ) return true; - FWObjectTypedChildIterator j=compiler->fw->findByType(Interface::TYPENAME); - for ( ; j!=j.end(); ++j ) + FWObjectTypedChildIterator j= compiler->fw->findByType(Interface::TYPENAME); + for ( ; j!=j.end(); ++j ) { - Interface *iface=Interface::cast(*j); + Interface *iface = Interface::cast(*j); if ( iface->isRegular() ) { - FWObjectTypedChildIterator k=iface->findByType(IPv4::TYPENAME); - for ( ; k!=k.end(); ++k ) { - IPv4 *ipv4=IPv4::cast(*k); + FWObjectTypedChildIterator k = iface->findByType(IPv4::TYPENAME); + for ( ; k!=k.end(); ++k ) + { + IPv4 *ipv4 = IPv4::cast(*k); /* * bug #780345: if interface has netmask 255.255.255.255, its own @@ -1736,7 +1738,8 @@ bool PolicyCompiler_ipt::bridgingFw::checkForMatchingBroadcastAndMulticast(Addre * interface, and the netmask is 255.255.255.255, then we get positive * match because this routine interprets this address as a broadcast. */ - if (ipv4->getNetmask()==Netmask("255.255.255.255")) continue; + if (ipv4->getNetmask().isHostMask()) + continue; /* * commented out to fix bug #637694 - "bridge enbaled / management" * Rule where firewall was in destination, and bridging option was on, @@ -1745,9 +1748,8 @@ bool PolicyCompiler_ipt::bridgingFw::checkForMatchingBroadcastAndMulticast(Addre if ( ipv4->getAddress()==obj1_addr ) return true; */ - IPNetwork n( ipv4->getAddress() , ipv4->getNetmask() ); - if (n.getAddress()==obj1_addr) return true; - if (n.getBroadcastAddress()==obj1_addr) return true; + if (ipv4->getNetworkAddress() == obj1_addr) return true; + if (ipv4->getBroadcastAddress() == obj1_addr) return true; } } } @@ -3467,7 +3469,6 @@ bool PolicyCompiler_ipt::processMultiAddressObjectsInRE::processNext() dynamic_cast(compiler->osconfigurator); RuleElement *re=RuleElement::cast( rule->getFirstByType(re_type) ); - bool neg = re->getNeg(); if (re->size()==1) { diff --git a/src/ipt/RoutingCompiler_ipt.cpp b/src/ipt/RoutingCompiler_ipt.cpp index 4314bfae0..a2e1ace46 100644 --- a/src/ipt/RoutingCompiler_ipt.cpp +++ b/src/ipt/RoutingCompiler_ipt.cpp @@ -56,8 +56,6 @@ using namespace libfwbuilder; using namespace fwcompiler; using namespace std; -static int chain_no=0; - static std::map tmp_chain_no; string RoutingCompiler_ipt::myPlatformName() { return "iptables"; } diff --git a/src/ipt/RoutingCompiler_ipt_writers.cpp b/src/ipt/RoutingCompiler_ipt_writers.cpp index 4471f6fa4..9734e89d0 100644 --- a/src/ipt/RoutingCompiler_ipt_writers.cpp +++ b/src/ipt/RoutingCompiler_ipt_writers.cpp @@ -78,13 +78,15 @@ string RoutingCompiler_ipt::PrintRule::_printAddr(Address *o) return ostr.str(); } - IPAddress addr; - Netmask mask; + InetAddr addr; + InetNetmask mask; try { addr=o->getAddress(); - if (Interface::cast(o)!=NULL || IPv4::cast(o)!=NULL) mask=Netmask("255.255.255.255"); - else mask=o->getNetmask(); + if (Interface::cast(o)!=NULL || IPv4::cast(o)!=NULL) + mask = InetNetmask(InetAddr::getAllOnes()); + else + mask = o->getNetmask(); } catch (FWException ex) { @@ -105,13 +107,13 @@ string RoutingCompiler_ipt::PrintRule::_printAddr(Address *o) } - if (addr.toString()=="0.0.0.0" && mask.toString()=="0.0.0.0") + if (addr == InetAddr::getAny() && mask == InetAddr::getAny()) { ostr << "default "; } else { ostr << addr.toString(); - if (mask.toString()!="255.255.255.255") + if (!mask.isHostMask()) { ostr << "/" << mask.getLength(); } diff --git a/src/ipt/ipt.cpp b/src/ipt/ipt.cpp index c3b1c0e8b..ff65c66a7 100644 --- a/src/ipt/ipt.cpp +++ b/src/ipt/ipt.cpp @@ -361,12 +361,15 @@ _("Dynamic interface %s should not have an IP address object attached to it. Thi for (list::iterator j=la.begin(); j!=la.end(); ++j) { IPv4 *ipv4 = IPv4::cast(*j); - if ( ipv4->getAddress().toString()=="0.0.0.0") + + if ( ipv4->getAddress().isAny()) { char errstr[256]; sprintf(errstr, - _("Interface %s has IP address \"0.0.0.0\".\n"), - iface->getName().c_str() ); + "Interface %s (id=%s) has IP address %s.\n", + iface->getName().c_str(), + iface->getId().c_str(), + ipv4->getAddress().toString().c_str()); throw FWException(errstr); } } diff --git a/src/pf/pf.cpp b/src/pf/pf.cpp index 6a1bc42fd..18908f5b0 100644 --- a/src/pf/pf.cpp +++ b/src/pf/pf.cpp @@ -344,7 +344,7 @@ _("Dynamic interface %s should not have an IP address object attached to it. Thi for (list::iterator j=la.begin(); j!=la.end(); ++j) { IPv4 *ipv4 = IPv4::cast(*j); - if ( ipv4->getAddress().toString()=="0.0.0.0") + if ( ipv4->getAddress() == InetAddr::getAny()) { char errstr[256]; sprintf(errstr, diff --git a/src/pflib/NATCompiler_ipf_writers.cpp b/src/pflib/NATCompiler_ipf_writers.cpp index 4db27a39d..664eca162 100644 --- a/src/pflib/NATCompiler_ipf_writers.cpp +++ b/src/pflib/NATCompiler_ipf_writers.cpp @@ -73,8 +73,8 @@ void NATCompiler_ipf::PrintRule::_printAddr_L(Address *o, bool print_netmask) { FWOptions* options=compiler->fw->getOptionsObject(); - IPAddress addr=o->getAddress(); - Netmask mask=o->getNetmask(); + InetAddr addr=o->getAddress(); + InetNetmask mask=o->getNetmask(); if (Interface::cast(o)!=NULL && Interface::cast(o)->isDyn()) { @@ -87,12 +87,13 @@ void NATCompiler_ipf::PrintRule::_printAddr_L(Address *o, bool print_netmask) } if (Interface::cast(o)!=NULL && ! Interface::cast(o)->isDyn()) - mask=Netmask("255.255.255.255"); + mask = InetNetmask(InetAddr::getAllOnes()); if (IPv4::cast(o)!=NULL) - mask=Netmask("255.255.255.255"); + mask = InetNetmask(InetAddr::getAllOnes()); - if (addr.toString()=="0.0.0.0" && mask.toString()=="0.0.0.0") { + if (addr.isAny() && mask.isAny()) + { compiler->output << "any "; } else { @@ -105,18 +106,19 @@ void NATCompiler_ipf::PrintRule::_printAddr_L(Address *o, bool print_netmask) void NATCompiler_ipf::PrintRule::_printAddr_R(Address *o, bool print_netmask) { - IPAddress addr=o->getAddress(); - Netmask mask=o->getNetmask(); + InetAddr addr = o->getAddress(); + InetNetmask mask = o->getNetmask(); - if (Interface::cast(o)!=NULL) - mask=Netmask("255.255.255.255"); + if (Interface::cast(o) != NULL) + mask = InetNetmask(InetAddr::getAllOnes()); if (IPv4::cast(o)!=NULL) - mask=Netmask("255.255.255.255"); + mask = InetNetmask(InetAddr::getAllOnes()); - if (addr.toString()=="0.0.0.0" && print_netmask && mask.toString()=="255.255.255.255") + if (addr.isAny() && print_netmask && mask.isHostMask()) + { compiler->output << "0/32 "; - else + } else { compiler->output << addr.toString(); if (print_netmask) @@ -137,7 +139,7 @@ void NATCompiler_ipf::PrintRule::_printAddr_R_LB(RuleElementTDst *tdst) Address *a=Address::cast(obj); - IPAddress addr=a->getAddress(); + InetAddr addr=a->getAddress(); if (!first) compiler->output << ","; compiler->output << addr.toString(); diff --git a/src/pflib/NATCompiler_pf.cpp b/src/pflib/NATCompiler_pf.cpp index 63ad0563e..1ed56bd18 100644 --- a/src/pflib/NATCompiler_pf.cpp +++ b/src/pflib/NATCompiler_pf.cpp @@ -90,7 +90,7 @@ int NATCompiler_pf::prolog() /* pseudo-host with ip address 127.0.0.1 We'll use it for redirection NAT rules */ //FWObject *grp; loopback_address=IPv4::cast(dbcopy->create(IPv4::TYPENAME) ); - loopback_address->setAddress("127.0.0.1"); + loopback_address->setAddress(InetAddr::getLoopbackAddr()); loopback_address->setName("__loopback_address__"); loopback_address->setId("__loopback_address_id__"); dbcopy->add(loopback_address,false); diff --git a/src/pflib/NATCompiler_pf_writers.cpp b/src/pflib/NATCompiler_pf_writers.cpp index 9db2cd49f..9024e7d2e 100644 --- a/src/pflib/NATCompiler_pf_writers.cpp +++ b/src/pflib/NATCompiler_pf_writers.cpp @@ -325,8 +325,8 @@ void NATCompiler_pf::PrintRule::_printAddr(FWObject *o) } Address *a = Address::cast(o); - IPAddress addr=a->getAddress(); - Netmask mask=a->getNetmask(); + InetAddr addr=a->getAddress(); + InetNetmask mask=a->getNetmask(); if (Interface::cast(o)!=NULL) { @@ -337,18 +337,20 @@ void NATCompiler_pf::PrintRule::_printAddr(FWObject *o) return; } - mask=Netmask("255.255.255.255"); + mask = InetNetmask(InetAddr::getAllOnes()); } if (IPv4::cast(o)!=NULL) { - mask=Netmask("255.255.255.255"); + mask = InetNetmask(InetAddr::getAllOnes()); } - if (addr.toString()=="0.0.0.0" && mask.toString()=="0.0.0.0") { + if (addr.isAny() && mask.isAny()) + { compiler->output << "any "; } else { compiler->output << addr.toString(); - if (mask.toString()!="255.255.255.255") { + if (!mask.isHostMask()) + { compiler->output << "/" << mask.getLength(); } compiler->output << " "; diff --git a/src/pflib/OSConfigurator_freebsd.cpp b/src/pflib/OSConfigurator_freebsd.cpp index ff2286a68..351a7d7b4 100644 --- a/src/pflib/OSConfigurator_freebsd.cpp +++ b/src/pflib/OSConfigurator_freebsd.cpp @@ -116,9 +116,8 @@ void OSConfigurator_freebsd::addVirtualAddressForNAT(const Address *addr) for ( ; j!=j.end(); ++j ) { IPv4 *iaddr=IPv4::cast(*j); - - IPNetwork n( iaddr->getAddress() , iaddr->getNetmask() ); - if ( n.belongs( addr->getAddress() ) ) { + if ( ipv4->belongs( addr->getAddress() ) ) + { output << "ifconfig " << iface->getName() << " " << addr->getAddress().toString() << " alias" << endl; diff --git a/src/pflib/OSConfigurator_freebsd.h b/src/pflib/OSConfigurator_freebsd.h index 0a3379765..2d7c95000 100644 --- a/src/pflib/OSConfigurator_freebsd.h +++ b/src/pflib/OSConfigurator_freebsd.h @@ -38,7 +38,7 @@ namespace fwcompiler { OSData os_data; - std::vector virtual_addresses; + std::vector virtual_addresses; std::string getInterfaceVarName(libfwbuilder::FWObject *iface); diff --git a/src/pflib/OSConfigurator_macosx.h b/src/pflib/OSConfigurator_macosx.h index 909c5a9bb..c33be2d02 100644 --- a/src/pflib/OSConfigurator_macosx.h +++ b/src/pflib/OSConfigurator_macosx.h @@ -38,7 +38,7 @@ namespace fwcompiler { OSData os_data; - std::vector virtual_addresses; + std::vector virtual_addresses; public: diff --git a/src/pflib/OSConfigurator_openbsd.cpp b/src/pflib/OSConfigurator_openbsd.cpp index 56785298c..5fc5af0a0 100644 --- a/src/pflib/OSConfigurator_openbsd.cpp +++ b/src/pflib/OSConfigurator_openbsd.cpp @@ -117,9 +117,8 @@ void OSConfigurator_openbsd::addVirtualAddressForNAT(const Address *addr) FWObjectTypedChildIterator j=iface->findByType(IPv4::TYPENAME); for ( ; j!=j.end(); ++j ) { IPv4 *iaddr=IPv4::cast(*j); - - IPNetwork n( iaddr->getAddress() , iaddr->getNetmask() ); - if ( n.belongs( addr->getAddress() ) ) { + if ( ipv4->belongs( addr->getAddress() ) ) + { output << "ifconfig " << iface->getName() << " " << addr->getAddress().toString() << " alias" << endl; diff --git a/src/pflib/OSConfigurator_openbsd.h b/src/pflib/OSConfigurator_openbsd.h index 478bc4226..5d7f50d7d 100644 --- a/src/pflib/OSConfigurator_openbsd.h +++ b/src/pflib/OSConfigurator_openbsd.h @@ -38,7 +38,7 @@ namespace fwcompiler { OSData os_data; - std::vector virtual_addresses; + std::vector virtual_addresses; public: diff --git a/src/pflib/OSConfigurator_solaris.cpp b/src/pflib/OSConfigurator_solaris.cpp index 89ab9ed41..52145d42a 100644 --- a/src/pflib/OSConfigurator_solaris.cpp +++ b/src/pflib/OSConfigurator_solaris.cpp @@ -128,9 +128,8 @@ void OSConfigurator_solaris::addVirtualAddressForNAT(const Address *addr) for ( ; j!=j.end(); ++j ) { IPv4 *iaddr=IPv4::cast(*j); - - IPNetwork n( iaddr->getAddress() , iaddr->getNetmask() ); - if ( n.belongs( addr->getAddress() ) ) { + if ( ipv4->belongs( addr->getAddress() ) ) + { output << "ifconfig " << iface->getName() << " " << addr->getAddress().toString() << " alias" << endl; diff --git a/src/pflib/OSConfigurator_solaris.h b/src/pflib/OSConfigurator_solaris.h index 6e3578073..14fea09c8 100644 --- a/src/pflib/OSConfigurator_solaris.h +++ b/src/pflib/OSConfigurator_solaris.h @@ -29,7 +29,7 @@ #include "config.h" #include "fwcompiler/OSConfigurator.h" -#include "fwbuilder/IPAddress.h" +#include "fwbuilder/InetAddr.h" #include @@ -41,7 +41,7 @@ namespace fwcompiler { OSData os_data; - std::vector virtual_addresses; + std::vector virtual_addresses; public: diff --git a/src/pflib/PolicyCompiler_ipf_writers.cpp b/src/pflib/PolicyCompiler_ipf_writers.cpp index a807eaf98..f07a0c348 100644 --- a/src/pflib/PolicyCompiler_ipf_writers.cpp +++ b/src/pflib/PolicyCompiler_ipf_writers.cpp @@ -267,8 +267,8 @@ void PolicyCompiler_ipf::PrintRule::_printAddr(Address *o,bool neg) assert(atrt==NULL); } - IPAddress addr=o->getAddress(); - Netmask mask=o->getNetmask(); + InetAddr addr=o->getAddress(); + InetNetmask mask=o->getNetmask(); if (options->getBool("dynAddr") && Interface::cast(o)!=NULL && Interface::cast(o)->isDyn()) @@ -279,19 +279,21 @@ void PolicyCompiler_ipf::PrintRule::_printAddr(Address *o,bool neg) } if (Interface::cast(o)!=NULL) { - mask=Netmask("255.255.255.255"); + mask = InetNetmask(InetAddr::getAllOnes()); } if (IPv4::cast(o)!=NULL) { - mask=Netmask("255.255.255.255"); + mask = InetNetmask(InetAddr::getAllOnes()); } - if (addr.toString()=="0.0.0.0" && mask.toString()=="0.0.0.0") { + if (addr.isAny() && mask.isAny()) + { compiler->output << "any "; } else { if (neg) compiler->output << "! "; compiler->output << addr.toString(); - if (mask.toString()!="255.255.255.255") { + if (!mask.isHostMask()) + { compiler->output << "/" << mask.getLength(); } compiler->output << " "; diff --git a/src/pflib/PolicyCompiler_ipfw_writers.cpp b/src/pflib/PolicyCompiler_ipfw_writers.cpp index acc5ffaec..a527f1aef 100644 --- a/src/pflib/PolicyCompiler_ipfw_writers.cpp +++ b/src/pflib/PolicyCompiler_ipfw_writers.cpp @@ -290,20 +290,21 @@ void PolicyCompiler_ipfw::PrintRule::_printAddr(Address *o,bool neg) assert(atrt==NULL); } - IPAddress addr=o->getAddress(); - Netmask mask=o->getNetmask(); + InetAddr addr=o->getAddress(); + InetNetmask mask=o->getNetmask(); - if (Interface::cast(o)!=NULL) mask=Netmask("255.255.255.255"); - if (IPv4::cast(o)!=NULL) mask=Netmask("255.255.255.255"); + if (Interface::cast(o)!=NULL) mask = InetNetmask(InetAddr::getAllOnes()); + if (IPv4::cast(o)!=NULL) mask = InetNetmask(InetAddr::getAllOnes()); - if (addr.toString()=="0.0.0.0" && mask.toString()=="0.0.0.0") + if (addr.isAny() && mask.isAny()) { compiler->output << "any "; } else { if (neg) compiler->output << "not "; compiler->output << addr.toString(); - if (mask.toString()!="255.255.255.255") { + if (!mask.isHostMask()) + { compiler->output << "/" << mask.getLength(); } compiler->output << " "; diff --git a/src/pflib/PolicyCompiler_pf.cpp b/src/pflib/PolicyCompiler_pf.cpp index 0f2408c79..698d82336 100644 --- a/src/pflib/PolicyCompiler_pf.cpp +++ b/src/pflib/PolicyCompiler_pf.cpp @@ -388,24 +388,24 @@ void PolicyCompiler_pf::addDefaultPolicyRule() cacheObj(ssh); // to keep cache consistent string mgmt_addr = getCachedFwOpt()->getStr("mgmt_addr"); - IPAddress addr; - Netmask netmask(32); + InetAddr addr; + InetNetmask netmask(InetAddr::getAllOnes()); try { - addr = IPAddress(mgmt_addr); + addr = InetAddr(mgmt_addr); string::size_type sep = mgmt_addr.find("/"); if (sep != string::npos) { - addr = IPAddress(mgmt_addr.substr(0,sep)); + addr = InetAddr(mgmt_addr.substr(0,sep)); string nm = mgmt_addr.substr(sep+1); int o1,o2,o3,o4; if(sscanf(nm.c_str(), "%3u.%3u.%3u.%3u", &o1, &o2, &o3, &o4)==4) { - netmask = Netmask(nm); + netmask = InetNetmask(nm); } else { sscanf(nm.c_str(),"%u",&o1); - netmask = Netmask(o1); + netmask = InetNetmask(o1); } } } catch(FWException &ex) diff --git a/src/pflib/PolicyCompiler_pf_writers.cpp b/src/pflib/PolicyCompiler_pf_writers.cpp index 5bc910019..c5c730ec1 100644 --- a/src/pflib/PolicyCompiler_pf_writers.cpp +++ b/src/pflib/PolicyCompiler_pf_writers.cpp @@ -187,7 +187,7 @@ void PolicyCompiler_pf::PrintRule::_printRouteOptions(PolicyRule *rule) try { string a = roaddr.substr(0,sp); - IPAddress roaddr_addr = IPAddress(a); + InetAddr roaddr_addr = InetAddr(a); } catch (FWException &ex) { compiler->abort( @@ -195,14 +195,14 @@ void PolicyCompiler_pf::PrintRule::_printRouteOptions(PolicyRule *rule) } try { - Netmask roaddr_netmask; + InetNetmask roaddr_netmask; string n = roaddr.substr(sp+1); if (n.find('.')!=std::string::npos) { - roaddr_netmask = n; + roaddr_netmask = InetNetmask(n); } else { - roaddr_netmask = Netmask( + roaddr_netmask = InetNetmask( atoi(n.c_str())); } if (roaddr_netmask.getLength()==32) @@ -224,7 +224,7 @@ void PolicyCompiler_pf::PrintRule::_printRouteOptions(PolicyRule *rule) // roaddr is just an addres try { - IPAddress roaddr_addr = IPAddress(roaddr); + InetAddr roaddr_addr = InetAddr(roaddr); } catch (FWException &ex) { compiler->abort( @@ -596,8 +596,8 @@ void PolicyCompiler_pf::PrintRule::_printAddr(Address *o,bool neg) assert(atrt==NULL); } - IPAddress addr=o->getAddress(); - Netmask mask=o->getNetmask(); + InetAddr addr=o->getAddress(); + InetNetmask mask=o->getNetmask(); if (Interface::cast(o)!=NULL) { @@ -608,22 +608,22 @@ void PolicyCompiler_pf::PrintRule::_printAddr(Address *o,bool neg) return; } - mask=Netmask("255.255.255.255"); + mask = InetNetmask(InetAddr::getAllOnes()); } if (IPv4::cast(o)!=NULL) { - mask=Netmask("255.255.255.255"); + mask = InetNetmask(InetAddr::getAllOnes()); } - if (addr.toString()=="0.0.0.0" && mask.toString()=="0.0.0.0") + if (addr.isAny() && mask.isAny()) { compiler->output << "any "; } else { // if (neg) compiler->output << "! "; compiler->output << addr.toString(); - if (mask.toString()!="255.255.255.255") + if (!mask.isHostMask()) { compiler->output << "/" << mask.getLength(); } diff --git a/src/pflib/TableFactory.cpp b/src/pflib/TableFactory.cpp index fad5fcbeb..2052cc463 100644 --- a/src/pflib/TableFactory.cpp +++ b/src/pflib/TableFactory.cpp @@ -212,15 +212,16 @@ string TableFactory::PrintTables() if (A==NULL) throw(FWException("table object must be an address: '"+o->getTypeName()+"'")); - IPAddress addr=A->getAddress(); - Netmask mask=A->getNetmask(); + InetAddr addr=A->getAddress(); + InetNetmask mask=A->getNetmask(); if (IPv4::cast(A)!=NULL) { - mask=Netmask("255.255.255.255"); + mask = InetNetmask(InetAddr::getAllOnes()); } output << addr.toString(); - if (mask.toString()!="255.255.255.255") { + if (!mask.isHostMask()) + { output << "/" << mask.getLength(); } } diff --git a/src/pix/NATCompiler_pix.cpp b/src/pix/NATCompiler_pix.cpp index 7a5d5170b..5e6477142 100644 --- a/src/pix/NATCompiler_pix.cpp +++ b/src/pix/NATCompiler_pix.cpp @@ -36,7 +36,7 @@ #include "fwbuilder/UDPService.h" #include "fwbuilder/Interface.h" #include "fwbuilder/IPv4.h" -#include "fwbuilder/IPAddress.h" +#include "fwbuilder/InetAddr.h" #include "fwbuilder/Network.h" #include "fwbuilder/Resources.h" #include "fwbuilder/AddressTable.h" @@ -421,8 +421,8 @@ bool NATCompiler_pix::verifyRuleElements::processNext() if (Network::isA(odst) && Network::isA(tdst)) { - Netmask n1=(Interface::cast(odst))?Netmask("255.255.255.255"):odst->getNetmask(); - Netmask n2=(Interface::cast(tdst))?Netmask("255.255.255.255"):tdst->getNetmask(); + InetNetmask n1=(Interface::cast(odst))?InetNetmask(InetAddr::getAllOnes()):odst->getNetmask(); + InetNetmask n2=(Interface::cast(tdst))?InetNetmask(InetAddr::getAllOnes()):tdst->getNetmask(); if ( !(n1==n2) ) compiler->abort( @@ -883,8 +883,8 @@ bool NATCompiler_pix::mergeNATCmd::processNext() */ if (natcmd==nc) break; - IPAddress a1=natcmd->t_addr->getAddress(); - IPAddress a2=nc->t_addr->getAddress(); + InetAddr a1=natcmd->t_addr->getAddress(); + InetAddr a2=nc->t_addr->getAddress(); Interface *int1=natcmd->t_iface; Interface *int2=nc->t_iface; @@ -1136,17 +1136,16 @@ NATCompiler_pix::DetectOverlap::~DetectOverlap() {}; bool NATCompiler_pix::DetectOverlap::checkOverlapping( const libfwbuilder::Address &addr1, - const libfwbuilder::IPAddress &addr2) + const libfwbuilder::InetAddr &addr2) { if (AddressRange::isA(&addr1)) { - const IPAddress a1=AddressRange::constcast(&addr1)->getRangeStart(); - const IPAddress a2=AddressRange::constcast(&addr1)->getRangeEnd(); + const InetAddr a1=AddressRange::constcast(&addr1)->getRangeStart(); + const InetAddr a2=AddressRange::constcast(&addr1)->getRangeEnd(); return (addr2==a1 || addr2==a2 || (addr2>a1 && addr2getRangeStart(); - const IPAddress a2=AddressRange::constcast(&pool)->getRangeEnd(); + const InetAddr a1=AddressRange::constcast(&pool)->getRangeStart(); + const InetAddr a2=AddressRange::constcast(&pool)->getRangeEnd(); return a1.toString()+"-"+a2.toString(); } else { @@ -1183,14 +1182,11 @@ bool NATCompiler_pix::DetectGlobalPoolProblems::processNext() +printGlobalPoolAddress(*(natcmd->t_addr)) +" overlaps with interface address. Rule " +rule->getLabel()); - - IPNetwork iface_net(natcmd->t_iface->getAddress(), - natcmd->t_iface->getNetmask()); if (checkOverlapping(*(natcmd->t_addr), - iface_net.getBroadcastAddress()) || + natcmd->t_iface->getBroadcastAddress()) || checkOverlapping(*(natcmd->t_addr), - iface_net.getAddress()) ) + natcmd->t_iface->getAddress()) ) compiler->warning("Global pool " +printGlobalPoolAddress(*(natcmd->t_addr)) +" overlaps with broadcast address. Rule " @@ -1273,7 +1269,7 @@ bool NATCompiler_pix::DetectOverlappingGlobalPoolsAndStaticRules::processNext() if (natcmd->type== INTERFACE) { - addr.setNetmask("255.255.255.255"); + addr.setNetmask(InetNetmask(InetAddr::getAllOnes())); } if ( checkOverlapping( addr, outa->getAddress()) || @@ -1314,11 +1310,11 @@ bool NATCompiler_pix::DetectDuplicateNAT::processNext() Interface *int1=natcmd->t_iface; Interface *int2=nc->t_iface; -// IPAddress a1=natcmd->o_addr->getAddress(); -// IPAddress a2=nc->o_addr->getAddress(); +// InetAddr a1=natcmd->o_addr->getAddress(); +// InetAddr a2=nc->o_addr->getAddress(); // -// Netmask m1=natcmd->o_addr->getNetmask(); -// Netmask m2=nc->o_addr->getNetmask(); +// InetNetmask m1=natcmd->o_addr->getInetNetmask(); +// InetNetmask m2=nc->o_addr->getNetmask(); if ( int1->getId()==int2->getId() && natcmd->o_src==nc->o_src && @@ -1357,9 +1353,6 @@ bool NATCompiler_pix::DetectOverlappingStatics::processNext() { StaticCmd *scmd=pix_comp->static_commands[ rule->getInt("sc_cmd") ]; - IPNetwork nn1( scmd->iaddr->getAddress(), scmd->iaddr->getNetmask() ); - IPNetwork nn2( scmd->oaddr->getAddress(), scmd->oaddr->getNetmask() ); - for (map::iterator i1=pix_comp->static_commands.begin(); i1!=pix_comp->static_commands.end(); i1++ ) { @@ -1374,32 +1367,30 @@ bool NATCompiler_pix::DetectOverlappingStatics::processNext() *(sc->tsrv) == *(scmd->tsrv) && *(sc->osrc) == *(scmd->osrc) && sc->oaddr->getId() == scmd->oaddr->getId()) - compiler->abort("Static NAT rules overlap or are redundant : rules "+ - sc->rule+" and "+scmd->rule+" : "+ - "outside address: "+ - "interface "+Interface::cast(scmd->oaddr)->getLabel()+ - " inside address: "+ - scmd->iaddr->getAddress().toString()+"/"+ - scmd->iaddr->getNetmask().toString()); - - + compiler->abort( + "Static NAT rules overlap or are redundant : rules "+ + sc->rule+" and "+scmd->rule+" : "+ + "outside address: "+ + "interface "+Interface::cast(scmd->oaddr)->getLabel()+ + " inside address: "+ + scmd->iaddr->getAddress().toString()+"/"+ + scmd->iaddr->getNetmask().toString()); } else { - IPNetwork n1( sc->iaddr->getAddress(), sc->iaddr->getNetmask() ); - IPNetwork n2( sc->oaddr->getAddress(), sc->oaddr->getNetmask() ); - if ( *(sc->osrv) == *(scmd->osrv) && *(sc->tsrv) == *(scmd->tsrv) && *(sc->osrc) == *(scmd->osrc) && - ( ! getOverlap(nn1,n1).empty() || ! getOverlap(nn2,n2).empty() ) ) - compiler->abort("Static NAT rules overlap or are redundant : rules "+ - sc->rule+" and "+scmd->rule+" : "+ - "outside address: "+ - scmd->oaddr->getAddress().toString()+"/"+ - scmd->oaddr->getNetmask().toString()+ - " inside address: "+ - scmd->iaddr->getAddress().toString()+"/"+ - scmd->iaddr->getNetmask().toString()); + ( ! getOverlap(*(scmd->iaddr), *(sc->iaddr)).empty() || + ! getOverlap(*(scmd->oaddr), *(sc->oaddr)).empty() ) ) + compiler->abort( + "Static NAT rules overlap or are redundant : rules "+ + sc->rule+" and "+scmd->rule+" : "+ + "outside address: "+ + scmd->oaddr->getAddress().toString()+"/"+ + scmd->oaddr->getNetmask().toString()+ + " inside address: "+ + scmd->iaddr->getAddress().toString()+"/"+ + scmd->iaddr->getNetmask().toString()); } } } diff --git a/src/pix/NATCompiler_pix.h b/src/pix/NATCompiler_pix.h index e0df5e362..f2c9b32be 100644 --- a/src/pix/NATCompiler_pix.h +++ b/src/pix/NATCompiler_pix.h @@ -373,7 +373,7 @@ namespace fwcompiler { { protected: bool checkOverlapping(const libfwbuilder::Address &a1, - const libfwbuilder::IPAddress &a2); + const libfwbuilder::InetAddr &a2); std::string printGlobalPoolAddress(const libfwbuilder::Address &pool); public: DetectOverlap(const std::string &n) : NATRuleProcessor(n){} @@ -419,8 +419,8 @@ namespace fwcompiler { protected: typedef struct { std::string iface1, iface2; - libfwbuilder::IPAddress addr; - libfwbuilder::Netmask mask; + libfwbuilder::InetAddr addr; + libfwbuilder::InetNetmask mask; } nonat_static_parameters; std::deque all_nonat_statics; public: diff --git a/src/pix/NATCompiler_pix_writers.cpp b/src/pix/NATCompiler_pix_writers.cpp index f5678beca..d2535215d 100644 --- a/src/pix/NATCompiler_pix_writers.cpp +++ b/src/pix/NATCompiler_pix_writers.cpp @@ -449,9 +449,9 @@ bool NATCompiler_pix::PrintRule::processNext() { StaticCmd *scmd=pix_comp->static_commands[ rule->getInt("sc_cmd") ]; - IPAddress outa=scmd->oaddr->getAddress(); - Netmask outm=scmd->oaddr->getNetmask(); - IPAddress insa=scmd->iaddr->getAddress(); + InetAddr outa=scmd->oaddr->getAddress(); + InetNetmask outm=scmd->oaddr->getNetmask(); + InetAddr insa=scmd->iaddr->getAddress(); /* * we verify that odst and tdst have the same size in verifyRuleElements, * so we can rely on that now. diff --git a/src/pix/OSConfigurator_pix_os.cpp b/src/pix/OSConfigurator_pix_os.cpp index 977020c86..6307dd130 100644 --- a/src/pix/OSConfigurator_pix_os.cpp +++ b/src/pix/OSConfigurator_pix_os.cpp @@ -193,7 +193,7 @@ string OSConfigurator_pix_os::_printLogging() if ( ! syslog_host.empty() ) { - string iface_id=helper.findInterfaceByNetzone(IPAddress(syslog_host)); + string iface_id=helper.findInterfaceByNetzone(InetAddr(syslog_host)); if (iface_id.empty()) abort("Log server "+syslog_host+" does not belong to any known network zone"); Interface *syslog_iface = getCachedFwInterface(iface_id); @@ -257,7 +257,7 @@ string OSConfigurator_pix_os::_printSNMPServer(const std::string &srv,int poll_ ostringstream str; - string iface_id=helper.findInterfaceByNetzone( IPAddress(srv) ); + string iface_id=helper.findInterfaceByNetzone( InetAddr(srv) ); if (iface_id.empty()) abort(string("SNMP server ")+srv+" does not belong to any known network zone"); Interface *snmp_iface = getCachedFwInterface(iface_id); @@ -335,7 +335,7 @@ string OSConfigurator_pix_os::_printNTPServer(const std::string &srv,bool pref) ostringstream str; - string iface_id=helper.findInterfaceByNetzone( IPAddress(srv) ); + string iface_id=helper.findInterfaceByNetzone( InetAddr(srv) ); if (iface_id.empty()) abort("NTP server "+srv+" does not belong to any known network zone"); Interface *ntp_iface = getCachedFwInterface(iface_id); str << "ntp server " << srv << " source " << ntp_iface->getLabel(); diff --git a/src/pix/PIXObjectGroup.h b/src/pix/PIXObjectGroup.h index 60f2c9074..f74c5021a 100644 --- a/src/pix/PIXObjectGroup.h +++ b/src/pix/PIXObjectGroup.h @@ -50,7 +50,7 @@ class PIXGroup : public libfwbuilder::Group { virtual ~PIXGroup() {}; DECLARE_FWOBJECT_SUBTYPE(PIXGroup); - virtual bool validateChild(FWObject *o) { return true; } + virtual bool validateChild(FWObject*) { return true; } void setPIXGroupType(pix_group_type _gt) { gt=_gt; } pix_group_type getPIXGroupType() { return gt; } diff --git a/src/pix/PolicyCompiler_pix.cpp b/src/pix/PolicyCompiler_pix.cpp index f19f25a1d..4f5042c8b 100644 --- a/src/pix/PolicyCompiler_pix.cpp +++ b/src/pix/PolicyCompiler_pix.cpp @@ -123,14 +123,14 @@ int PolicyCompiler_pix::prolog() { if (netmask.find(".")!=string::npos) { - Netmask nm(netmask); - nm.to32BitInt(); // to avoid warning abt unused var + InetNetmask nm(netmask); + nm.isAny(); // to avoid warning abt unused var } else { int nm_length; istringstream str(netmask); str >> nm_length; - Netmask nm(nm_length); + InetNetmask nm(nm_length); netmask = nm.toString(); } } catch(FWException &ex) @@ -141,8 +141,7 @@ int PolicyCompiler_pix::prolog() try { - IPAddress a(addr); - a.to32BitInt(); + InetAddr(addr); } catch(FWException &ex) { abort("Invalid address for management subnet: '"+addr+"'"); diff --git a/src/pix/PolicyCompiler_pix_writers.cpp b/src/pix/PolicyCompiler_pix_writers.cpp index 1b7a31d63..e7405f717 100644 --- a/src/pix/PolicyCompiler_pix_writers.cpp +++ b/src/pix/PolicyCompiler_pix_writers.cpp @@ -161,10 +161,10 @@ bool PolicyCompiler_pix::PrintObjectGroupsAndClearCommands::processNext() { Address *a=Address::cast(obj); assert(a!=NULL); - IPAddress addr=a->getAddress(); + InetAddr addr=a->getAddress(); pix_comp->output << " network-object "; if (Network::cast(obj)!=NULL) { - Netmask mask=a->getNetmask(); + InetNetmask mask=a->getNetmask(); pix_comp->output << addr.toString() << " "; pix_comp->output << mask.toString() << " "; } else { @@ -352,8 +352,8 @@ string PolicyCompiler_pix::PrintRule::_printAddr(libfwbuilder::Address *o) { ostringstream str; - IPAddress srcaddr=o->getAddress(); - Netmask srcmask=o->getNetmask(); + InetAddr srcaddr=o->getAddress(); + InetNetmask srcmask=o->getNetmask(); if (Interface::cast(o)!=NULL) { @@ -363,18 +363,18 @@ string PolicyCompiler_pix::PrintRule::_printAddr(libfwbuilder::Address *o) return string("interface ") + interface_->getLabel() + " "; } - srcmask=Netmask("255.255.255.255"); + srcmask=InetNetmask(InetAddr::getAllOnes()); } if (IPv4::cast(o)!=NULL) - srcmask=Netmask("255.255.255.255"); + srcmask=InetNetmask(InetAddr::getAllOnes()); - if (srcaddr.toString()=="0.0.0.0" && srcmask.toString()=="0.0.0.0") + if (srcaddr.isAny() && srcmask.isAny()) { str << "any "; } else { - if (srcmask.toString()=="255.255.255.255") + if (srcmask.isHostMask()) { str << "host " << srcaddr.toString() << " "; } else diff --git a/test/ipf/objects-for-regression-tests.fwb b/test/ipf/objects-for-regression-tests.fwb index d183f9a8e..44e11ff92 100644 --- a/test/ipf/objects-for-regression-tests.fwb +++ b/test/ipf/objects-for-regression-tests.fwb @@ -1,6 +1,6 @@ - + diff --git a/test/ipfw/objects-for-regression-tests.fwb b/test/ipfw/objects-for-regression-tests.fwb index 4fcacad74..01084e8d1 100644 --- a/test/ipfw/objects-for-regression-tests.fwb +++ b/test/ipfw/objects-for-regression-tests.fwb @@ -1,6 +1,6 @@ - + diff --git a/test/ipt/objects-for-regression-tests.fwb b/test/ipt/objects-for-regression-tests.fwb index d1e0f0ad4..c7fa2ba5c 100644 --- a/test/ipt/objects-for-regression-tests.fwb +++ b/test/ipt/objects-for-regression-tests.fwb @@ -1,14 +1,14 @@ - + - + - + @@ -20,11 +20,11 @@ - - - - - + + + + + @@ -103,11 +103,15 @@ + + + + - + @@ -124,7 +128,7 @@ - + @@ -141,7 +145,7 @@ - + @@ -158,7 +162,7 @@ - + @@ -175,7 +179,7 @@ - + @@ -192,7 +196,7 @@ - + @@ -209,7 +213,7 @@ - + @@ -226,7 +230,7 @@ - + @@ -239,7 +243,7 @@ - + @@ -304,7 +308,7 @@ - + @@ -321,7 +325,7 @@ - + @@ -334,7 +338,7 @@ - + @@ -347,7 +351,7 @@ - + @@ -360,7 +364,7 @@ - + @@ -368,7 +372,7 @@ - + @@ -381,8 +385,8 @@ - - + + @@ -398,10 +402,10 @@ - + - + @@ -417,13 +421,13 @@ - + - + - + @@ -439,7 +443,7 @@ - + @@ -455,7 +459,7 @@ - + @@ -472,7 +476,7 @@ - + @@ -489,7 +493,7 @@ - + @@ -506,7 +510,7 @@ - + @@ -523,7 +527,7 @@ - + @@ -540,7 +544,7 @@ - + @@ -557,7 +561,7 @@ - + @@ -565,7 +569,7 @@ - + @@ -578,7 +582,7 @@ - + @@ -591,7 +595,7 @@ - + @@ -605,7 +609,7 @@ - + @@ -623,10 +627,10 @@ - + - + @@ -639,7 +643,7 @@ - + @@ -652,7 +656,7 @@ - + @@ -665,7 +669,7 @@ - + @@ -682,7 +686,7 @@ - + @@ -699,7 +703,7 @@ - + @@ -716,7 +720,7 @@ - + @@ -729,7 +733,7 @@ - + @@ -740,7 +744,7 @@ - + @@ -755,8 +759,8 @@ - - + + @@ -767,6 +771,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -964,7 +988,7 @@ - + @@ -2615,10 +2639,10 @@ - + - + @@ -3989,19 +4013,19 @@ - + - + - + - + - + @@ -4093,7 +4117,7 @@ - + @@ -5554,21 +5578,21 @@ - + - + - - + + - - + + - + @@ -5585,6 +5609,7 @@ + @@ -5640,6 +5665,7 @@ + @@ -5655,7 +5681,7 @@ - + @@ -6214,16 +6240,16 @@ - + - + - + - + @@ -6996,19 +7022,19 @@ - + - + - + - + - + @@ -7102,7 +7128,7 @@ - + @@ -7146,7 +7172,28 @@ - + + + + + + + + + + + + + + + + + + + + + + @@ -7309,7 +7356,7 @@ - + @@ -7328,7 +7375,7 @@ - + @@ -7443,13 +7490,13 @@ - + - + - + @@ -7711,10 +7758,10 @@ - + - + @@ -8087,19 +8134,19 @@ - + - + - + - + - + @@ -8497,19 +8544,19 @@ - + - + - + - + - + @@ -8592,13 +8639,13 @@ - + - + - + @@ -8990,13 +9037,13 @@ - + - + - + @@ -9282,13 +9329,13 @@ - + - + - + @@ -9803,11 +9850,11 @@ - + - + @@ -10155,10 +10202,10 @@ - + - + @@ -10329,10 +10376,10 @@ - + - + @@ -10551,14 +10598,14 @@ - + - - + + - + @@ -10668,13 +10715,13 @@ - + - + - + @@ -11082,13 +11129,13 @@ - + - + - + @@ -11382,21 +11429,21 @@ - + - - + + - + - + - - + + @@ -11724,16 +11771,16 @@ - + - + - + - + @@ -12102,16 +12149,16 @@ - + - + - + - + @@ -12636,13 +12683,13 @@ - + - + - + @@ -12825,10 +12872,10 @@ - + - + @@ -13024,10 +13071,10 @@ - + - + @@ -13419,10 +13466,10 @@ - + - + @@ -13889,10 +13936,10 @@ - + - + @@ -14072,10 +14119,10 @@ - + - + @@ -14094,10 +14141,10 @@ cat > %FWDIR%/%FWSCRIPT%; -echo '%FWBPROMPT%'; chmod +x %FWDIR%/%FWSCRIPT%; sudo -S %FWDIR%/%FWSCRIPT%; sudo -S ps ax|awk '/shutdown/ {printf "kill %d\n",$1;}'|sh +echo '%FWBPROMPT%'; chmod +x %FWDIR%/%FWSCRIPT%; sudo -S %FWDIR%/%FWSCRIPT%; sudo -S ps ax|awk '/shutdown/ {printf "kill %d\n",$1;}'|sh -echo '%FWBPROMPT%'; chmod +x %FWDIR%/%FWSCRIPT%; sudo -S %FWDIR%/%FWSCRIPT%; sudo -S ps ax|awk '/shutdown/ {printf "kill %d\n",$1;}'|sh +echo '%FWBPROMPT%'; chmod +x %FWDIR%/%FWSCRIPT%; sudo -S %FWDIR%/%FWSCRIPT%; sudo -S ps ax|awk '/shutdown/ {printf "kill %d\n",$1;}'|sh @@ -14119,10 +14166,10 @@ cat > %FWDIR%/%FWSCRIPT%; -echo '%FWBPROMPT%'; sh %FWDIR%/%FWSCRIPT%; ps ax|awk '/shutdown/ {printf "kill %d\n",$1;}'|sh +echo '%FWBPROMPT%'; sh %FWDIR%/%FWSCRIPT%; ps ax|awk '/shutdown/ {printf "kill %d\n",$1;}'|sh -echo '%FWBPROMPT%'; sh %FWDIR%/%FWSCRIPT%; ps ax|awk '/shutdown/ {printf "kill %d\n",$1;}'|sh +echo '%FWBPROMPT%'; sh %FWDIR%/%FWSCRIPT%; ps ax|awk '/shutdown/ {printf "kill %d\n",$1;}'|sh @@ -14622,13 +14669,13 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + - + @@ -15156,10 +15203,10 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + @@ -15246,7 +15293,7 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + @@ -15686,13 +15733,13 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + - + @@ -15883,10 +15930,10 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + @@ -16073,10 +16120,10 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + @@ -16216,13 +16263,13 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + - + @@ -16437,10 +16484,10 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + @@ -16523,7 +16570,7 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + @@ -16629,10 +16676,10 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + @@ -16724,7 +16771,7 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + @@ -17061,7 +17108,28 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + + + + + + + + + + + + + + + + + + + + + + @@ -17085,10 +17153,10 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + @@ -17180,7 +17248,7 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + @@ -17555,10 +17623,10 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + @@ -17935,10 +18003,10 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + @@ -18331,16 +18399,16 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + - + - + @@ -19299,13 +19367,13 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + - + @@ -19859,13 +19927,13 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + - + @@ -20412,10 +20480,10 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + @@ -21494,13 +21562,13 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + - + @@ -21813,16 +21881,16 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + - + - + @@ -21963,10 +22031,10 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + @@ -22214,13 +22282,13 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + - + @@ -22457,13 +22525,13 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + - + @@ -23678,13 +23746,13 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + - + @@ -23862,11 +23930,11 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - - + + @@ -24095,14 +24163,14 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + - - + + @@ -24204,7 +24272,7 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + @@ -24646,10 +24714,10 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + @@ -24738,19 +24806,19 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + - + - + - + @@ -24774,12 +24842,12 @@ echo '%FWBPROMPT%'; sh /tmp/%FWSCRIPT% - + - + - + diff --git a/test/pf/objects-for-regression-tests.fwb b/test/pf/objects-for-regression-tests.fwb index 4ecab5228..0d1d60559 100644 --- a/test/pf/objects-for-regression-tests.fwb +++ b/test/pf/objects-for-regression-tests.fwb @@ -1,6 +1,6 @@ - + @@ -76,9 +76,9 @@ - - - + @@ -92,9 +92,9 @@ - - - + @@ -202,9 +202,9 @@ - - - + @@ -219,9 +219,9 @@ - - - + @@ -235,9 +235,9 @@ - - - + @@ -252,9 +252,9 @@ - - - + @@ -269,9 +269,9 @@ - - - + @@ -286,9 +286,9 @@ - - - + @@ -303,9 +303,9 @@ - - - + @@ -320,9 +320,9 @@ - - - + @@ -337,9 +337,9 @@ - - - + @@ -483,17 +483,17 @@ - - + + -m ip_conntrack_talk -m ip_nat_talk - - - + + + proto {tcp udp icmp gre} - - + + @@ -694,9 +694,9 @@ - + - + @@ -740,10 +740,10 @@ - - + - + @@ -763,10 +763,10 @@ - - + - + @@ -789,10 +789,10 @@ - - + - + @@ -815,10 +815,10 @@ - - + - + @@ -843,18 +843,18 @@ - - + - + - + - + @@ -881,10 +881,10 @@ - - + - + @@ -910,10 +910,10 @@ - - + - + @@ -934,10 +934,10 @@ - - + - + @@ -957,10 +957,10 @@ - - + - + @@ -980,10 +980,10 @@ - - + - + @@ -1024,10 +1024,10 @@ - - + - + @@ -1047,11 +1047,11 @@ - - + - - + @@ -1075,26 +1075,26 @@ - - - + - - + - + - + - - - + @@ -1119,9 +1119,9 @@ - - - + @@ -1140,7 +1140,7 @@ - + @@ -1183,11 +1183,11 @@ - - - - - + @@ -1679,10 +1679,10 @@ - + - + @@ -1704,10 +1704,10 @@ - + - + @@ -1792,10 +1792,10 @@ - + - + @@ -1925,26 +1925,26 @@ - - - + - - + - + - + - - - + @@ -1956,18 +1956,18 @@ - + - + - - - + @@ -1980,7 +1980,7 @@ - + @@ -2029,11 +2029,11 @@ - - - - - + @@ -2183,19 +2183,19 @@ - - + - + - - - + @@ -2207,7 +2207,7 @@ - + @@ -2218,13 +2218,13 @@ - - + - + @@ -2236,10 +2236,10 @@ - - - - + @@ -2267,7 +2267,7 @@ - + @@ -2292,7 +2292,7 @@ - + @@ -2340,7 +2340,7 @@ - + @@ -2365,7 +2365,7 @@ - + @@ -2413,7 +2413,7 @@ - + @@ -2438,7 +2438,7 @@ - + @@ -2549,7 +2549,7 @@ - + @@ -2928,8 +2928,8 @@ - - + @@ -2953,8 +2953,8 @@ - - + @@ -2979,8 +2979,8 @@ - - + @@ -3005,8 +3005,8 @@ - - + @@ -3027,8 +3027,8 @@ - - + @@ -3051,7 +3051,7 @@ - + @@ -3073,7 +3073,7 @@ - + @@ -3134,7 +3134,7 @@ - + @@ -3193,7 +3193,7 @@ - + @@ -3223,27 +3223,27 @@ - - - + - - + - + - + - + - - - + @@ -3270,9 +3270,9 @@ - - - + @@ -3336,11 +3336,11 @@ # prolog commands go after set commands - - - - - + @@ -3368,7 +3368,7 @@ - + @@ -3391,7 +3391,7 @@ - + @@ -3508,7 +3508,7 @@ - + @@ -3529,7 +3529,7 @@ - + @@ -3551,7 +3551,7 @@ - + @@ -3574,7 +3574,7 @@ - + @@ -3595,7 +3595,7 @@ - + @@ -3615,7 +3615,7 @@ - + @@ -3645,27 +3645,27 @@ - - - + - - + - + - + - + - - - + @@ -3677,18 +3677,18 @@ - + - + - - - + @@ -3701,7 +3701,7 @@ - + @@ -3745,11 +3745,11 @@ - - - - - + @@ -3797,10 +3797,10 @@ - + - - + @@ -3822,10 +3822,10 @@ - + - - + @@ -3869,23 +3869,23 @@ - - + - - + - + - - - + @@ -3897,7 +3897,7 @@ - + @@ -3908,13 +3908,13 @@ - - + - + @@ -3927,10 +3927,10 @@ - - - - + @@ -4003,19 +4003,19 @@ - - + - + - - - + @@ -4027,20 +4027,20 @@ - + - - + - + @@ -4053,10 +4053,10 @@ - - - - + @@ -4131,19 +4131,19 @@ - - + - + - - - + @@ -4155,20 +4155,20 @@ - + - - + - + @@ -4181,10 +4181,10 @@ - - - - + @@ -4517,14 +4517,14 @@ - - + - + @@ -4535,7 +4535,7 @@ - + @@ -4546,9 +4546,9 @@ - - - + @@ -4712,22 +4712,22 @@ - - + - + - - - + - - - + @@ -4739,20 +4739,20 @@ - + - - + - + @@ -4765,10 +4765,10 @@ - - - - + @@ -5107,50 +5107,50 @@ - - - + - - + - - + - - - + - - - - - - - - - - - - - - - - + - - - - + @@ -5164,20 +5164,20 @@ - + - + - + - - - - - + @@ -5535,7 +5535,7 @@ - + @@ -5543,7 +5543,7 @@ - + @@ -5608,50 +5608,50 @@ - - - + - - + - - + - - - + - - - - - - - - - - - - - - - - + - - - - + @@ -5665,20 +5665,20 @@ - + - + - + - - - - - + @@ -5752,12 +5752,12 @@ - - - + - + @@ -5924,14 +5924,14 @@ - + - + - + - + @@ -5975,29 +5975,29 @@ - - - + - - + - + - + - - - + - - - + @@ -6009,18 +6009,18 @@ - + - + - - - + @@ -6033,7 +6033,7 @@ - + @@ -6073,13 +6073,13 @@ - + - - - - - + @@ -6272,7 +6272,7 @@ - + @@ -6300,16 +6300,16 @@ - - - + - - + - + @@ -6325,11 +6325,11 @@ - + - + @@ -6342,7 +6342,7 @@ - + @@ -6400,7 +6400,7 @@ - + @@ -6468,12 +6468,12 @@ - - - + - + @@ -6749,14 +6749,14 @@ - + - + - + - + @@ -6800,29 +6800,29 @@ - - - + - - + - + - + - - - + - - - + @@ -6834,18 +6834,18 @@ - + - + - - - + @@ -6858,7 +6858,7 @@ - + @@ -6898,13 +6898,13 @@ - + - - - - - + @@ -6973,7 +6973,7 @@ - + @@ -6998,7 +6998,7 @@ - + @@ -7024,28 +7024,28 @@ - - - - - - - + - - + - + - + @@ -7066,28 +7066,28 @@ - - - - - - - + - - + - + - + @@ -7151,16 +7151,16 @@ - - - + - - + - + @@ -7176,11 +7176,11 @@ - + - + @@ -7193,7 +7193,7 @@ - + @@ -7244,11 +7244,11 @@ - + - + @@ -7452,16 +7452,16 @@ - + - + - + @@ -7487,16 +7487,16 @@ - + - + - + @@ -7543,29 +7543,29 @@ - - - + - - + - + - + - - - + - - - + @@ -7577,7 +7577,7 @@ - + @@ -7586,9 +7586,9 @@ - - - + @@ -7607,7 +7607,7 @@ - + @@ -7648,13 +7648,13 @@ - + - - - - - + @@ -7744,16 +7744,16 @@ - + - + - + @@ -7779,16 +7779,16 @@ - + - + - + @@ -7835,29 +7835,29 @@ - - - + - - + - + - + - - - + - - - + @@ -7869,7 +7869,7 @@ - + @@ -7878,9 +7878,9 @@ - - - + @@ -7899,7 +7899,7 @@ - + @@ -7940,13 +7940,13 @@ - + - - - - - + @@ -8036,16 +8036,16 @@ - + - + - + @@ -8071,16 +8071,16 @@ - + - + - + @@ -8127,29 +8127,29 @@ - - - + - - + - + - + - - - + - - - + @@ -8161,7 +8161,7 @@ - + @@ -8170,9 +8170,9 @@ - - - + @@ -8191,7 +8191,7 @@ - + @@ -8232,13 +8232,13 @@ - + - - - - - + @@ -8328,16 +8328,16 @@ - + - + - + @@ -8363,16 +8363,16 @@ - + - + - + @@ -8419,29 +8419,29 @@ - - - + - - + - + - + - - - + - - - + @@ -8453,7 +8453,7 @@ - + @@ -8462,9 +8462,9 @@ - - - + @@ -8483,7 +8483,7 @@ - + @@ -8524,13 +8524,13 @@ - + - - - - - + @@ -8599,16 +8599,16 @@ - + - + - + @@ -8655,16 +8655,16 @@ - + - + - + @@ -8690,16 +8690,16 @@ - + - + - + @@ -8746,29 +8746,29 @@ - - - + - - + - + - + - - - + - - - + @@ -8780,7 +8780,7 @@ - + @@ -8789,9 +8789,9 @@ - - - + @@ -8810,7 +8810,7 @@ - + @@ -8851,13 +8851,13 @@ - + - - - - - + @@ -8947,16 +8947,16 @@ - + - + - + @@ -8982,16 +8982,16 @@ - + - + - + @@ -9038,29 +9038,29 @@ - - - + - - + - + - + - - - + - - - + @@ -9072,7 +9072,7 @@ - + @@ -9081,9 +9081,9 @@ - - - + @@ -9102,7 +9102,7 @@ - + @@ -9143,13 +9143,13 @@ - + - - - - - + @@ -9218,35 +9218,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9256,7 +9256,7 @@ - + @@ -9277,35 +9277,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9315,7 +9315,7 @@ - + @@ -9336,35 +9336,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9374,7 +9374,7 @@ - + @@ -9395,35 +9395,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9433,7 +9433,7 @@ - + @@ -9454,35 +9454,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9492,7 +9492,7 @@ - + @@ -9513,35 +9513,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9551,7 +9551,7 @@ - + @@ -9572,35 +9572,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9610,7 +9610,7 @@ - + @@ -9631,35 +9631,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9669,7 +9669,7 @@ - + @@ -9690,35 +9690,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9728,7 +9728,7 @@ - + @@ -9749,35 +9749,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9787,7 +9787,7 @@ - + @@ -9808,35 +9808,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9846,7 +9846,7 @@ - + @@ -9867,35 +9867,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9905,7 +9905,7 @@ - + @@ -9931,16 +9931,16 @@ - - - + - - + - + @@ -9956,11 +9956,11 @@ - + - + @@ -9973,7 +9973,7 @@ - + @@ -10024,11 +10024,11 @@ - + - + @@ -10409,26 +10409,26 @@ - + - - + - + - - - + @@ -10438,9 +10438,9 @@ - + - + @@ -10449,13 +10449,13 @@ - + - - - - - + @@ -10468,7 +10468,7 @@ - + @@ -10509,12 +10509,12 @@ - - - - - - + @@ -10701,33 +10701,33 @@ - + - - + - + - - - - - - + - - - + @@ -10737,9 +10737,9 @@ - + - + @@ -10748,13 +10748,13 @@ - + - - - - - + @@ -10767,7 +10767,7 @@ - + @@ -10807,12 +10807,12 @@ - - - - - - + @@ -11003,26 +11003,26 @@ - + - + - - + - + - - - + @@ -11032,9 +11032,9 @@ - + - + @@ -11043,13 +11043,13 @@ - + - - - - - + @@ -11062,7 +11062,7 @@ - + @@ -11103,12 +11103,12 @@ - - - - - - + @@ -11299,26 +11299,26 @@ - + - + - - + - + - - - + @@ -11328,9 +11328,9 @@ - + - + @@ -11339,13 +11339,13 @@ - + - - - - - + @@ -11364,7 +11364,7 @@ - + @@ -11405,12 +11405,12 @@ - - - - - - + diff --git a/test/pix/quick-cmp.sh b/test/pix/quick-cmp.sh index 515b1bd28..b86e16ec3 100755 --- a/test/pix/quick-cmp.sh +++ b/test/pix/quick-cmp.sh @@ -2,7 +2,9 @@ $XMLFILE=@ARGV[0]; -$DIFFCMD="diff -0 -u -b -B -I \"! Generated\" "; +$DIFFCMD="diff -C 1 -c -b -B -I \"! Generated\" -I 'Activating ' -I '! Firewall Builder fwb_pix v' -I 'Can not find file' "; + +#$DIFFCMD="diff -u -b -B -I \"! Generated\" "; while (<>) { $str=$_;