Kea 2.7.5
d2_tsig_key.cc
Go to the documentation of this file.
1// Copyright (C) 2021-2024 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
8
9#include <config.h>
10
11#include <d2srv/d2_stats.h>
12#include <d2srv/d2_tsig_key.h>
13#include <stats/stats_mgr.h>
14
15using namespace isc::dns;
16using namespace isc::stats;
17using namespace std;
18
19namespace isc {
20namespace d2 {
21
22D2TsigKey::D2TsigKey(const std::string& key_spec) : TSIGKey(key_spec) {
23 initStats();
24}
25
26D2TsigKey::D2TsigKey(const Name& key_name, const Name& algorithm_name,
27 const void* secret, size_t secret_len, size_t digestbits)
28 : TSIGKey(key_name, algorithm_name, secret, secret_len, digestbits) {
29 initStats();
30}
31
33 removeStats();
34}
35
36void
37D2TsigKey::initStats() {
38 StatsMgr& stats_mgr = StatsMgr::instance();
39 const string& kname = getKeyName().toText();
40 for (auto const& name : D2Stats::key) {
41 const string& sname = StatsMgr::generateName("key", kname, name);
42 stats_mgr.setValue(sname, static_cast<int64_t>(0));
43 }
44}
45
46void
47D2TsigKey::removeStats() {
48 StatsMgr& stats_mgr = StatsMgr::instance();
49 const string& kname = getKeyName().toText();
50 for (auto const& name : D2Stats::key) {
51 string sname = StatsMgr::generateName("key", kname, name);
52 stats_mgr.del(sname);
53 }
54}
55
56void
58 StatsMgr& stats_mgr = StatsMgr::instance();
59 const string& kname = getKeyName().toText();
60 for (auto const& name : D2Stats::key) {
61 string sname = StatsMgr::generateName("key", kname, name);
62 stats_mgr.reset(sname);
63 }
64}
65
68 return (TSIGContextPtr(new TSIGContext(*this)));
69}
70
71} // namespace d2
72} // namespace isc
Statistics Names.
Definition d2_stats.h:17
static const std::list< std::string > key
Key DNS update statistics names.
Definition d2_stats.h:43
D2TsigKey(const std::string &key_spec)
Constructor.
virtual void resetStats()
Reset statistics.
virtual dns::TSIGContextPtr createContext()
Create TSIG context.
virtual ~D2TsigKey()
Destructor.
The Name class encapsulates DNS names.
Definition name.h:219
TSIG session context.
Definition tsig.h:171
TSIG key.
Definition tsigkey.h:56
const Name & getKeyName() const
Getter Methods.
Definition tsigkey.cc:204
Statistics Manager class.
static StatsMgr & instance()
Statistics Manager accessor method.
static std::string generateName(const std::string &context, Type index, const std::string &stat_name)
Generates statistic name in a given context.
boost::shared_ptr< TSIGContext > TSIGContextPtr
Definition tsig.h:435
Defines the logger used by the top-level component of kea-lfc.