} 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
#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>
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.
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_;
///
/// 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.
void receivePackets();
/// \brief Read a packet directly from the socket.
- PktPtr readPktFromSocket();
+ dhcp::PktPtr readPktFromSocket();
};
}
HWAddrPtr& storage);
};
+/// @brief A pointer to either Pkt4 or Pkt6 packet
+typedef boost::shared_ptr<isc::dhcp::Pkt> PktPtr;
+
}; // namespace isc::dhcp
}; // namespace isc