Kea 2.7.5
|
Read and write raw data to DHCP packets. More...
#include <pkt_transform.h>
Static Public Member Functions | |
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. | |
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. | |
template<typename T > | |
static void | writeValueAt (dhcp::OptionBuffer &in_buffer, size_t dest_pos, T val) |
Replace contents of one vector with uint16 value. | |
Read and write raw data to DHCP packets.
This class provides static functions to read/write raw data from/to the packet buffer. When reading data with the unpack() method, the corresponding options objects are updated. When writing to the packet buffer with pack(), options objects carry input data to be written.
This class is used both by PerfPkt4 and PerfPkt6 classes in case DHCP packets are created from template files. In this case, some of the template packet's options are replaced before sending it to the server. Offset of specific options are provided from the command line by the perfdhcp tool user, and passed in an options collection.
Definition at line 31 of file pkt_transform.h.
|
static |
Prepares on-wire format from raw buffer.
The method copies the input buffer and options contents to the output buffer. The input buffer must contain whole initial packet data. Parts of this data will be overridden by options data specified in an options collection. Such options must have their offsets within a packet specified (see LocalizedOption to find out how to specify options offset).
universe | Universe used, V4 or V6 |
in_buffer | Input buffer holding initial packet data, this can be directly read from template file |
options | Options collection with offsets |
transid_offset | offset of transaction id in a packet, transaction ID will be written to output buffer at this offset |
transid | Transaction ID value |
out_buffer | Output buffer holding "packed" data |
Definition at line 29 of file pkt_transform.cc.
References isc::dhcp::Option::V4, and isc::dhcp::Option::V6.
Referenced by isc::perfdhcp::PerfPkt4::rawPack(), and isc::perfdhcp::PerfPkt6::rawPack().
|
static |
Handles selective binary packet parsing.
This method handles the parsing of packets that have non-default options or transaction ID offsets. The client class has to use isc::dhcp::Pkt6::addOption to specify which options to parse. Each option should be of the isc::perfdhcp::LocalizedOption type with the offset value specified.
universe | universe used, V4 or V6 |
in_buffer | input buffer to be parsed |
options | options collection with options offsets |
transid_offset | offset of transaction id in input buffer |
transid | transaction id value read from input buffer |
Definition at line 72 of file pkt_transform.cc.
References isc::perfdhcp::ExchangeStats::malformed_pkts_, and isc::dhcp::Option::V6.
Referenced by isc::perfdhcp::PerfPkt4::rawUnpack(), and isc::perfdhcp::PerfPkt6::rawUnpack().
|
static |
Replace contents of buffer with vector.
Function replaces data of the buffer with data from vector.
in_buffer | destination buffer. |
dest_pos | position in destination buffer. |
first | beginning of data range in source vector. |
last | end of data range in source vector. |
Definition at line 212 of file pkt_transform.cc.
Referenced by isc::perfdhcp::PerfPkt4::writeAt(), and isc::perfdhcp::PerfPkt6::writeAt().
|
inlinestatic |
Replace contents of one vector with uint16 value.
Function replaces data inside one vector with uint16_t value.
in_buffer | destination buffer. |
dest_pos | position in destination buffer. |
val | value to be written. |
Definition at line 107 of file pkt_transform.h.