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";
107 result->set(
"identifier",
114 result->set(
"enterprise-id",
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
A generic exception that is thrown when an unexpected error condition occurs.
static ElementPtr create(const Position &pos=ZERO_POSITION())
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
std::vector< uint8_t > getIdentifier() const
Returns identifier.
DUID::DUIDType getType() const
Returns DUID type.
void setIdentifier(const std::string &identifier_as_hex)
Sets new identifier as hex string.
DuidPtr create(const std::string &duid_file_path)
Creates instance of a DUID from the current configuration.
uint32_t getEnterpriseId() const
Returns enterprise id for the DUID-EN.
uint32_t getTime() const
Returns time for the DUID-LLT.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
uint16_t getHType() const
Returns hardware type for DUID-LLT and DUID-LL.
bool persist() const
Checks if server identifier should be stored on disk.
Factory for generating DUIDs (DHCP Unique Identifiers).
void createLLT(const uint16_t htype, const uint32_t time_in, const std::vector< uint8_t > &ll_identifier)
Generates DUID-LLT.
void createEN(const uint32_t enterprise_id, const std::vector< uint8_t > &identifier)
Generates DUID-EN.
DuidPtr get()
Returns current DUID.
void createLL(const uint16_t htype, const std::vector< uint8_t > &ll_identifier)
Generates DUID-LL.
Holds DUID (DHCPv6 Unique Identifier)
@ DUID_LL
link-layer, see RFC3315, section 11.4
@ DUID_LLT
link-layer + time, see RFC3315, section 11.2
@ DUID_EN
enterprise-id, see RFC3315, section 11.3
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< Element > ElementPtr
boost::shared_ptr< DUID > DuidPtr
void decodeHex(const string &encoded_str, vector< uint8_t > &output)
Decode a base16 encoded string into binary data.
string encodeHex(const vector< uint8_t > &binary)
Encode binary data in the base16 format.
string trim(const string &input)
Trim leading and trailing spaces.
Defines the logger used by the top-level component of kea-lfc.
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.