]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5404] Finished 4o6 code
authorFrancis Dupont <fdupont@isc.org>
Sat, 23 Dec 2017 21:59:15 +0000 (22:59 +0100)
committerFrancis Dupont <fdupont@isc.org>
Sat, 23 Dec 2017 21:59:15 +0000 (22:59 +0100)
src/bin/dhcp4/dhcp4_messages.mes
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/dhcp4to6_ipc.cc
src/bin/dhcp6/dhcp6_messages.mes
src/bin/dhcp6/dhcp6to4_ipc.cc
src/lib/dhcpsrv/dhcp4o6_ipc.cc

index 05426d29e7a0cf3f56a3a8b5846fe21479200edc..ddcb93bb138d6dbc2671d386f2897a495bd7154e 100644 (file)
@@ -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.
index a834e30987827a14f5a09a5abe44217464890bcf..7bfcb39d1798f72e2914c28c560b081c656a2d3f 100644 (file)
@@ -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));
 }
 
index b21920726552923e99288edbb3005d522a1c1c0c..f3cfb2bdf1981b477553f4a4d2db557541df17ca 100644 (file)
@@ -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())
index 0d6c9caebe892e93ddd4261d678ec869610e3672..8a8173c504a43b6e796ed7133f0f745fbc31a5c8 100644 (file)
@@ -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.
 
index 71759732f37970194a0867ff08cd6ee86c42864d..a3fa09120ed0eac18797cbb9f23d783d43a8e87d 100644 (file)
@@ -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);
index 031c805956e50029e34936626e43aa6190327067..e3f23fc1f1815bebb8cafe68a8a8005e81e67b75 100644 (file)
@@ -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());