perf_pkt4.cc 1.62 KB
Newer Older
1
// Copyright (C) 2012, 2015 Internet Systems Consortium, Inc. ("ISC")
2
//
3 4 5
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6

7 8
#include <config.h>

9
#include <dhcp/libdhcp++.h>
10
#include <dhcp/dhcp4.h>
11 12 13 14 15 16 17 18 19 20

#include "perf_pkt4.h"

using namespace std;
using namespace isc;
using namespace dhcp;

namespace isc {
namespace perfdhcp {

21 22 23 24
PerfPkt4::PerfPkt4(const uint8_t* buf,
                   size_t len,
                   size_t transid_offset,
                   uint32_t transid) :
25 26
    Pkt4(buf, len),
    transid_offset_(transid_offset) {
27
    setTransid(transid);
28 29 30 31
}

bool
PerfPkt4::rawPack() {
32 33 34
    return (PktTransform::pack(dhcp::Option::V4,
                               data_,
                               options_,
35 36
                               getTransidOffset(),
                               getTransid(),
Tomek Mrugalski's avatar
Tomek Mrugalski committed
37
                               buffer_out_));
38 39 40 41
}

bool
PerfPkt4::rawUnpack() {
42 43 44 45 46 47 48 49 50 51
    uint32_t transid = getTransid();
    bool res = PktTransform::unpack(dhcp::Option::V4,
                                    data_,
                                    options_,
                                    getTransidOffset(),
                                    transid);
    if (res) {
        setTransid(transid);
    }
    return (res);
52 53
}

54 55 56 57 58 59 60 61 62
void
PerfPkt4::writeAt(size_t dest_pos,
                  std::vector<uint8_t>::iterator first,
                  std::vector<uint8_t>::iterator last) {
    return (PktTransform::writeAt(data_, dest_pos, first, last));
}



63 64
} // namespace perfdhcp
} // namespace isc