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 "pixInterfaces.h"
27 
28 #include <QRegExp>
29 
30 /*
31  * http://www.cisco.com/en/US/docs/security/asa/asa70/command/reference/gl.html#wp1644971
32  *
33  * hostname(config)# interface gigabitethernet0/1.1
34  * hostname(config-subif)# vlan 101
35  * hostname(config-subif)# nameif dmz1
36  * hostname(config-subif)# security-level 50
37  * hostname(config-subif)# ip address 10.1.2.1 255.255.255.0
38  * hostname(config-subif)# no shutdown
39  *
40  */
41 
parseVlan(const QString & name,QString * base_name,int * vlan_id)42 bool pixInterfaces::parseVlan(const QString &name, QString *base_name, int *vlan_id)
43 {
44     QRegExp vlan_name_pattern("([a-zA-Z-]+\\d{1,}(/\\d{1,})*)\\.(\\d{1,})");
45     if (vlan_name_pattern.indexIn(name) != -1)
46     {
47         if (base_name!=NULL) *base_name = vlan_name_pattern.cap(1);
48         if (vlan_id!=NULL) *vlan_id = vlan_name_pattern.cap(3).toInt();
49         return true;
50     }
51     return false;
52 }
53 
54