Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ClntTransMgr.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  *
7  * released under GNU GPL v2 only licence
8  *
9  */
10 
11 #ifndef CLNTTRANSMGR_H
12 #define CLNTTRANSMGR_H
13 #include <string>
14 #include "ClntCfgIface.h"
15 #include "Opt.h"
16 #include "OptAddrLst.h"
17 #include "IPv6Addr.h"
18 #include "AddrIA.h"
19 #include "ClntMsg.h"
20 
21 #define ClntTransMgr() (TClntTransMgr::instance())
22 
24 {
25  private:
26  TClntTransMgr(const std::string& config);
27 
28  public:
29  static void instanceCreate(const std::string& config);
30  static TClntTransMgr &instance();
32  void doDuties();
33  void relayMsg(SPtr<TClntMsg> msg);
34  unsigned long getTimeout();
35  void stop();
36  void sendRequest(TOptList requestOptions, int iface);
37  void sendInfRequest(TOptList requestOptions, int iface);
38  void sendRebind(TOptList ptrIA, int iface);
40  bool handleResponse(SPtr<TClntMsg> question, SPtr<TClntMsg> answer);
41  void handleReconfigure(SPtr<TClntMsg> reconfMsg);
42  void sendRenew();
43 
44  void shutdown();
45  bool isDone();
46 
47  char * getCtrlAddr();
48  int getCtrlIface();
49 
50  // Backup server list management
51  void addAdvertise(SPtr<TClntMsg> advertise); // adds ADVERTISE to the list
52  void firstAdvertise();
54  SPtr<TOpt> getAdvertiseDUID(); // returns server DUID of the best advertise on the list
55  void sortAdvertise(); // sorts advertise messages
56  void delFirstAdvertise(); // deletes first advertise
57  int getMaxPreference();
59  void printAdvertiseLst();
60 
61  bool sanitizeAddrDB();
62 
63 #ifdef MOD_REMOTE_AUTOCONF
64  struct TNeighborInfo {
65  typedef enum {
66  NeighborInfoState_Added, // just added (waiting to be sent)
67  NeighborInfoState_Sent, // sent, awaiting remote reply
68  NeighborInfoState_Received // remote reply received
69  } NeighborInfoState;
70  SPtr<TIPv6Addr> srvAddr;
71  int ifindex;
72  int transid;
73  SPtr<TDUID> srvDuid;
74  SPtr<TClntMsg> reply;
75  SPtr<TIPv6Addr> rcvdAddr;
76  NeighborInfoState state;
77  TNeighborInfo(SPtr<TIPv6Addr> addr)
78  : srvAddr(addr), ifindex(0), transid(0),
79  srvDuid(0), reply(0), rcvdAddr(0), state(NeighborInfoState_Added) { }
80  };
81  typedef std::list< SPtr<TNeighborInfo> > TNeighborInfoLst;
82  TNeighborInfoLst Neighbors;
83 
84  SPtr<TNeighborInfo> neighborInfoGet(SPtr<TIPv6Addr> addr);
85  SPtr<TNeighborInfo> neighborInfoGet(int transid);
86 
87  SPtr<TNeighborInfo> neighborAdd(int ifindex, SPtr<TIPv6Addr> addr);
88 
89  bool checkRemoteSolicits();
90  bool updateNeighbors(int ifindex, SPtr<TOptAddrLst> neighbors);
91  bool sendRemoteSolicit(SPtr<TNeighborInfo> neighbor);
92  bool processRemoteReply(SPtr<TClntMsg> reply);
93 #endif
94 
95  protected:
96  void removeExpired();
97  void checkDecline();
98  void checkConfirm();
99  void checkDB();
100  void checkRenew();
101  void checkRequest();
102  void checkSolicit();
103  void checkInfRequest();
104 
105  private:
106  bool openLoopbackSocket();
107  bool openSockets(SPtr<TClntCfgIface> iface);
109 
110  void sortAdvertiseLst();
112 
113  TContainer< SPtr<TClntMsg> > Transactions;
114  bool IsDone; // isDone = true - client operation is finished
115  bool Shutdown; // is shutdown in progress?
116 
117  bool BindReuse; // Bug #56. Shall we allow running client and server on the same machine?
118 
120  char CtrlAddr_[48];
121 
122  TContainer< SPtr<TClntMsg> > AdvertiseLst; // list of backup servers (i.e. not used ADVERTISE messages)
123 
125 };
126 
127 #endif
128 
129