]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[4106_update] Addressed last comments
authorFrancis Dupont <fdupont@isc.org>
Thu, 16 Jun 2016 16:48:36 +0000 (18:48 +0200)
committerFrancis Dupont <fdupont@isc.org>
Thu, 16 Jun 2016 16:48:36 +0000 (18:48 +0200)
15 files changed:
src/bin/dhcp4/Makefile.am
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp4/dhcp4to6_ipc.cc [moved from src/bin/dhcp4/dhcp4_dhcp4o6_ipc.cc with 98% similarity]
src/bin/dhcp4/dhcp4to6_ipc.h [moved from src/bin/dhcp4/dhcp4_dhcp4o6_ipc.h with 93% similarity]
src/bin/dhcp4/tests/Makefile.am
src/bin/dhcp4/tests/dhcp4to6_ipc_unittest.cc [moved from src/bin/dhcp4/tests/dhcp4o6_ipc_unittest.cc with 99% similarity]
src/bin/dhcp6/Makefile.am
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/dhcp6to4_ipc.cc [moved from src/bin/dhcp6/dhcp6_dhcp4o6_ipc.cc with 98% similarity]
src/bin/dhcp6/dhcp6to4_ipc.h [moved from src/bin/dhcp6/dhcp6_dhcp4o6_ipc.h with 91% similarity]
src/bin/dhcp6/tests/Makefile.am
src/bin/dhcp6/tests/dhcp6to4_ipc_unittest.cc [moved from src/bin/dhcp6/tests/dhcp4o6_ipc_unittest.cc with 96% similarity]
src/lib/dhcpsrv/dhcp4o6_ipc.cc
src/lib/dhcpsrv/dhcp4o6_ipc.h

index 2b23bfa44731fc4d141cb52d45ca570fc14fc54c..f428d039d8728d2aef28f44218086b9a452ba3a9 100644 (file)
@@ -62,7 +62,7 @@ libdhcp4_la_SOURCES += ctrl_dhcp4_srv.cc ctrl_dhcp4_srv.h
 libdhcp4_la_SOURCES += json_config_parser.cc json_config_parser.h
 libdhcp4_la_SOURCES += dhcp4_log.cc dhcp4_log.h
 libdhcp4_la_SOURCES += dhcp4_srv.cc dhcp4_srv.h
-libdhcp4_la_SOURCES += dhcp4_dhcp4o6_ipc.cc dhcp4_dhcp4o6_ipc.h
+libdhcp4_la_SOURCES += dhcp4to6_ipc.cc dhcp4to6_ipc.h
 
 libdhcp4_la_SOURCES += kea_controller.cc
 
index 78eeec3a94a6b011e09a816952cb8edb766f5f11..4cd019a315a6236ae4f9986ad9c7b3bc5ea796d7 100644 (file)
@@ -8,7 +8,7 @@
 #include <cc/data.h>
 #include <dhcp4/ctrl_dhcp4_srv.h>
 #include <dhcp4/dhcp4_log.h>
-#include <dhcp4/dhcp4_dhcp4o6_ipc.h>
+#include <dhcp4/dhcp4to6_ipc.h>
 #include <hooks/hooks_manager.h>
 #include <dhcp4/json_config_parser.h>
 #include <dhcpsrv/cfgmgr.h>
similarity index 98%
rename from src/bin/dhcp4/dhcp4_dhcp4o6_ipc.cc
rename to src/bin/dhcp4/dhcp4to6_ipc.cc
index a8efe493fe78a77c0249d109cd0f7a4eb39b70d4..05598a15a53ee7ea89b40a68a438d556c9535d04 100644 (file)
@@ -9,7 +9,7 @@
 #include <util/buffer.h>
 #include <dhcp/iface_mgr.h>
 #include <dhcpsrv/cfgmgr.h>
-#include <dhcp4/dhcp4_dhcp4o6_ipc.h>
+#include <dhcp4/dhcp4to6_ipc.h>
 
 using namespace std;
 
