1 /*
2 
3                           Firewall Builder
4 
5                  Copyright (C) 2002 NetCitadel, LLC
6 
7   Author:  Vadim Kurland     vadim@vk.crocodile.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 #ifndef _OSCONFIGURATOR_LINUX24_HH
27 #define _OSCONFIGURATOR_LINUX24_HH
28 
29 #include "config.h"
30 
31 #include "fwcompiler/OSConfigurator.h"
32 
33 #include "OSData.h"
34 
35 class QString;
36 class QStringList;
37 
38 namespace libfwbuilder {
39     class FWObject;
40     class MultiAddressRunTime;
41 };
42 
43 class Configlet;
44 
45 namespace fwcompiler {
46 
47     class OSConfigurator_linux24 : public OSConfigurator {
48 
49         OSData os_data;
50         Configlet *command_wrappers;
51         bool using_ipset;
52 
53         std::map<std::string,std::string> address_table_objects;
54 
55         // this vector is used to avoid duplication of virtual addresses for nat
56         std::vector<libfwbuilder::InetAddr> virtual_addresses;
57         // map of virt. addresses for nat for each interface
58         std::map<std::string, std::string> virtual_addresses_for_nat;
59         std::list<std::string> known_interfaces;
60 
61         std::string getInterfaceVarName(libfwbuilder::FWObject *iface,
62                                         bool v6=false);
63 
64         std::string getPathForATool(const std::string &os_variant, OSData::tools tool_name);
65         void setConfigletMacroForOptionStr(const std::string &opt,
66                                            Configlet *c,
67                                            const char *option_name);
68         void setConfigletMacroForOptionInt(int opt,
69                                            Configlet *c,
70                                            const char *option_name);
71         virtual QString addressTableWrapper(libfwbuilder::FWObject *rule,
72                                             const QString &command,
73                                             bool ipv6=false);
74 
75         virtual QString printUpdateAddressCommand(
76             libfwbuilder::Interface *intf,
77             QStringList &update_addresses,
78             QStringList &ignore_addresses);
79 
80 public:
81 
82 	virtual ~OSConfigurator_linux24();
83 	OSConfigurator_linux24(libfwbuilder::FWObjectDatabase *_db,
84                                libfwbuilder::Firewall *fw, bool ipv6_policy);
85 
86 	virtual std::string myPlatformName();
87 
88         virtual int  prolog();
89         virtual void epilog();
90 
usingIpSetModule()91         bool usingIpSetModule() { return using_ipset; }
92         /*
93          * Try to find conflicts in subinterface types and unsupported
94          * interface configurations.
95          */
96         virtual bool validateInterfaces();
97 
98 	virtual void processFirewallOptions();
99         virtual std::string generateCodeForProtocolHandlers();
100 
101 	virtual void addVirtualAddressForNAT(const libfwbuilder::Address *addr);
102 	virtual void addVirtualAddressForNAT(const libfwbuilder::Network *nw);
103 
104         virtual void registerMultiAddressObject(libfwbuilder::MultiAddressRunTime *at);
105         virtual std::string printShellFunctions(bool have_ipv6);
106         virtual std::string printPathForAllTools(const std::string &os);
107         virtual std::string printIPForwardingCommands();
108         virtual std::string printRunTimeWrappers(libfwbuilder::FWObject *rule,
109                                                  const std::string &command,
110                                                  bool ipv6=false);
111         virtual std::string printVerifyInterfacesCommands();
112 
113 
114         virtual std::string printVirtualAddressesForNatCommands();
115         virtual std::string printInterfaceConfigurationCommands();
116         virtual std::string printCommandsToClearKnownInterfaces();
117 
118         virtual std::string printVlanInterfaceConfigurationCommands();
119         virtual std::string printBridgeInterfaceConfigurationCommands();
120         virtual std::string printBondingInterfaceConfigurationCommands();
121         virtual std::string printDynamicAddressesConfigurationCommands();
122 
123         virtual std::string printRunTimeAddressTablesCode();
124 
125         virtual std::map<std::string, std::string> getGeneratedFiles() const;
126 
127         std::string normalizeSetName(const std::string &txt);
128 
129     };
130 };
131 
132 #endif
133