perf_pkt4.cc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #include <iostream>
  15. #include <exceptions/exceptions.h>
  16. #include <dhcp/libdhcp++.h>
  17. #include <dhcp/dhcp6.h>
  18. #include "perf_pkt4.h"
  19. #include "pkt_transform.h"
  20. using namespace std;
  21. using namespace isc;
  22. using namespace dhcp;
  23. namespace isc {
  24. namespace perfdhcp {
  25. PerfPkt4::PerfPkt4(const uint8_t* buf, uint32_t len, size_t transid_offset, uint32_t transid) :
  26. Pkt4(buf, len),
  27. transid_offset_(transid_offset) {
  28. transid_ = transid;
  29. }
  30. PerfPkt4::PerfPkt4(const uint8_t* buf, uint32_t len, size_t transid_offset) :
  31. Pkt4(buf, len),
  32. transid_offset_(transid_offset) {
  33. }
  34. bool
  35. PerfPkt4::rawPack() {
  36. return (PktTransform::pack(dhcp::Option::V4,
  37. data_,
  38. options_,
  39. transid_offset_,
  40. transid_,
  41. bufferOut_));
  42. }
  43. bool
  44. PerfPkt4::rawUnpack() {
  45. return (PktTransform::unpack(dhcp::Option::V4,
  46. data_,
  47. options_,
  48. transid_offset_,
  49. transid_));
  50. }
  51. } // namespace perfdhcp
  52. } // namespace isc