similarity index 93%
rename from src/bin/dhcp4/dhcp4_dhcp4o6_ipc.h
rename to src/bin/dhcp4/dhcp4to6_ipc.h
index 7c9cee252fa91e49e5f731cb97bc8075e5c0bcbc..a643a043fd2e75fd28fa9cd0be01c70d27f44467 100644 (file)
@@ -4,10 +4,10 @@
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-#ifndef DHCP4_DHCP4O6_IPC_H
-#define DHCP4_DHCP4O6_IPC_H
+#ifndef DHCP4TO6_IPC_H
+#define DHCP4TO6_IPC_H
 
-/// @file dhcp4_dhcp4o6_ipc.h Defines the Dhcp4o6Ipc class.
+/// @file dhcp4to6_ipc.h Defines the Dhcp4o6Ipc class.
 /// This file defines the class Kea uses to act as the DHCPv4 server
 /// side of DHCPv4-over-DHCPv6 communication between servers.
 ///
index fde5f26d26e9e16e86d846b6df47d4f2a501a411..fae174cd5c726cd4bbc721e6ddaef8409d268af5 100644 (file)
@@ -93,7 +93,7 @@ dhcp4_unittests_SOURCES += release_unittest.cc
 dhcp4_unittests_SOURCES += out_of_range_unittest.cc
 dhcp4_unittests_SOURCES += decline_unittest.cc
 dhcp4_unittests_SOURCES += kea_controller_unittest.cc
-dhcp4_unittests_SOURCES += dhcp4o6_ipc_unittest.cc
+dhcp4_unittests_SOURCES += dhcp4to6_ipc_unittest.cc
 
 nodist_dhcp4_unittests_SOURCES = marker_file.h test_libraries.h
 
similarity index 99%
rename from src/bin/dhcp4/tests/dhcp4o6_ipc_unittest.cc
rename to src/bin/dhcp4/tests/dhcp4to6_ipc_unittest.cc
index df3c53e89cfe94129502b2172ab8c36efff51fe6..f5d7ac1fcbd5b5e58c1c8ea8ce5afe1e622d6ab0 100644 (file)
@@ -9,7 +9,7 @@
 #include <dhcp/pkt4o6.h>
 #include <dhcp/pkt6.h>
 #include <dhcp/tests/iface_mgr_test_config.h>
-#include <dhcp4/dhcp4_dhcp4o6_ipc.h>
+#include <dhcp4/dhcp4to6_ipc.h>
 #include <dhcpsrv/cfgmgr.h>
 #include <dhcpsrv/testutils/dhcp4o6_test_ipc.h>
 #include <gtest/gtest.h>
index ad82c4d8dd72c882e5b6a873d327b006230c61c3..f5426334a264842f9570c43dcc7474d34ce69bee 100644 (file)
@@ -63,7 +63,7 @@ libdhcp6_la_SOURCES += dhcp6_log.cc dhcp6_log.h
 libdhcp6_la_SOURCES += dhcp6_srv.cc dhcp6_srv.h
 libdhcp6_la_SOURCES += ctrl_dhcp6_srv.cc ctrl_dhcp6_srv.h
 libdhcp6_la_SOURCES += json_config_parser.cc json_config_parser.h
-libdhcp6_la_SOURCES += dhcp6_dhcp4o6_ipc.cc dhcp6_dhcp4o6_ipc.h
+libdhcp6_la_SOURCES += dhcp6to4_ipc.cc dhcp6to4_ipc.h
 
 libdhcp6_la_SOURCES += kea_controller.cc
 
index f546ad7c8024288f125d2a4dbe8aea97a56fc6b8..8a398209166d0ca51e56711d4f9629ebf15486d1 100644 (file)
@@ -11,7 +11,7 @@
 #include <dhcpsrv/cfgmgr.h>
 #include <dhcpsrv/cfg_db_access.h>
 #include <dhcp6/ctrl_dhcp6_srv.h>
-#include <dhcp6/dhcp6_dhcp4o6_ipc.h>
+#include <dhcp6/dhcp6to4_ipc.h>
 #include <dhcp6/dhcp6_log.h>
 #include <dhcp6/json_config_parser.h>
 #include <hooks/hooks_manager.h>
index 30f095ab2276d8665047334af6cb0bd7d4a80aed..c1453479d4e337133fa916d74f240448f67233ba 100644 (file)
@@ -25,7 +25,7 @@
 #include <dhcp/option_vendor_class.h>
 #include <dhcp/option_int_array.h>
 #include <dhcp/pkt6.h>
