Kea: option_vendor_class.h Source File

| Kea 1.5.0

option_vendor_class.h
Go to the documentation of this file.
1// Copyright (C) 2014-2018 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
18namespace isc {
19namespace dhcp {
20
41 class OptionVendorClass : public Option {
42public:
43
45 typedef std::vector<OpaqueDataTuple> TuplesCollection;
46
58 OptionVendorClass(Option::Universe u, const uint32_t vendor_id);
59
69 OptionVendorClass(Option::Universe u, OptionBufferConstIter begin,
70 OptionBufferConstIter end);
71
73 OptionPtr clone() const;
74
78 virtual void pack(isc::util::OutputBuffer& buf) const;
79
88 virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end);
89
91 uint32_t getVendorId() const {
92 return (vendor_id_);
93 }
94
100 void addTuple(const OpaqueDataTuple& tuple);
101
113 void setTuple(const size_t at, const OpaqueDataTuple& tuple);
114
121 OpaqueDataTuple getTuple(const size_t at) const;
122
124 size_t getTuplesNum() const {
125 return (tuples_.size());
126 }
127
129 const TuplesCollection& getTuples() const {
130 return (tuples_);
131 }
132
138 bool hasTuple(const std::string& tuple_str) const;
139
141 virtual uint16_t len() const;
142
147 virtual std::string toText(int indent = 0) const;
148
149private:
150
158 static uint16_t getOptionCode(Option::Universe u) {
159 if (u == V4) {
160 return (DHO_VIVCO_SUBOPTIONS);
161 } else {
162 return (D6O_VENDOR_CLASS);
163 }
164 }
165
172 OpaqueDataTuple::LengthFieldType getLengthFieldType() const {
173 return (getUniverse() == V4 ? OpaqueDataTuple::LENGTH_1_BYTE :
174 OpaqueDataTuple::LENGTH_2_BYTES);
175 }
176
192 uint16_t getMinimalLength() const {
193 return (getUniverse() == Option::V4 ? 6 : 8);
194 }
195
197 uint32_t vendor_id_;
198
200 TuplesCollection tuples_;
201
202};
203
205 typedef boost::shared_ptr<OptionVendorClass> OptionVendorClassPtr;
206
207}
208}
209
210#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:45
isc::dhcp::OpaqueDataTuple::LengthFieldType
LengthFieldType
Size of the length field in the tuple.
Definition: opaque_data_tuple.h:55
isc::dhcp::OpaqueDataTuple::LENGTH_2_BYTES
@ LENGTH_2_BYTES
Definition: opaque_data_tuple.h:57
isc::dhcp::OpaqueDataTuple::LENGTH_1_BYTE
@ LENGTH_1_BYTE
Definition: opaque_data_tuple.h:56
isc::dhcp::OptionVendorClass
This class encapsulates DHCPv6 Vendor Class and DHCPv4 V-I Vendor Class options.
Definition: option_vendor_class.h:41
isc::dhcp::OptionVendorClass::toText
virtual std::string toText(int indent=0) const
Returns text representation of the option.
Definition: option_vendor_class.cc:167
isc::dhcp::OptionVendorClass::unpack
virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end)
Parses buffer holding an option.
Definition: option_vendor_class.cc:57
isc::dhcp::OptionVendorClass::clone
OptionPtr clone() const
Copies this option and returns a pointer to the copy.
Definition: option_vendor_class.cc:33
isc::dhcp::OptionVendorClass::len
virtual uint16_t len() const
Returns the full length of the option, including option header.
Definition: option_vendor_class.cc:148
isc::dhcp::OptionVendorClass::TuplesCollection
std::vector< OpaqueDataTuple > TuplesCollection
Collection of opaque data tuples carried by the option.
Definition: option_vendor_class.h:45
isc::dhcp::OptionVendorClass::getVendorId
uint32_t getVendorId() const
Returns enterprise id.
Definition: option_vendor_class.h:91
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:108
isc::dhcp::OptionVendorClass::getTuple
OpaqueDataTuple getTuple(const size_t at) const
Returns opaque data tuple at the specified position.
Definition: option_vendor_class.cc:124
isc::dhcp::OptionVendorClass::getTuples
const TuplesCollection & getTuples() const
Returns collection of opaque data tuples carried in the option.
Definition: option_vendor_class.h:129
isc::dhcp::OptionVendorClass::pack
virtual void pack(isc::util::OutputBuffer &buf) const
Renders option into the buffer in the wire format.
Definition: option_vendor_class.cc:38
isc::dhcp::OptionVendorClass::addTuple
void addTuple(const OpaqueDataTuple &tuple)
Adds a new opaque data tuple to the option.
Definition: option_vendor_class.cc:96
isc::dhcp::OptionVendorClass::getTuplesNum
size_t getTuplesNum() const
Returns the number of opaque data tuples added to the option.
Definition: option_vendor_class.h:124
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:134
isc::dhcp::Option
Definition: option.h:58
isc::dhcp::Option::Universe
Universe
defines option universe DHCPv4 or DHCPv6
Definition: option.h:67
isc::dhcp::Option::V4
@ V4
Definition: option.h:67
isc::dhcp::Option::getUniverse
Universe getUniverse() const
returns option universe (V4 or V6)
Definition: option.h:190
isc::util::OutputBuffer
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition: buffer.h:294
dhcp4.h
dhcp6.h
D6O_VENDOR_CLASS
@ D6O_VENDOR_CLASS
Definition: dhcp6.h:36
isc::dhcp::DHO_VIVCO_SUBOPTIONS
@ DHO_VIVCO_SUBOPTIONS
Definition: dhcp4.h:184
isc::dhcp::OptionBufferConstIter
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer
Definition: option.h:31
isc::dhcp::OptionVendorClassPtr
boost::shared_ptr< OptionVendorClass > OptionVendorClassPtr
Defines a pointer to the OptionVendorClass.
Definition: option_vendor_class.h:205
isc::dhcp::OptionPtr
boost::shared_ptr< Option > OptionPtr
Definition: option.h:38
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
opaque_data_tuple.h
option.h