OpenVPN 3 Core Library
Loading...
Searching...
No Matches
relcommon.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// Common reliability layer classes
13
14#ifndef OPENVPN_RELIABLE_RELCOMMON_H
15#define OPENVPN_RELIABLE_RELCOMMON_H
16
18
19namespace openvpn {
20
21namespace reliable {
22typedef std::uint32_t id_t;
23constexpr static std::size_t id_size = sizeof(id_t);
24
25} // namespace reliable
26
27template <typename PACKET>
29{
30 public:
32
34 : id_(0), erased_(false)
35 {
36 }
37 bool defined() const
38 {
39 return bool(packet);
40 }
41 bool erased() const
42 {
43 return erased_;
44 }
45
46 void erase()
47 {
48 id_ = id_t(0);
49 packet.reset();
50 erased_ = true;
51 }
52
53 id_t id() const
54 {
55 return id_;
56 }
57
58 PACKET packet;
59
60 protected:
62 bool erased_;
63};
64
65} // namespace openvpn
66
67#endif // OPENVPN_RELIABLE_RELCOMMON_H
std::uint32_t id_t
Definition relcommon.hpp:22
static constexpr std::size_t id_size
Definition relcommon.hpp:23