OpenVPN 3 Core Library
Loading...
Searching...
No Matches
randistrib.hpp
Go to the documentation of this file.
1
// OpenVPN -- An application to securely tunnel IP networks
2
// over a single port, with support for SSL/TLS-based
3
// session authentication and key exchange,
4
// packet encryption, packet authentication, and
5
// packet compression.
6
//
7
// Copyright (C) 2012- OpenVPN Inc.
8
//
9
// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10
//
11
12
#pragma once
13
14
#include <cstdint>
15
16
namespace
openvpn
{
17
18
// Return a uniformly distributed random number in the range [0, end)
19
// using seed as a random seed. This version is strictly 32-bit only
20
// and optimizes by avoiding integer division.
21
inline
std::uint32_t
rand32_distribute
(
const
std::uint32_t seed,
22
const
std::uint32_t end)
23
{
24
return
static_cast<
uint32_t
>
((std::uint64_t(seed) * end) >> 32);
25
}
26
27
}
// namespace openvpn
openvpn
Support deferred server-side state creation when client connects.
Definition
ovpncli.cpp:95
openvpn::rand32_distribute
std::uint32_t rand32_distribute(const std::uint32_t seed, const std::uint32_t end)
Definition
randistrib.hpp:21
openvpn
random
randistrib.hpp
Generated by
1.9.8