]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#447] exception for incorrect pkt in perfdhcp
authorWlodek Wencel <wlodek@isc.org>
Mon, 18 May 2020 15:09:20 +0000 (17:09 +0200)
committerWlodzimierz Wencel <wlodek@isc.org>
Fri, 22 May 2020 15:37:16 +0000 (15:37 +0000)
src/bin/perfdhcp/perf_socket.cc

index 2beb7a7713d545a3c799f14de302eb40e864a268..129d1ae5bdbf210ea31ba8bc2032af373f63eeb3 100644 (file)
@@ -150,9 +150,12 @@ Pkt4Ptr
 PerfSocket::receive4(uint32_t timeout_sec, uint32_t timeout_usec) {
     Pkt4Ptr pkt = IfaceMgr::instance().receive4(timeout_sec, timeout_usec);
     if (pkt) {
-        /// @todo: Add packet exception handling here. Right now any
-        /// malformed packet will cause perfdhcp to abort.
-        pkt->unpack();
+       try {
+            pkt->unpack();
+       } catch (const std::exception &e) {
+               std::cout << "Incorrect DHCP packet received"
+                         << e.what() << std::endl;
+       }
     }
     return (pkt);
 }
@@ -161,9 +164,12 @@ Pkt6Ptr
 PerfSocket::receive6(uint32_t timeout_sec, uint32_t timeout_usec) {
     Pkt6Ptr pkt = IfaceMgr::instance().receive6(timeout_sec, timeout_usec);
     if (pkt) {
-        /// @todo: Add packet exception handling here. Right now any
-        /// malformed packet will cause perfdhcp to abort.
-        pkt->unpack();
+        try {
+            pkt->unpack();
+        } catch (const std::exception &e) {
+                std::cout << "Incorrect DHCP packet received"
+                          << e.what() << std::endl;
+        }
     }
     return (pkt);
 }