1 |
tdb |
1.7 |
/* |
2 |
|
|
* i-scream central monitoring system |
3 |
tdb |
1.8 |
* http://www.i-scream.org.uk |
4 |
tdb |
1.7 |
* Copyright (C) 2000-2002 i-scream |
5 |
|
|
* |
6 |
|
|
* This program is free software; you can redistribute it and/or |
7 |
|
|
* modify it under the terms of the GNU General Public License |
8 |
|
|
* as published by the Free Software Foundation; either version 2 |
9 |
|
|
* of the License, or (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 |
|
|
*/ |
20 |
|
|
|
21 |
ab11 |
1.1 |
#include <iostream> |
22 |
|
|
#include <string> |
23 |
|
|
#include <unistd.h> // linux header for the sleep function |
24 |
ab11 |
1.3 |
#ifndef SMALLNET_H /* Has the file been INCLUDE'd already? */ |
25 |
|
|
#define SMALLNET_H yes |
26 |
|
|
#include "SmallNet.h" |
27 |
|
|
#endif |
28 |
ab11 |
1.1 |
|
29 |
|
|
using std::string; |
30 |
|
|
|
31 |
|
|
class Config { |
32 |
|
|
|
33 |
|
|
public: |
34 |
|
|
// public methods |
35 |
ab11 |
1.3 |
Config( string serverName, int serverPort, int printDebug); |
36 |
ab11 |
1.1 |
int getUDPFilterPort(){ return UDPFilterPort; }; // inline function |
37 |
|
|
string getUDPFilterName(){ return UDPFilterName; }; // inline |
38 |
ab11 |
1.3 |
int getIntProperty( string propertyName ); |
39 |
|
|
string getStrProperty( string propertyName ); |
40 |
|
|
SmallNet * getSmallNet(){ return net; }; // returns a pointer to the smallnet class |
41 |
|
|
string getFilterName(){ return UDPFilterName; }; |
42 |
|
|
int getFilterPort(){ return TCPFilterPort; }; |
43 |
ab11 |
1.6 |
string getFQDN(){ return fQDN; }; // inline. Returns this host name. |
44 |
ab11 |
1.5 |
int chatHeartBeat(); |
45 |
ab11 |
1.1 |
|
46 |
|
|
// public variables |
47 |
|
|
|
48 |
|
|
private: |
49 |
|
|
// private methods |
50 |
ab11 |
1.6 |
int loadConfig(); // do the chat dialog |
51 |
|
|
int establishHeartbeat(); // tell smallnet to make a connection |
52 |
|
|
int chatHeartbeat(); // send the relevant commands to the heartbeat |
53 |
|
|
int destroyHeartbeat(); // tell smallnet to close a connection |
54 |
|
|
int establishConfig(); // tell smallnet to make a connection to the config manager |
55 |
|
|
int chatConfig(); // send the relevant commands to get the config |
56 |
|
|
int destroyConfig(); // tell smallnet to close the connection to the config manager |
57 |
ab11 |
1.1 |
|
58 |
|
|
|
59 |
|
|
// private (global) variables |
60 |
ab11 |
1.3 |
int MAX_CONNECTION_ATTEMPTS; // how many times should it try? |
61 |
ab11 |
1.1 |
int configConnectionRetryTime; // how long to wait before retrying a connection to the |
62 |
ab11 |
1.6 |
// config manager if a connection cannot be established |
63 |
ab11 |
1.1 |
string configName; // the name of the server which will return our config |
64 |
|
|
int configPort; // the port on the server which will return our config |
65 |
|
|
int UDPFilterPort; // the port number of our assigned filter |
66 |
ab11 |
1.6 |
string UDPFilterName; // the name of our assigned filter |
67 |
ab11 |
1.1 |
int TCPFilterPort; // the tcp port for heartbeats |
68 |
|
|
bool configChanged; // has the config changed since we last loaded it? |
69 |
ab11 |
1.6 |
string lastModified; // saves the last modifed long integer |
70 |
ab11 |
1.1 |
string fileList; // saves the last modifed file list |
71 |
ab11 |
1.4 |
string fQDN; |
72 |
ab11 |
1.1 |
int numProperties; // the number of properties which this host wants |
73 |
ab11 |
1.6 |
string propertyNames[20]; // an array of strings which corrisponds to... |
74 |
|
|
string propertyValues[20]; // these values |
75 |
ab11 |
1.3 |
SmallNet * net; // interface onto SmallNet |
76 |
ab11 |
1.6 |
int debug; // print debug info? |
77 |
ab11 |
1.1 |
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
}; // class Config |