summaryrefslogtreecommitdiffstats
path: root/kmyfirewall/core/iptable.h
blob: ad92fe3fc3fd0dceb68ac1d17e152e220f19c82c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/***************************************************************************
begin                : Tue Aug 20 2002
copyright            : (C) 2002 by Christian Hubinger
email                : chubinger@irrsinnig.org
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef IPTABLE_H
#define IPTABLE_H

/**Class that represents the properties of a "table" in the iptables
 
  *@author Christian Hubinger
  */

#include "netfilterobject.h"

// TQt includes
#include <tqptrlist.h>
#include <tquuid.h>
// project includes
#include "iptchain.h"
// tqt classes
class TQString;
namespace KMF {
// project classes
class KMFError;
class KMFIPTDoc;


class KDE_EXPORT IPTable : public NetfilterObject {
public:
	/** initialise a IPTable with the given name */
	IPTable( KMFIPTDoc*, const char* name, const TQString& tableName );
	~IPTable();

	virtual int type();
	virtual void clear();
	
	/** Set the used flag */
	void setUsed( bool used ) {
		m_used = used;
	};

	/** Simply deletes all chains */
	void reset();

	/** Return the IPTChain with the name provided */
	IPTChain* chainForName( const TQString& );
	
	/** Return the IPTChain for the given ID */
	IPTChain* chainForUuid( const TQUuid& );

	/**  Add a new IPTChain object to this table with the given prperties */
	IPTChain* addChain( const TQString& chain_name,
	                    const TQString& chain_target,
	                    bool builtin,
	                    KMFError* );

	/** Remove the given IPTChain */
	KMFError* delChain( IPTChain *chain );


	/** Move rule to target_chain */
	KMFError* moveRuleToChain( IPTRule* rule, IPTChain *target_chain );

	/** Copy rule to target_chain */
	KMFError* copyRuleToChain( IPTRule* rule, IPTChain *target_chain );

	/** Return a pointer to KMFIPTDoc object to which this
		table belongs */
	KMFIPTDoc* kmfDoc() const {
		return kmfdoc;
	};


	/** Returns true if it used by the current configuration */
	bool used() const {
		return m_used;
	};

	/** Returns the list with the iptchains in this table */
	TQPtrList<IPTChain>& chains() const;

	/** Return a TQDomDocument representation of this Table */
	virtual const TQDomDocument& getDOMTree();
	
	/** Load the Table from the TQDomDocument */
	virtual void loadXML( const TQDomDocument&, TQStringList& errors );
	
	/** Load Table From DomNode */
	virtual void loadXML( TQDomNode, TQStringList& errors );
	
	/** Stup the built-in chains */
	void settupDefaultChains();

private:
	/** the list holding the chains in this table */
	private: TQPtrList<IPTChain> m_chains;

	/** used by the current configuration */
	private: bool m_used;


	private: KMFError* m_err;
	private: KMFIPTDoc* kmfdoc;
};
}
#endif