]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1147] Split processPacket
authorFrancis Dupont <fdupont@isc.org>
Sat, 9 May 2020 12:44:22 +0000 (14:44 +0200)
committerFrancis Dupont <fdupont@isc.org>
Tue, 26 May 2020 09:51:57 +0000 (11:51 +0200)
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/dhcp4_srv.h
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/dhcp6_srv.h

index cac51e8bf9f161b12e1cc11be5629e0912b00a19..e33e7de9cb2ae6a920b083994ab333b88e0ff5ef 100644 (file)
@@ -1238,6 +1238,31 @@ Dhcpv4Srv::processPacket(Pkt4Ptr& query, Pkt4Ptr& rsp, bool allow_packet_park) {
         }
     }
 
+    processDhcp4Query(query, rsp, allow_packet_park);
+}
+
+void
+Dhcpv4Srv::processDhcp4QueryAndSendResponse(Pkt4Ptr& query, Pkt4Ptr& rsp,
+                                            bool allow_packet_park) {
+    try {
+        processDhcp4Query(query, rsp, allow_packet_park);
+        if (!rsp) {
+            return;
+        }
+
+        CalloutHandlePtr callout_handle = getCalloutHandle(query);
+        processPacketBufferSend(callout_handle, rsp);
+    } catch (const std::exception& e) {
+        LOG_ERROR(packet4_logger, DHCP4_PACKET_PROCESS_STD_EXCEPTION)
+            .arg(e.what());
+    } catch (...) {
+        LOG_ERROR(packet4_logger, DHCP4_PACKET_PROCESS_EXCEPTION);
+    }
+}
+
+void
+Dhcpv4Srv::processDhcp4Query(Pkt4Ptr& query, Pkt4Ptr& rsp,
+                             bool allow_packet_park) {
     AllocEngine::ClientContext4Ptr ctx;
 
     try {
index b8ae7787578ad4128d77dc523addf61a4c4062a2..fdddf9746ad88aeaa225f1466a5c3efc1b4a8970 100644 (file)
@@ -327,7 +327,7 @@ public:
 
     /// @brief Process a single incoming DHCPv4 packet and sends the response.
     ///
-    /// It verifies correctness of the passed packet, call per-type processXXX
+    /// It verifies correctness of the passed packet, calls per-type processXXX
     /// methods, generates appropriate answer, sends the answer to the client.
     ///
     /// @param query A pointer to the packet to be processed.
@@ -335,7 +335,7 @@ public:
 
     /// @brief Process a single incoming DHCPv4 packet and sends the response.
     ///
-    /// It verifies correctness of the passed packet, call per-type processXXX
+    /// It verifies correctness of the passed packet, calls per-type processXXX
     /// methods, generates appropriate answer, sends the answer to the client.
     ///
     /// @param query A pointer to the packet to be processed.
@@ -345,21 +345,42 @@ public:
     ///
     /// @param callout_handle pointer to the callout handle.
     /// @param query A pointer to the packet to be processed.
-    /// @param rsp A pointer to the response
+    /// @param rsp A pointer to the response.
     void sendResponseNoThrow(hooks::CalloutHandlePtr& callout_handle,
                              Pkt4Ptr& query, Pkt4Ptr& rsp);
 
     /// @brief Process a single incoming DHCPv4 packet.
     ///
-    /// It verifies correctness of the passed packet, call per-type processXXX
+    /// It verifies correctness of the passed packet, calls per-type processXXX
     /// methods, generates appropriate answer.
     ///
     /// @param query A pointer to the packet to be processed.
-    /// @param rsp A pointer to the response
+    /// @param rsp A pointer to the response.
     /// @param allow_packet_park Indicates if parking a packet is allowed.
     void processPacket(Pkt4Ptr& query, Pkt4Ptr& rsp,
                        bool allow_packet_park = true);
 
+    /// @brief Process a single incoming DHCPv4 query.
+    ///
+    /// It calls per-type processXXX methods, generates appropriate answer.
+    ///
+    /// @param query A pointer to the packet to be processed.
+    /// @param rsp A pointer to the response.
+    /// @param allow_packet_park Indicates if parking a packet is allowed.
+    void processDhcp4Query(Pkt4Ptr& query, Pkt4Ptr& rsp,
+                           bool allow_packet_park);
+
+    /// @brief Process a single incoming DHCPv4 query.
+    ///
+    /// It calls per-type processXXX methods, generates appropriate answer,
+    /// sends the answer to the client.
+    ///
+    /// @param query A pointer to the packet to be processed.
+    /// @param rsp A pointer to the response.
+    /// @param allow_packet_park Indicates if parking a packet is allowed.
+    void processDhcp4QueryAndSendResponse(Pkt4Ptr& query, Pkt4Ptr& rsp,
+                                          bool allow_packet_park);
+
     /// @brief Instructs the server to shut down.
     void shutdown();
 
index 6338288c939e7abc86e4c2e3f8ef27bc8129a3e6..cf673b0e8ea7408c592ecc7841017015be80b1b9 100644 (file)
@@ -816,6 +816,29 @@ Dhcpv6Srv::processPacket(Pkt6Ptr& query, Pkt6Ptr& rsp) {
         return;
     }
 
+    processDhcp6Query(query, rsp);
+}
+
+void
+Dhcpv6Srv::processDhcp6QueryAndSendResponse(Pkt6Ptr& query, Pkt6Ptr& rsp) {
+    try {
+        processDhcp6Query(query, rsp);
+        if (!rsp) {
+            return;
+        }
+
+        CalloutHandlePtr callout_handle = getCalloutHandle(query);
+        processPacketBufferSend(callout_handle, rsp);
+    } catch (const std::exception& e) {
+        LOG_ERROR(packet6_logger, DHCP6_PACKET_PROCESS_STD_EXCEPTION)
+            .arg(e.what());
+    } catch (...) {
+        LOG_ERROR(packet6_logger, DHCP6_PACKET_PROCESS_EXCEPTION);
+    }
+}
+
+void
+Dhcpv6Srv::processDhcp6Query(Pkt6Ptr& query, Pkt6Ptr& rsp) {
     // Create a client race avoidance RAII handler.
     ClientHandler client_handler;
     bool drop = false;
index a7de75fae8fc375e1979c7d751a60c3f72e53052..6845921bbcbfdeafe6cbc735ff4401aef15cb362 100644 (file)
@@ -151,7 +151,7 @@ public:
 
     /// @brief Process a single incoming DHCPv6 packet and sends the response.
     ///
-    /// It verifies correctness of the passed packet, call per-type processXXX
+    /// It verifies correctness of the passed packet, calls per-type processXXX
     /// methods, generates appropriate answer, sends the answer to the client.
     ///
     /// @param query A pointer to the packet to be processed.
@@ -159,7 +159,7 @@ public:
 
     /// @brief Process a single incoming DHCPv6 packet and sends the response.
     ///
-    /// It verifies correctness of the passed packet, call per-type processXXX
+    /// It verifies correctness of the passed packet, calls per-type processXXX
     /// methods, generates appropriate answer, sends the answer to the client.
     ///
     /// @param query A pointer to the packet to be processed.
@@ -169,19 +169,36 @@ public:
     ///
     /// @param callout_handle pointer to the callout handle.
     /// @param query A pointer to the packet to be processed.
-    /// @param rsp A pointer to the response
+    /// @param rsp A pointer to the response.
     void sendResponseNoThrow(hooks::CalloutHandlePtr& callout_handle,
                              Pkt6Ptr& query, Pkt6Ptr& rsp);
 
     /// @brief Process a single incoming DHCPv6 packet.
     ///
-    /// It verifies correctness of the passed packet, call per-type processXXX
+    /// It verifies correctness of the passed packet, calls per-type processXXX
     /// methods, generates appropriate answer.
     ///
     /// @param query A pointer to the packet to be processed.
-    /// @param rsp A pointer to the response
+    /// @param rsp A pointer to the response.
     void processPacket(Pkt6Ptr& query, Pkt6Ptr& rsp);
 
+    /// @brief Process a single incoming DHCPv6 query.
+    ///
+    /// It calls per-type processXXX methods, generates appropriate answer.
+    ///
+    /// @param query A pointer to the packet to be processed.
+    /// @param rsp A pointer to the response.
+    void processDhcp6Query(Pkt6Ptr& query, Pkt6Ptr& rsp);
+
+    /// @brief Process a single incoming DHCPv6 query.
+    ///
+    /// It calls per-type processXXX methods, generates appropriate answer,
+    /// sends the answer to the client.
+    ///
+    /// @param query A pointer to the packet to be processed.
+    /// @param rsp A pointer to the response.
+    void processDhcp6QueryAndSendResponse(Pkt6Ptr& query, Pkt6Ptr& rsp);
+
     /// @brief Instructs the server to shut down.
     void shutdown();