Kea: tkey_exchange.h Source File

| Kea 3.2.0-git

tkey_exchange.h
Go to the documentation of this file.
1// Copyright (C) 2021-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 TKEY_EXCHANGE_H
8#define TKEY_EXCHANGE_H
9
10#include <asiodns/io_fetch.h>
11#include <asiolink/io_service.h>
12#include <gss_tsig_cfg.h>
13#include <gss_tsig_key.h>
14#include <util/buffer.h>
15#include <memory>
16
17namespace isc {
18namespace gss_tsig {
19
20class TKeyExchange;
21 typedef boost::shared_ptr<TKeyExchange> TKeyExchangePtr;
22
24class TKeyExchangeImpl;
25
36 class TKeyExchange : boost::noncopyable {
37public:
39 enum Status {
40 SUCCESS,
41 TIMEOUT,
42 IO_STOPPED,
43 INVALID_RESPONSE,
44 UNSIGNED_RESPONSE,
45 BAD_CREDENTIALS,
46 OTHER
47 };
48
50 static std::string statusToText(Status status);
51
58 class Callback {
59 public:
61 virtual ~Callback() { }
62
67 virtual void operator()(TKeyExchange::Status status) = 0;
68 };
69
83 TKeyExchange(const isc::asiolink::IOServicePtr& io_service,
84 const DnsServerPtr& server, const GssTsigKeyPtr& key,
85 Callback* callback, uint32_t timeout = TKEY_EXCHANGE_IO_TIMEOUT,
86 OM_uint32 flags = TKEY_EXCHANGE_FLAGS);
87
89 virtual ~TKeyExchange();
90
93 void doExchange();
94
96 void cancel();
97
101 isc::asiolink::IOServicePtr getIOService();
102
106 void setIOService(const isc::asiolink::IOServicePtr io_service);
107
117 static const OM_uint32 TKEY_EXCHANGE_FLAGS;
118
121 static const uint32_t TKEY_EXCHANGE_IO_TIMEOUT;
122
123private:
125 std::unique_ptr<TKeyExchangeImpl> impl_;
126};
127
128} // namespace isc
129} // namespace gss_tsig
130
131#endif // TKEY_EXCHANGE_H
buffer.h
isc::gss_tsig::TKeyExchangeImpl
Definition tkey_exchange.cc:69
isc::gss_tsig::TKeyExchange::Callback
Callback for the TKeyExchange class.
Definition tkey_exchange.h:58
isc::gss_tsig::TKeyExchange::Callback::operator()
virtual void operator()(TKeyExchange::Status status)=0
Function operator implementing a callback.
isc::gss_tsig::TKeyExchange::Callback::~Callback
virtual ~Callback()
Virtual destructor.
Definition tkey_exchange.h:61
isc::gss_tsig::TKeyExchange
The TKeyExchange class handles communication with the DNS server.
Definition tkey_exchange.h:36
isc::gss_tsig::TKeyExchange::cancel
void cancel()
This function cancels the in-flight TKEY exchange.
Definition tkey_exchange.cc:567
isc::gss_tsig::TKeyExchange::Status
Status
A status code of the TKeyExchange.
Definition tkey_exchange.h:39
isc::gss_tsig::TKeyExchange::SUCCESS
@ SUCCESS
Response received and is ok.
Definition tkey_exchange.h:40
isc::gss_tsig::TKeyExchange::BAD_CREDENTIALS
@ BAD_CREDENTIALS
Bad client credentials.
Definition tkey_exchange.h:45
isc::gss_tsig::TKeyExchange::IO_STOPPED
@ IO_STOPPED
IO was stopped.
Definition tkey_exchange.h:42
isc::gss_tsig::TKeyExchange::UNSIGNED_RESPONSE
@ UNSIGNED_RESPONSE
Response received but not signed.
Definition tkey_exchange.h:44
isc::gss_tsig::TKeyExchange::INVALID_RESPONSE
@ INVALID_RESPONSE
Response received but invalid.
Definition tkey_exchange.h:43
isc::gss_tsig::TKeyExchange::TIMEOUT
@ TIMEOUT
No response, timeout.
Definition tkey_exchange.h:41
isc::gss_tsig::TKeyExchange::OTHER
@ OTHER
Other, unclassified error.
Definition tkey_exchange.h:46
isc::gss_tsig::TKeyExchange::statusToText
static std::string statusToText(Status status)
Convert a status to its textual form.
Definition tkey_exchange.cc:44
isc::gss_tsig::TKeyExchange::TKeyExchange
TKeyExchange(const isc::asiolink::IOServicePtr &io_service, const DnsServerPtr &server, const GssTsigKeyPtr &key, Callback *callback, uint32_t timeout=TKEY_EXCHANGE_IO_TIMEOUT, OM_uint32 flags=TKEY_EXCHANGE_FLAGS)
Constructor.
Definition tkey_exchange.cc:551
isc::gss_tsig::TKeyExchange::getIOService
isc::asiolink::IOServicePtr getIOService()
Gets IO service.
Definition tkey_exchange.cc:572
isc::gss_tsig::TKeyExchange::doExchange
void doExchange()
This function handles the repeated communication with the DNS server trying to complete the TKEY exch...
Definition tkey_exchange.cc:562
isc::gss_tsig::TKeyExchange::setIOService
void setIOService(const isc::asiolink::IOServicePtr io_service)
Sets IO service.
Definition tkey_exchange.cc:577
isc::gss_tsig::TKeyExchange::TKEY_EXCHANGE_IO_TIMEOUT
static const uint32_t TKEY_EXCHANGE_IO_TIMEOUT
The default IO timeout used for IO operations (in milliseconds) set to 3000 (3 seconds).
Definition tkey_exchange.h:121
isc::gss_tsig::TKeyExchange::TKEY_EXCHANGE_FLAGS
static const OM_uint32 TKEY_EXCHANGE_FLAGS
The default TKEY exchange flags.
Definition tkey_exchange.h:117
isc::gss_tsig::TKeyExchange::~TKeyExchange
virtual ~TKeyExchange()
Virtual destructor, does nothing.
Definition tkey_exchange.cc:557
gss_tsig_cfg.h
gss_tsig_key.h
io_fetch.h
io_service.h
isc::asiolink::IOServicePtr
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
Definition io_service.h:35
isc::gss_tsig
Definition gss_tsig_api.cc:19
isc::gss_tsig::DnsServerPtr
boost::shared_ptr< DnsServer > DnsServerPtr
A pointer to a DNS server.
Definition gss_tsig_cfg.h:399
isc::gss_tsig::TKeyExchangePtr
boost::shared_ptr< TKeyExchange > TKeyExchangePtr
Definition tkey_exchange.h:21
isc::gss_tsig::GssTsigKeyPtr
boost::shared_ptr< GssTsigKey > GssTsigKeyPtr
Type of pointer to a GSS-TSIG key.
Definition gss_tsig_key.h:115
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18