OpenVPN 3 Core Library
Loading...
Searching...
No Matches
bufcomposed.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 OPENVPN_BUFFER_BUFCOMPOSED_H
13#define OPENVPN_BUFFER_BUFCOMPOSED_H
14
18
19namespace openvpn {
21{
22 public:
23 class Complete : public BufferComplete
24 {
25 public:
27 {
28#if 0 // don't include for production
29 if (iter_defined())
30 throw Exception("BufferComposed::Complete: residual data");
31#endif
33 bc.bv.clear();
34 return ret;
35 }
36
37 private:
38 friend class BufferComposed;
39
41 : bc(bc_arg),
42 iter(bc.bv.cbegin())
43 {
45 }
46
48 {
49 return iter != bc.bv.end();
50 }
51
52 virtual void next_buffer() override
53 {
55 }
56
57 // Both ctor and next_buffer delegate here
59 {
60 if (iter_defined())
61 reset_buf(**iter++);
62 else
63 reset_buf();
64 }
65
67 BufferVector::const_iterator iter;
68 };
69
70 size_t size() const
71 {
72 return bv.join_size();
73 }
74
75 void put(BufferPtr bp)
76 {
77 bv.push_back(std::move(bp));
78 }
79
81 {
82 return Complete(*this);
83 }
84
85 private:
87};
88} // namespace openvpn
89
90#endif
virtual void next_buffer() override
BufferVector::const_iterator iter
Complete(BufferComposed &bc_arg)
void put(BufferPtr bp)
size_t join_size() const
Definition buflist.hpp:64
BufferPtr join(const size_t headroom, const size_t tailroom, const bool size_1_optim) const
Definition buflist.hpp:32
std::string ret