-#include <dhcp6/dhcp6_dhcp4o6_ipc.h>
+#include <dhcp6/dhcp6to4_ipc.h>
 #include <dhcp6/dhcp6_log.h>
 #include <dhcp6/dhcp6_srv.h>
 #include <dhcpsrv/callout_handle_store.h>
similarity index 98%
rename from src/bin/dhcp6/dhcp6_dhcp4o6_ipc.cc
rename to src/bin/dhcp6/dhcp6to4_ipc.cc
index f6975c190f8b03d2c0337f44d8de0030d1b820dc..f242f17a6cc59af85a5c9c07baeef0d0fd871a66 100644 (file)
@@ -9,7 +9,7 @@
 #include <util/buffer.h>
 #include <dhcp/iface_mgr.h>
 #include <dhcpsrv/cfgmgr.h>
-#include <dhcp6/dhcp6_dhcp4o6_ipc.h>
+#include <dhcp6/dhcp6to4_ipc.h>
 
 using namespace std;
 
similarity index 91%
rename from src/bin/dhcp6/dhcp6_dhcp4o6_ipc.h
rename to src/bin/dhcp6/dhcp6to4_ipc.h
index b53ee6377e83aeaa4a2f094202f25432213b4548..844033531b0dd5f7173308314c9226cf2a169e6f 100644 (file)
@@ -4,10 +4,10 @@
 // License, v. 2.0. If a copy of the MPL was not distributed with this
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-#ifndef DHCP6_DHCP4O6_IPC_H
-#define DHCP6_DHCP4O6_IPC_H
+#ifndef DHCP6TO4_IPC_H
+#define DHCP6TO4_IPC_H
 
-/// @file dhcp6_dhcp4o6_ipc.h Defines the Dhcp6to4Ipc class.
+/// @file dhcp6to4_ipc.h Defines the Dhcp6to4Ipc class.
 /// This file defines the class Kea uses to act as the DHCPv6 server
 /// side of DHCPv4-over-DHCPv6 communication between servers.
 ///
index 034b0f9535b4caffbe2d20aa5f8d1912ba726339..4471dac380fa8cfdab07a7935d1217110b773cc9 100644 (file)
@@ -95,7 +95,7 @@ dhcp6_unittests_SOURCES += infrequest_unittest.cc
 dhcp6_unittests_SOURCES += decline_unittest.cc
 dhcp6_unittests_SOURCES += dhcp6_message_test.cc dhcp6_message_test.h
 dhcp6_unittests_SOURCES += kea_controller_unittest.cc
-dhcp6_unittests_SOURCES += dhcp4o6_ipc_unittest.cc
+dhcp6_unittests_SOURCES += dhcp6to4_ipc_unittest.cc
 
 nodist_dhcp6_unittests_SOURCES  = marker_file.h test_libraries.h
 
similarity index 96%
rename from src/bin/dhcp6/tests/dhcp4o6_ipc_unittest.cc
rename to src/bin/dhcp6/tests/dhcp6to4_ipc_unittest.cc
index a88107ba3de77be43542405bff398eb57876319a..964586db5eead7f3379d1fc03be503177657e861 100644 (file)
@@ -10,7 +10,7 @@
 #include <dhcp/iface_mgr.h>
 #include <dhcp/tests/iface_mgr_test_config.h>
 #include <dhcp/tests/pkt_filter6_test_stub.h>
-#include <dhcp6/dhcp6_dhcp4o6_ipc.h>
+#include <dhcp6/dhcp6to4_ipc.h>
 #include <dhcpsrv/cfgmgr.h>
 #include <dhcpsrv/testutils/dhcp4o6_test_ipc.h>
 #include <gtest/gtest.h>
@@ -51,6 +51,9 @@ public:
 
     /// @brief Creates an instance of the DHCPv4o6 Message option.
     ///
+    /// The option will contain an empty DHCPREQUEST message, with
+    /// just the Message Type option inside and nothing else.
+    ///
     /// @return Pointer to the instance of the DHCPv4-query Message option.
     OptionPtr createDHCPv4MsgOption() const;
 
