Kea: perf_pkt4.cc Source File

| Kea 3.2.0-git

perf_pkt4.cc
Go to the documentation of this file.
1// Copyright (C) 2012-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#include <config.h>
8
9#include <perfdhcp/perf_pkt4.h>
10
11#include <dhcp/libdhcp++.h>
12#include <dhcp/dhcp4.h>
13
14using namespace std;
15using namespace isc;
16using namespace dhcp;
17
18namespace isc {
19namespace perfdhcp {
20
21PerfPkt4::PerfPkt4(const uint8_t* buf,
22 size_t len,
23 size_t transid_offset,
24 uint32_t transid) :
25 Pkt4(buf, len),
26 transid_offset_(transid_offset) {
27 setTransid(transid);
28}
29
30bool
31PerfPkt4::rawPack() {
32 return (PktTransform::pack(dhcp::Option::V4,
33 data_,
34 options_,
35 getTransidOffset(),
36 getTransid(),
37 buffer_out_));
38}
39
40bool
41PerfPkt4::rawUnpack() {
42 uint32_t transid = getTransid();
43 bool res = PktTransform::unpack(dhcp::Option::V4,
44 data_,
45 options_,
46 getTransidOffset(),
47 transid);
48 if (res) {
49 setTransid(transid);
50 }
51 return (res);
52}
53
54void
55PerfPkt4::writeAt(size_t dest_pos,
56 std::vector<uint8_t>::iterator first,
57 std::vector<uint8_t>::iterator last) {
58 return (PktTransform::writeAt(data_, dest_pos, first, last));
59}
60
61
62
63} // namespace perfdhcp
64} // namespace isc
isc::dhcp::Option::V4
@ V4
Definition option.h:90
isc::dhcp::Pkt4::Pkt4
Pkt4(uint8_t msg_type, uint32_t transid)
Constructor, used in replying to a message.
Definition pkt4.cc:34
isc::dhcp::Pkt4::len
size_t len()
Returns the size of the required buffer to build the packet.
Definition pkt4.cc:61
isc::dhcp::Pkt::data_
OptionBuffer data_
Unparsed data (in received packets).
Definition pkt.h:415
isc::dhcp::Pkt::getTransid
uint32_t getTransid() const
Returns value of transaction-id field.
Definition pkt.h:342
isc::dhcp::Pkt::options_
isc::dhcp::OptionCollection options_
Collection of options present in this message.
Definition pkt.h:813
isc::dhcp::Pkt::buffer_out_
isc::util::OutputBuffer buffer_out_
Output buffer (used during message transmission).
Definition pkt.h:963
isc::dhcp::Pkt::setTransid
void setTransid(uint32_t transid)
Sets transaction-id value.
Definition pkt.h:335
isc::perfdhcp::PerfPkt4::rawUnpack
bool rawUnpack()
Handles limited binary packet parsing for packets with custom offsets of options and transaction ID.
Definition perf_pkt4.cc:41
isc::perfdhcp::PerfPkt4::rawPack
bool rawPack()
Prepares on-wire format from raw buffer.
Definition perf_pkt4.cc:31
isc::perfdhcp::PerfPkt4::writeAt
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
isc::perfdhcp::PerfPkt4::PerfPkt4
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
isc::perfdhcp::PerfPkt4::getTransidOffset
size_t getTransidOffset() const
Returns transaction id offset in packet buffer.
Definition perf_pkt4.h:72
isc::perfdhcp::PktTransform::unpack
static bool unpack(const dhcp::Option::Universe universe, const dhcp::OptionBuffer &in_buffer, const dhcp::OptionCollection &options, const size_t transid_offset, uint32_t &transid)
Handles selective binary packet parsing.
Definition pkt_transform.cc:72
isc::perfdhcp::PktTransform::writeAt
static void writeAt(dhcp::OptionBuffer &in_buffer, size_t dest_pos, std::vector< uint8_t >::iterator first, std::vector< uint8_t >::iterator last)
Replace contents of buffer with vector.
Definition pkt_transform.cc:212
isc::perfdhcp::PktTransform::pack
static bool pack(const dhcp::Option::Universe universe, const dhcp::OptionBuffer &in_buffer, const dhcp::OptionCollection &options, const size_t transid_offset, const uint32_t transid, util::OutputBuffer &out_buffer)
Prepares on-wire format from raw buffer.
Definition pkt_transform.cc:29
dhcp4.h
libdhcp++.h
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::perfdhcp
Definition abstract_scen.h:15
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
perf_pkt4.h