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()) {
49 Receiver::~Receiver() {
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;
101 Receiver::readPktFromSocket() {
104 if (single_threaded_) {
114 if (ip_version_ == 4) {
115 pkt = socket_.receive4(0, timeout);
117 pkt = socket_.receive6(0, timeout);
119 }
catch (
const Exception& e) {
120 cerr <<
"Failed to receive DHCP packet: " << e.what() << endl;
127 Receiver::receivePackets() {
129 PktPtr pkt = readPktFromSocket();
138 std::lock_guard<std::mutex> lock(pkt_queue_mutex_);
139 pkt_queue_.push(pkt);
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
A generic exception that is thrown when an unexpected error condition occurs.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
Defines the logger used by the top-level component of kea-dhcp-ddns.