Kea  1.9.9-git
perf_pkt4.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2019 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 PERF_PKT4_H
8 #define PERF_PKT4_H
9 
11 #include <perfdhcp/pkt_transform.h>
12 
13 #include <dhcp/pkt4.h>
14 
15 #include <boost/shared_ptr.hpp>
16 #include <time.h>
17 
18 
19 namespace isc {
20 namespace perfdhcp {
21 
41 
42 class PerfPkt4 : public dhcp::Pkt4 {
43 public:
44 
46  typedef boost::shared_ptr<LocalizedOption> LocalizedOptionPtr;
47 
64  PerfPkt4(const uint8_t* buf,
65  size_t len,
66  size_t transid_offset = 1,
67  uint32_t transid = 0);
68 
72  size_t getTransidOffset() const { return transid_offset_; };
73 
85  bool rawPack();
86 
98  bool rawUnpack();
99 
107  void writeAt(size_t dest_pos,
108  std::vector<uint8_t>::iterator first,
109  std::vector<uint8_t>::iterator last);
110 
118  template<typename T>
119  void writeValueAt(size_t dest_pos, T val) {
120  PktTransform::writeValueAt<T>(data_, dest_pos, val);
121  }
122 
123 private:
124  size_t transid_offset_;
125 
126 };
127 
128 typedef boost::shared_ptr<PerfPkt4> PerfPkt4Ptr;
129 
130 } // namespace perfdhcp
131 } // namespace isc
132 
133 #endif // PERF_PKT4_H
OptionBuffer data_
Unparsed data (in received packets).
Definition: pkt.h:312
boost::shared_ptr< LocalizedOption > LocalizedOptionPtr
Localized option pointer type.
Definition: perf_pkt4.h:46
void writeAt(size_t dest_pos, std::vector< uint8_t >::iterator first, std::vector< uint8_t >::iterator last)
Replace contents of buffer with data.
Definition: perf_pkt4.cc:55
bool rawPack()
Prepares on-wire format from raw buffer.
Definition: perf_pkt4.cc:31
boost::shared_ptr< PerfPkt4 > PerfPkt4Ptr
Definition: perf_pkt4.h:128
PerfPkt4 (DHCPv4 packet)
Definition: perf_pkt4.h:42
Defines the logger used by the top-level component of kea-dhcp-ddns.
Represents DHCPv4 packet.
Definition: pkt4.h:37
size_t getTransidOffset() const
Returns transaction id offset in packet buffer.
Definition: perf_pkt4.h:72
bool rawUnpack()
Handles limited binary packet parsing for packets with custom offsets of options and transaction ID...
Definition: perf_pkt4.cc:41
void writeValueAt(size_t dest_pos, T val)
Replace contents of buffer with value.
Definition: perf_pkt4.h:119
PerfPkt4(const uint8_t *buf, size_t len, size_t transid_offset=1, uint32_t transid=0)
Constructor, used to create messages from packet template files.
Definition: perf_pkt4.cc:21
size_t len()
Returns the size of the required buffer to build the packet.
Definition: pkt4.cc:75