pkt4o6.h 2.64 KB
Newer Older
1
// Copyright (C) 2015-2016 Internet Systems Consortium, Inc. ("ISC")
2
//
3 4 5
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

#ifndef PKT4O6_H
#define PKT4O6_H

#include <dhcp/pkt4.h>
#include <dhcp/pkt6.h>

#include <boost/shared_ptr.hpp>

namespace isc {

namespace dhcp {

/// @brief Represents DHCPv4-over-DHCPv6 packet
///
/// This class derives from @c Pkt4 in order to be handled by
/// the DHCPv4 server code. It includes a shared pointer to the
/// DHCPv6 message too.
JINMEI Tatuya's avatar
JINMEI Tatuya committed
24 25 26
///
/// This is an implementation of the DHCPv4-query/response DHCPv6 messages
/// defined in RFC 7341 (http://ietf.org/rfc/rfc7341.txt).
27
/// See also http://oldkea.isc.org/wiki/Dhcp4o6Design for design discussions.
28 29 30 31 32
class Pkt4o6 : public Pkt4 {
public:

    /// @brief Constructor, used in message reception.
    ///
Tomek Mrugalski's avatar
Tomek Mrugalski committed
33
    /// @param pkt4 Content of the DHCPv4-message option
34 35 36 37 38 39 40 41 42
    /// @param pkt6 encapsulating unpacked DHCPv6 message
    /// the DHCPv4 message option will be removed
    Pkt4o6(const OptionBuffer& pkt4, const Pkt6Ptr& pkt6);

    /// @brief Constructor, used in replying to a message
    ///
    /// @param pkt4 DHCPv4 message
    /// @param pkt6 DHCPv6 message
    Pkt4o6(const Pkt4Ptr& pkt4, const Pkt6Ptr& pkt6);
43 44

    /// @brief Returns encapsulating DHCPv6 message
45
    Pkt6Ptr getPkt6() const { return (pkt6_); }
46 47 48 49 50

    /// @brief Prepares on-wire format of DHCPv4-over-DHCPv6 packet.
    ///
    /// Calls pack() on both DHCPv4 and DHCPv6 parts
    /// Inserts the DHCPv4-message option
Tomek Mrugalski's avatar
Tomek Mrugalski committed
51
    /// @ref Pkt4::pack and @ref Pkt6::pack
52 53
    virtual void pack();

Tomek Mrugalski's avatar
Tomek Mrugalski committed
54
    /// @brief Checks if a DHCPv4 message has been transported over DHCPv6
55 56 57 58 59 60
    ///
    /// @return Boolean value which indicates whether the message is
    /// transported over DHCPv6 (true) or native DHCPv4 (false)
    virtual bool isDhcp4o6() const {
        return (true);
    }
61

62 63 64 65 66 67 68 69 70 71 72
    /// @brief Overrides the @ref Pkt::setCopyRetrievedOptions to also
    /// set the flag for encapsulated @ref Pkt6 instance.
    ///
    /// When the flag is set for the instance of the @ref Pkt4o6 the
    /// encapsulated Pkt6, retrieved with @ref Pkt4o6::getPkt6, will
    /// inherit this setting.
    ///
    /// @param copy Indicates if the options should be copied when
    /// retrieved (if true), or not copied (if false).
    virtual void setCopyRetrievedOptions(const bool copy);

73
private:
74
    /// Encapsulating DHCPv6 message
75
    Pkt6Ptr pkt6_;
76 77 78 79 80 81 82 83 84 85 86

}; // Pkt4o6 class

/// @brief A pointer to Pkt4o6 object.
typedef boost::shared_ptr<Pkt4o6> Pkt4o6Ptr;

} // isc::dhcp namespace

} // isc namespace

#endif