Kea  2.3.3-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 
51  void pack(isc::util::OutputBuffer& buf, bool check = true) const;
52 
59  void packHashInput(isc::util::OutputBuffer& buf) const;
60 
68  virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end);
69 
75  virtual std::string toText(int indent = 0) const;
76 
80  void setProtocol(uint8_t proto) { protocol_ = proto; }
81 
85  void setHashAlgo(uint8_t algo) { algorithm_ = algo; }
86 
90  void setReplyDetectionMethod(uint8_t method) { rdm_method_ = method; }
91 
95  void setReplyDetectionValue(uint64_t value) { rdm_value_ = value; }
96 
100  void setAuthInfo(const std::vector<uint8_t>& auth_info) { auth_info_ = auth_info; }
101 
105  uint8_t getProtocol() const { return protocol_; }
106 
110  uint8_t getHashAlgo() const { return algorithm_; }
111 
115  uint8_t getReplyDetectionMethod() const { return rdm_method_; }
116 
120  uint64_t getReplyDetectionValue() const { return rdm_value_; }
121 
125  std::vector<uint8_t> getAuthInfo() const { return auth_info_; }
126 
127 protected:
129  uint8_t protocol_;
130 
132  uint8_t algorithm_;
133 
135  uint8_t rdm_method_;
136 
138  uint64_t rdm_value_;
139 
141  std::vector<uint8_t> auth_info_;
142 };
143 
144 } // isc::dhcp namespace
145 } // isc namespace
uint8_t getHashAlgo() const
Returns hash algorithm type.
Definition: option6_auth.h:110
uint8_t getProtocol() const
Returns protocol type.
Definition: option6_auth.h:105
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:138
uint8_t rdm_method_
keeps replay detection method type
Definition: option6_auth.h:135
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:100
uint8_t getReplyDetectionMethod() const
Returns replay detection method type.
Definition: option6_auth.h:115
void setReplyDetectionMethod(uint8_t method)
Set replay detection method type.
Definition: option6_auth.h:90
std::vector< uint8_t > auth_info_
keeps authentication information
Definition: option6_auth.h:141
static const uint8_t OPTION6_HDR
Definition: option6_auth.h:32
uint8_t protocol_
keeps protocol type
Definition: option6_auth.h:129
void setHashAlgo(uint8_t algo)
Set hash algorithm type.
Definition: option6_auth.h:85
uint8_t algorithm_
keeps hash algorithm value
Definition: option6_auth.h:132
void setProtocol(uint8_t proto)
Set protocol type.
Definition: option6_auth.h:80
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:125
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:120
void setReplyDetectionValue(uint64_t value)
Set replay detection method value.
Definition: option6_auth.h:95