perf_pkt4.cc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright (C) 2012 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 <dhcp/libdhcp++.h>
  15. #include <dhcp/dhcp6.h>
  16. #include "perf_pkt4.h"
  17. #include "pkt_transform.h"
  18. using namespace std;
  19. using namespace isc;
  20. using namespace dhcp;
  21. namespace isc {
  22. namespace perfdhcp {
  23. PerfPkt4::PerfPkt4(const uint8_t* buf, size_t len) :
  24. Pkt4(buf, len),
  25. transid_offset_(1) {
  26. }
  27. PerfPkt4::PerfPkt4(const uint8_t* buf,
  28. size_t len,
  29. size_t transid_offset,
  30. uint32_t transid) :
  31. Pkt4(buf, len),
  32. transid_offset_(transid_offset) {
  33. transid_ = transid;
  34. }
  35. PerfPkt4::PerfPkt4(const uint8_t* buf, size_t len, size_t transid_offset) :
  36. Pkt4(buf, len),
  37. transid_offset_(transid_offset) {
  38. }
  39. bool
  40. PerfPkt4::rawPack() {
  41. return (PktTransform::pack(dhcp::Option::V4,
  42. data_,
  43. options_,
  44. transid_offset_,
  45. transid_,
  46. bufferOut_));
  47. }
  48. bool
  49. PerfPkt4::rawUnpack() {
  50. return (PktTransform::unpack(dhcp::Option::V4,
  51. data_,
  52. options_,
  53. transid_offset_,
  54. transid_));
  55. }
  56. } // namespace perfdhcp
  57. } // namespace isc