mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 14:05:33 +00:00
[4027] incorporated part of c0044e3 from fd4o6 branch
(not cherry-picking it because the commit has other irrelevant changes)
This commit is contained in:
@@ -13,20 +13,17 @@
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
#include <config.h>
|
||||
#include <asiolink/io_address.h>
|
||||
#include <dhcp/dhcp4.h>
|
||||
#include <dhcp/libdhcp++.h>
|
||||
#include <dhcp/option_int.h>
|
||||
|
||||
#include <dhcp/dhcp6.h>
|
||||
#include <dhcp/option.h>
|
||||
#include <dhcp/pkt4o6.h>
|
||||
#include <exceptions/exceptions.h>
|
||||
#include <util/buffer.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
using namespace isc::dhcp;
|
||||
using namespace isc::asiolink;
|
||||
using namespace isc::dhcp;
|
||||
using namespace isc::util;
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -37,14 +34,29 @@ const IOAddress DEFAULT_ADDRESS("0.0.0.0");
|
||||
namespace isc {
|
||||
namespace dhcp {
|
||||
|
||||
Pkt4o6::Pkt4o6(const uint8_t* data, size_t len, const Pkt6Ptr& pkt6)
|
||||
:Pkt4(data, len), pkt6_(pkt6)
|
||||
Pkt4o6::Pkt4o6(const OptionBuffer& pkt4, const Pkt6Ptr& pkt6)
|
||||
:Pkt4(&pkt4[0], pkt4.size()), pkt6_(pkt6)
|
||||
{
|
||||
static_cast<void>(pkt6->delOption(D6O_DHCPV4_MSG));
|
||||
setIface(pkt6->getIface());
|
||||
setIndex(pkt6->getIndex());
|
||||
setRemoteAddr(pkt6->getRemoteAddr());
|
||||
}
|
||||
|
||||
Pkt4o6::Pkt4o6(const Pkt4Ptr& pkt4, const Pkt6Ptr& pkt6)
|
||||
:Pkt4(*pkt4), pkt6_(pkt6) {
|
||||
}
|
||||
|
||||
void Pkt4o6::pack() {
|
||||
Pkt4::pack();
|
||||
OutputBuffer& buf = getBuffer();
|
||||
const uint8_t* ptr = static_cast<const uint8_t*>(buf.getData());
|
||||
OptionBuffer msg(ptr, ptr + buf.getLength());
|
||||
OptionPtr dhcp4_msg(new Option(Option::V6, D6O_DHCPV4_MSG, msg));
|
||||
pkt6_->addOption(dhcp4_msg);
|
||||
pkt6_->pack();
|
||||
}
|
||||
|
||||
} // end of namespace isc::dhcp
|
||||
|
||||
} // end of namespace isc
|
||||
|
@@ -34,13 +34,34 @@ public:
|
||||
|
||||
/// @brief Constructor, used in message reception.
|
||||
///
|
||||
/// @param data pointer to received data
|
||||
/// @param len size of buffer to be allocated for this packet
|
||||
/// @param pkt6 encapsulating DHCPv6 message.
|
||||
Pkt4o6(const uint8_t* data, size_t len, const Pkt6Ptr& pkt6);
|
||||
/// @param pkt4 DHCPv4 message
|
||||
/// @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);
|
||||
|
||||
/// @brief Returns encapsulating DHCPv6 message
|
||||
const Pkt6Ptr& getPkt6() { return (pkt6_); }
|
||||
const Pkt6Ptr& getPkt6() const { return (pkt6_); }
|
||||
|
||||
/// @brief Prepares on-wire format of DHCPv4-over-DHCPv6 packet.
|
||||
///
|
||||
/// Calls pack() on both DHCPv4 and DHCPv6 parts
|
||||
/// Inserts the DHCPv4-message option
|
||||
/// @ref pkt4::pack and @ref pkt6::pack
|
||||
virtual void pack();
|
||||
|
||||
/// @brief Checks if a DHCPv4 message has beeb transported over DHCPv6
|
||||
///
|
||||
/// @return Boolean value which indicates whether the message is
|
||||
/// transported over DHCPv6 (true) or native DHCPv4 (false)
|
||||
virtual bool isDhcp4o6() const {
|
||||
return (true);
|
||||
}
|
||||
|
||||
protected:
|
||||
/// Encapsulating DHCPv6 message
|
||||
|
Reference in New Issue
Block a user