diff options
author | JINMEI Tatuya <jinmei@wide.ad.jp> | 2015-10-31 05:29:05 +0100 |
---|---|---|
committer | JINMEI Tatuya <jinmei@wide.ad.jp> | 2015-10-31 05:29:05 +0100 |
commit | 72ba32da5f6a946ca7f131a450663cb345dd51cc (patch) | |
tree | 99ddba376d7549e053dc0f8a2042acc2f892cf70 /src/lib/dhcp/pkt4o6.cc | |
parent | [fd4o6] Added DHCPv4-over-DHCPv6 packet class (diff) | |
download | kea-72ba32da5f6a946ca7f131a450663cb345dd51cc.tar.xz kea-72ba32da5f6a946ca7f131a450663cb345dd51cc.zip |
[4027] incorporated part of c0044e3 from fd4o6 branch
(not cherry-picking it because the commit has other irrelevant changes)
Diffstat (limited to 'src/lib/dhcp/pkt4o6.cc')
-rw-r--r-- | src/lib/dhcp/pkt4o6.cc | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/lib/dhcp/pkt4o6.cc b/src/lib/dhcp/pkt4o6.cc index f328e82f7d..7fb087a6e3 100644 --- a/src/lib/dhcp/pkt4o6.cc +++ b/src/lib/dhcp/pkt4o6.cc @@ -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 |