]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#283,!135] Changes after review: PktPtr moved to dhcp/pkt.h
authorTomek Mrugalski <tomasz@isc.org>
Tue, 15 Jan 2019 13:21:30 +0000 (14:21 +0100)
committerMichal Nowikowski <godfryd@isc.org>
Fri, 18 Jan 2019 09:05:12 +0000 (10:05 +0100)
src/bin/perfdhcp/receiver.cc
src/bin/perfdhcp/receiver.h
src/lib/dhcp/pkt.h

index 1eb5d9f28418d048865e3be887c4bd964ef85733..adbf905c85ca8469b14bf74ddc1009e3c548293e 100644 (file)
@@ -118,14 +118,14 @@ Receiver::readPktFromSocket() {
     } catch (const Exception& e) {
         cerr << "Failed to receive DHCP packet: " << e.what() << endl;
     }
-    if (!pkt) {
-        return nullptr;
+
+    if (pkt) {
+        /// @todo: Add packet exception handling here. Right now any
+        /// malformed packet will cause perfdhcp to abort.
+        pkt->unpack();
     }
 
-    /// @todo: Add packet exception handling here. Right now any
-    /// malformed packet will cause perfdhcp to abort.
-    pkt->unpack();
-    return pkt;
+    return (pkt);
 }
 
 void
index a2ed33360eefdf62045f643fb88bc877c5d7eda6..482972c7561133fd577fc8616a2a3239cf4d2bc6 100644 (file)
@@ -10,8 +10,7 @@
 #include <perfdhcp/better_socket.h>
 #include <perfdhcp/command_options.h>
 
-#include <dhcp/pkt4.h>
-#include <dhcp/pkt6.h>
+#include <dhcp/pkt.h>
 #include <util/threads/thread.h>
 
 #include <queue>
@@ -22,8 +21,6 @@
 namespace isc {
 namespace perfdhcp {
 
-typedef boost::shared_ptr<isc::dhcp::Pkt> PktPtr;
-
 /// \brief A receviving DHCP packets class.
 ///
 /// Receiver can be used in two modes: single-thread and multi-thread.
@@ -48,7 +45,7 @@ private:
     std::unique_ptr<util::thread::Thread> recv_thread_;
 
     /// \brief Queue for passing packets from receiver thread to main thread.
-    std::queue<PktPtr> pkt_queue_;
+    std::queue<dhcp::PktPtr> pkt_queue_;
 
     /// \brief Mutex for controlling access to the queue.
     std::mutex pkt_queue_mutex_;
@@ -82,7 +79,7 @@ public:
     ///
     /// In single-thread mode it reads directly from the socket.
     /// In multi-thread mode it reads packets from the queue.
-    PktPtr getPkt();
+    dhcp::PktPtr getPkt();
 
 private:
     /// \brief Receiving thread main function.
@@ -94,7 +91,7 @@ private:
     void receivePackets();
 
     /// \brief Read a packet directly from the socket.
-    PktPtr readPktFromSocket();
+    dhcp::PktPtr readPktFromSocket();
 };
 
 }
index 53ab96a6c7fe219d96c7d3c97035a3e68eaa53a2..cf90eb40732319efa55c16570e118d927b7b8e41 100644 (file)
@@ -785,6 +785,9 @@ private:
                                  HWAddrPtr& storage);
 };
 
+/// @brief A pointer to either Pkt4 or Pkt6 packet
+typedef boost::shared_ptr<isc::dhcp::Pkt> PktPtr;
+
 }; // namespace isc::dhcp
 }; // namespace isc