Kea 2.5.8
receiver.h
Go to the documentation of this file.
1// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef PERFDHCP_RECEIVER_H
8#define PERFDHCP_RECEIVER_H
9
12
13#include <dhcp/pkt.h>
14
15#include <queue>
16#include <thread>
17#include <mutex>
18#include <atomic>
19
20namespace isc {
21namespace perfdhcp {
22
34class Receiver {
35private:
37 std::atomic_flag run_flag_;
38
40 std::unique_ptr<std::thread> recv_thread_;
41
43 std::queue<dhcp::PktPtr> pkt_queue_;
44
46 std::mutex pkt_queue_mutex_;
47
48 BasePerfSocket &socket_;
49
51 bool single_threaded_;
52
53 uint8_t ip_version_;
54
55public:
61 Receiver(BasePerfSocket &socket, bool single_threaded, uint8_t ip_version) :
62 socket_(socket),
63 single_threaded_(single_threaded),
64 ip_version_(ip_version) {
65 run_flag_.clear();
66 }
67
69 ~Receiver();
70
74 void start();
75
79 void stop();
80
86
87private:
89 void run();
90
94 void receivePackets();
95
97 dhcp::PktPtr readPktFromSocket();
98};
99
100}
101}
102
103#endif /* PERFDHCP_RECEIVER_H */
Socket wrapper structure.
Definition: perf_socket.h:26
A receiving DHCP packets class.
Definition: receiver.h:34
void start()
Start a receiving thread in multi-thread mode.
Definition: receiver.cc:24
Receiver(BasePerfSocket &socket, bool single_threaded, uint8_t ip_version)
Receiver constructor.
Definition: receiver.h:61
void stop()
Stop a receiving thread in multi-thread mode.
Definition: receiver.cc:36
~Receiver()
Destructor.
Definition: receiver.cc:49
dhcp::PktPtr getPkt()
Get DHCP packet.
Definition: receiver.cc:58
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
Definition: pkt.h:982
Defines the logger used by the top-level component of kea-lfc.