pkt4o6.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright (C) 2015 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. #ifndef PKT4O6_H
  15. #define PKT4O6_H
  16. #include <dhcp/pkt4.h>
  17. #include <dhcp/pkt6.h>
  18. #include <boost/shared_ptr.hpp>
  19. namespace isc {
  20. namespace dhcp {
  21. /// @brief Represents DHCPv4-over-DHCPv6 packet
  22. ///
  23. /// This class derives from @c Pkt4 in order to be handled by
  24. /// the DHCPv4 server code. It includes a shared pointer to the
  25. /// DHCPv6 message too.
  26. class Pkt4o6 : public Pkt4 {
  27. public:
  28. /// @brief Constructor, used in message reception.
  29. ///
  30. /// @param pkt4 DHCPv4 message
  31. /// @param pkt6 encapsulating unpacked DHCPv6 message
  32. /// the DHCPv4 message option will be removed
  33. Pkt4o6(const OptionBuffer& pkt4, const Pkt6Ptr& pkt6);
  34. /// @brief Constructor, used in replying to a message
  35. ///
  36. /// @param pkt4 DHCPv4 message
  37. /// @param pkt6 DHCPv6 message
  38. Pkt4o6(const Pkt4Ptr& pkt4, const Pkt6Ptr& pkt6);
  39. /// @brief Returns encapsulating DHCPv6 message
  40. Pkt6Ptr getPkt6() const { return (pkt6_); }
  41. /// @brief Prepares on-wire format of DHCPv4-over-DHCPv6 packet.
  42. ///
  43. /// Calls pack() on both DHCPv4 and DHCPv6 parts
  44. /// Inserts the DHCPv4-message option
  45. /// @ref pkt4::pack and @ref pkt6::pack
  46. virtual void pack();
  47. /// @brief Checks if a DHCPv4 message has beeb transported over DHCPv6
  48. ///
  49. /// @return Boolean value which indicates whether the message is
  50. /// transported over DHCPv6 (true) or native DHCPv4 (false)
  51. virtual bool isDhcp4o6() const {
  52. return (true);
  53. }
  54. protected:
  55. /// Encapsulating DHCPv6 message
  56. Pkt6Ptr pkt6_;
  57. }; // Pkt4o6 class
  58. /// @brief A pointer to Pkt4o6 object.
  59. typedef boost::shared_ptr<Pkt4o6> Pkt4o6Ptr;
  60. } // isc::dhcp namespace
  61. } // isc namespace
  62. #endif