1 /* 2 3 Firewall Builder 4 5 Copyright (C) 2004 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 27 #ifndef __NEWFIREWALLDIALOG_H_ 28 #define __NEWFIREWALLDIALOG_H_ 29 30 #include "config.h" 31 #include <ui_newfirewalldialog_q.h> 32 33 #include "fwbuilder/InterfaceData.h" 34 #include "fwbuilder/InetAddrMask.h" 35 #include "fwbuilder/InterfaceData.h" 36 37 #include "fakeWizard.h" 38 39 #include <map> 40 41 namespace libfwbuilder { 42 class FWObject; 43 class FWObjectDatabase; 44 class Firewall; 45 class Interface; 46 class Logger; 47 class SNMPQuery; 48 }; 49 50 class QTreeWidgetItem; 51 class QTimer; 52 class QTextEdit; 53 54 class newFirewallDialog : public QDialog, public FakeWizard 55 { 56 Q_OBJECT; 57 58 Ui::newFirewallDialog_q *m_dialog; 59 60 libfwbuilder::FWObject *currentTemplate; 61 libfwbuilder::Firewall *nfw; 62 bool snmpPollCompleted; 63 libfwbuilder::Logger *logger; 64 libfwbuilder::SNMPQuery *q; 65 QTimer *timer; 66 libfwbuilder::FWObjectDatabase *db_orig; 67 libfwbuilder::FWObjectDatabase *tmpldb; 68 libfwbuilder::FWObjectDatabase *db_copy; 69 libfwbuilder::FWObject *parent; 70 std::map<QListWidgetItem*, libfwbuilder::FWObject*> templates; 71 bool unloadTemplatesLib; 72 bool getInterfacesBusy; 73 QString discovered_platform; 74 QString discovered_host_os; 75 QString discovered_version; 76 77 std::list<std::string> possible_inside_interface_labels; 78 std::list<std::string> possible_outside_interface_labels; 79 std::list<std::string> possible_dmz_interface_labels; 80 81 void fillInterfaceData(libfwbuilder::Interface *intf, QTextBrowser *qte); 82 83 void fillInterfaceSLList(); 84 void fillInterfaceNZList(); 85 86 void getInterfaceDataFromInterfaceEditor(EditedInterfaceData &edata, 87 libfwbuilder::InterfaceData &idata); 88 89 void createFirewallFromTemplate(); 90 void changedAddressesInNewFirewall(); 91 92 void replaceInterfaceAttributes(libfwbuilder::Firewall *fw, 93 libfwbuilder::Interface *intf, 94 EditedInterfaceData *new_data); 95 libfwbuilder::Address* replaceInterfaceAddressData( 96 libfwbuilder::Firewall *fw, 97 libfwbuilder::Interface *intf, 98 libfwbuilder::Address *addr_obj, 99 const QString &address, 100 const QString &netmask, 101 bool ipv4); 102 void replaceReferencesToNetworks(libfwbuilder::Firewall *fw, 103 libfwbuilder::Interface *intf, 104 libfwbuilder::InetAddrMask old_net, 105 libfwbuilder::InetAddrMask new_net); 106 void replaceReferencesToObject(libfwbuilder::Firewall *fw, 107 libfwbuilder::FWObject *old_obj, 108 libfwbuilder::FWObject *new_obj); 109 110 public: 111 newFirewallDialog(QWidget *parentw, libfwbuilder::FWObject *parent); 112 virtual ~newFirewallDialog(); 113 getNewFirewall()114 libfwbuilder::Firewall* getNewFirewall() { return nfw; }; 115 116 virtual bool appropriate(const int page) const; 117 118 void showPage(const int page); //it was "selected(QString)" 119 bool validateAddressAndMask(const QString &addr,const QString &netm); 120 void getIPAddressOfFirewallByName(); 121 122 public slots: 123 virtual void changed(); 124 virtual void getInterfacesViaSNMP(); 125 virtual void monitor(); 126 virtual void templateSelected(QListWidgetItem *itm); 127 void browseTemplate(); 128 void useStandardTemplate(); 129 void updateTemplatePanel(); 130 131 protected slots: 132 133 void finishClicked(); 134 void cancelClicked(); 135 void nextClicked(); 136 void backClicked(); 137 138 void cleanup(); 139 }; 140 141 #endif // __NEWFIREWALLDIALOG_H 142