Kea: option_vendor_class.h Source File

| Kea 3.2.0-git

option_vendor_class.h
Go to the documentation of this file.
1// Copyright (C) 2014-2026 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 OPTION_VENDOR_CLASS_H
8#define OPTION_VENDOR_CLASS_H
9
10#include <dhcp/dhcp4.h>
11#include <dhcp/dhcp6.h>
12#include <dhcp/opaque_data_tuple.h>
13#include <dhcp/option.h>
14#include <util/buffer.h>
15#include <boost/shared_ptr.hpp>
16#include <dhcp/option_data_types.h>
17#include <stdint.h>
18
19namespace isc {
20namespace dhcp {
21
42 class OptionVendorClass : public Option {
43public:
44
46 typedef std::vector<OpaqueDataTuple> TuplesCollection;
47
59 OptionVendorClass(Option::Universe u, const uint32_t vendor_id);
60
70 OptionVendorClass(Option::Universe u, OptionBufferConstIter begin,
71 OptionBufferConstIter end);
72
74 OptionPtr clone() const;
75
80 virtual void pack(isc::util::OutputBuffer& buf, bool check = true) const;
81
90 virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end);
91
93 uint32_t getVendorId() const {
94 return (vendor_id_);
95 }
96
102 void addTuple(const OpaqueDataTuple& tuple);
103
115 void setTuple(const size_t at, const OpaqueDataTuple& tuple);
116
123 OpaqueDataTuple getTuple(const size_t at) const;
124
126 size_t getTuplesNum() const {
127 return (tuples_.size());
128 }
129
131 const TuplesCollection& getTuples() const {
132 return (tuples_);
133 }
134
140 bool hasTuple(const std::string& tuple_str) const;
141
143 virtual uint16_t len() const;
144
149 virtual std::string toText(int indent = 0) const;
150
151private:
152
160 static uint16_t getOptionCode(Option::Universe u) {
161 if (u == V4) {
162 return (DHO_VIVCO_SUBOPTIONS);
163 } else {
164 return (D6O_VENDOR_CLASS);
165 }
166 }
167
183 uint16_t getMinimalLength() const {
184 return (getUniverse() == Option::V4 ? 6 : 8);
185 }
186
188 uint32_t vendor_id_;
189
191 TuplesCollection tuples_;
192
193};
194
196 typedef boost::shared_ptr<OptionVendorClass> OptionVendorClassPtr;
197
198}
199}
200
201#endif // OPTION_VENDOR_CLASS_H
buffer.h
isc::dhcp::OpaqueDataTuple
Represents a single instance of the opaque data preceded by length.
Definition opaque_data_tuple.h:46
isc::dhcp::OptionVendorClass::toText
virtual std::string toText(int indent=0) const
Returns text representation of the option.
Definition option_vendor_class.cc:182
isc::dhcp::OptionVendorClass::unpack
virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end)
Parses buffer holding an option.
Definition option_vendor_class.cc:61
isc::dhcp::OptionVendorClass::OptionVendorClass
OptionVendorClass(Option::Universe u, const uint32_t vendor_id)
Constructor.
Definition option_vendor_class.cc:19
isc::dhcp::OptionVendorClass::clone
OptionPtr clone() const
Copies this option and returns a pointer to the copy.
Definition option_vendor_class.cc:35
isc::dhcp::OptionVendorClass::pack
virtual void pack(isc::util::OutputBuffer &buf, bool check=true) const
Renders option into the buffer in the wire format.
Definition option_vendor_class.cc:40
isc::dhcp::OptionVendorClass::len
virtual uint16_t len() const
Returns the full length of the option, including option header.
Definition option_vendor_class.cc:162
isc::dhcp::OptionVendorClass::TuplesCollection
std::vector< OpaqueDataTuple > TuplesCollection
Collection of opaque data tuples carried by the option.
Definition option_vendor_class.h:46
isc::dhcp::OptionVendorClass::getVendorId
uint32_t getVendorId() const
Returns enterprise id.
Definition option_vendor_class.h:93
isc::dhcp::OptionVendorClass::setTuple
void setTuple(const size_t at, const OpaqueDataTuple &tuple)
Replaces tuple at the specified index with a new tuple.
Definition option_vendor_class.cc:123
isc::dhcp::OptionVendorClass::getTuple
OpaqueDataTuple getTuple(const size_t at) const
Returns opaque data tuple at the specified position.
Definition option_vendor_class.cc:139
isc::dhcp::OptionVendorClass::getTuples
const TuplesCollection & getTuples() const
Returns collection of opaque data tuples carried in the option.
Definition option_vendor_class.h:131
isc::dhcp::OptionVendorClass::addTuple
void addTuple(const OpaqueDataTuple &tuple)
Adds a new opaque data tuple to the option.
Definition option_vendor_class.cc:111
isc::dhcp::OptionVendorClass::getTuplesNum
size_t getTuplesNum() const
Returns the number of opaque data tuples added to the option.
Definition option_vendor_class.h:126
isc::dhcp::OptionVendorClass::hasTuple
bool hasTuple(const std::string &tuple_str) const
Checks if the Vendor Class holds the opaque data tuple with the specified string.
Definition option_vendor_class.cc:149
isc::dhcp::Option::Universe
Universe
defines option universe DHCPv4 or DHCPv6
Definition option.h:90
isc::dhcp::Option::V4
@ V4
Definition option.h:90
isc::dhcp::Option::getUniverse
Universe getUniverse() const
returns option universe (V4 or V6)
Definition option.h:240
isc::dhcp::Option::Option
Option(Universe u, uint16_t type)
ctor, used for options constructed, usually during transmission
Definition option.cc:39
isc::dhcp::Option::check
void check() const
A protected method used for option correctness.
Definition option.cc:90
isc::util::OutputBuffer
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition buffer.h:346
dhcp4.h
dhcp6.h
D6O_VENDOR_CLASS
@ D6O_VENDOR_CLASS
Definition dhcp6.h:36
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::dhcp::DHO_VIVCO_SUBOPTIONS
@ DHO_VIVCO_SUBOPTIONS
Definition dhcp4.h:188
isc::dhcp::OptionBufferConstIter
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer
Definition option.h:30
isc::dhcp::OptionVendorClassPtr
boost::shared_ptr< OptionVendorClass > OptionVendorClassPtr
Defines a pointer to the OptionVendorClass.
Definition option_vendor_class.h:196
isc::dhcp::OptionPtr
boost::shared_ptr< Option > OptionPtr
Definition option.h:37
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
opaque_data_tuple.h
option.h
option_data_types.h