Kea
1.5.0
qid_gen.h
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
#ifndef QID_GEN_H
14
#define QID_GEN_H
15
16
#include <boost/random/mersenne_twister.hpp>
17
#include <boost/random/uniform_int.hpp>
18
#include <boost/random/variate_generator.hpp>
19
20
#include <stdint.h>
21
22
namespace
isc
{
23
namespace
util {
24
namespace
random
{
25
33
class
QidGenerator
{
34
public
:
38
static
QidGenerator
&
getInstance
();
39
47
QidGenerator
();
48
52
uint16_t
generateQid
();
53
57
void
seed
();
58
59
private
:
60
// "Mersenne Twister: A 623-dimensionally equidistributed
61
// uniform pseudo-random number generator", Makoto Matsumoto and
62
// Takuji Nishimura, ACM Transactions on Modeling and Computer
63
// Simulation: Special Issue on Uniform Random Number Generation,
64
// Vol. 8, No. 1, January 1998, pp. 3-30.
65
//
66
// mt19937 is an implementation of one of the pseudo random
67
// generators described in this paper.
68
boost::mt19937 generator_;
69
70
// For qid's we want a uniform distribution
71
boost::uniform_int<> dist_;
72
73
boost::variate_generator<boost::mt19937&, boost::uniform_int<> > vgen_;
74
};
75
76
77
}
// namespace random
78
}
// namespace util
79
}
// namespace isc
80
81
#endif // QID_GEN_H
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
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.h
Generated on Fri Jul 10 2020 09:12:51 for Kea by
1.8.18