OpenVPN 3 Core Library
Loading...
Searching...
No Matches
alignment.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
#ifndef ALIGNMENT_HEADER_PARSED
13
#define ALIGNMENT_HEADER_PARSED
14
15
#include <cstring>
16
#include <type_traits>
17
18
namespace
openvpn
{
19
35
template
<
typename
T>
36
requires ::std::is_trivially_copyable_v<T>
37
T
alignment_safe_extract
(
const
void
*toAlign)
noexcept
38
{
39
T
ret
;
40
std::memcpy(&
ret
, toAlign,
sizeof
(T));
41
return
ret
;
42
}
43
44
}
// namespace openvpn
45
46
#endif
openvpn
Definition
ovpncli.cpp:97
openvpn::alignment_safe_extract
requires ::std::is_trivially_copyable_v< T > T alignment_safe_extract(const void *toAlign) noexcept
Converts a byte buffer to the desired type, avoiding undefined behavior due to alignment.
Definition
alignment.hpp:37
ret
std::string ret
Definition
test_capture.cpp:268
openvpn
common
alignment.hpp
Generated by
1.9.8