1 |
/* |
2 |
* i-scream central monitoring system |
3 |
* http://www.i-scream.org.uk |
4 |
* 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 |
#include <iostream> |
22 |
#include <string> |
23 |
#include <unistd.h> // linux header for the sleep function |
24 |
#ifndef SMALLNET_H /* Has the file been INCLUDE'd already? */ |
25 |
#define SMALLNET_H yes |
26 |
#include "SmallNet.h" |
27 |
#endif |
28 |
|
29 |
using std::string; |
30 |
|
31 |
class Config { |
32 |
|
33 |
public: |
34 |
// public methods |
35 |
Config( string serverName, int serverPort, int printDebug); |
36 |
int getUDPFilterPort(){ return UDPFilterPort; }; // inline function |
37 |
string getUDPFilterName(){ return UDPFilterName; }; // inline |
38 |
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 |
string getFQDN(){ return fQDN; }; // inline. Returns this host name. |
44 |
int chatHeartBeat(); |
45 |
|
46 |
// public variables |
47 |
|
48 |
private: |
49 |
// private methods |
50 |
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 |
|
58 |
|
59 |
// private (global) variables |
60 |
int MAX_CONNECTION_ATTEMPTS; // how many times should it try? |
61 |
int configConnectionRetryTime; // how long to wait before retrying a connection to the |
62 |
// config manager if a connection cannot be established |
63 |
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 |
string UDPFilterName; // the name of our assigned filter |
67 |
int TCPFilterPort; // the tcp port for heartbeats |
68 |
bool configChanged; // has the config changed since we last loaded it? |
69 |
string lastModified; // saves the last modifed long integer |
70 |
string fileList; // saves the last modifed file list |
71 |
string fQDN; |
72 |
int numProperties; // the number of properties which this host wants |
73 |
string propertyNames[20]; // an array of strings which corrisponds to... |
74 |
string propertyValues[20]; // these values |
75 |
SmallNet * net; // interface onto SmallNet |
76 |
int debug; // print debug info? |
77 |
|
78 |
|
79 |
|
80 |
}; // class Config |