-// Copyright (C) 2013-2020 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2021 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
#include <d2/d2_log.h>
#include <d2/nc_trans.h>
+#include <dns/qid_gen.h>
#include <dns/rdata.h>
-#include <util/random/qid_gen.h>
#include <sstream>
using namespace isc::util;
-using namespace isc::util::random;
namespace isc {
namespace d2 {
D2UpdateMessagePtr request(new D2UpdateMessage(D2UpdateMessage::
OUTBOUND));
// Set the query id
- request->setId(QidGenerator::getInstance().generateQid());
+ request->setId(dns::QidGenerator::getInstance().generateQid());
// Construct the Zone Section.
dns::Name zone_name(domain->getName());
request->setZone(zone_name, dns::RRClass::IN());
libperfdhcp_la_SOURCES += rate_control.cc rate_control.h
libperfdhcp_la_SOURCES += stats_mgr.cc stats_mgr.h
libperfdhcp_la_SOURCES += test_control.cc test_control.h
+libperfdhcp_la_SOURCES += random_number_generator.h
libperfdhcp_la_SOURCES += receiver.cc receiver.h
libperfdhcp_la_SOURCES += perf_socket.cc perf_socket.h
libperfdhcp_la_SOURCES += abstract_scen.h
-// Copyright (C) 2010-2020 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2010-2021 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
/// PLEASE DO NOT USE THIS IN CRYPTOGRAPHICALLY SENSITIVE CODE.
namespace isc {
-namespace util {
-namespace random {
+namespace perfdhcp {
class InvalidLimits : public isc::BadValue {
public:
size_t min_; ///< The minimum integer that will be generated
};
-} // namespace random
-} // namespace util
+} // namespace perfdhcp
} // namespace isc
#endif//NSAS_RANDOM_NUMBER_GENERATOR_H
#include <perfdhcp/receiver.h>
#include <perfdhcp/command_options.h>
#include <perfdhcp/perf_socket.h>
+#include <perfdhcp/random_number_generator.h>
#include <dhcp/iface_mgr.h>
#include <dhcp/dhcp4.h>
#include <dhcp/dhcp6.h>
#include <dhcp/pkt4.h>
#include <dhcp/pkt6.h>
-#include <util/random/random_number_generator.h>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
// what's followed in other classes.
protected:
/// Generate uniformly distributed integers in range of [min, max]
- isc::util::random::UniformRandomIntegerGenerator number_generator_;
+ UniformRandomIntegerGenerator number_generator_;
/// \brief Creates DHCPREQUEST from a DHCPACK message.
///
run_unittests_SOURCES += basic_scen_unittest.cc
run_unittests_SOURCES += avalanche_scen_unittest.cc
run_unittests_SOURCES += command_options_helper.h
+run_unittests_SOURCES += random_number_generator_unittest.cc
run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
run_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS)
-// Copyright (C) 2010-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2010-2021 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
#include <config.h>
-#include <util/random/random_number_generator.h>
+#include "../random_number_generator.h"
#include <gtest/gtest.h>
#include <boost/shared_ptr.hpp>
#include <iostream>
-
-namespace isc {
-namespace util {
-namespace random {
-
+using namespace isc;
+using namespace isc::perfdhcp;
using namespace std;
/// \brief Test Fixture Class for uniform random number generator
ASSERT_TRUE(fabs(c1 - mu1) < 4*sigma1);
ASSERT_TRUE(fabs(c2 - mu2) < 4*sigma2);
}
-
-} // namespace random
-} // namespace util
-} // namespace isc
-// Copyright (C) 2011-2020 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011-2021 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
#include <asiodns/logger.h>
#include <dns/messagerenderer.h>
#include <dns/opcode.h>
+#include <dns/qid_gen.h>
#include <dns/rcode.h>
#include <util/buffer.h>
-#include <util/random/qid_gen.h>
#include <boost/scoped_ptr.hpp>
#include <boost/date_time/posix_time/posix_time_types.hpp>
using namespace isc::asiolink;
using namespace isc::dns;
using namespace isc::util;
-using namespace isc::util::random;
using namespace isc::log;
using namespace std;
libkea_dns___la_SOURCES += rrttl.h rrttl.cc
libkea_dns___la_SOURCES += rrtype.cc
libkea_dns___la_SOURCES += rrcollator.h rrcollator.cc
+libkea_dns___la_SOURCES += qid_gen.h qid_gen.cc
libkea_dns___la_SOURCES += question.h question.cc
libkea_dns___la_SOURCES += serial.h serial.cc
libkea_dns___la_SOURCES += tsig.h tsig.cc
name.h \
nsec3hash.h \
opcode.h \
+ qid_gen.h \
question.h \
rcode.h \
rdata.h \
-// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011-2021 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
#include <config.h>
-#include <util/random/qid_gen.h>
-
-#include <sys/time.h>
+#include <cryptolink/crypto_rng.h>
+#include <dns/qid_gen.h>
+#include <cstring>
namespace isc {
-namespace util {
-namespace random {
+namespace dns {
QidGenerator qid_generator_instance;
return (qid_generator_instance);
}
-QidGenerator::QidGenerator() : dist_(0, 65535),
- vgen_(generator_, dist_)
+QidGenerator::QidGenerator()
{
- seed();
-}
-
-void
-QidGenerator::seed() {
- struct timeval tv;
- gettimeofday(&tv, 0);
- generator_.seed((tv.tv_sec * 1000000) + tv.tv_usec);
}
uint16_t
QidGenerator::generateQid() {
- return (vgen_());
+ uint16_t val;
+ std::vector<uint8_t> rnd = isc::cryptolink::random(sizeof(uint16_t));
+ memmove(&val, &rnd[0], sizeof(uint16_t));
+ return (val);
}
-
-} // namespace random
-} // namespace util
+} // namespace dns
} // namespace isc
-// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011-2021 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
#ifndef QID_GEN_H
#define QID_GEN_H
-#include <boost/random/mersenne_twister.hpp>
-#include <boost/random/uniform_int.hpp>
-#include <boost/random/variate_generator.hpp>
-
+#include <cryptolink/crypto_rng.h>
#include <stdint.h>
namespace isc {
-namespace util {
-namespace random {
+namespace dns {
/// This class generates Qids for outgoing queries
///
///
/// \return A random Qid
uint16_t generateQid();
-
- /// \brief Seeds the QidGenerator (based on the current time)
- ///
- /// This is automatically called by the constructor
- void seed();
-
-private:
- // "Mersenne Twister: A 623-dimensionally equidistributed
- // uniform pseudo-random number generator", Makoto Matsumoto and
- // Takuji Nishimura, ACM Transactions on Modeling and Computer
- // Simulation: Special Issue on Uniform Random Number Generation,
- // Vol. 8, No. 1, January 1998, pp. 3-30.
- //
- // mt19937 is an implementation of one of the pseudo random
- // generators described in this paper.
- boost::mt19937 generator_;
-
- // For qid's we want a uniform distribution
- boost::uniform_int<> dist_;
-
- boost::variate_generator<boost::mt19937&, boost::uniform_int<> > vgen_;
};
-
-} // namespace random
-} // namespace util
+} // namespace dns
} // namespace isc
#endif // QID_GEN_H
run_unittests_SOURCES += rdata_caa_unittest.cc
run_unittests_SOURCES += rdata_tkey_unittest.cc
run_unittests_SOURCES += rrset_unittest.cc
+run_unittests_SOURCES += qid_gen_unittest.cc
run_unittests_SOURCES += question_unittest.cc
run_unittests_SOURCES += rrparamregistry_unittest.cc
run_unittests_SOURCES += masterload_unittest.cc
#include <gtest/gtest.h>
-#include <util/random/qid_gen.h>
+#include <dns/qid_gen.h>
-using namespace isc::util::random;
+using namespace isc::dns;
// Tests the operation of the Qid generator
}
TEST(QidGenerator, generate) {
- // We'll assume that boost's generator is 'good enough', and won't
+ // We'll assume that cryptolink's generator is 'good enough', and won't
// do full statistical checking here. Let's just call it the xkcd
// test (http://xkcd.com/221/), and check if three consecutive
// generates are not all the same.
libkea_util_la_SOURCES += encode/binary_from_base32hex.h
libkea_util_la_SOURCES += encode/binary_from_base16.h
libkea_util_la_SOURCES += encode/utf8.cc encode/utf8.h
-libkea_util_la_SOURCES += random/qid_gen.h random/qid_gen.cc
-libkea_util_la_SOURCES += random/random_number_generator.h
libkea_util_la_LIBADD = $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
io/fd_share.h \
io/pktinfo_utilities.h \
io/sockaddr_util.h
-
-libkea_util_random_includedir = $(pkgincludedir)/util/random
-libkea_util_random_include_HEADERS = \
- random/qid_gen.h \
- random/random_number_generator.h
+++ /dev/null
-/.dirstamp
run_unittests_SOURCES += multi_threading_mgr_unittest.cc
run_unittests_SOURCES += optional_unittest.cc
run_unittests_SOURCES += pid_file_unittest.cc
-run_unittests_SOURCES += qid_gen_unittest.cc
-run_unittests_SOURCES += random_number_generator_unittest.cc
run_unittests_SOURCES += staged_value_unittest.cc
run_unittests_SOURCES += state_model_unittest.cc
run_unittests_SOURCES += strutil_unittest.cc