Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SrvMsg.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 <keczi@poczta.onet.pl>
7  * Michal Kowalczuk <michal@kowalczuk.eu>
8  *
9  * released under GNU GPL v2 only licence
10  *
11  */
12 
13 #ifndef SRVMSG_H
14 #define SRVMSG_H
15 
16 #include <vector>
17 #include "Msg.h"
18 #include "SmartPtr.h"
19 #include "SrvAddrMgr.h"
20 #include "IPv6Addr.h"
21 #include "SrvCfgIface.h"
22 #include "OptOptionRequest.h"
23 #include "SrvOptInterfaceID.h"
24 #include "SrvOptFQDN.h"
25 #include "SrvOptIA_NA.h"
26 #include "SrvOptTA.h"
27 #include "SrvOptIA_PD.h"
28 #include "OptVendorData.h"
29 #include "OptGeneric.h"
30 
31 class TSrvMsg : public TMsg
32 {
33 public:
34  struct RelayInfo {
35  int Hop_;
38  size_t Len_;
40  };
41 
42  TSrvMsg(int iface, SPtr<TIPv6Addr> addr, char* buf, int bufSize);
43  TSrvMsg(int iface, SPtr<TIPv6Addr> addr, int msgType, long transID);
44 
46  void copyAAASPI(SPtr<TSrvMsg> q);
48  bool copyClientID(SPtr<TMsg> donor);
49 
51  bool appendMandatoryOptions(SPtr<TOptOptionRequest> oro, bool includeClientID = true);
53  int iface, SPtr<TOptOptionRequest> reqOpt);
55  bool appendVendorSpec(SPtr<TDUID> duid, int iface, int vendor, SPtr<TOptOptionRequest> reqOpt);
56  void appendStatusCode();
57 
58 #ifndef MOD_DISABLE_AUTH
59  void appendReconfigureKey();
61 #endif
62 
64  void addRelayInfo(SPtr<TIPv6Addr> linkAddr,
65  SPtr<TIPv6Addr> peerAddr,
66  int hop,
67  const TOptList& echoList);
68 
69  bool releaseAll(bool quiet);
70 
71 
72  virtual bool check() = 0;
73 
75  void setRemoteID(SPtr<TOptVendorData> remoteID);
77 
78  unsigned long getTimeout();
79  void doDuties();
80  void send(int dstPort = 0);
81 
82  void processOptions(SPtr<TSrvMsg> clientMsg, bool quiet);
85 
89  inline void setMsgType(uint8_t type) {
91  }
92 
94  void clearRelayInfo() {
95  RelayInfo_.clear();
96  }
97 
102  std::vector<RelayInfo> RelayInfo_;
103 
104  void setPhysicalIface(int iface);
105  int getPhysicalIface() const;
106 
107 
108 protected:
109  void setDefaults();
111  void handleDefaultOption(SPtr<TOpt> ptrOpt);
112  void getORO(SPtr<TMsg> clientMessage);
114 
115  bool check(bool clntIDmandatory, bool srvIDmandatory);
116 
117  void processIA_NA(SPtr<TSrvMsg> clientMsg, SPtr<TSrvOptIA_NA> q);
118  void processIA_TA(SPtr<TSrvMsg> clientMsg, SPtr<TSrvOptTA> q);
119  void processIA_PD(SPtr<TSrvMsg> clientMsg, SPtr<TSrvOptIA_PD> q);
120  void processFQDN(SPtr<TSrvMsg> clientMsg, SPtr<TSrvOptFQDN> q);
121 
122 #if 0
123  SPtr<TSrvOptFQDN> prepareFQDN(SPtr<TSrvOptFQDN> requestFQDN, SPtr<TDUID> clntDuid,
124  SPtr<TIPv6Addr> clntAddr, std::string hint, bool doRealUpdate);
125  void fqdnRelease(SPtr<TSrvCfgIface> ptrIface, SPtr<TAddrIA> ia, SPtr<TFQDN> fqdn);
126 #endif
128  SPtr<TDUID> clntDuid, SPtr<TIPv6Addr> clntAddr,
129  std::string hint, bool doRealUpdate);
130  void delFQDN(SPtr<TSrvCfgIface> cfgIface, SPtr<TAddrIA> ptrIA, SPtr<TFQDN> fqdn);
131 
132 
133  int storeSelfRelay(char * buf, uint8_t relayLevel, ESrvIfaceIdOrder order);
134 
135  unsigned long FirstTimeStamp_; // timestamp of first message transmission
136  unsigned long MRT_; // maximum retransmission timeout
137 
139  SPtr<TOptVendorData> RemoteID; // this MAY be set, if message was recevied via relay
140  // AND relay appended RemoteID
141 
143  uint8_t forceMsgType_;
144 
147 };
148 
149 typedef std::vector< SPtr<TSrvMsg> > SrvMsgList;
150 
151 #endif
152