Kea  2.3.5-git
perf_socket.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2019 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 
17 namespace isc {
18 namespace perfdhcp {
19 
27 public:
29  uint16_t 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 
64 class PerfSocket : public BasePerfSocket {
65 public:
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 
109 protected:
117  void initSocketData();
118 
137  int openSocket(CommandOptions& options) const;
138 };
139 
140 }
141 }
142 
143 #endif /* PERF_SOCKET_H */
virtual dhcp::Pkt6Ptr receive6(uint32_t timeout_sec, uint32_t timeout_usec)=0
See description of this method in PerfSocket class below.
boost::shared_ptr< Iface > IfacePtr
Type definition for the pointer to an Iface object.
Definition: iface_mgr.h:487
Socket wrapper structure.
Definition: perf_socket.h:64
virtual dhcp::IfacePtr getIface()=0
See description of this method in PerfSocket class below.
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
Definition: pkt6.h:28
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
Definition: pkt4.h:547
virtual dhcp::Pkt4Ptr receive4(uint32_t timeout_sec, uint32_t timeout_usec)=0
See description of this method in PerfSocket class below.
uint16_t ifindex_
Interface index.
Definition: perf_socket.h:29
Defines the logger used by the top-level component of kea-lfc.
virtual ~BasePerfSocket()=default
Destructor of the socket wrapper class.
SocketInfo(const isc::asiolink::IOAddress &addr, const uint16_t port, const int sockfd, const int fallbackfd=-1)
SocketInfo constructor.
Definition: socket_info.h:58
Socket wrapper structure.
Definition: perf_socket.h:26
BasePerfSocket()
Default constructor of BasePerfSocket.
Definition: perf_socket.h:32
Holds information about socket.
Definition: socket_info.h:19
virtual bool send(const dhcp::Pkt4Ptr &pkt)=0
See description of this method in PerfSocket class below.