Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OptAuthentication.h
Go to the documentation of this file.
1 /*
2  * Dibbler - a portable DHCPv6
3  *
4  * author: Michal Kowalczuk <michal@kowalczuk.eu>
5  * changes: Tomek Mrugalski <thomson(at)klub(dot)com(dot)pl>
6  *
7  * released under GNU GPL v2 only licence
8  */
9 
10 #ifndef OPTAUTHENTICATION_H
11 #define OPTAUTHENTICATION_H
12 
13 #include <vector>
14 #include "DHCPConst.h"
15 #include "Opt.h"
16 #include "Portable.h"
17 
18 class TOptAuthentication : public TOpt
19 {
20 public:
21  const static size_t OPT_AUTH_FIXED_SIZE = 11;
22 
23  TOptAuthentication(AuthProtocols proto, uint8_t algo, AuthReplay rdm,
24  TMsg* parent);
25 
26  TOptAuthentication(char* buf, size_t buflen, TMsg* parent);
27 
28  AuthProtocols getProto() const;
29  uint8_t getAlgorithm() const;
30  AuthReplay getRDM() const;
31 
32  void setRDM(AuthReplay value);
33 
34  void setReplayDetection(uint64_t value);
35  uint64_t getReplayDetection();
36 
37  size_t getSize();
38  char * storeSelf(char* buf);
39  bool doDuties();
40 
41  void setPayload(const std::vector<uint8_t>& data);
42  void getPayload(std::vector<uint8_t>& data);
43 
44  // not real fields, those are used for checksum calculations
45 
47  // specific for method 4 (see DHCPConst.h)
48  uint32_t getSPI() const;
49  void setAuthInfoLen(uint16_t len);
51 
52  inline char* getAuthDataPtr() const { return authDataPtr_; }
53 
54  void setRealm(const std::string& realm);
55 
56 private:
57  AuthProtocols proto_; // protocol
58  uint8_t algo_; // algorithm
59  AuthReplay rdm_; // replay detection method
60  uint64_t replay_;
61 
62  std::vector<uint8_t> data_;
63 
64  std::string realm_;
65 
66  char* authDataPtr_;
67 
68  // specific for AUTH_PROTO_DIBBLER
70 };
71 
72 #endif
73