diff options
author | Michal Nowikowski <godfryd@isc.org> | 2019-01-17 16:48:06 +0100 |
---|---|---|
committer | Michal Nowikowski <godfryd@isc.org> | 2019-01-18 10:05:12 +0100 |
commit | 1311cb038abc6431fc9103709db69ae75d0222ce (patch) | |
tree | fb31a2692f4fc5a8a5d1d96c22a23ba0c68614ec /src/bin/perfdhcp/perf_socket.h | |
parent | [#283,!135] Obsolete TestControl::receivePackets declaration removed (diff) | |
download | kea-1311cb038abc6431fc9103709db69ae75d0222ce.tar.xz kea-1311cb038abc6431fc9103709db69ae75d0222ce.zip |
perfdhcp: renamed BetterSocket to PerfSocket, replaced std::mutex with isc::util::thread::Mutex
Diffstat (limited to 'src/bin/perfdhcp/perf_socket.h')
-rw-r--r-- | src/bin/perfdhcp/perf_socket.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/bin/perfdhcp/perf_socket.h b/src/bin/perfdhcp/perf_socket.h new file mode 100644 index 0000000000..de593d317f --- /dev/null +++ b/src/bin/perfdhcp/perf_socket.h @@ -0,0 +1,61 @@ +// Copyright (C) 2012-2019 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef PERF_SOCKET_H +#define PERF_SOCKET_H + +#include <dhcp/socket_info.h> + +namespace isc { +namespace perfdhcp { + + +/// \brief Socket wrapper structure. +/// +/// This is the wrapper that holds descriptor of the socket +/// used to run DHCP test. The wrapped socket is closed in +/// the destructor. This prevents resource leaks when +/// function that created the socket ends (normally or +/// when exception occurs). This structure extends parent +/// structure with new field ifindex_ that holds interface +/// index where socket is bound to. +struct PerfSocket : public dhcp::SocketInfo { + /// Interface index. + uint16_t ifindex_; + /// Is socket valid. It will not be valid if the provided socket + /// descriptor does not point to valid socket. + bool valid_; + + /// \brief Constructor of socket wrapper class. + /// + /// This constructor uses provided socket descriptor to + /// find the name of the interface where socket has been + /// bound to. If provided socket descriptor is invalid then + /// valid_ field is set to false; + /// + /// \param socket socket descriptor. + PerfSocket(const int socket); + + /// \brief Destructor of the socket wrapper class. + /// + /// Destructor closes wrapped socket. + virtual ~PerfSocket(); + +private: + /// \brief Initialize socket data. + /// + /// This method initializes members of the class that Interface + /// Manager holds: interface name, local address. + /// + /// \throw isc::BadValue if interface for specified socket + /// descriptor does not exist. + void initSocketData(); +}; + +} +} + +#endif /* PERF_SOCKET_H */ |