Commit 7e4953a9 authored by Francis Dupont's avatar Francis Dupont

[5404] Finished 4o6 code

parent 4fb30e28
......@@ -176,11 +176,11 @@ a client's error or a server's purged database.
% DHCP4_DHCP4O6_BAD_PACKET received malformed DHCPv4o6 packet: %1
A malformed DHCPv4o6 packet was received.
% DHCP4_DHCP4O6_PACKET_SEND %1: trying to send packet %2 (type %3) to %4 on interface %5 encapsulating %6: %7 (type %8)
% DHCP4_DHCP4O6_PACKET_SEND %1: trying to send packet %2 (type %3) to %4 port %5 on interface %6 encapsulating %7: %8 (type %9)
The arguments specify the client identification information (HW address
and client identifier), DHCPv6 message name and type, source IPv6
address and interface name, DHCPv4 client identification, message
name and type.
address and port, and interface name, DHCPv4 client identification,
message name and type.
% DHCP4_DHCP4O6_PACKET_SEND_FAIL %1: failed to send DHCPv4o6 packet: %2
This error is output if the IPv4 DHCP server fails to send an
......@@ -693,6 +693,6 @@ and will send DHCPNAK if the received message was DHCPREQUEST.
The argument includes the client and the transaction identification
information.
% DHCP6_DHCP4O6_PACKET_RECEIVED received DHCPv4o6 packet from DHCPv6 server (type %1) for %2 on interface %3
% DHCP6_DHCP4O6_PACKET_RECEIVED received DHCPv4o6 packet from DHCPv6 server (type %1) for %2 port %3 on interface %4
This debug message is printed when the server is receiving a DHCPv4o6
from the DHCPv6 server over inter-process communication.
......@@ -205,10 +205,11 @@ Dhcpv4Exchange::initResponse4o6() {
if (!query6->relay_info_.empty()) {
resp6->copyRelayInfo(query6);
}
// Copy interface and remote address
// Copy interface, and remote address and port
resp6->setIface(query6->getIface());
resp6->setIndex(query6->getIndex());
resp6->setRemoteAddr(query6->getRemoteAddr());
resp6->setRemotePort(query6->getRemotePort());
resp_.reset(new Pkt4o6(resp_, resp6));
}
......
......@@ -66,6 +66,7 @@ void Dhcp4to6Ipc::handler() {
LOG_DEBUG(packet4_logger, DBG_DHCP4_BASIC, DHCP6_DHCP4O6_PACKET_RECEIVED)
.arg(static_cast<int>(pkt->getType()))
.arg(pkt->getRemoteAddr().toText())
.arg(pkt->getRemotePort())
.arg(pkt->getIface());
}
} catch (const std::exception& e) {
......@@ -156,6 +157,7 @@ void Dhcp4to6Ipc::handler() {
.arg(rsp6->getName())
.arg(static_cast<int>(rsp6->getType()))
.arg(rsp6->getRemoteAddr())
.arg(rsp6->getRemotePort())
.arg(rsp6->getIface())
.arg(rsp->getLabel())
.arg(rsp->getName())
......
......@@ -205,7 +205,7 @@ received in Decline message. It's expected that the option will contain an
address that is being declined. Specific information will be printed in a
separate message.
% DHCP6_DHCP4O6_PACKET_RECEIVED received DHCPv4o6 packet from DHCPv4 server (type %1) for %2 on interface %3
% DHCP6_DHCP4O6_PACKET_RECEIVED received DHCPv4o6 packet from DHCPv4 server (type %1) for %2 port %3 on interface %4
This debug message is printed when the server is receiving a DHCPv4o6
from the DHCPv4 server over inter-process communication.
......
......@@ -64,6 +64,7 @@ void Dhcp6to4Ipc::handler() {
LOG_DEBUG(packet6_logger, DBG_DHCP6_BASIC, DHCP6_DHCP4O6_PACKET_RECEIVED)
.arg(static_cast<int>(pkt->getType()))
.arg(pkt->getRemoteAddr().toText())
.arg(pkt->getRemotePort())
.arg(pkt->getIface());
}
} catch (const std::exception& e) {
......@@ -77,6 +78,9 @@ void Dhcp6to4Ipc::handler() {
// Should we check it is a DHCPV6_DHCPV4_RESPONSE?
// Handle relay port
uint16_t relay_port = Dhcpv6Srv::testRelaySourcePort(pkt);
// The received message has been unpacked by the receive() function. This
// method could have modified the message so it's better to pack() it
// again because we'll be forwarding it to a client.
......@@ -89,7 +93,6 @@ void Dhcp6to4Ipc::handler() {
// getType() always returns the type of internal message.
uint8_t msg_type = buf[0];
if ((msg_type == DHCPV6_RELAY_FORW) || (msg_type == DHCPV6_RELAY_REPL)) {
uint16_t relay_port = Dhcpv6Srv::testRelaySourcePort(pkt);
pkt->setRemotePort(relay_port ? relay_port : DHCP6_SERVER_PORT);
} else {
pkt->setRemotePort(DHCP6_CLIENT_PORT);
......
......@@ -193,21 +193,19 @@ Pkt6Ptr Dhcp4o6IpcBase::receive() {
}
// Get the option holding source port.
OptionPtr sport = option_vendor->getOption(ISC_V6_4O6_SRC_PORT);
if (!sport || (sport->len() - sport->getHeaderLen() != 2)) {
OptionUint16Ptr sport = boost::dynamic_pointer_cast<
OptionUint16>(option_vendor->getOption(ISC_V6_4O6_SRC_PORT));
if (!sport) {
LOG_WARN(dhcpsrv_logger, DHCPSRV_DHCP4O6_RECEIVED_BAD_PACKET)
.arg("no source port suboption");
isc_throw(Dhcp4o6IpcError,
"malformed packet (source port suboption missing "
"or has incorrect length)");
"or has incorrect type)");
}
const OptionBuffer& sport_buf = sport->getData();
uint16_t sport_value = static_cast<uint16_t>(sport_buf[0]) << 8;
sport_value |= static_cast<uint16_t>(sport_buf[1]);
// Update the packet.
pkt->setRemoteAddr(srcs->readAddress());
pkt->setRemotePort(sport_value);
pkt->setRemotePort(sport->getValue());
pkt->setIface(iface->getName());
pkt->setIndex(iface->getIndex());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment