Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SrvCfgPD.h
Go to the documentation of this file.
1 /*
2  * Dibbler - a portable DHCPv6
3  *
4  * authors: Krzysztof Wnuk <keczi@poczta.onet.pl>
5  * changes: Tomasz Mrugalski
6  * Nguyen Vinh Nghiem
7  *
8  * released under GNU GPL v2 only licence
9  *
10  * $Id: SrvCfgPD.h,v 1.6 2008-10-12 20:07:31 thomson Exp $
11  *
12  */
13 
14 
15 /*
16  Generally prefixes can be divided into 3 parts:
17  - constant prefix (a)
18  - variable section (b)
19  - zeroed tail (c)
20 
21  (a) (b) (c)
22  aaaa:aaaa:aaaa:bbbb:bbbb:bbbb:0000:0000
23 
24  When there are several prefix pools defined,
25  (a) becomes pool-specific prefix
26  (b) becomes common part
27  (c) stays zeroed tail
28 */
29 
30 class TSrvCfgPD;
31 #ifndef SRVCONFPD_H
32 #define SRVCONFPD_H
33 
34 #include <string>
35 #include <iostream>
36 #include <iomanip>
37 
38 #include "SrvAddrMgr.h"
39 #include "SrvParsGlobalOpt.h"
40 #include "DHCPConst.h"
41 #include "SmartPtr.h"
42 #include "IPv6Addr.h"
43 #include "DUID.h"
44 #include "SmartPtr.h"
45 #include "SrvCfgPD.h"
46 #include "Node.h"
47 
48 class TSrvCfgClientClass;
49 
50 class TSrvCfgPD
51 {
52  friend std::ostream& operator<<(std::ostream& out, TSrvCfgPD& iface);
53  public:
54  TSrvCfgPD();
55 
56  //Is client with this DUID and IP address supported?
57  bool clntSupported(SPtr<TDUID> duid,SPtr<TIPv6Addr> clntAddr);
58  bool clntSupported(SPtr<TDUID> duid,SPtr<TIPv6Addr> clntAddr, SPtr<TSrvMsg> msg);
59  //Is client with this DUID and IP address prefered? (is in accept-only?)
60  bool clntPrefered(SPtr<TDUID> duid,SPtr<TIPv6Addr> clntAddr);
61 
62  //checks if the prefix belongs to the pool
63  bool prefixInPool(SPtr<TIPv6Addr> prefix);
64  unsigned long countPrefixesInPool();
66  TContainer< SPtr<TIPv6Addr> > getRandomTContainer< SPtr<> >;
67 
68  unsigned long getT1(unsigned long hintT1);
69  unsigned long getT2(unsigned long hintT2);
70  unsigned long getPrefered(unsigned long hintPrefered);
71  unsigned long getValid(unsigned long hintValid);
72 
73  unsigned long getPD_Length(); // length of prefix
74  unsigned long getPD_MaxLease();
75  unsigned long getID();
76 
77  bool isLinkLocal();
78 
79  unsigned long getAssignedCount();
80  unsigned long getTotalCount();
81  long incrAssigned(int count=1);
82  long decrAssigned(int count=1);
83 
84  bool setOptions(SPtr<TSrvParsGlobalOpt> opt, int PDPrefix);
85  virtual ~TSrvCfgPD();
86  void mapAllowDenyList( TContainer< SPtr<TSrvCfgClientClass> > clientClassLst);
87 
88  private:
89  unsigned long PD_T1Beg_;
90  unsigned long PD_T1End_;
91  unsigned long PD_T2Beg_;
92  unsigned long PD_T2End_;
93  unsigned long PD_Length_; // (shorter) prefix, assigned to the user, e.g. 64
94  unsigned long PD_PrefBeg_;
95  unsigned long PD_PrefEnd_;
96  unsigned long PD_ValidBeg_;
97  unsigned long PD_ValidEnd_;
98 
99  unsigned long chooseTime(unsigned long beg, unsigned long end, unsigned long clntTime);
100 
101  unsigned long ID_;
102  static unsigned long StaticID_;
103 
104  TContainer< SPtr<THostRange> > PoolLst_;
105  SPtr<THostRange> CommonPool_; /* common part of all available prefix pools (section b in the description above) */
106  unsigned long PD_MaxLease_;
107  unsigned long PD_Assigned_;
108  unsigned long PD_Count_;
109 
110  List(std::string) AllowLst_;
111  List(std::string) DenyLst_;
112 
115 };
116 
117 #endif
118