From: JINMEI Tatuya Date: Sun, 1 Nov 2015 01:39:10 +0000 (+0900) Subject: [4108] extract packet processing of Dhcpv4Srv::run() into a new method. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a107ba0eaf00f6bcf2146392b2e68c3069317a1;p=thirdparty%2Fkea.git [4108] extract packet processing of Dhcpv4Srv::run() into a new method. the new one is named processPacket(). this is a trivial refactoring, intentionally not making any other editorial cleanups (such as indentation fixup). --- diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index e3e1e85ebb..2606714732 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -423,7 +423,6 @@ Dhcpv4Srv::run() { while (!shutdown_) { // client's message and server's response Pkt4Ptr query; - Pkt4Ptr rsp; try { uint32_t timeout = 1000; @@ -488,6 +487,16 @@ Dhcpv4Srv::run() { continue; } + processPacket(query); + } + + return (true); +} + +void +Dhcpv4Srv::processPacket(Pkt4Ptr& query) { + Pkt4Ptr rsp; + // Log reception of the packet. We need to increase it early, as any // failures in unpacking will cause the packet to be dropped. We // will increase type specific packets further down the road. @@ -561,7 +570,7 @@ Dhcpv4Srv::run() { static_cast(1)); isc::stats::StatsMgr::instance().addValue("pkt4-receive-drop", static_cast(1)); - continue; + return; } } @@ -579,7 +588,7 @@ Dhcpv4Srv::run() { // Increase the statistic of dropped packets. isc::stats::StatsMgr::instance().addValue("pkt4-receive-drop", static_cast(1)); - continue; + return; } // We have sanity checked (in accept() that the Message Type option @@ -616,7 +625,7 @@ Dhcpv4Srv::run() { if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) { LOG_DEBUG(hooks_logger, DBG_DHCP4_HOOKS, DHCP4_HOOK_PACKET_RCVD_SKIP) .arg(query->getLabel()); - continue; + return; } /// @todo: Add support for DROP status @@ -675,7 +684,7 @@ Dhcpv4Srv::run() { } if (!rsp) { - continue; + return; } @@ -748,7 +757,7 @@ Dhcpv4Srv::run() { LOG_DEBUG(hooks_logger, DBG_DHCP4_HOOKS, DHCP4_HOOK_BUFFER_SEND_SKIP) .arg(rsp->getLabel()); - continue; + return; } /// @todo: Add support for DROP status. @@ -782,9 +791,6 @@ Dhcpv4Srv::run() { .arg(rsp->getLabel()) .arg(e.what()); } - } - - return (true); } string diff --git a/src/bin/dhcp4/dhcp4_srv.h b/src/bin/dhcp4/dhcp4_srv.h index b8b1077402..62f0a855ca 100644 --- a/src/bin/dhcp4/dhcp4_srv.h +++ b/src/bin/dhcp4/dhcp4_srv.h @@ -209,6 +209,8 @@ public: /// critical error. bool run(); + void processPacket(Pkt4Ptr& packet); + /// @brief Instructs the server to shut down. void shutdown();