see #2519 Avoid creating duplicate network objects for the

AttachedNetwork object if the parent interface has multiple ip
addresses that belong to the same subnet.
This commit is contained in:
Vadim Kurland
2011-06-22 15:25:18 -07:00
parent c940bed072
commit d7a749154f
3 changed files with 30 additions and 4 deletions
+5
View File
@@ -1,5 +1,10 @@
2011-06-22 Vadim Kurland <vadim@netcitadel.com>
* AttachedNetworksDialog.cpp (addAddressToList): see #2519 Avoid
creating duplicate network objects for the AttachedNetwork object
if the parent interface has multiple ip addresses that belong to
the same subnet.
* CompilerDriver.cpp (CompilerDriver): fixed #2521 "Compile fails
if firewall has locked interface that is set to dynamic".
@@ -115,12 +115,30 @@ void AttachedNetworks::loadFromSource(bool ipv6, bool ) throw(FWException)
string c_type = (ipv6) ? IPv6::TYPENAME : IPv4::TYPENAME;
// assemble list of address/netmask pairs to eliminate duplicates
map<string, Address*> networks;
FWObjectTypedChildIterator k = parent_intf->findByType(c_type);
for ( ; k!=k.end(); ++k)
{
Address *addr = Address::cast(*k);
const InetAddr *ip_netm = addr->getNetmaskPtr();
const InetAddr *ip_net_addr = addr->getNetworkAddressPtr();
ostringstream net;
if (ip_net_addr->isV6())
{
net << ip_net_addr->toString() << "/" << ip_netm->getLength();
} else
{
net << ip_net_addr->toString() << "/" << ip_netm->toString();
}
networks[net.str()] = addr;
}
for (map<string, Address*>::iterator it=networks.begin(); it!=networks.end(); ++it)
{
const InetAddr *ip_netm = it->second->getNetmaskPtr();
const InetAddr *ip_net_addr = it->second->getNetworkAddressPtr();
addNetworkObject(ip_net_addr, ip_netm);
}
}
+7 -4
View File
@@ -111,15 +111,18 @@ void AttachedNetworksDialog::addAddressToList(const InetAddr *ip_addr,
const InetAddr *ip_netm)
{
QString name("%1/%2");
QString itm;
if (ip_addr->isV6())
{
m_dialog->addresses->addItem(
name.arg(ip_addr->toString().c_str()).arg(ip_netm->getLength()));
itm = name.arg(ip_addr->toString().c_str()).arg(ip_netm->getLength());
} else
{
m_dialog->addresses->addItem(
name.arg(ip_addr->toString().c_str()).arg(ip_netm->toString().c_str()));
itm = name.arg(ip_addr->toString().c_str()).arg(ip_netm->toString().c_str());
}
QList<QListWidgetItem*> items = m_dialog->addresses->findItems(
itm, Qt::MatchExactly);
if (items.size() == 0) m_dialog->addresses->addItem(itm);
}
void AttachedNetworksDialog::validate(bool *result)