00001 #ifndef CONFIGURATION_H_
00002 #define CONFIGURATION_H_
00003
00004 #include "ibrcommon/data/ConfigFile.h"
00005 #include "core/Node.h"
00006 #include "routing/StaticRoutingExtension.h"
00007 #include "ibrcommon/Exceptions.h"
00008 #include "ibrcommon/net/NetInterface.h"
00009
00010 using namespace dtn::net;
00011 using namespace dtn::core;
00012 using namespace dtn::data;
00013
00014 namespace dtn
00015 {
00016 namespace daemon
00017 {
00021 class Configuration
00022 {
00023 private:
00024 Configuration();
00025 virtual ~Configuration();
00026
00027 public:
00028 class NetConfig
00029 {
00030 public:
00031 enum NetType
00032 {
00033 NETWORK_UNKNOWN = 0,
00034 NETWORK_TCP = 1,
00035 NETWORK_UDP = 2,
00036 NETWORK_HTTP = 3,
00037 NETWORK_LOWPAN = 4
00038 };
00039
00040 NetConfig(std::string name, NetType type, const std::string &address, int port, bool discovery = true);
00041 NetConfig(std::string name, NetType type, const ibrcommon::NetInterface &iface, int port, bool discovery = true);
00042 ~NetConfig();
00043
00044 std::string name;
00045 NetType type;
00046 ibrcommon::NetInterface interface;
00047 std::string address;
00048 int port;
00049 bool discovery;
00050 };
00051
00052 class ParameterNotSetException : ibrcommon::Exception
00053 {
00054 };
00055
00056 class ParameterNotFoundException : ibrcommon::Exception
00057 {
00058 };
00059
00060 static Configuration &getInstance();
00061
00065 void load();
00066 void load(string filename);
00067
00068 void params(int argc, char *argv[]);
00069
00073 string getNodename();
00074
00078 std::list<NetConfig> getInterfaces();
00079
00080 std::string getDiscoveryAddress();
00081 int getDiscoveryPort();
00082
00083 Configuration::NetConfig getAPIInterface();
00084
00088 list<Node> getStaticNodes();
00089
00093 list<dtn::routing::StaticRoutingExtension::StaticRoute> getStaticRoutes();
00094
00095 int getTimezone();
00096
00097 ibrcommon::File getPath(string name);
00098
00099 unsigned int getUID();
00100 unsigned int getGID();
00101
00102 bool doDiscovery();
00103 bool doAPI();
00104
00105 std::string version();
00106
00107 string getNotifyCommand();
00108
00109 enum RoutingExtension
00110 {
00111 DEFAULT_ROUTING = 0,
00112 EPIDEMIC_ROUTING = 1
00113 };
00114
00118 RoutingExtension getRoutingExtension();
00119
00124 bool doForwarding();
00125
00129 bool useStatLogger();
00130
00134 ibrcommon::File getStatLogfile();
00135
00139 std::string getStatLogType();
00140
00144 unsigned int getStatLogInterval();
00145
00149 std::string getStatAddress();
00150
00154 unsigned int getStatPort();
00155
00159 int getDebugLevel() const;
00160
00164 bool doDebug() const;
00165
00170 bool beQuiet() const;
00171
00177 size_t getLimit(std::string);
00178
00179 private:
00180 ibrcommon::ConfigFile _conf;
00181
00182 string _filename;
00183 ibrcommon::NetInterface _default_net;
00184 bool _use_default_net;
00185 bool _doapi;
00186 bool _dodiscovery;
00187 int _debuglevel;
00188 bool _debug;
00189 bool _quiet;
00190 };
00191 }
00192 }
00193
00194 #endif