]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[4108] extract packet processing of Dhcpv4Srv::run() into a new method.
authorJINMEI Tatuya <jinmei@wide.ad.jp>
Sun, 1 Nov 2015 01:39:10 +0000 (10:39 +0900)
committerJINMEI Tatuya <jinmei@wide.ad.jp>
Sun, 1 Nov 2015 01:39:10 +0000 (10:39 +0900)
the new one is named processPacket().  this is a trivial refactoring,
intentionally not making any other editorial cleanups (such as indentation
fixup).

src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/dhcp4_srv.h

index e3e1e85ebbf312a8d1359d97a099a9a82b199431..2606714732733e649b93e7b30923fb29379bd260 100644 (file)
@@ -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<int64_t>(1));
                 isc::stats::StatsMgr::instance().addValue("pkt4-receive-drop",
                                                           static_cast<int64_t>(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<int64_t>(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
index b8b1077402c048ccb6351e3ee5477bf5e17a20ce..62f0a855ca2d1e289a938976dda8738ea355af8d 100644 (file)
@@ -209,6 +209,8 @@ public:
     ///         critical error.
     bool run();
 
+    void processPacket(Pkt4Ptr& packet);
+
     /// @brief Instructs the server to shut down.
     void shutdown();