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 #include <config.h>
8
9 #include <perfdhcp/perf_pkt4.h>
10
11 #include <dhcp/libdhcp++.h>
12 #include <dhcp/dhcp4.h>
13
14 using namespace std;
15 using namespace isc;
16 using namespace dhcp;
17
18 namespace isc {
19 namespace perfdhcp {
20
PerfPkt4(const uint8_t * buf,size_t len,size_t transid_offset,uint32_t transid)21 PerfPkt4::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
30 bool
rawPack()31 PerfPkt4::rawPack() {
32 return (PktTransform::pack(dhcp::Option::V4,
33 data_,
34 options_,
35 getTransidOffset(),
36 getTransid(),
37 buffer_out_));
38 }
39
40 bool
rawUnpack()41 PerfPkt4::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
54 void
writeAt(size_t dest_pos,std::vector<uint8_t>::iterator first,std::vector<uint8_t>::iterator last)55 PerfPkt4::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
65