Kea  2.1.7-git
option6_auth.h
Go to the documentation of this file.
1 // Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef OPTION6_AUTH_H
8 #define OPTION6_AUTH_H
9 #endif
10 
11 #include <dhcp/option.h>
12 #include <boost/shared_ptr.hpp>
13 
14 #include <vector>
15 
16 namespace isc {
17 namespace dhcp {
18 
20 
22 typedef boost::shared_ptr<Option6Auth> Option6AuthPtr;
23 
27 class Option6Auth: public Option {
28 
29 public:
30  static const uint8_t OPTION6_AUTH_MIN_LEN = 11;
31  static const uint8_t OPTION6_HASH_MSG_LEN = 16;
32  static const uint8_t OPTION6_HDR = 4;
40  Option6Auth(const uint8_t proto, const uint8_t algo, const uint8_t method,
41  const uint64_t rdm, const std::vector<uint8_t>& info);
42 
44  virtual OptionPtr clone() const;
45 
50  void pack(isc::util::OutputBuffer& buf, bool check = true) const;
51 
58  void packHashInput(isc::util::OutputBuffer& buf) const;
59 
67  virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end);
68 
74  virtual std::string toText(int indent = 0) const;
75 
79  void setProtocol(uint8_t proto) { protocol_ = proto; }
80 
84  void setHashAlgo(uint8_t algo) { algorithm_ = algo; }
85 
89  void setReplyDetectionMethod(uint8_t method) { rdm_method_ = method; }
90 
94  void setReplyDetectionValue(uint64_t value) { rdm_value_ = value; }
95 
99  void setAuthInfo(const std::vector<uint8_t>& auth_info) { auth_info_ = auth_info; }
100 
104  uint8_t getProtocol() const { return protocol_; }
105 
109  uint8_t getHashAlgo() const { return algorithm_; }
110 
114  uint8_t getReplyDetectionMethod() const { return rdm_method_; }
115 
119  uint64_t getReplyDetectionValue() const { return rdm_value_; }
120 
124  std::vector<uint8_t> getAuthInfo() const { return auth_info_; }
125 
126 protected:
128  uint8_t protocol_;
129 
131  uint8_t algorithm_;
132 
134  uint8_t rdm_method_;
135 
137  uint64_t rdm_value_;
138 
140  std::vector<uint8_t> auth_info_;
141 };
142 
143 } // isc::dhcp namespace
144 } // isc namespace
145 
uint8_t getHashAlgo() const
Returns hash algorithm type.
Definition: option6_auth.h:109
uint8_t getProtocol() const
Returns protocol type.
Definition: option6_auth.h:104
boost::shared_ptr< Option6Auth > Option6AuthPtr
A pointer to the isc::dhcp::Option6Auth object.
Definition: option6_auth.h:19
uint64_t rdm_value_
keeps replay detection method value
Definition: option6_auth.h:137
uint8_t rdm_method_
keeps replay detection method type
Definition: option6_auth.h:134
boost::shared_ptr< Option > OptionPtr
Definition: option.h:36
Option6Auth(const uint8_t proto, const uint8_t algo, const uint8_t method, const uint64_t rdm, const std::vector< uint8_t > &info)
Constructor, used for auth options while transmitting.
Definition: option6_auth.cc:25
static const uint8_t OPTION6_AUTH_MIN_LEN
Definition: option6_auth.h:30
void pack(isc::util::OutputBuffer &buf, bool check=true) const
Writes option in wire-format to buf, returns pointer to first unused byte after stored option...
Definition: option6_auth.cc:40
void setAuthInfo(const std::vector< uint8_t > &auth_info)
Set authentication information.
Definition: option6_auth.h:99
uint8_t getReplyDetectionMethod() const
Returns replay detection method type.
Definition: option6_auth.h:114
void setReplyDetectionMethod(uint8_t method)
Set replay detection method type.
Definition: option6_auth.h:89
std::vector< uint8_t > auth_info_
keeps authentication information
Definition: option6_auth.h:140
static const uint8_t OPTION6_HDR
Definition: option6_auth.h:32
uint8_t protocol_
keeps protocol type
Definition: option6_auth.h:128
void setHashAlgo(uint8_t algo)
Set hash algorithm type.
Definition: option6_auth.h:84
uint8_t algorithm_
keeps hash algorithm value
Definition: option6_auth.h:131
void setProtocol(uint8_t proto)
Set protocol type.
Definition: option6_auth.h:79
void check() const
A protected method used for option correctness.
Definition: option.cc:90
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition: buffer.h:294
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer
Definition: option.h:30
Defines the logger used by the top-level component of kea-lfc.
static const uint8_t OPTION6_HASH_MSG_LEN
Definition: option6_auth.h:31
This class represents Authentication (11) DHCPv6 option.
Definition: option6_auth.h:27
virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end)
Parses received buffer.
Definition: option6_auth.cc:93
std::vector< uint8_t > getAuthInfo() const
Return authentication information.
Definition: option6_auth.h:124
virtual OptionPtr clone() const
Copies this option and returns a pointer to the copy.
Definition: option6_auth.cc:35
virtual std::string toText(int indent=0) const
Provides human readable text representation.
void packHashInput(isc::util::OutputBuffer &buf) const
Writes option in wire-format to buf, for computing hash auth info filled with 0 for a length of 128 b...
Definition: option6_auth.cc:67
uint64_t getReplyDetectionValue() const
Return replay detection mechanism.
Definition: option6_auth.h:119
void setReplyDetectionValue(uint64_t value)
Set replay detection method value.
Definition: option6_auth.h:94