From: Francis Dupont Date: Thu, 16 Jun 2016 16:48:36 +0000 (+0200) Subject: [4106_update] Addressed last comments X-Git-Tag: trac4109a_base~2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=828ef3991e964ed792a7f895bb126c0860fdb411;p=thirdparty%2Fkea.git [4106_update] Addressed last comments --- diff --git a/src/bin/dhcp4/Makefile.am b/src/bin/dhcp4/Makefile.am index 2b23bfa447..f428d039d8 100644 --- a/src/bin/dhcp4/Makefile.am +++ b/src/bin/dhcp4/Makefile.am @@ -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 diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index 78eeec3a94..4cd019a315 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/bin/dhcp4/dhcp4_dhcp4o6_ipc.cc b/src/bin/dhcp4/dhcp4to6_ipc.cc similarity index 98% rename from src/bin/dhcp4/dhcp4_dhcp4o6_ipc.cc rename to src/bin/dhcp4/dhcp4to6_ipc.cc index a8efe493fe..05598a15a5 100644 --- a/src/bin/dhcp4/dhcp4_dhcp4o6_ipc.cc +++ b/src/bin/dhcp4/dhcp4to6_ipc.cc @@ -9,7 +9,7 @@ #include #include #include -#include +#include using namespace std; diff --git a/src/bin/dhcp4/dhcp4_dhcp4o6_ipc.h b/src/bin/dhcp4/dhcp4to6_ipc.h similarity index 93% rename from src/bin/dhcp4/dhcp4_dhcp4o6_ipc.h rename to src/bin/dhcp4/dhcp4to6_ipc.h index 7c9cee252f..a643a043fd 100644 --- a/src/bin/dhcp4/dhcp4_dhcp4o6_ipc.h +++ b/src/bin/dhcp4/dhcp4to6_ipc.h @@ -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. /// diff --git a/src/bin/dhcp4/tests/Makefile.am b/src/bin/dhcp4/tests/Makefile.am index fde5f26d26..fae174cd5c 100644 --- a/src/bin/dhcp4/tests/Makefile.am +++ b/src/bin/dhcp4/tests/Makefile.am @@ -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 diff --git a/src/bin/dhcp4/tests/dhcp4o6_ipc_unittest.cc b/src/bin/dhcp4/tests/dhcp4to6_ipc_unittest.cc similarity index 99% rename from src/bin/dhcp4/tests/dhcp4o6_ipc_unittest.cc rename to src/bin/dhcp4/tests/dhcp4to6_ipc_unittest.cc index df3c53e89c..f5d7ac1fcb 100644 --- a/src/bin/dhcp4/tests/dhcp4o6_ipc_unittest.cc +++ b/src/bin/dhcp4/tests/dhcp4to6_ipc_unittest.cc @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/bin/dhcp6/Makefile.am b/src/bin/dhcp6/Makefile.am index ad82c4d8dd..f5426334a2 100644 --- a/src/bin/dhcp6/Makefile.am +++ b/src/bin/dhcp6/Makefile.am @@ -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 diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index f546ad7c80..8a39820916 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 30f095ab22..c1453479d4 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/bin/dhcp6/dhcp6_dhcp4o6_ipc.cc b/src/bin/dhcp6/dhcp6to4_ipc.cc similarity index 98% rename from src/bin/dhcp6/dhcp6_dhcp4o6_ipc.cc rename to src/bin/dhcp6/dhcp6to4_ipc.cc index f6975c190f..f242f17a6c 100644 --- a/src/bin/dhcp6/dhcp6_dhcp4o6_ipc.cc +++ b/src/bin/dhcp6/dhcp6to4_ipc.cc @@ -9,7 +9,7 @@ #include #include #include -#include +#include using namespace std; diff --git a/src/bin/dhcp6/dhcp6_dhcp4o6_ipc.h b/src/bin/dhcp6/dhcp6to4_ipc.h similarity index 91% rename from src/bin/dhcp6/dhcp6_dhcp4o6_ipc.h rename to src/bin/dhcp6/dhcp6to4_ipc.h index b53ee6377e..844033531b 100644 --- a/src/bin/dhcp6/dhcp6_dhcp4o6_ipc.h +++ b/src/bin/dhcp6/dhcp6to4_ipc.h @@ -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. /// diff --git a/src/bin/dhcp6/tests/Makefile.am b/src/bin/dhcp6/tests/Makefile.am index 034b0f9535..4471dac380 100644 --- a/src/bin/dhcp6/tests/Makefile.am +++ b/src/bin/dhcp6/tests/Makefile.am @@ -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 diff --git a/src/bin/dhcp6/tests/dhcp4o6_ipc_unittest.cc b/src/bin/dhcp6/tests/dhcp6to4_ipc_unittest.cc similarity index 96% rename from src/bin/dhcp6/tests/dhcp4o6_ipc_unittest.cc rename to src/bin/dhcp6/tests/dhcp6to4_ipc_unittest.cc index a88107ba3d..964586db5e 100644 --- a/src/bin/dhcp6/tests/dhcp4o6_ipc_unittest.cc +++ b/src/bin/dhcp6/tests/dhcp6to4_ipc_unittest.cc @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -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; diff --git a/src/lib/dhcpsrv/dhcp4o6_ipc.cc b/src/lib/dhcpsrv/dhcp4o6_ipc.cc index c26283ea65..43223a6096 100644 --- a/src/lib/dhcpsrv/dhcp4o6_ipc.cc +++ b/src/lib/dhcpsrv/dhcp4o6_ipc.cc @@ -13,7 +13,10 @@ #include #include #include +#include + #include + #include #include #include @@ -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" diff --git a/src/lib/dhcpsrv/dhcp4o6_ipc.h b/src/lib/dhcpsrv/dhcp4o6_ipc.h index 580cc2e6bf..fd7c4d8c16 100644 --- a/src/lib/dhcpsrv/dhcp4o6_ipc.h +++ b/src/lib/dhcpsrv/dhcp4o6_ipc.h @@ -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: