OpenVPN 3 Core Library
Loading...
Searching...
No Matches
timespec.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 <time.h>
15
#include <cstdint>
// for std::uint64_t
16
17
namespace
openvpn
{
18
19
typedef
std::uint64_t
nanotime_t
;
20
21
namespace
TimeSpec {
22
23
inline
std::uint64_t
milliseconds_since_epoch
(
const
struct
timespec &ts)
24
{
25
return
std::uint64_t(ts.tv_sec) * std::uint64_t(1000)
26
+ std::uint64_t(ts.tv_nsec) / std::uint64_t(1000000);
27
}
28
29
inline
nanotime_t
nanoseconds_since_epoch
(
const
struct
timespec &ts)
30
{
31
return
std::uint64_t(ts.tv_sec) * std::uint64_t(1000000000)
32
+ std::uint64_t(ts.tv_nsec);
33
}
34
35
}
// namespace TimeSpec
36
}
// namespace openvpn
openvpn
Definition
ovpncli.cpp:97
openvpn::milliseconds_since_epoch
std::uint64_t milliseconds_since_epoch()
Definition
epoch.hpp:22
openvpn::nanotime_t
std::uint64_t nanotime_t
Definition
epoch.hpp:20
openvpn::nanoseconds_since_epoch
nanotime_t nanoseconds_since_epoch()
Definition
epoch.hpp:30
openvpn
time
timespec.hpp
Generated by
1.9.8