Kea: mt_lease_query_mgr.cc Source File

| Kea 3.0.3-git

mt_lease_query_mgr.cc
Go to the documentation of this file.
1// Copyright (C) 2022-2025 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#include <config.h>
8#include <asiolink/asio_wrapper.h>
9#include <asiolink/io_address.h>
10#include <asiolink/io_error.h>
11#include <asiolink/io_service.h>
12#include <mt_lease_query_mgr.h>
13#include <util/multi_threading_mgr.h>
14
15#include <boost/pointer_cast.hpp>
16
17using namespace isc::asiolink;
18using namespace isc::tcp;
19using namespace isc::util;
20
21namespace ph = std::placeholders;
22
23namespace isc {
24namespace lease_query {
25
26MtLeaseQueryListenerMgr::MtLeaseQueryListenerMgr(const IOAddress& address,
27 const uint16_t port,
28 const uint16_t family,
29 const tcp::TcpListener::IdleTimeout& idle_timeout,
30 const uint16_t thread_pool_size /* = 1 */,
31 TlsContextPtr context /* = () */,
32 TcpConnectionFilterCallback connection_filter /* = 0 */,
33 const size_t max_concurrent_queries /* = 0 */)
34 : MtTcpListenerMgr(std::bind(&MtLeaseQueryListenerMgr::listenerFactory,
35 this, ph::_1, ph::_2, ph::_3, ph::_4, ph::_5,
36 ph::_6),
37 address, port, thread_pool_size, context,
38 connection_filter),
39 family_(family),
40 max_concurrent_queries_(max_concurrent_queries) {
41 setIdleTimeout(idle_timeout.value_);
42}
43
44 TcpListenerPtr
45MtLeaseQueryListenerMgr::listenerFactory(const asiolink::IOServicePtr& io_service,
46 const asiolink::IOAddress& server_address,
47 const unsigned short server_port,
48 const asiolink::TlsContextPtr& tls_context,
49 const TcpListener::IdleTimeout& idle_timeout,
50 const TcpConnectionFilterCallback& connection_filter) {
51 TcpListenerPtr listener(new LeaseQueryListener(io_service,
52 server_address,
53 server_port,
54 tls_context,
55 idle_timeout,
56 connection_filter,
57 family_,
58 max_concurrent_queries_));
59 return (listener);
60}
61
62
63MtLeaseQueryListenerMgr::~MtLeaseQueryListenerMgr() {
64 stop();
65}
66
67} // namespace isc::lease_query
68} // namespace isc
asio_wrapper.h
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic).
Definition io_address.h:45
isc::lease_query::LeaseQueryListener
Derivation of TcpListener specific to Bulk Lease Query.
Definition lease_query_listener.h:22
isc::lease_query::MtLeaseQueryListenerMgr::listenerFactory
tcp::TcpListenerPtr listenerFactory(const asiolink::IOServicePtr &io_service, const asiolink::IOAddress &server_address, const unsigned short server_port, const asiolink::TlsContextPtr &tls_context, const tcp::TcpListener::IdleTimeout &idle_timeout, const tcp::TcpConnectionFilterCallback &connection_filter)
Defines a factory function for creating listeners.
Definition mt_lease_query_mgr.cc:45
isc::lease_query::MtLeaseQueryListenerMgr::~MtLeaseQueryListenerMgr
virtual ~MtLeaseQueryListenerMgr()
Destructor.
Definition mt_lease_query_mgr.cc:63
isc::lease_query::MtLeaseQueryListenerMgr::MtLeaseQueryListenerMgr
MtLeaseQueryListenerMgr(const asiolink::IOAddress &address, const uint16_t port, const uint16_t family, const tcp::TcpListener::IdleTimeout &idle_timeout, const uint16_t thread_pool_size=1, asiolink::TlsContextPtr context=asiolink::TlsContextPtr(), tcp::TcpConnectionFilterCallback connection_filter=0, const size_t max_concurrent_queries=0)
Constructor.
Definition mt_lease_query_mgr.cc:26
isc::tcp::MtTcpListenerMgr::MtTcpListenerMgr
MtTcpListenerMgr(TcpListenerFactory listener_factory, const asiolink::IOAddress &address, const uint16_t port, const uint16_t thread_pool_size=1, asiolink::TlsContextPtr context=asiolink::TlsContextPtr(), TcpConnectionFilterCallback connection_filter=0)
Constructor.
Definition mt_tcp_listener_mgr.cc:25
isc::tcp::MtTcpListenerMgr::setIdleTimeout
void setIdleTimeout(long milliseconds)
Sets the idle time per connection.
Definition mt_tcp_listener_mgr.h:164
isc::tcp::MtTcpListenerMgr::stop
void stop()
Stops the listener's thread pool.
Definition mt_tcp_listener_mgr.cc:133
io_address.h
io_error.h
io_service.h
mt_lease_query_mgr.h
multi_threading_mgr.h
isc::asiolink
Definition addr_utilities.cc:170
isc::asiolink::TlsContextPtr
boost::shared_ptr< TlsContext > TlsContextPtr
The type of shared pointers to TlsContext objects.
Definition common_tls.h:37
isc::asiolink::IOServicePtr
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
Definition io_service.h:28
isc::lease_query
Definition blq_msg.h:15
isc::tcp
Definition mt_tcp_listener_mgr.cc:23
isc::tcp::TcpConnectionFilterCallback
std::function< bool(const boost::asio::ip::tcp::endpoint &)> TcpConnectionFilterCallback
Type of the callback for filtering new connections by ip address.
Definition tcp_connection.h:154
isc::tcp::TcpListenerPtr
boost::shared_ptr< TcpListener > TcpListenerPtr
Pointer to a TcpListener.
Definition tcp_listener.h:164
isc::util
Definition time_utils.cc:43
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
isc::tcp::TcpListener::IdleTimeout
Idle connection timeout.
Definition tcp_listener.h:31
isc::tcp::TcpListener::IdleTimeout::value_
long value_
Connection idle timeout value specified.
Definition tcp_listener.h:38