Kea: perf_socket.h Source File

| Kea 3.2.0-git

perf_socket.h
Go to the documentation of this file.
1// Copyright (C) 2012-2023 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 PERF_SOCKET_H
8#define PERF_SOCKET_H
9
10#include <perfdhcp/command_options.h>
11
12#include <dhcp/pkt4.h>
13#include <dhcp/pkt6.h>
14#include <dhcp/socket_info.h>
15#include <dhcp/iface_mgr.h>
16
17namespace isc {
18namespace perfdhcp {
19
26 class BasePerfSocket : public dhcp::SocketInfo {
27public:
29 unsigned int ifindex_;
30
32 BasePerfSocket() :
33 SocketInfo(asiolink::IOAddress("127.0.0.1"), 0, 0),
34 ifindex_(0) {}
35
37 virtual ~BasePerfSocket() = default;
38
40 virtual dhcp::Pkt4Ptr receive4(uint32_t timeout_sec, uint32_t timeout_usec) = 0;
41
43 virtual dhcp::Pkt6Ptr receive6(uint32_t timeout_sec, uint32_t timeout_usec) = 0;
44
46 virtual bool send(const dhcp::Pkt4Ptr& pkt) = 0;
47
49 virtual bool send(const dhcp::Pkt6Ptr& pkt) = 0;
50
52 virtual dhcp::IfacePtr getIface() = 0;
53};
54
64 class PerfSocket : public BasePerfSocket {
65public:
71 PerfSocket(CommandOptions& options);
72
76 virtual ~PerfSocket();
77
83 virtual dhcp::Pkt4Ptr receive4(uint32_t timeout_sec, uint32_t timeout_usec) override;
84
90 virtual dhcp::Pkt6Ptr receive6(uint32_t timeout_sec, uint32_t timeout_usec) override;
91
96 virtual bool send(const dhcp::Pkt4Ptr& pkt) override;
97
102 virtual bool send(const dhcp::Pkt6Ptr& pkt) override;
103
107 virtual dhcp::IfacePtr getIface() override;
108
109protected:
117 void initSocketData();
118
137 int openSocket(CommandOptions& options) const;
138};
139
140}
141}
142
143#endif /* PERF_SOCKET_H */
isc::perfdhcp::BasePerfSocket::receive4
virtual dhcp::Pkt4Ptr receive4(uint32_t timeout_sec, uint32_t timeout_usec)=0
See description of this method in PerfSocket class below.
isc::perfdhcp::BasePerfSocket::getIface
virtual dhcp::IfacePtr getIface()=0
See description of this method in PerfSocket class below.
isc::perfdhcp::BasePerfSocket::send
virtual bool send(const dhcp::Pkt6Ptr &pkt)=0
See description of this method in PerfSocket class below.
isc::perfdhcp::BasePerfSocket::receive6
virtual dhcp::Pkt6Ptr receive6(uint32_t timeout_sec, uint32_t timeout_usec)=0
See description of this method in PerfSocket class below.
isc::perfdhcp::BasePerfSocket::BasePerfSocket
BasePerfSocket()
Default constructor of BasePerfSocket.
Definition perf_socket.h:32
isc::perfdhcp::BasePerfSocket::ifindex_
unsigned int ifindex_
Interface index.
Definition perf_socket.h:29
isc::perfdhcp::BasePerfSocket::send
virtual bool send(const dhcp::Pkt4Ptr &pkt)=0
See description of this method in PerfSocket class below.
isc::perfdhcp::BasePerfSocket::~BasePerfSocket
virtual ~BasePerfSocket()=default
Destructor of the socket wrapper class.
isc::perfdhcp::CommandOptions
Command Options.
Definition command_options.h:30
isc::perfdhcp::PerfSocket::~PerfSocket
virtual ~PerfSocket()
Destructor of the socket wrapper class.
Definition perf_socket.cc:128
isc::perfdhcp::PerfSocket::PerfSocket
PerfSocket(CommandOptions &options)
Constructor of socket wrapper class.
Definition perf_socket.cc:23
isc::perfdhcp::PerfSocket::receive6
virtual dhcp::Pkt6Ptr receive6(uint32_t timeout_sec, uint32_t timeout_usec) override
Receive DHCPv6 packet from interface.
Definition perf_socket.cc:165
isc::perfdhcp::PerfSocket::getIface
virtual dhcp::IfacePtr getIface() override
Get interface from IfaceMgr.
Definition perf_socket.cc:190
isc::perfdhcp::PerfSocket::send
virtual bool send(const dhcp::Pkt4Ptr &pkt) override
Send DHCPv4 packet through interface.
Definition perf_socket.cc:180
isc::perfdhcp::PerfSocket::openSocket
int openSocket(CommandOptions &options) const
Open socket to communicate with DHCP server.
Definition perf_socket.cc:30
isc::perfdhcp::PerfSocket::initSocketData
void initSocketData()
Initialize socket data.
Definition perf_socket.cc:136
isc::perfdhcp::PerfSocket::receive4
virtual dhcp::Pkt4Ptr receive4(uint32_t timeout_sec, uint32_t timeout_usec) override
Receive DHCPv4 packet from interface.
Definition perf_socket.cc:150
command_options.h
iface_mgr.h
asiolink
A wrapper interface for the ASIO library.
isc::dhcp::Pkt4Ptr
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
Definition pkt4.h:556
isc::dhcp::IfacePtr
boost::shared_ptr< Iface > IfacePtr
Type definition for the pointer to an Iface object.
Definition iface_mgr.h:555
isc::dhcp::Pkt6Ptr
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
Definition pkt6.h:31
isc::perfdhcp
Definition abstract_scen.h:15
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
pkt4.h
pkt6.h
socket_info.h
isc::dhcp::SocketInfo
Holds information about socket.
Definition socket_info.h:18
isc::dhcp::SocketInfo::SocketInfo
SocketInfo(const isc::asiolink::IOAddress &addr, const uint16_t port, const int sockfd, const int fallbackfd=-1)
SocketInfo constructor.
Definition socket_info.h:62