1 /*
2
3 Firewall Builder
4
5 Copyright (C) 2009 NetCitadel, LLC
6
7 Author: Vadim Kurland vadim@fwbuilder.org
8
9 $Id$
10
11 This program is free software which we release under the GNU General Public
12 License. You may redistribute and/or modify this program under the terms
13 of that license as published by the Free Software Foundation; either
14 version 2 of the License, or (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 To get a copy of the GNU General Public License, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
24 */
25
26 #include "nxosInterfaces.h"
27
28 #include "fwbuilder/Interface.h"
29
30 #include <QDebug>
31 #include <QObject>
32 #include <QRegExp>
33
34 using namespace std;
35 using namespace libfwbuilder;
36
37
parseVlan(const QString & name,QString * base_name,int * vlan_id)38 bool nxosInterfaces::parseVlan(const QString &name, QString *base_name, int *vlan_id)
39 {
40 QRegExp vlan_name_pattern("([a-zA-Z-]+\\d{1,}/\\d{1,})\\.(\\d{1,})");
41 if (vlan_name_pattern.indexIn(name) != -1)
42 {
43 if (base_name!=NULL) *base_name = vlan_name_pattern.cap(1);
44 if (vlan_id!=NULL) *vlan_id = vlan_name_pattern.cap(2).toInt();
45 return true;
46 }
47 return false;
48 }
49
50 // simple name validation: does not allow space and "-"
51 // However some platform permit space (procurve).
basicValidateInterfaceName(Interface *,const QString & obj_name,QString & err)52 bool nxosInterfaces::basicValidateInterfaceName(Interface *,
53 const QString &obj_name,
54 QString &err)
55 {
56 if (obj_name.indexOf(' ') != -1)
57 {
58 err = QObject::tr("Interface name '%1' can not contain white space").arg(obj_name);
59 return false;
60 }
61 return true;
62 }
63
64