23 const uint32_t vendor_id)
24 :
Option(u, getOptionCode(u)), vendor_id_(vendor_id) {
33 :
Option(u, getOptionCode(u)) {
49 for (
auto const& it : tuples_) {
66 if (std::distance(begin, end) < getMinimalLength() -
getHeaderLen()) {
68 " size " << std::distance(begin, end));
73 begin +=
sizeof(vendor_id_);
77 while (offset <
static_cast<size_t>(std::distance(begin, end))) {
91 distance(begin + offset,
94 if (other_id != vendor_id_) {
96 "different enterprise ids: " << vendor_id_
97 <<
" and " << other_id);
100 offset +=
sizeof(vendor_id_);
104 if (offset + 1 >=
static_cast<size_t>(std::distance(begin, end))) {
106 " option - it should contain enterprise id followed"
107 " by opaque data field tuple");
117 " invalid size of the length field "
121 tuples_.push_back(tuple);
129 " vendor option at position " << at <<
" which is out of"
134 " invalid size of the length field "
145 " vendor option at position " << at <<
" which is out of"
146 " range. There are only " <<
getTuplesNum() <<
" tuples");
148 return (tuples_[at]);
155 for (
auto const& it : tuples_) {
156 if (it == tuple_str) {
170 for (
auto const& it : tuples_) {
174 length +=
sizeof(uint32_t);
177 length += it.getTotalLength();
186 std::ostringstream s;
189 s << std::string(indent,
' ');
192 " enterprise id=0x" << std::hex <<
getVendorId() << std::dec;
198 s <<
", enterprise id=0x" << std::hex <<
getVendorId() << std::dec;
201 s <<
", data-len" << i <<
"=" << t.getLength();
202 s <<
", vendor-class-data" << i <<
"=" <<
str::dumpAsHex(t.getData());
203 auto txt = t.getText();
205 s <<
" '" << txt <<
"'";
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 if a parameter given to a method would refer to or modify out-of-r...
Represents a single instance of the opaque data preceded by length.
int getDataFieldSize() const
Returns the size of the tuple length field.
LengthFieldType getLengthFieldType() const
Returns tuple length data field type.
size_t getTotalLength() const
Returns a total size of the tuple, including length field.
static OpaqueDataTuple::LengthFieldType getTupleLenFieldType(Option::Universe u)
Returns Length Field Type for a tuple.
virtual std::string toText(int indent=0) const
Returns text representation of the option.
virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end)
Parses buffer holding an option.
OptionVendorClass(Option::Universe u, const uint32_t vendor_id)
Constructor.
OptionPtr clone() const
Copies this option and returns a pointer to the copy.
virtual void pack(isc::util::OutputBuffer &buf, bool check=true) const
Renders option into the buffer in the wire format.
virtual uint16_t len() const
Returns the full length of the option, including option header.
uint32_t getVendorId() const
Returns enterprise id.
void setTuple(const size_t at, const OpaqueDataTuple &tuple)
Replaces tuple at the specified index with a new tuple.
OpaqueDataTuple getTuple(const size_t at) const
Returns opaque data tuple at the specified position.
void addTuple(const OpaqueDataTuple &tuple)
Adds a new opaque data tuple to the option.
size_t getTuplesNum() const
Returns the number of opaque data tuples added to the option.
bool hasTuple(const std::string &tuple_str) const
Checks if the Vendor Class holds the opaque data tuple with the specified string.
Universe
defines option universe DHCPv4 or DHCPv6
virtual uint16_t getHeaderLen() const
Returns length of header (2 for v4, 4 for v6).
uint16_t getType() const
Returns option type (0-255 for DHCPv4, 0-65535 for DHCPv6).
OptionPtr cloneInternal() const
Copies this option and returns a pointer to the copy.
Universe getUniverse() const
returns option universe (V4 or V6)
void packHeader(isc::util::OutputBuffer &buf, bool check=true) const
Store option's header in a buffer.
Option(Universe u, uint16_t type)
ctor, used for options constructed, usually during transmission
void check() const
A protected method used for option correctness.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
void writeUint32(uint32_t data)
Write an unsigned 32-bit integer in host byte order into the buffer in network byte order.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer
boost::shared_ptr< Option > OptionPtr
string dumpAsHex(const uint8_t *data, size_t length)
Dumps a buffer of bytes as a string of hexadecimal digits.
bool isPrintable(const string &content)
Check if a string is printable.
uint32_t readUint32(void const *const buffer, size_t const length)
uint32_t wrapper over readUint.
Defines the logger used by the top-level component of kea-lfc.