Kea: receiver.h Source File

| Kea 3.0.2-git

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
10#include <perfdhcp/perf_socket.h>
11#include <perfdhcp/command_options.h>
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
34 class 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
85 dhcp::PktPtr getPkt();
86
87private:
89 void run();
90
94 void receivePackets();
95
97 dhcp::PktPtr readPktFromSocket();
98};
99
100}
101}
102
103#endif /* PERFDHCP_RECEIVER_H */
isc::perfdhcp::BasePerfSocket
Socket wrapper structure.
Definition perf_socket.h:26
isc::perfdhcp::Receiver::start
void start()
Start a receiving thread in multi-thread mode.
Definition receiver.cc:24
isc::perfdhcp::Receiver::Receiver
Receiver(BasePerfSocket &socket, bool single_threaded, uint8_t ip_version)
Receiver constructor.
Definition receiver.h:61
isc::perfdhcp::Receiver::stop
void stop()
Stop a receiving thread in multi-thread mode.
Definition receiver.cc:36
isc::perfdhcp::Receiver::~Receiver
~Receiver()
Destructor.
Definition receiver.cc:49
isc::perfdhcp::Receiver::getPkt
dhcp::PktPtr getPkt()
Get DHCP packet.
Definition receiver.cc:58
command_options.h
isc::dhcp::PktPtr
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
Definition pkt.h:998
isc::perfdhcp
Definition abstract_scen.h:15
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
perf_socket.h
pkt.h