index c26283ea6522b85d2cc7b91359fead4d4e955678..43223a6096bf515c41f7e21621fffcf135cd5e7d 100644 (file)
 #include <dhcp/option_string.h>
 #include <dhcp/option_vendor.h>
 #include <dhcpsrv/dhcp4o6_ipc.h>
+#include <dhcpsrv/dhcpsrv_log.h>
+
 #include <boost/pointer_cast.hpp>
+
 #include <errno.h>
 #include <netinet/in.h>
 #include <sys/fcntl.h>
@@ -151,6 +154,8 @@ Pkt6Ptr Dhcp4o6IpcBase::receive() {
          
     // Vendor option must exist.
     if (!option_vendor) {
+        LOG_WARN(dhcpsrv_logger, DHCPSRV_DHCP4O6_RECEIVED_BAD_PACKET)
+            .arg("no ISC vendor option");
         isc_throw(Dhcp4o6IpcError, "option " << D6O_VENDOR_OPTS
                   << " with ISC enterprise id is not present in the DHCP4o6"
                   " message sent between the servers");
@@ -160,6 +165,8 @@ Pkt6Ptr Dhcp4o6IpcBase::receive() {
     OptionStringPtr ifname = boost::dynamic_pointer_cast<
         OptionString>(option_vendor->getOption(ISC_V6_4O6_INTERFACE));
     if (!ifname) {
+        LOG_WARN(dhcpsrv_logger, DHCPSRV_DHCP4O6_RECEIVED_BAD_PACKET)
+            .arg("no interface suboption");
         isc_throw(Dhcp4o6IpcError, "option " << D6O_VENDOR_OPTS
                   << " doesn't contain the " << ISC_V6_4O6_INTERFACE
                   << " option required in the DHCP4o6 message sent"
@@ -169,6 +176,8 @@ Pkt6Ptr Dhcp4o6IpcBase::receive() {
     // Check if this interface is present in the system.
     IfacePtr iface = IfaceMgr::instance().getIface(ifname->getValue());
     if (!iface) {
+        LOG_WARN(dhcpsrv_logger, DHCPSRV_DHCP4O6_RECEIVED_BAD_PACKET)
+            .arg("can't get interface " + ifname->getValue());
         isc_throw(Dhcp4o6IpcError, "option " << ISC_V6_4O6_INTERFACE
                   << " sent in the DHCP4o6 message contains non-existing"
                   " interface name '" << ifname->getValue() << "'");
@@ -178,6 +187,8 @@ Pkt6Ptr Dhcp4o6IpcBase::receive() {
     OptionCustomPtr srcs = boost::dynamic_pointer_cast<
         OptionCustom>(option_vendor->getOption(ISC_V6_4O6_SRC_ADDRESS));
     if (!srcs) {
+        LOG_WARN(dhcpsrv_logger, DHCPSRV_DHCP4O6_RECEIVED_BAD_PACKET)
+            .arg("no source address suboption");
         isc_throw(Dhcp4o6IpcError, "option " << D6O_VENDOR_OPTS
                   << " doesn't contain the " << ISC_V6_4O6_SRC_ADDRESS
                   << " option required in the DHCP4o6 message sent"
index 580cc2e6bfff8e166200b5a4d283cb5e410e3481..fd7c4d8c1603b92ce653ad5f341323a91bb53289 100644 (file)
@@ -84,6 +84,7 @@ protected:
     /// @param endpoint_type Endpoint type (DHCPv4 or DHCPv6 server).
     ///
     /// @return New socket descriptor.
+    /// @throw isc::dhcp::Dhcp4o6IpcError on system call errors.
     int open(uint16_t port, EndpointType endpoint_type);
 
 public:
@@ -98,6 +99,8 @@ public:
     ///
     /// @return a pointer to a DHCPv6 message with interface and remote
     /// address set from the IPC message
+    /// @throw isc::dhcp::Dhcp4o6IpcError on system call error or
+    /// malformed packets.
     Pkt6Ptr receive();
 
     /// @brief Send message over IPC.
@@ -110,6 +113,7 @@ public:
     ///
     /// @param pkt Pointer to a DHCPv6 message with interface and remote
     /// address.
+    /// @throw isc::dhcp::Dhcp4o6IpcError.
     void send(const Pkt6Ptr& pkt);
 
 protected: