Kea 2.5.8
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
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
27public:
29 unsigned int ifindex_;
30
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
64class 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 */
Socket wrapper structure.
Definition: perf_socket.h:26
virtual dhcp::Pkt4Ptr receive4(uint32_t timeout_sec, uint32_t timeout_usec)=0
See description of this method in PerfSocket class below.
virtual dhcp::IfacePtr getIface()=0
See description of this method in PerfSocket class below.
virtual bool send(const dhcp::Pkt6Ptr &pkt)=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.
BasePerfSocket()
Default constructor of BasePerfSocket.
Definition: perf_socket.h:32
unsigned int ifindex_
Interface index.
Definition: perf_socket.h:29
virtual bool send(const dhcp::Pkt4Ptr &pkt)=0
See description of this method in PerfSocket class below.
virtual ~BasePerfSocket()=default
Destructor of the socket wrapper class.
Socket wrapper structure.
Definition: perf_socket.h:64
virtual ~PerfSocket()
Destructor of the socket wrapper class.
Definition: perf_socket.cc:128
virtual dhcp::Pkt6Ptr receive6(uint32_t timeout_sec, uint32_t timeout_usec) override
Receive DHCPv6 packet from interface.
Definition: perf_socket.cc:165
virtual dhcp::IfacePtr getIface() override
Get interface from IfaceMgr.
Definition: perf_socket.cc:190
virtual bool send(const dhcp::Pkt4Ptr &pkt) override
Send DHCPv4 packet through interface.
Definition: perf_socket.cc:180
int openSocket(CommandOptions &options) const
Open socket to communicate with DHCP server.
Definition: perf_socket.cc:30
void initSocketData()
Initialize socket data.
Definition: perf_socket.cc:136
virtual dhcp::Pkt4Ptr receive4(uint32_t timeout_sec, uint32_t timeout_usec) override
Receive DHCPv4 packet from interface.
Definition: perf_socket.cc:150
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
Definition: pkt4.h:555
boost::shared_ptr< Iface > IfacePtr
Type definition for the pointer to an Iface object.
Definition: iface_mgr.h:487
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
Definition: pkt6.h:31
Defines the logger used by the top-level component of kea-lfc.
Holds information about socket.
Definition: socket_info.h:19
SocketInfo(const isc::asiolink::IOAddress &addr, const uint16_t port, const int sockfd, const int fallbackfd=-1)
SocketInfo constructor.
Definition: socket_info.h:58