Kea
1.5.0
qid_gen.cc
Go to the documentation of this file.
1
// Copyright (C) 2011-2015 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
// qid_gen defines a generator for query id's
8
//
9
// We probably want to merge this with the weighted random in the nsas
10
// (and other parts where we need randomness, perhaps another thing
11
// for a general libutil?)
12
13
#include <config.h>
14
15
#include <
util/random/qid_gen.h
>
16
17
#include <sys/time.h>
18
19
namespace
isc
{
20
namespace
util {
21
namespace
random
{
22
23
QidGenerator
qid_generator_instance
;
24
25
QidGenerator
&
26
QidGenerator::getInstance
() {
27
return
(
qid_generator_instance
);
28
}
29
30
QidGenerator::QidGenerator
() : dist_(0, 65535),
31
vgen_(generator_, dist_)
32
{
33
seed
();
34
}
35
36
void
37
QidGenerator::seed
() {
38
struct
timeval tv;
39
gettimeofday(&tv, 0);
40
generator_.seed((tv.tv_sec * 1000000) + tv.tv_usec);
41
}
42
43
uint16_t
44
QidGenerator::generateQid
() {
45
return
(vgen_());
46
}
47
48
49
}
// namespace random
50
}
// namespace util
51
}
// namespace isc
isc::util::random::QidGenerator
This class generates Qids for outgoing queries.
Definition:
qid_gen.h:33
isc::util::random::QidGenerator::generateQid
uint16_t generateQid()
Generate a Qid.
Definition:
qid_gen.cc:44
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition:
agent_parser.cc:144
isc::util::random::QidGenerator::QidGenerator
QidGenerator()
Default constructor.
Definition:
qid_gen.cc:30
isc::util::random::QidGenerator::seed
void seed()
Seeds the QidGenerator (based on the current time)
Definition:
qid_gen.cc:37
qid_gen.h
isc::util::random::qid_generator_instance
QidGenerator qid_generator_instance
Definition:
qid_gen.cc:23
isc::util::random::QidGenerator::getInstance
static QidGenerator & getInstance()
Returns the singleton instance of the QidGenerator.
Definition:
qid_gen.cc:26
isc::cryptolink::random
std::vector< uint8_t > random(size_t len)
Generate random value.
Definition:
crypto_rng.cc:26
src
lib
util
random
qid_gen.cc
Generated on Fri Jul 10 2020 09:12:51 for Kea by
1.8.18