Kea: listener.h Source File

| Kea 3.0.3-git

listener.h
Go to the documentation of this file.
1// Copyright (C) 2017-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#ifndef HTTP_LISTENER_H
8#define HTTP_LISTENER_H
9
10#include <asiolink/io_address.h>
11#include <asiolink/io_service.h>
12#include <asiolink/crypto_tls.h>
13#include <exceptions/exceptions.h>
14#include <http/response_creator_factory.h>
15#include <boost/shared_ptr.hpp>
16#include <cstdint>
17
18namespace isc {
19namespace http {
20
22 class HttpListenerError : public Exception {
23public:
24 HttpListenerError(const char* file, size_t line, const char* what) :
25 isc::Exception(file, line, what) { }
26};
27
29class HttpListenerImpl;
30
52 class HttpListener {
53public:
54
56 struct RequestTimeout {
60 explicit RequestTimeout(long value)
61 : value_(value) {
62 }
63 long value_;
64 };
65
67 struct IdleTimeout {
71 explicit IdleTimeout(long value)
72 : value_(value) {
73 }
74 long value_;
75 };
76
99 HttpListener(const asiolink::IOServicePtr& io_service,
100 const asiolink::IOAddress& server_address,
101 const unsigned short server_port,
102 const asiolink::TlsContextPtr& tls_context,
103 const HttpResponseCreatorFactoryPtr& creator_factory,
104 const RequestTimeout& request_timeout,
105 const IdleTimeout& idle_timeout);
106
110 ~HttpListener();
111
113 asiolink::IOAddress getLocalAddress() const;
114
116 uint16_t getLocalPort() const;
117
119 const asiolink::TlsContextPtr& getTlsContext() const;
120
122 void setTlsContext(const asiolink::TlsContextPtr& context);
123
125 int getNative() const;
126
133 void addExternalSockets(bool use_external = false);
134
144 void start();
145
147 void stop();
148
149protected:
150
152 boost::shared_ptr<HttpListenerImpl> impl_;
153};
154
156 typedef boost::shared_ptr<HttpListener> HttpListenerPtr;
157
159 typedef boost::shared_ptr<const HttpListener> ConstHttpListenerPtr;
160
161} // end of namespace isc::http
162} // end of namespace isc
163
164#endif
isc::Exception::Exception
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
Definition exceptions/exceptions.cc:17
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition exceptions/exceptions.cc:32
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic).
Definition io_address.h:45
isc::http::HttpListenerError::HttpListenerError
HttpListenerError(const char *file, size_t line, const char *what)
Definition listener.h:24
isc::http::HttpListener::getTlsContext
const asiolink::TlsContextPtr & getTlsContext() const
Returns reference to the current TLS context.
Definition listener.cc:46
isc::http::HttpListener::HttpListener
HttpListener(const asiolink::IOServicePtr &io_service, const asiolink::IOAddress &server_address, const unsigned short server_port, const asiolink::TlsContextPtr &tls_context, const HttpResponseCreatorFactoryPtr &creator_factory, const RequestTimeout &request_timeout, const IdleTimeout &idle_timeout)
Constructor.
Definition listener.cc:18
isc::http::HttpListener::getLocalPort
uint16_t getLocalPort() const
Returns local port on which server is listening.
Definition listener.cc:41
isc::http::HttpListener::getLocalAddress
asiolink::IOAddress getLocalAddress() const
Returns local address on which server is listening.
Definition listener.cc:36
isc::http::HttpListener::addExternalSockets
void addExternalSockets(bool use_external=false)
Use external sockets flag.
Definition listener.cc:61
isc::http::HttpListener::~HttpListener
~HttpListener()
Destructor.
Definition listener.cc:31
isc::http::HttpListener::stop
void stop()
Stops all active connections and shuts down the service.
Definition listener.cc:71
isc::http::HttpListener::start
void start()
Starts accepting new connections.
Definition listener.cc:66
isc::http::HttpListener::getNative
int getNative() const
file descriptor of the underlying acceptor socket.
Definition listener.cc:56
isc::http::HttpListener::impl_
boost::shared_ptr< HttpListenerImpl > impl_
Pointer to the implementation of the HttpListener.
Definition listener.h:152
isc::http::HttpListener::setTlsContext
void setTlsContext(const asiolink::TlsContextPtr &context)
Sets reference of the current TLS context.
Definition listener.cc:51
crypto_tls.h
TLS API.
exceptions.h
io_address.h
io_service.h
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::http
Definition auth_config.h:19
isc::http::ConstHttpListenerPtr
boost::shared_ptr< const HttpListener > ConstHttpListenerPtr
Pointer to the const HttpListener.
Definition listener.h:159
isc::http::HttpListenerPtr
boost::shared_ptr< HttpListener > HttpListenerPtr
Pointer to the HttpListener.
Definition listener.h:156
isc::http::HttpResponseCreatorFactoryPtr
boost::shared_ptr< HttpResponseCreatorFactory > HttpResponseCreatorFactoryPtr
Pointer to the HttpResponseCreatorFactory.
Definition response_creator_factory.h:54
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
response_creator_factory.h
isc::http::HttpListener::IdleTimeout
Idle connection timeout.
Definition listener.h:67
isc::http::HttpListener::IdleTimeout::value_
long value_
Connection idle timeout value specified.
Definition listener.h:74
isc::http::HttpListener::IdleTimeout::IdleTimeout
IdleTimeout(long value)
Constructor.
Definition listener.h:71
isc::http::HttpListener::RequestTimeout
HTTP request timeout value.
Definition listener.h:56
isc::http::HttpListener::RequestTimeout::RequestTimeout
RequestTimeout(long value)
Constructor.
Definition listener.h:60
isc::http::HttpListener::RequestTimeout::value_
long value_
Request timeout value specified.
Definition listener.h:63