1 /* 2 3 Firewall Builder 4 5 Copyright (C) 2006 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 __GEN_MULTIADDRESS_HH_FLAG__ 28 #define __GEN_MULTIADDRESS_HH_FLAG__ 29 30 #include "fwbuilder/FWObject.h" 31 #include "fwbuilder/Address.h" 32 #include "fwbuilder/ObjectGroup.h" 33 #include <vector> 34 35 36 37 namespace libfwbuilder 38 { 39 40 class MultiAddress : public ObjectGroup 41 { 42 private: 43 44 public: 45 46 DECLARE_FWOBJECT_SUBTYPE(MultiAddress); 47 48 DECLARE_DISPATCH_METHODS(MultiAddress); 49 50 MultiAddress(); 51 virtual ~MultiAddress(); 52 53 virtual std::string getSourceName(); 54 virtual void setSourceName(const std::string& source_name); 55 virtual void loadFromSource(bool ipv6, FWOptions *options, 56 bool test_mode=false) throw(FWException) = 0; 57 58 /* 59 * functions isCompileTime() and isRunTime() are virtual because 60 * some multi-address objects allow the user to set these flags, 61 * while other object types behave as run-time or compile-time 62 * depending on attributes of other objects (e.g. AttachedNetworks) 63 */ 64 virtual bool isCompileTime() const; 65 virtual bool isRunTime() const; 66 void setCompileTime(const bool b); 67 void setRunTime(const bool b); 68 69 virtual bool validateChild(FWObject *o); 70 isPrimaryObject()71 virtual bool isPrimaryObject() const { return true; } 72 }; 73 74 /* 75 * compilers assume that object that appear in Src, Dst, OSrc, ODst 76 * are inherited from class Address and use this in many 77 * places. MultiAddress is derived from ObjectGroup to simplify 78 * processing in compile-time mode, which creates lots of problems 79 * with it when it is configured in run-time mode. To simplify things, 80 * we'll use class MultiAddressRunTime which is derived from 81 * Address. We'll replace MultiAddress objects with run-time mode with 82 * objects of this class in a special rule processor 83 * 84 * Objects of this class are never stored in the data file and do not 85 * appear in DTD; they are only used in compilers. 86 */ 87 class MultiAddressRunTime : public Address 88 { 89 std::string subst_type_name; 90 std::string source_name; 91 bool run_time; 92 93 public: 94 95 DECLARE_FWOBJECT_SUBTYPE(MultiAddressRunTime); 96 97 DECLARE_DISPATCH_METHODS(MultiAddressRunTime); 98 99 MultiAddressRunTime(); 100 MultiAddressRunTime(MultiAddress *maddr); 101 getSourceName()102 std::string getSourceName() const { return source_name; } getSubstitutionTypeName()103 std::string getSubstitutionTypeName() const { return subst_type_name; } 104 105 std::string getSourceNameAsPath(FWOptions *options) const; 106 isCompileTime()107 bool isCompileTime() const { return !run_time; } isRunTime()108 bool isRunTime() const { return run_time; } 109 isPrimaryObject()110 virtual bool isPrimaryObject() const { return true; } 111 }; 112 113 } 114 115 116 #endif 117 118