mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-03-23 19:57:21 +01:00
refactored useful classes AddressSpec, PortSpec, InterfaceSpec, IcmpSpec and RouteSpec to separate modules so they can be used with other installers
This commit is contained in:
parent
564500768e
commit
52ea731f92
@ -4,6 +4,7 @@
|
||||
rules. Known limitations:
|
||||
- as of v4.2 we can not generate optinal parameters for the
|
||||
"source-hash" pooltype. "sticky-address" is not supported either.
|
||||
- Interface group names are not recognized
|
||||
|
||||
2011-05-27 vadim <vadim@netcitadel.com>
|
||||
|
||||
|
||||
70
src/import/AddressSpec.h
Normal file
70
src/import/AddressSpec.h
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2011 NetCitadel, LLC
|
||||
|
||||
Author: Vadim Kurland vadim@fwbuilder.org
|
||||
|
||||
This program is free software which we release under the GNU General Public
|
||||
License. You may redistribute and/or modify this program under the terms
|
||||
of that license as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
To get a copy of the GNU General Public License, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _ADDRESS_SPEC_H_
|
||||
#define _ADDRESS_SPEC_H_
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
|
||||
class AddressSpec
|
||||
{
|
||||
public:
|
||||
|
||||
typedef enum {
|
||||
UNKNOWN,
|
||||
ANY,
|
||||
HOST_NAME,
|
||||
HOST_ADDRESS,
|
||||
NETWORK_ADDRESS,
|
||||
SPECIAL_ADDRESS,
|
||||
INTERFACE_NAME,
|
||||
INTERFACE_NETWORK,
|
||||
INTERFACE_BROADCAST,
|
||||
TABLE } address_type;
|
||||
|
||||
address_type at;
|
||||
bool neg;
|
||||
std::string address;
|
||||
std::string netmask;
|
||||
|
||||
AddressSpec()
|
||||
{ at = UNKNOWN; neg = false; address = ""; netmask = ""; }
|
||||
|
||||
AddressSpec(const AddressSpec &other)
|
||||
{
|
||||
at = other.at;
|
||||
neg = other.neg;
|
||||
address = other.address;
|
||||
netmask = other.netmask;
|
||||
}
|
||||
|
||||
AddressSpec(address_type _at, bool _neg, const std::string _addr, const std::string _nm)
|
||||
{ at = _at; neg= _neg; address = _addr; netmask = _nm; }
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
69
src/import/IcmpSpec.h
Normal file
69
src/import/IcmpSpec.h
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2011 NetCitadel, LLC
|
||||
|
||||
Author: Vadim Kurland vadim@fwbuilder.org
|
||||
|
||||
This program is free software which we release under the GNU General Public
|
||||
License. You may redistribute and/or modify this program under the terms
|
||||
of that license as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
To get a copy of the GNU General Public License, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _ICMP_SPEC_H_
|
||||
#define _ICMP_SPEC_H_
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
|
||||
class IcmpSpec
|
||||
{
|
||||
public:
|
||||
std::string icmp_type_name;
|
||||
std::string icmp_type_int;
|
||||
std::string icmp_code_name;
|
||||
std::string icmp_code_int;
|
||||
|
||||
IcmpSpec()
|
||||
{
|
||||
icmp_type_name = "";
|
||||
icmp_type_int = "";
|
||||
icmp_code_name = "";
|
||||
icmp_code_int = "";
|
||||
}
|
||||
|
||||
IcmpSpec(const IcmpSpec &other)
|
||||
{
|
||||
icmp_type_name = other.icmp_type_name;
|
||||
icmp_type_int = other.icmp_type_int;
|
||||
icmp_code_name = other.icmp_code_name;
|
||||
icmp_code_int = other.icmp_code_int;
|
||||
}
|
||||
|
||||
IcmpSpec(const std::string s1, const std::string s2,
|
||||
const std::string s3, const std::string s4)
|
||||
{
|
||||
icmp_type_name = s1;
|
||||
icmp_type_int = s2;
|
||||
icmp_code_name = s3;
|
||||
icmp_code_int = s4;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
91
src/import/InterfaceSpec.h
Normal file
91
src/import/InterfaceSpec.h
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2011 NetCitadel, LLC
|
||||
|
||||
Author: Vadim Kurland vadim@fwbuilder.org
|
||||
|
||||
This program is free software which we release under the GNU General Public
|
||||
License. You may redistribute and/or modify this program under the terms
|
||||
of that license as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
To get a copy of the GNU General Public License, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _INTERFACE_SPEC_H_
|
||||
#define _INTERFACE_SPEC_H_
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
|
||||
class InterfaceSpec
|
||||
{
|
||||
public:
|
||||
|
||||
bool neg;
|
||||
std::string name;
|
||||
std::string inet_address;
|
||||
std::string inet_netmask;
|
||||
std::string inet_broadcast;
|
||||
std::string inet6_address;
|
||||
std::string inet6_prefixlen;
|
||||
bool status; // up / down
|
||||
std::list<std::string> groups;
|
||||
int mtu;
|
||||
|
||||
InterfaceSpec()
|
||||
{
|
||||
neg = false;
|
||||
name = "";
|
||||
inet_address = "";
|
||||
inet_netmask = "";
|
||||
inet_broadcast = "";
|
||||
inet6_address = "";
|
||||
inet6_prefixlen = "";
|
||||
status = false;
|
||||
groups.clear();
|
||||
mtu = 0;
|
||||
}
|
||||
|
||||
InterfaceSpec(const InterfaceSpec &other)
|
||||
{
|
||||
neg = other.neg;
|
||||
name = other.name;
|
||||
inet_address = other.inet_address;
|
||||
inet_netmask = other.inet_netmask;
|
||||
inet_broadcast = other.inet_broadcast;
|
||||
inet6_address = other.inet6_address;
|
||||
inet6_prefixlen = other.inet6_prefixlen;
|
||||
status = other.status;
|
||||
groups = other.groups;
|
||||
mtu = other.mtu;
|
||||
}
|
||||
|
||||
InterfaceSpec(bool _neg, const std::string _name)
|
||||
{
|
||||
neg = _neg;
|
||||
name = _name;
|
||||
inet_address = "";
|
||||
inet_netmask = "";
|
||||
inet_broadcast = "";
|
||||
inet6_address = "";
|
||||
inet6_prefixlen = "";
|
||||
status = false;
|
||||
groups.clear();
|
||||
mtu = 0;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -32,6 +32,11 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "IOSImporter.h"
|
||||
#include "AddressSpec.h"
|
||||
#include "InterfaceSpec.h"
|
||||
#include "PortSpec.h"
|
||||
#include "IcmpSpec.h"
|
||||
#include "RouteSpec.h"
|
||||
|
||||
#include "fwbuilder/libfwbuilder-config.h"
|
||||
#include "fwbuilder/Logger.h"
|
||||
@ -41,146 +46,7 @@
|
||||
#include <QString>
|
||||
|
||||
|
||||
class InterfaceSpec
|
||||
{
|
||||
public:
|
||||
|
||||
bool neg;
|
||||
std::string name;
|
||||
|
||||
InterfaceSpec()
|
||||
{ neg = false; name = ""; }
|
||||
|
||||
InterfaceSpec(const InterfaceSpec &other)
|
||||
{
|
||||
neg = other.neg;
|
||||
name = other.name;
|
||||
}
|
||||
|
||||
InterfaceSpec(bool _neg, const std::string _name)
|
||||
{ neg = _neg; name = _name; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
class AddressSpec
|
||||
{
|
||||
public:
|
||||
|
||||
typedef enum {
|
||||
UNKNOWN,
|
||||
ANY,
|
||||
HOST_NAME,
|
||||
HOST_ADDRESS,
|
||||
NETWORK_ADDRESS,
|
||||
SPECIAL_ADDRESS,
|
||||
INTERFACE_NAME,
|
||||
INTERFACE_NETWORK,
|
||||
INTERFACE_BROADCAST,
|
||||
TABLE } address_type;
|
||||
|
||||
address_type at;
|
||||
bool neg;
|
||||
std::string address;
|
||||
std::string netmask;
|
||||
|
||||
AddressSpec()
|
||||
{ at = UNKNOWN; neg = false; address = ""; netmask = ""; }
|
||||
|
||||
AddressSpec(const AddressSpec &other)
|
||||
{
|
||||
at = other.at;
|
||||
neg = other.neg;
|
||||
address = other.address;
|
||||
netmask = other.netmask;
|
||||
}
|
||||
|
||||
AddressSpec(address_type _at, bool _neg, const std::string _addr, const std::string _nm)
|
||||
{ at = _at; neg= _neg; address = _addr; netmask = _nm; }
|
||||
};
|
||||
|
||||
|
||||
class PortSpec
|
||||
{
|
||||
public:
|
||||
std::string port1;
|
||||
std::string port2;
|
||||
std::string port_op;
|
||||
|
||||
PortSpec()
|
||||
{ port1 = ""; port2 = ""; port_op = ""; }
|
||||
|
||||
PortSpec(const PortSpec &other)
|
||||
{
|
||||
port1 = other.port1;
|
||||
port2 = other.port2;
|
||||
port_op = other.port_op;
|
||||
}
|
||||
|
||||
PortSpec(const std::string s1, const std::string s2, const std::string s3)
|
||||
{ port1 = s1; port2 = s2; port_op = s3; }
|
||||
|
||||
std::string toString()
|
||||
{ return std::string("PortSpec: ") + port_op + " " + port1 + " " + port2; }
|
||||
};
|
||||
|
||||
class IcmpSpec
|
||||
{
|
||||
public:
|
||||
std::string icmp_type_name;
|
||||
std::string icmp_type_int;
|
||||
std::string icmp_code_name;
|
||||
std::string icmp_code_int;
|
||||
|
||||
IcmpSpec()
|
||||
{
|
||||
icmp_type_name = "";
|
||||
icmp_type_int = "";
|
||||
icmp_code_name = "";
|
||||
icmp_code_int = "";
|
||||
}
|
||||
|
||||
IcmpSpec(const IcmpSpec &other)
|
||||
{
|
||||
icmp_type_name = other.icmp_type_name;
|
||||
icmp_type_int = other.icmp_type_int;
|
||||
icmp_code_name = other.icmp_code_name;
|
||||
icmp_code_int = other.icmp_code_int;
|
||||
}
|
||||
|
||||
IcmpSpec(const std::string s1, const std::string s2,
|
||||
const std::string s3, const std::string s4)
|
||||
{
|
||||
icmp_type_name = s1;
|
||||
icmp_type_int = s2;
|
||||
icmp_code_name = s3;
|
||||
icmp_code_int = s4;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class RouteSpec
|
||||
{
|
||||
public:
|
||||
|
||||
std::string iface;
|
||||
std::string address;
|
||||
std::string netmask;
|
||||
|
||||
RouteSpec()
|
||||
{ iface = ""; address = ""; netmask = ""; }
|
||||
|
||||
RouteSpec(const RouteSpec &other)
|
||||
{
|
||||
iface = other.iface;
|
||||
address = other.address;
|
||||
netmask = other.netmask;
|
||||
}
|
||||
|
||||
RouteSpec(const std::string _iface,
|
||||
const std::string _addr, const std::string _nm)
|
||||
{ iface = _iface; address = _addr; netmask = _nm; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
57
src/import/PortSpec.h
Normal file
57
src/import/PortSpec.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2011 NetCitadel, LLC
|
||||
|
||||
Author: Vadim Kurland vadim@fwbuilder.org
|
||||
|
||||
This program is free software which we release under the GNU General Public
|
||||
License. You may redistribute and/or modify this program under the terms
|
||||
of that license as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
To get a copy of the GNU General Public License, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _PORT_SPEC_H_
|
||||
#define _PORT_SPEC_H_
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
|
||||
class PortSpec
|
||||
{
|
||||
public:
|
||||
std::string port1;
|
||||
std::string port2;
|
||||
std::string port_op;
|
||||
|
||||
PortSpec()
|
||||
{ port1 = ""; port2 = ""; port_op = ""; }
|
||||
|
||||
PortSpec(const PortSpec &other)
|
||||
{
|
||||
port1 = other.port1;
|
||||
port2 = other.port2;
|
||||
port_op = other.port_op;
|
||||
}
|
||||
|
||||
PortSpec(const std::string s1, const std::string s2, const std::string s3)
|
||||
{ port1 = s1; port2 = s2; port_op = s3; }
|
||||
|
||||
std::string toString()
|
||||
{ return std::string("PortSpec: ") + port_op + " " + port1 + " " + port2; }
|
||||
};
|
||||
|
||||
#endif
|
||||
57
src/import/RouteSpec.h
Normal file
57
src/import/RouteSpec.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2011 NetCitadel, LLC
|
||||
|
||||
Author: Vadim Kurland vadim@fwbuilder.org
|
||||
|
||||
This program is free software which we release under the GNU General Public
|
||||
License. You may redistribute and/or modify this program under the terms
|
||||
of that license as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
To get a copy of the GNU General Public License, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _ROUTE_SPEC_H_
|
||||
#define _ROUTE_SPEC_H_
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
class RouteSpec
|
||||
{
|
||||
public:
|
||||
|
||||
std::string iface;
|
||||
std::string address;
|
||||
std::string netmask;
|
||||
|
||||
RouteSpec()
|
||||
{ iface = ""; address = ""; netmask = ""; }
|
||||
|
||||
RouteSpec(const RouteSpec &other)
|
||||
{
|
||||
iface = other.iface;
|
||||
address = other.address;
|
||||
netmask = other.netmask;
|
||||
}
|
||||
|
||||
RouteSpec(const std::string _iface,
|
||||
const std::string _addr, const std::string _nm)
|
||||
{ iface = _iface; address = _addr; netmask = _nm; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@ -35,6 +35,12 @@ HEADERS = QStringListOperators.h \
|
||||
IPTImporter.h \
|
||||
PIXImporter.h \
|
||||
PFImporter.h \
|
||||
InterfaceSpec.h \
|
||||
AddressSpec.h \
|
||||
PortSpec.h \
|
||||
IcmpSpec.h \
|
||||
RouteSpec.h \
|
||||
|
||||
|
||||
CONFIG += staticlib
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user