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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
//
// C++ Interface: kmfnetzone
//
// Description:
//
//
// Author: Christian Hubinger <[email protected]>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
/***************************************************************************
* *
* 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 KMFNETZONE_H
#define KMFNETZONE_H
#include "netfilterobject.h"
// QT includes
#include <qptrlist.h>
#include <qguardedptr.h>
#include <qstring.h>
#include <quuid.h>
#include <qobject.h>
// KDE includes
#include <kdemacros.h>
// Project includes
#include "ipaddress.h"
namespace KMF {
class KMFGenericDoc;
class KMFProtocol;
class KMFProtocolUsage;
class KMFError;
class KMFCheckInput;
class IPAddress;
class KMFNetHost;
class KMFTarget;
class KMFNetwork;
//############ KMFNetZone #############
class KDE_EXPORT KMFNetZone : public NetfilterObject {
Q_OBJECT
public:
KMFNetZone( NetfilterObject *parent, const char* objectname, const QString& name );
virtual ~KMFNetZone();
virtual int type();
virtual void clear();
IPAddress* address() const {
return m_address;
};
int operator==( const KMFNetZone& );
bool isSameZone( KMFNetZone* );
IPAddress* mask() const {
IPAddress *addr = new IPAddress();
addr->setAddress( IPAddress::calcNetworkMaskFromLength( m_maskLen ).toString() );
return addr;
};
int maskLength() const {
return m_maskLen;
}
KMFGenericDoc* doc() const;
KMFNetwork* network() const;
KMFNetZone* zone() const;
KMFNetZone* rootZone();
int getZoneType() const {
return m_zoneType;
};
const QString& guiName() const {
return m_guiName;
};
virtual const QString& name();
const QString& generateName( const QString& );
void setGuiName( const QString& );
void setNetwork( KMFNetwork* );
void setZone( const IPAddress& , int );
void setParentZone( KMFNetZone* );
bool isRootZone();
void setMaskLength( int );
const QDomDocument& getDOMTree();
virtual void loadXML(const QDomDocument&, QStringList& errors );
virtual void loadXML( QDomNode, QStringList& errors );
KMFNetZone* addZone( const QString& , KMFError* );
void delZone( KMFNetZone*, bool desructive = true );
KMFProtocolUsage* addProtocolUsage( const QUuid& uuid, const QDomDocument& xml );
void delProtocolUsage( KMFProtocolUsage*, bool desructive = true );
KMFNetHost* addNetHost( const QString& name, const QDomDocument& xml );
KMFTarget* addTarget( const QString& name, const QDomDocument& xml );
KMFTarget* findTargetByName( const QString& name, bool fromRoot = true );
KMFNetHost* findNetHostByName( const QString& name, bool fromRoot = true );
KMFNetZone* findNetZoneByName( const QString& name, bool fromRoot = true );
void delHost( KMFTarget*, bool desructive = true );
QPtrList<KMFProtocolUsage>& protocols() const;
QPtrList<KMFNetZone>& zones() const;
QPtrList<KMFTarget>& hosts() const;
KMFProtocolUsage* findProtocolUsageByProtocolUuid( const QUuid& uuid ) const;
bool protocolInherited( const QUuid& uuid ) const;
KMFTarget* placeHostInZone( KMFTarget* host );
KMFNetZone* placeZoneInZone( KMFNetZone* zone );
void refreshNetworkTree();
bool readOnly() const {
return m_readOnly;
};
void setReadOnly( bool );
QString toString();
enum { ROOT, NODE } Type;
void getAllTargets( KMFNetZone* zone, QPtrList<KMFTarget>* list );
protected slots:
void slotOnProtocolUsageDeleted( QObject* protocol );
private: // Methods
KMFTarget* findTargetByName_internal( const QString& name );
KMFNetZone* findNetZoneByName_internal( const QString& name );
QString zoneInfo();
void getAllZones( KMFNetZone* zone, QPtrList<KMFNetZone>* list );
void getAllHosts( KMFNetZone* zone, QPtrList<KMFTarget>* list );
private: // Data
QGuardedPtr<KMFGenericDoc> m_doc;
QGuardedPtr<KMFNetZone> m_zone;
QGuardedPtr<KMFNetwork> m_network;
IPAddress* m_address;
QPtrList<KMFProtocolUsage> m_protocols;
QPtrList<KMFNetZone> m_zones;
QPtrList<KMFTarget> m_hosts;
KMFError *m_err;
int m_zoneType;
int m_maskLen;
// bool m_deadEnd;
QString m_guiName;
bool m_readOnly;
};
}
#endif
|