Kea 2.7.6
pkt_transform.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 PKT_TRANSFORM_H
8#define PKT_TRANSFORM_H
9
11
12#include <dhcp/option.h>
13
14namespace isc {
15namespace perfdhcp {
16
32public:
33
59 static bool pack(const dhcp::Option::Universe universe,
60 const dhcp::OptionBuffer& in_buffer,
61 const dhcp::OptionCollection& options,
62 const size_t transid_offset,
63 const uint32_t transid,
64 util::OutputBuffer& out_buffer);
65
81 static bool unpack(const dhcp::Option::Universe universe,
82 const dhcp::OptionBuffer& in_buffer,
83 const dhcp::OptionCollection& options,
84 const size_t transid_offset,
85 uint32_t& transid);
86
95 static void writeAt(dhcp::OptionBuffer& in_buffer, size_t dest_pos,
96 std::vector<uint8_t>::iterator first,
97 std::vector<uint8_t>::iterator last);
98
106 template<typename T>
107 static void writeValueAt(dhcp::OptionBuffer& in_buffer, size_t dest_pos,
108 T val) {
109 // @todo consider replacing the loop with switch statement
110 // checking sizeof(T).
111 for (int i = 0; i < sizeof(T); ++i) {
112 in_buffer[dest_pos + i] = (val >> 8 * (sizeof(T) - i - 1)) & 0xFF;
113 }
114 }
115
116private:
129 static void packOptions(const dhcp::OptionBuffer& in_buffer,
130 const dhcp::OptionCollection& options,
131 util::OutputBuffer& out_buffer);
132
153 static void unpackOptions(const dhcp::OptionBuffer& in_buffer,
154 const dhcp::OptionCollection& options);
155
156};
157
158} // namespace perfdhcp
159} // namespace isc
160
161#endif // PKT_TRANSFORM_H
Universe
defines option universe DHCPv4 or DHCPv6
Definition option.h:90
Read and write raw data to DHCP packets.
static void writeValueAt(dhcp::OptionBuffer &in_buffer, size_t dest_pos, T val)
Replace contents of one vector with uint16 value.
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.
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.
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.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
Definition buffer.h:343
std::multimap< unsigned int, OptionPtr > OptionCollection
A collection of DHCP (v4 or v6) options.
Definition option.h:40
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
Definition option.h:24
Defines the logger used by the top-level component of kea-lfc.