Kea  1.9.9-git
option_opaque_data_tuples.h
Go to the documentation of this file.
1 // Copyright (C) 2015-2016 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_OPAQUE_DATA_TUPLES_H
8 #define OPTION_OPAQUE_DATA_TUPLES_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 
37 public:
38 
40  typedef std::vector<OpaqueDataTuple> TuplesCollection;
41 
49  OptionOpaqueDataTuples(Option::Universe u, const uint16_t type);
50 
61  OptionOpaqueDataTuples(Option::Universe u, const uint16_t type,
64 
66  OptionPtr clone() const;
67 
71  virtual void pack(isc::util::OutputBuffer& buf) const;
72 
81  virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end);
82 
88  void addTuple(const OpaqueDataTuple& tuple);
89 
101  void setTuple(const size_t at, const OpaqueDataTuple& tuple);
102 
109  OpaqueDataTuple getTuple(const size_t at) const;
110 
112  size_t getTuplesNum() const {
113  return (tuples_.size());
114  }
115 
117  const TuplesCollection& getTuples() const {
118  return (tuples_);
119  }
120 
126  bool hasTuple(const std::string& tuple_str) const;
127 
129  virtual uint16_t len() const;
130 
135  virtual std::string toText(int indent = 0) const;
136 
137 private:
138 
145  OpaqueDataTuple::LengthFieldType getLengthFieldType() const {
148  }
149 
153  uint16_t getMinimalLength() const {
154  return (4);
155  }
156 
158  TuplesCollection tuples_;
159 
160 };
161 
163 typedef boost::shared_ptr<OptionOpaqueDataTuples> OptionOpaqueDataTuplesPtr;
164 
165 }
166 }
167 
168 #endif // OPTION_OPAQUE_DATA_TUPLES_H
void setTuple(const size_t at, const OpaqueDataTuple &tuple)
Replaces tuple at the specified index with a new tuple.
virtual void pack(isc::util::OutputBuffer &buf) const
Renders option into the buffer in the wire format.
void addTuple(const OpaqueDataTuple &tuple)
Adds a new opaque data tuple to the option.
OptionOpaqueDataTuples(Option::Universe u, const uint16_t type)
Constructor.
size_t getTuplesNum() const
Returns the number of opaque data tuples added to the option.
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.
boost::shared_ptr< Option > OptionPtr
Definition: option.h:36
Universe
defines option universe DHCPv4 or DHCPv6
Definition: option.h:82
virtual std::string toText(int indent=0) const
Returns text representation of the option.
Universe universe_
option universe (V4 or V6)
Definition: option.h:566
OptionPtr clone() const
Copies this option and returns a pointer to the copy.
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
bool hasTuple(const std::string &tuple_str) const
Checks if the object holds the opaque data tuple with the specified string.
OptionBuffer::const_iterator OptionBufferConstIter
const_iterator for walking over OptionBuffer
Definition: option.h:30
LengthFieldType
Size of the length field in the tuple.
Defines the logger used by the top-level component of kea-dhcp-ddns.
Represents a single instance of the opaque data preceded by length.
OpaqueDataTuple getTuple(const size_t at) const
Returns opaque data tuple at the specified position.
This class encapsulates a collection of data tuples and could be used by multiple options...
virtual void unpack(OptionBufferConstIter begin, OptionBufferConstIter end)
Parses buffer holding an option.
boost::shared_ptr< OptionOpaqueDataTuples > OptionOpaqueDataTuplesPtr
Defines a pointer to the OptionOpaqueDataTuples.