17#include <boost/shared_ptr.hpp>
36template<
size_t min_size,
size_t max_size>
44 if (data.size() < min_size) {
46 <<
"), at least "<< min_size <<
" is required");
48 if (data.size() > max_size) {
50 <<
"), at most " << max_size <<
" is required");
62 <<
"), at least "<< min_size <<
" is required");
66 <<
"), at most " << max_size <<
" is required");
68 data_ = std::vector<uint8_t>(data, data + len);
89 std::stringstream tmp;
92 for (
auto const& data :
data_) {
96 tmp << std::setw(2) << std::setfill('0') << static_cast<unsigned int>(data);
108 static std::vector<uint8_t>
fromText(
const std::string& text) {
109 std::vector<uint8_t> binary;
170 DUID(
const std::vector<uint8_t>& data);
176 DUID(
const uint8_t* data,
size_t len);
186 const std::vector<uint8_t>&
getDuid()
const;
240 ClientId(
const std::vector<uint8_t>& data);
246 ClientId(
const uint8_t* data,
size_t len);
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Holds Client identifier or client IPv4 address.
static constexpr size_t MAX_CLIENT_ID_LEN
Maximum size of a client ID.
const std::vector< uint8_t > & getClientId() const
Returns reference to the client-id data.
ClientId(const std::vector< uint8_t > &data)
Constructor based on vector<uint8_t>
static ClientIdPtr fromText(const std::string &text)
Create client identifier from the textual format.
static constexpr size_t MIN_CLIENT_ID_LEN
Minimum size of a client ID.
Holds DUID (DHCPv6 Unique Identifier)
static constexpr size_t MIN_DUID_LEN
minimum duid size
static DUID fromText(const std::string &text)
Create DUID from the textual format.
static const DUID & EMPTY()
Defines the constant "empty" DUID.
static constexpr size_t MAX_DUID_LEN
maximum duid size
DUIDType
specifies DUID type
@ DUID_LL
link-layer, see RFC3315, section 11.4
@ DUID_LLT
link-layer + time, see RFC3315, section 11.2
@ DUID_MAX
not a real type, just maximum defined value + 1
@ DUID_UNKNOWN
invalid/unknown type
@ DUID_EN
enterprise-id, see RFC3315, section 11.3
@ DUID_UUID
UUID, see RFC3315, section 11.5.
const std::vector< uint8_t > & getDuid() const
Returns a const reference to the actual DUID value.
DUIDType getType() const
Returns the DUID type.
DUID(const std::vector< uint8_t > &data)
Constructor from vector.
Base type used to define a common smart pointer for all derived types.
virtual ~IdentifierBaseType()=0
Pure virtual destructor.
std::vector< uint8_t > data_
The actual content of the Identifier.
static std::vector< uint8_t > fromText(const std::string &text)
This static function parses an Identifier specified in the textual format.
IdentifierType(const uint8_t *data, size_t len)
Constructor from array and array size.
bool operator==(const IdentifierType &other) const
Compares two identifiers for equality.
IdentifierType(const std::vector< uint8_t > &data)
Constructor from vector.
bool operator!=(const IdentifierType &other) const
Compares two identifiers for inequality.
static constexpr size_t getMaxSize()
Return the maximum size of the acceptable data.
std::string toText() const
Returns textual representation of the identifier (e.g.
static constexpr size_t getMinSize()
Return the minimum size of the acceptable data.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< DUID > DuidPtr
boost::shared_ptr< IdentifierBaseType > IdentifierBaseTypePtr
Shared pointer to a IdentifierType.
boost::shared_ptr< ClientId > ClientIdPtr
Shared pointer to a Client ID.
void decodeFormattedHexString(const string &hex_string, vector< uint8_t > &binary)
Converts a formatted string of hexadecimal digits into a vector.
Defines the logger used by the top-level component of kea-lfc.