25 if (single_threaded_) {
28 if (run_flag_.test_and_set()) {
32 recv_thread_.reset(
new std::thread(std::bind(&Receiver::run,
this)));
37 if (single_threaded_) {
42 if (run_flag_.test_and_set()) {
50 if (single_threaded_) {
59 if (single_threaded_) {
61 return readPktFromSocket();
64 std::lock_guard<std::mutex> lock(pkt_queue_mutex_);
65 if (pkt_queue_.empty()) {
66 if (ip_version_ == 4) {
72 auto pkt = pkt_queue_.front();
80 if (single_threaded_) {
85 while (run_flag_.test_and_set()) {
91 }
catch (
const exception& e) {
92 cerr <<
"Something went wrong: " << e.what() << endl;
95 cerr <<
"Something went wrong" << endl;
101Receiver::readPktFromSocket() {
104 if (single_threaded_) {
114 if (ip_version_ == 4) {
120 cerr <<
"Failed to receive DHCP packet: " << e.what() << endl;
127Receiver::receivePackets() {
129 PktPtr pkt = readPktFromSocket();
138 std::lock_guard<std::mutex> lock(pkt_queue_mutex_);
139 pkt_queue_.push(pkt);
This is a base class for exceptions thrown from the DNS library module.
A generic exception that is thrown when an unexpected error condition occurs.
virtual dhcp::Pkt4Ptr receive4(uint32_t timeout_sec, uint32_t timeout_usec)=0
See description of this method in PerfSocket class below.
virtual dhcp::Pkt6Ptr receive6(uint32_t timeout_sec, uint32_t timeout_usec)=0
See description of this method in PerfSocket class below.
void start()
Start a receiving thread in multi-thread mode.
void stop()
Stop a receiving thread in multi-thread mode.
dhcp::PktPtr getPkt()
Get DHCP packet.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
Defines the logger used by the top-level component of kea-lfc.