Kea 1.5.0
perf_pkt4.h
Go to the documentation of this file.
1// Copyright (C) 2012-2015 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
10#include <time.h>
11#include <boost/shared_ptr.hpp>
12#include <dhcp/pkt4.h>
13
14#include "localized_option.h"
15#include "pkt_transform.h"
16
17namespace isc {
18namespace perfdhcp {
19
39
40class PerfPkt4 : public dhcp::Pkt4 {
41public:
42
44 typedef boost::shared_ptr<LocalizedOption> LocalizedOptionPtr;
45
62 PerfPkt4(const uint8_t* buf,
63 size_t len,
64 size_t transid_offset = 1,
65 uint32_t transid = 0);
66
70 size_t getTransidOffset() const { return transid_offset_; };
71
83 bool rawPack();
84
96 bool rawUnpack();
97
105 void writeAt(size_t dest_pos,
106 std::vector<uint8_t>::iterator first,
107 std::vector<uint8_t>::iterator last);
108
116 template<typename T>
117 void writeValueAt(size_t dest_pos, T val) {
118 PktTransform::writeValueAt<T>(data_, dest_pos, val);
119 }
120
121private:
122 size_t transid_offset_;
123
124};
125
126typedef boost::shared_ptr<PerfPkt4> PerfPkt4Ptr;
127
128} // namespace perfdhcp
129} // namespace isc
130
131#endif // PERF_PKT4_H
Represents DHCPv4 packet.
Definition: pkt4.h:38
size_t len()
Returns the size of the required buffer to build the packet.
Definition: pkt4.cc:75
OptionBuffer data_
Unparsed data (in received packets).
Definition: pkt.h:312
PerfPkt4 (DHCPv4 packet)
Definition: perf_pkt4.h:40
bool rawUnpack()
Handles limited binary packet parsing for packets with custom offsets of options and transaction ID.
Definition: perf_pkt4.cc:41
boost::shared_ptr< LocalizedOption > LocalizedOptionPtr
Localized option pointer type.
Definition: perf_pkt4.h:44
bool rawPack()
Prepares on-wire format from raw buffer.
Definition: perf_pkt4.cc:31
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
void writeValueAt(size_t dest_pos, T val)
Replace contents of buffer with value.
Definition: perf_pkt4.h:117
size_t getTransidOffset() const
Returns transaction id offset in packet buffer.
Definition: perf_pkt4.h:70
boost::shared_ptr< PerfPkt4 > PerfPkt4Ptr
Definition: perf_pkt4.h:126
Defines the logger used by the top-level component of kea-dhcp-ddns.