From 6f4a98627301e05a1d047d0793a957e7971dd80f Mon Sep 17 00:00:00 2001 From: Vadim Kurland Date: Wed, 18 Aug 2010 02:49:40 +0000 Subject: [PATCH] * procurveInterfaces.cpp (procurveInterfaces::parseVlan): fixed #1683 class procurveInterfaces interprets interface "DEFAULT_VLAN" as vlan interface with vlan id 1. --- build_num | 2 +- doc/ChangeLog | 9 ++++++++ .../interfacePropertiesObjectFactory.cpp | 1 + src/compiler_lib/procurveInterfaces.cpp | 10 +++++++- src/gui/DiscoveryDruid.cpp | 23 ++++++++++++++++--- src/gui/newFirewallDialog.cpp | 16 +++++++++++++ 6 files changed, 56 insertions(+), 5 deletions(-) diff --git a/build_num b/build_num index c77d297d9..70dc84630 100644 --- a/build_num +++ b/build_num @@ -1 +1 @@ -#define BUILD_NUM 3232 +#define BUILD_NUM 3233 diff --git a/doc/ChangeLog b/doc/ChangeLog index ec345577f..fe4dd36a1 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,5 +1,14 @@ 2010-08-17 Vadim Kurland + * procurveInterfaces.cpp (procurveInterfaces::parseVlan): fixed #1683 + class procurveInterfaces interprets interface "DEFAULT_VLAN" as + vlan interface with vlan id 1. + + * newFirewallDialog.cpp (newFirewallDialog::finishClicked): + fixed #1683 When user creates new firewall using snmp scan, + fwbuilder will now guess and assign the type to interfaces that + look like vlans for the given platform and host OS. + * safety_net_acl: fixed #1687 "temporary access list commands syntax is incorrect". Temporary ACL generated for the Procurve platform was incorrect. diff --git a/src/compiler_lib/interfacePropertiesObjectFactory.cpp b/src/compiler_lib/interfacePropertiesObjectFactory.cpp index 1c0b0d6b3..caf058a0c 100644 --- a/src/compiler_lib/interfacePropertiesObjectFactory.cpp +++ b/src/compiler_lib/interfacePropertiesObjectFactory.cpp @@ -27,6 +27,7 @@ #include "interfaceProperties.h" #include "linux24Interfaces.h" #include "iosInterfaces.h" +#include "procurveInterfaces.h" #include "bsdInterfaces.h" #include "pixInterfaces.h" #include "procurveInterfaces.h" diff --git a/src/compiler_lib/procurveInterfaces.cpp b/src/compiler_lib/procurveInterfaces.cpp index fc8d00cd8..59713fe2f 100644 --- a/src/compiler_lib/procurveInterfaces.cpp +++ b/src/compiler_lib/procurveInterfaces.cpp @@ -58,7 +58,15 @@ bool procurveInterfaces::basicValidateInterfaceName(Interface*, bool procurveInterfaces::parseVlan( const QString &name, QString *base_name, int *vlan_id) { - QRegExp vlan_name_pattern("(vlan|Vlan|VLAN) (\\d{1,})"); + if (name == "DEFAULT_VLAN") + { + if (base_name!=NULL) *base_name = "vlan"; + if (vlan_id!=NULL) *vlan_id = 1; + return true; + } + + // Procurve SNMP reports vlan interface names without space + QRegExp vlan_name_pattern("(vlan|Vlan|VLAN) *(\\d{1,})"); if (vlan_name_pattern.indexIn(name) != -1) { if (base_name!=NULL) *base_name = vlan_name_pattern.cap(1); diff --git a/src/gui/DiscoveryDruid.cpp b/src/gui/DiscoveryDruid.cpp index 54a18e8b3..43c3e4c4a 100644 --- a/src/gui/DiscoveryDruid.cpp +++ b/src/gui/DiscoveryDruid.cpp @@ -2090,12 +2090,12 @@ FWObject* DiscoveryDruid::addInterface(FWObject *parent, InterfaceData *in, return NULL; } + QString obj_name = in->name.c_str(); Interface *itf = NULL; itf = Interface::cast( mw->createObject(parent, - QString(Interface::TYPENAME), - QString(in->name.c_str()))); - + QString(Interface::TYPENAME), obj_name)); + QString iname = om->getStandardName(itf, physAddress::TYPENAME, "mac"); iname = om->makeNameUnique(itf, iname, physAddress::TYPENAME); @@ -2107,11 +2107,28 @@ FWObject* DiscoveryDruid::addInterface(FWObject *parent, InterfaceData *in, itf->setLabel(in->label); itf->setSecurityLevel(in->securityLevel); + if (fwbdebug) + qDebug() << "Interface=" << obj_name + << "type=" << in->interface_type.c_str(); + if (!in->interface_type.empty()) { itf->getOptionsObject()->setStr("type", in->interface_type); if (in->interface_type == "8021q") itf->getOptionsObject()->setInt("vlan_id", in->vlan_id); + } else + { + std::auto_ptr int_prop( + interfacePropertiesObjectFactory::getInterfacePropertiesObject(parent)); + if (int_prop->looksLikeVlanInterface(obj_name)) + { + QString base_name; + int vlan_id; + int_prop->parseVlan(obj_name, &base_name, &vlan_id); + + itf->getOptionsObject()->setStr("type", "8021q"); + itf->getOptionsObject()->setInt("vlan_id", vlan_id); + } } if (in->addr_mask.size()==0 || diff --git a/src/gui/newFirewallDialog.cpp b/src/gui/newFirewallDialog.cpp index fcac5a53f..d3c64b193 100644 --- a/src/gui/newFirewallDialog.cpp +++ b/src/gui/newFirewallDialog.cpp @@ -39,6 +39,9 @@ #include "FWBApplication.h" #include "QDesktopWidget" +#include "interfaceProperties.h" +#include "interfacePropertiesObjectFactory.h" + #include "fwbuilder/Library.h" #include "fwbuilder/Firewall.h" #include "fwbuilder/Resources.h" @@ -983,6 +986,19 @@ void newFirewallDialog::finishClicked() qDebug("Adding interface %s: security_level=%d", oi->getName().c_str(), sl); + std::auto_ptr int_prop( + interfacePropertiesObjectFactory::getInterfacePropertiesObject(nfw)); + if (int_prop->looksLikeVlanInterface(name)) + { + QString base_name; + int vlan_id; + int_prop->parseVlan(name, &base_name, &vlan_id); + + oi->getOptionsObject()->setStr("type", "8021q"); + oi->getOptionsObject()->setInt("vlan_id", vlan_id); + } + + if (iface.type == 0) { foreach(AddressInfo address, iface.addresses)