26 : type_(
DUID::DUID_LLT), identifier_(), htype_(0), time_(0),
27 enterprise_id_(0), persist_(true) {
33 const std::string identifier =
trim(identifier_as_hex);
35 std::vector<uint8_t> binary;
36 if (!identifier.empty()) {
41 identifier_.swap(binary);
42 }
catch (
const std::exception& ex) {
44 " configuration '" << identifier
45 <<
"' is not a valid string of hexadecimal digits");
57 current_duid_.reset();
75 <<
" to create a new DUID");
79 current_duid_ = factory.
get();
82 return (current_duid_);
91 std::string duid_type =
"LLT";
105 result->set(
"type", Element::create(duid_type));
107 result->set(
"identifier",
110 result->set(
"htype", Element::create(htype_));
112 result->set(
"time", Element::create(static_cast<long long>(time_)));
114 result->set(
"enterprise-id",
115 Element::create(static_cast<long long>(enterprise_id_)));
117 result->set(
"persist", Element::create(persist_));
boost::shared_ptr< DUID > DuidPtr
uint32_t getTime() const
Returns time for the DUID-LLT.
void createLLT(const uint16_t htype, const uint32_t time_in, const std::vector< uint8_t > &ll_identifier)
Generates DUID-LLT.
link-layer + time, see RFC3315, section 11.2
boost::shared_ptr< Element > ElementPtr
bool persist() const
Checks if server identifier should be stored on disk.
uint16_t getHType() const
Returns hardware type for DUID-LLT and DUID-LL.
DuidPtr get()
Returns current DUID.
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.
Holds DUID (DHCPv6 Unique Identifier)
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
void createLL(const uint16_t htype, const std::vector< uint8_t > &ll_identifier)
Generates DUID-LL.
void decodeHex(const string &input, vector< uint8_t > &result)
Decode a text encoded in the base16 ('hex') format into the original data.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
A generic exception that is thrown when an unexpected error condition occurs.
DUID::DUIDType getType() const
Returns DUID type.
link-layer, see RFC3315, section 11.4
Defines the logger used by the top-level component of kea-dhcp-ddns.
string encodeHex(const vector< uint8_t > &binary)
Encode binary data in the base16 ('hex') format.
std::vector< uint8_t > getIdentifier() const
Returns identifier.
uint32_t getEnterpriseId() const
Returns enterprise id for the DUID-EN.
void createEN(const uint32_t enterprise_id, const std::vector< uint8_t > &identifier)
Generates DUID-EN.
string trim(const string &instring)
Trim Leading and Trailing Spaces.
enterprise-id, see RFC3315, section 11.3
Factory for generating DUIDs (DHCP Unique Identifiers).
DuidPtr create(const std::string &duid_file_path)
Creates instance of a DUID from the current configuration.
void setIdentifier(const std::string &identifier_as_hex)
Sets new identifier as hex string.