1 /*
2  * OSConfigurator_secuwall.h - OS configurator for secunet wall host OS
3  *
4  * Copyright (c) 2008 secunet Security Networks AG
5  * Copyright (c) 2008 Adrian-Ken Rueegsegger <rueegsegger@swiss-it.ch>
6  * Copyright (c) 2008 Reto Buerki <buerki@swiss-it.ch>
7  *
8  * This work is dual-licensed under:
9  *
10  * o The terms of the GNU General Public License as published by the Free
11  *   Software Foundation, either version 2 of the License, or (at your option)
12  *   any later version.
13  *
14  * o The terms of NetCitadel End User License Agreement
15  */
16 
17 #ifndef __OSNETWORKCONFIGURATOR_SECUWALL_H_
18 #define __OSNETWORKCONFIGURATOR_SECUWALL_H_
19 
20 #include "fwbuilder/Tools.h"
21 #include "OSConfigurator_linux24.h"
22 #include <map>
23 #include <QIODevice>
24 
25 namespace fwcompiler
26 {
27 
28 class OSConfigurator_secuwall : public OSConfigurator_linux24
29 {
30 
31 public:
~OSConfigurator_secuwall()32     virtual ~OSConfigurator_secuwall() {};
33     OSConfigurator_secuwall(libfwbuilder::FWObjectDatabase *_db,
34                             libfwbuilder::Firewall *fw, bool ipv6_policy);
35 
36     virtual std::string myPlatformName();
37 
38     virtual void processFirewallOptions();
39 
40     virtual std::string printPathForAllTools(const std::string &);
41 
42     virtual std::map<std::string, std::string> getGeneratedFiles() const;
43 
44     /* TODO: Merge this mapping with gui interface types mapping */
45     /* Value-Defintions of the different String values */
46     enum ifaceType { ifNotDefined,
47                      ETHERNET,
48                      ALIAS,
49                      BRIDGE,
50                      BONDING,
51                      CLUSTER,
52                      VLAN,
53                      ifEnd
54                    };
55 
56     /* Map to associate the strings with the enum values */
57     std::map<std::string, ifaceType> s_mapIfaceTypes;
58     /* and vice versa for the config files */
59     std::map<ifaceType, std::string> s_mapIfaceStrings;
60 
61 private:
62     bool createDirStructure() const;
63     int generateManagementFile();
64     int generateNetworkFile();
65     int generateHostsFile();
66     int generateDNSFile();
67     int generateNsswitchFile();
68     int generateInterfaces();
69     int generateInterfaceFile(libfwbuilder::Interface * iface,
70                               std::string name = "",
71                               libfwbuilder::IPv4 * ip_address = NULL,
72                               int iface_number = 0);
73 
74     int generateSSHKeys();
75 
76     int stringToFile(const std::string data,
77                      const std::string filename,
78                      const QIODevice::OpenMode mode = QIODevice::ReadWrite|QIODevice::Truncate) const;
79 
80     bool containsFirewallKey(std::string in) const;
81 
82     std::list<libfwbuilder::Interface *> m_ifaces;
83 };
84 };
85 
86 #endif
87