Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SrvCfgIface.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: Krzysztof Wnuk
7  * Nguyen Vinh Nghiem
8  *
9  * released under GNU GPL v2 only licence
10  *
11  */
12 
13 class TSrvCfgIface;
14 #ifndef SRVCONFIFACE_H
15 #define SRVCONFIFACE_H
16 #include "DHCPConst.h"
17 #include "SrvCfgAddrClass.h"
18 #include "SrvCfgTA.h"
19 #include "SrvCfgPD.h"
20 #include "SrvParsGlobalOpt.h"
21 #include <iostream>
22 #include <string>
23 #include <vector>
24 #include "OptVendorSpecInfo.h"
25 #include "SrvCfgOptions.h"
26 
28 {
29  friend std::ostream& operator<<(std::ostream& out, TSrvCfgIface& iface);
30 public:
31  TSrvCfgIface(const std::string& ifaceName);
32  TSrvCfgIface(int ifindex);
33  virtual ~TSrvCfgIface();
34  void setDefaults();
35  void setName(const std::string& ifaceName);
36  void setID(int ifindex);
37  int getID() const;
38  std::string getName() const;
39  std::string getFullName() const;
40 
41  // permanent address management (IA_NA)
42  void addAddrClass(SPtr<TSrvCfgAddrClass> addrClass);
43  void firstAddrClass();
46 
48  SPtr<TSrvCfgAddrClass> getClassByID(unsigned long id);
50  long countAddrClass() const;
51 
52  // temporary address management (IA_TA)
53  void addTA(SPtr<TSrvCfgTA> ta);
54  void firstTA();
57 
58  // prefix management (IA_PD)
59  void addPDClass(SPtr<TSrvCfgPD> PDClass);
60  SPtr<TSrvCfgPD> getPDByID(unsigned long id);
61  //SPtr<TSrvCfgPD> getRandomPrefix(SPtr<TDUID> clntDuid, SPtr<TIPv6Addr> clntAddr);
62  long countPD() const;
63  void addPD(SPtr<TSrvCfgPD> pd);
64  void firstPD();
66  bool addClntPrefix(SPtr<TIPv6Addr> ptrPD, bool quiet = false);
67  bool delClntPrefix(SPtr<TIPv6Addr> ptrPD, bool quiet = false);
68  bool supportPrefixDelegation() const;
69 
70  // CONFIRM support
72  bool addrInPool(SPtr<TIPv6Addr> addr);
73  bool addrInTaPool(SPtr<TIPv6Addr> addr);
75 
76  // subnet management
78  bool addrInSubnet(SPtr<TIPv6Addr> addr);
79  bool subnetDefined();
80 
81  // other
83  void setNoConfig();
85 
86  unsigned char getPreference() const;
87 
88  bool getRapidCommit() const;
89 
90  long getIfaceMaxLease() const;
91  unsigned long getClntMaxLease() const;
92 
93  // IA address functions
94  void addClntAddr(SPtr<TIPv6Addr> ptrAddr, bool quiet = false);
95  void delClntAddr(SPtr<TIPv6Addr> ptrAddr, bool quiet = false);
96 
97  // TA address functions
98  void addTAAddr();
99  void delTAAddr();
100 
101  // relays
102  std::string getRelayName() const;
103  int getRelayID() const;
105  bool isRelay() const;
106  void setRelayName(const std::string& name);
107  void setRelayID(int id);
108 
109  // per-client parameters (exceptions)
110  unsigned int removeReservedFromCache();
112  SPtr<TSrvCfgOptions> getClientException(SPtr<TDUID> duid, TMsg* message, bool quiet=true);
114  SPtr<TDUID> duid,
115  SPtr<TOptVendorData> remoteID,
116  SPtr<TIPv6Addr> linkLocal);
117  bool addrReserved(SPtr<TIPv6Addr> addr);
118  bool prefixReserved(SPtr<TIPv6Addr> prefix);
119 
120  // option: FQDN
121  TContainer< SPtr<TFQDN> > * getFQDNLst();
122  SPtr<TFQDN> getFQDNName(SPtr<TDUID> duid, SPtr<TIPv6Addr> addr, const std::string& hint);
123  SPtr<TDUID> getFQDNDuid(const std::string& name);
124  void setFQDNLst(TContainer< SPtr<TFQDN> > * fqdn);
125  int getFQDNMode() const;
126  std::string getFQDNModeString() const;
127  int getRevDNSZoneRootLength() const;
128  void setRevDNSZoneRootLength(int revDNSZoneRootLength);
129  bool supportFQDN() const;
130  bool leaseQuerySupport() const;
131 
132  void mapAllowDenyList( TContainer< SPtr<TSrvCfgClientClass> > clientClassLst);
133 
134  // following methods are used by out-of-pool reservations (others are using
135  // methods from pool (SrvCfgAddrClass)
136  uint32_t getT1(uint32_t proposal);
137  uint32_t getT2(uint32_t proposal);
138  uint32_t getPref(uint32_t proposal);
139  uint32_t getValid(uint32_t proposal);
140 private:
141  uint32_t chooseTime(uint32_t min, uint32_t max, uint32_t proposal);
142 
143  unsigned char Preference_;
144  int ID_;
145  std::string Name_;
146  bool NoConfig_;
148  unsigned long IfaceMaxLease_;
149  unsigned long ClntMaxLease_;
151  TContainer< SPtr<TSrvCfgAddrClass> > SrvCfgAddrClassLst_; // IA_NA list (normal addresses)
153 
154  // --- Temporary Addresses ---
155  TContainer< SPtr<TSrvCfgTA> > SrvCfgTALst_; // IA_TA list (temporary addresses)
156 
157  // --- Prefix Delegation ---
158  TContainer< SPtr<TSrvCfgPD> > SrvCfgPDLst_;
159 
160  // --- subnets ---
161  std::vector<THostRange> Subnets_;
162 
163  // --- relay ---
164  bool Relay_;
165  std::string RelayName_; // name of the underlaying physical interface (or other relay)
166  int RelayID_; // ifindex (-1 means this is not a relay)
167  SPtr<TSrvOptInterfaceID> RelayInterfaceID_; // value of interface-id option (optional)
168 
169  // --- option: FQDN ---
170  TContainer< SPtr<TFQDN> > FQDNLst_;
174  std::string FQDNDomain_;
175 
176  // --- per-client parameters (exceptions) ---
177  TContainer< SPtr<TSrvCfgOptions> > ExceptionsLst_;
186 };
187 
188 #endif /* SRVCONFIFACE_H */
189