Kea  2.3.4-git
option_vendor_class.h
Go to the documentation of this file.
1 // Copyright (C) 2014-2022 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 <stdint.h>
17 
18 namespace isc {
19 namespace dhcp {
20 
41 class OptionVendorClass : public Option {
42 public:
43 
45  typedef std::vector<OpaqueDataTuple> TuplesCollection;
46 
58  OptionVendorClass(Option::Universe u, const uint32_t vendor_id);
59 
71 
73  OptionPtr clone() const;
74 
79  virtual void pack(isc::util::OutputBuffer& buf, bool check = true) const;
80 
89  virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end);
90 
92  uint32_t getVendorId() const {
93  return (vendor_id_);
94  }
95 
101  void addTuple(const OpaqueDataTuple& tuple);
102 
114  void setTuple(const size_t at, const OpaqueDataTuple& tuple);
115 
122  OpaqueDataTuple getTuple(const size_t at) const;
123 
125  size_t getTuplesNum() const {
126  return (tuples_.size());
127  }
128 
130  const TuplesCollection& getTuples() const {
131  return (tuples_);
132  }
133 
139  bool hasTuple(const std::string& tuple_str) const;
140 
142  virtual uint16_t len() const;
143 
148  virtual std::string toText(int indent = 0) const;
149 
150 private:
151 
159  static uint16_t getOptionCode(Option::Universe u) {
160  if (u == V4) {
161  return (DHO_VIVCO_SUBOPTIONS);
162  } else {
163  return (D6O_VENDOR_CLASS);
164  }
165  }
166 
173  OpaqueDataTuple::LengthFieldType getLengthFieldType() const {
176  }
177 
193  uint16_t getMinimalLength() const {
194  return (getUniverse() == Option::V4 ? 6 : 8);
195  }
196 
198  uint32_t vendor_id_;
199 
201  TuplesCollection tuples_;
202 
203 };
204 
206 typedef boost::shared_ptr<OptionVendorClass> OptionVendorClassPtr;
207 
208 }
209 }
210 
211 #endif // OPTION_VENDOR_CLASS_H
boost::shared_ptr< OptionVendorClass > OptionVendorClassPtr
Defines a pointer to the OptionVendorClass.
size_t getTuplesNum() const
Returns the number of opaque data tuples added to the option.
OptionVendorClass(Option::Universe u, const uint32_t vendor_id)
Constructor.
boost::shared_ptr< Option > OptionPtr
Definition: option.h:36
Universe
defines option universe DHCPv4 or DHCPv6
Definition: option.h:83
OptionPtr clone() const
Copies this option and returns a pointer to the copy.
void addTuple(const OpaqueDataTuple &tuple)
Adds a new opaque data tuple to the option.
Universe getUniverse() const
returns option universe (V4 or V6)
Definition: option.h:233
bool hasTuple(const std::string &tuple_str) const
Checks if the Vendor Class holds the opaque data tuple with the specified string. ...
OpaqueDataTuple getTuple(const size_t at) const
Returns opaque data tuple at the specified position.
virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end)
Parses buffer holding an option.
void check() const
A protected method used for option correctness.
Definition: option.cc:90
virtual uint16_t len() const
Returns the full length of the option, including option header.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition: buffer.h:294
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer
Definition: option.h:30
LengthFieldType
Size of the length field in the tuple.
const TuplesCollection & getTuples() const
Returns collection of opaque data tuples carried in the option.
std::vector< OpaqueDataTuple > TuplesCollection
Collection of opaque data tuples carried by the option.
Defines the logger used by the top-level component of kea-lfc.
Represents a single instance of the opaque data preceded by length.
virtual std::string toText(int indent=0) const
Returns text representation of the option.
uint32_t getVendorId() const
Returns enterprise id.
virtual void pack(isc::util::OutputBuffer &buf, bool check=true) const
Renders option into the buffer in the wire format.
void setTuple(const size_t at, const OpaqueDataTuple &tuple)
Replaces tuple at the specified index with a new tuple.
This class encapsulates DHCPv6 Vendor Class and DHCPv4 V-I Vendor Class options.