Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SrvCfgMgr.h
Go to the documentation of this file.
1 /*
2  * Dibbler - a portable DHCPv6
3  *
4  * authors: Tomasz Mrugalski <thomson@klub.com.pl>
5  * Marek Senderski <msend@o2.pl>
6  * changes: Michal Kowalczuk <michal@kowalczuk.eu>
7  * Nguyen Vinh Nghiem
8  *
9  * released under GNU GPL v2 only licence
10  *
11  */
12 
13 class TSrvCfgMgr;
14 
15 #ifndef SRVCONFMGR_H
16 #define SRVCONFMGR_H
17 #include "SmartPtr.h"
18 #include "SrvCfgIface.h"
19 #include "SrvIfaceMgr.h"
20 #include "CfgMgr.h"
21 #include "DHCPConst.h"
22 #include "Container.h"
23 #include "DUID.h"
24 #include "KeyList.h"
25 #include "SrvCfgClientClass.h"
26 
27 #define SrvCfgMgr() (TSrvCfgMgr::instance())
28 
29 class SrvParser;
30 
31 class TSrvCfgMgr : public TCfgMgr
32 {
33 public:
34  friend std::ostream & operator<<(std::ostream &strum, TSrvCfgMgr &x);
35 
36  static void instanceCreate(const std::string& cfgFile, const std::string& xmlDumpFile);
37  static TSrvCfgMgr &instance();
38 
39  bool parseConfigFile(const std::string& cfgFile);
40 
41  //Interfaces acccess methods
42  void firstIface();
45  SPtr<TSrvCfgIface> getIfaceByName(const std::string& name);
46  long countIface();
47  void addIface(SPtr<TSrvCfgIface> iface);
48  void makeInactiveIface(int ifindex, bool inactive);
49  int inactiveIfacesCnt();
51 
52  void dump();
53 
54  bool setupRelay(SPtr<TSrvCfgIface> cfgIface);
55 
56  //Address assignment connected methods
57  void setCounters();
58 
60 
61  long countAvailAddrs(SPtr<TDUID> clntDuid, SPtr<TIPv6Addr> clntAddr, int iface);
64  SPtr<TIPv6Addr> getRandomAddr(SPtr<TDUID> duid, SPtr<TIPv6Addr> clntAddr, int iface);
65  // bool isClntSupported(SPtr<TDUID> duid, SPtr<TIPv6Addr> clntAddr, int iface);
66  bool isClntSupported(/*SPtr<TDUID> duid, SPtr<TIPv6Addr> clntAddr, int iface,*/ SPtr<TSrvMsg> msg);
67 
68  // prefix-related
69  bool incrPrefixCount(int iface, SPtr<TIPv6Addr> prefix);
70  bool decrPrefixCount(int iface, SPtr<TIPv6Addr> prefix);
71 
72  // class' usage management
73  void delClntAddr(int iface, SPtr<TIPv6Addr> addr);
74  void addClntAddr(int iface, SPtr<TIPv6Addr> addr);
75 
76  void addTAAddr(int iface);
77  void delTAAddr(int iface);
78 
79  bool addrReserved(SPtr<TIPv6Addr> addr);
80  bool prefixReserved(SPtr<TIPv6Addr> prefix);
81 
82  bool isDone();
83  virtual ~TSrvCfgMgr();
85 
86  // configuration parameters
87  std::string getWorkdir();
88  bool stateless();
89  bool inactiveMode();
90  bool guessMode();
92  int getCacheSize();
93 
97  bool getReconfigureSupport();
98 
102  void setReconfigureSupport(bool reconf);
103 
104  void setDDNSAddress(SPtr<TIPv6Addr> ddnsAddress);
105  SPtr<TIPv6Addr> getDDNSAddress(int iface);
106 
107  // Bulk-LeaseQuery
108  void bulkLQAccept(bool enabled);
109  void bulkLQTcpPort(unsigned short portNumber);
110  void bulkLQMaxConns(unsigned int maxConnections);
111  void bulkLQTimeout(unsigned int timeout);
112 
113  //Authentication
114 #ifndef MOD_DISABLE_AUTH
116  void setAuthDigests(const DigestTypesLst& digests);
117  DigestTypesLst getAuthDigests();
118  enum DigestTypes getDigest();
119  uint32_t getDelayedAuthKeyID(const char* mapping_file, SPtr<TDUID> clientid);
120 #endif
121 
122  void setDefaults();
123  std::string getScriptName() { return ScriptName; }
124  void setScriptName(std::string scriptFile) { ScriptName = scriptFile; }
125 
126  // Client List check
127  void InClientClass(SPtr<TSrvMsg> msg);
128 
129  // Used to find specific relay
132  int getAnyRelay();
133 
134 
135  // Sets performance mode (not write whole XML)
136  void setPerformanceMode(bool mode);
137  bool getPerformanceMode();
138 
139  void dropUnicast(bool drop);
140  bool dropUnicast();
141 
142  // used to be private, but we need access in tests
143 protected:
144  TSrvCfgMgr(const std::string& cfgFile, const std::string& xmlFile);
146  static int NextRelayID;
147  std::string XmlFile;
148 
151 
152  bool IsDone;
153  bool validateConfig();
154  bool validateIface(SPtr<TSrvCfgIface> ptrIface);
156  TContainer< SPtr<TSrvCfgIface> > SrvCfgIfaceLst;
157  TContainer< SPtr<TSrvCfgIface> > InactiveLst;
158  TContainer< SPtr<TSrvCfgClientClass> > ClientClassLst;
160 
161  // global options
162  bool Stateless;
164  bool GuessMode;
167  std::string ScriptName;
168 
169 #ifndef MOD_DISABLE_AUTH
170  unsigned int AuthLifetime;
171  unsigned int AuthKeyGenNonceLen;
172  DigestTypesLst DigestTypesLst_;
173 #endif
174 
175  // DDNS address
177 
178  // lease-query parameters
180  unsigned short BulkLQTcpPort;
181  unsigned int BulkLQMaxConns;
182  unsigned int BulkLQTimeout;
183 
186 };
187 
188 #endif /* SRVCONFMGR_H */
189