| Kea 3.0.2-git

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
15 using namespace isc::dns;
16 using namespace isc::stats;
17 using namespace std;
18
19 namespace isc {
20 namespace d2 {
21
22 D2TsigKey::D2TsigKey(const std::string& key_spec) : TSIGKey(key_spec) {
23 initStats();
24}
25
26 D2TsigKey::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
32 D2TsigKey::~D2TsigKey() {
33 removeStats();
34}
35
36 void
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
46 void
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
56 void
57 D2TsigKey::resetStats() {
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
66 TSIGContextPtr
67 D2TsigKey::createContext() {
68 return (TSIGContextPtr(new TSIGContext(*this)));
69}
70
71} // namespace d2
72} // namespace isc
isc::d2::D2Stats::key
static const std::list< std::string > key
Key DNS update statistics names.
Definition d2_stats.h:43
isc::d2::D2TsigKey::D2TsigKey
D2TsigKey(const std::string &key_spec)
Constructor.
Definition d2_tsig_key.cc:22
isc::d2::D2TsigKey::resetStats
virtual void resetStats()
Reset statistics.
Definition d2_tsig_key.cc:57
isc::d2::D2TsigKey::createContext
virtual dns::TSIGContextPtr createContext()
Create TSIG context.
Definition d2_tsig_key.cc:67
isc::d2::D2TsigKey::~D2TsigKey
virtual ~D2TsigKey()
Destructor.
Definition d2_tsig_key.cc:32
isc::dns::Name
The Name class encapsulates DNS names.
Definition name.h:219
isc::dns::Name::toText
std::string toText(bool omit_final_dot=false) const
Convert the Name to a string.
Definition name.cc:503
isc::dns::TSIGContext
TSIG session context.
Definition tsig.h:171
isc::dns::TSIGKey::getKeyName
const Name & getKeyName() const
Getter Methods.
Definition tsigkey.cc:204
isc::dns::TSIGKey::TSIGKey
TSIGKey(const Name &key_name, const Name &algorithm_name, const void *secret, size_t secret_len, size_t digestbits=0)
Constructors, Assignment Operator and Destructor.
Definition tsigkey.cc:95
isc::stats::StatsMgr
Statistics Manager class.
Definition lib/stats/stats_mgr.h:65
isc::stats::StatsMgr::instance
static StatsMgr & instance()
Statistics Manager accessor method.
Definition lib/stats/stats_mgr.cc:30
isc::stats::StatsMgr::generateName
static std::string generateName(const std::string &context, Type index, const std::string &stat_name)
Generates statistic name in a given context.
Definition lib/stats/stats_mgr.h:298
d2_stats.h
d2_tsig_key.h
isc::stats::StatsMgr::reset
bool reset(const std::string &name)
Resets specified statistic.
Definition lib/stats/stats_mgr.cc:239
isc::stats::StatsMgr::del
bool del(const std::string &name)
Removes specified statistic.
Definition lib/stats/stats_mgr.cc:255
isc::stats::StatsMgr::setValue
void setValue(const std::string &name, const int64_t value)
Records absolute integer observation.
Definition lib/stats/stats_mgr.cc:40
stats_mgr.h
isc::d2
Definition check_exists_add.cc:19
isc::dns::name
Definition name.cc:69
isc::dns
Definition char_string.cc:26
isc::dns::TSIGContextPtr
boost::shared_ptr< TSIGContext > TSIGContextPtr
Definition tsig.h:435
isc::stats
Definition context.cc:18
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148