pkt4o6.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. ///
  27. /// This is an implementation of the DHCPv4-query/response DHCPv6 messages
  28. /// defined in RFC 7341 (http://ietf.org/rfc/rfc7341.txt).
  29. /// See also http://kea.isc.org/wiki/Dhcp4o6Design for design discussions.
  30. class Pkt4o6 : public Pkt4 {
  31. public:
  32. /// @brief Constructor, used in message reception.
  33. ///
  34. /// @param pkt4 Content of the DHCPv4-message option
  35. /// @param pkt6 encapsulating unpacked DHCPv6 message
  36. /// the DHCPv4 message option will be removed
  37. Pkt4o6(const OptionBuffer& pkt4, const Pkt6Ptr& pkt6);
  38. /// @brief Constructor, used in replying to a message
  39. ///
  40. /// @param pkt4 DHCPv4 message
  41. /// @param pkt6 DHCPv6 message
  42. Pkt4o6(const Pkt4Ptr& pkt4, const Pkt6Ptr& pkt6);
  43. /// @brief Returns encapsulating DHCPv6 message
  44. Pkt6Ptr getPkt6() const { return (pkt6_); }
  45. /// @brief Prepares on-wire format of DHCPv4-over-DHCPv6 packet.
  46. ///
  47. /// Calls pack() on both DHCPv4 and DHCPv6 parts
  48. /// Inserts the DHCPv4-message option
  49. /// @ref Pkt4::pack and @ref Pkt6::pack
  50. virtual void pack();
  51. /// @brief Checks if a DHCPv4 message has been transported over DHCPv6
  52. ///
  53. /// @return Boolean value which indicates whether the message is
  54. /// transported over DHCPv6 (true) or native DHCPv4 (false)
  55. virtual bool isDhcp4o6() const {
  56. return (true);
  57. }
  58. private:
  59. /// Encapsulating DHCPv6 message
  60. Pkt6Ptr pkt6_;
  61. }; // Pkt4o6 class
  62. /// @brief A pointer to Pkt4o6 object.
  63. typedef boost::shared_ptr<Pkt4o6> Pkt4o6Ptr;
  64. } // isc::dhcp namespace
  65. } // isc namespace
  66. #endif