perf_pkt6.cc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_pkt6.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. PerfPkt6::PerfPkt6(const uint8_t* buf,
  26. size_t len,
  27. size_t transid_offset,
  28. uint32_t transid) :
  29. Pkt6(buf, len, Pkt6::UDP),
  30. transid_offset_(transid_offset) {
  31. transid_ = transid;
  32. }
  33. bool
  34. PerfPkt6::rawPack() {
  35. return (PktTransform::pack(dhcp::Option::V6,
  36. data_,
  37. options_,
  38. transid_offset_,
  39. transid_,
  40. bufferOut_));
  41. }
  42. bool
  43. PerfPkt6::rawUnpack() {
  44. return (PktTransform::unpack(dhcp::Option::V6,
  45. data_,
  46. options_,
  47. transid_offset_,
  48. transid_));
  49. }
  50. } // namespace perfdhcp
  51. } // namespace isc