Kea 2.7.6
pkt4o6.cc
Go to the documentation of this file.
1// Copyright (C) 2015-2024 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
9#include <dhcp/dhcp6.h>
10#include <dhcp/option.h>
11#include <dhcp/pkt4o6.h>
13#include <util/buffer.h>
14
15using namespace isc::asiolink;
16using namespace isc::dhcp;
17using namespace isc::util;
18using namespace std;
19
20namespace isc {
21namespace dhcp {
22
23Pkt4o6::Pkt4o6(const OptionBuffer& pkt4, const Pkt6Ptr& pkt6)
24 :Pkt4(&pkt4[0], pkt4.size()), pkt6_(pkt6)
25{
26 static_cast<void>(pkt6->delOption(D6O_DHCPV4_MSG));
27 setIface(pkt6->getIface());
28 setIndex(pkt6->getIndex());
29 setRemoteAddr(pkt6->getRemoteAddr());
30}
31
32Pkt4o6::Pkt4o6(const Pkt4Ptr& pkt4, const Pkt6Ptr& pkt6)
33 :Pkt4(*pkt4), pkt6_(pkt6) {
34}
35
37 // Convert wire-format Pkt4 data in the form of OptionBuffer.
38 Pkt4::pack();
39 const OptionBuffer& msg = getBuffer().getVector();
40
41 // Build the DHCPv4 Message option for the DHCPv6 message, and pack the
42 // entire stuff.
43 OptionPtr dhcp4_msg(new Option(Option::V6, D6O_DHCPV4_MSG, msg));
44 pkt6_->addOption(dhcp4_msg);
45 pkt6_->pack();
46}
47
48void
51 // Copy the new setting to the encapsulated instance of Pkt6.
52 pkt6_->setCopyRetrievedOptions(copy);
53}
54
55
56} // end of namespace isc::dhcp
57
58} // end of namespace isc
Represents DHCPv4 packet.
Definition pkt4.h:37
virtual void pack()
Prepares on-wire format of DHCPv4 packet.
Definition pkt4.cc:71
Pkt4o6(const OptionBuffer &pkt4, const Pkt6Ptr &pkt6)
Constructor, used in message reception.
Definition pkt4o6.cc:23
virtual void pack()
Prepares on-wire format of DHCPv4-over-DHCPv6 packet.
Definition pkt4o6.cc:36
virtual void setCopyRetrievedOptions(const bool copy)
Overrides the Pkt::setCopyRetrievedOptions to also set the flag for encapsulated Pkt6 instance.
Definition pkt4o6.cc:49
void setIface(const std::string &iface)
Sets interface name.
Definition pkt.h:702
isc::util::OutputBuffer & getBuffer()
Returns reference to output buffer.
Definition pkt.h:245
void setIndex(const unsigned int ifindex)
Sets interface index.
Definition pkt.h:663
virtual void setCopyRetrievedOptions(const bool copy)
Controls whether the option retrieved by the Pkt::getOption should be copied before being returned.
Definition pkt.h:497
void setRemoteAddr(const isc::asiolink::IOAddress &remote)
Sets remote IP address.
Definition pkt.h:598
const std::vector< uint8_t > & getVector() const
Return the buffer.
Definition buffer.h:433
@ D6O_DHCPV4_MSG
Definition dhcp6.h:107
ElementPtr copy(ConstElementPtr from, int level)
Copy the data up to a nesting level.
Definition data.cc:1420
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
Definition pkt4.h:555
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
Definition pkt6.h:31
std::vector< uint8_t > OptionBuffer
buffer types used in DHCP code.
Definition option.h:24
boost::shared_ptr< Option > OptionPtr
Definition option.h:37
Defines the logger used by the top-level component of kea-lfc.