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
15
#include <
openvpn/common/exception.hpp
>
16
#include <
openvpn/buffer/bufcomplete.hpp
>
17
#include <
openvpn/buffer/buflist.hpp
>
18
19
namespace
openvpn
{
20
class
BufferComposed
21
{
22
public
:
23
class
Complete
:
public
BufferComplete
24
{
25
public
:
26
BufferPtr
get
()
27
{
28
#if 0
// don't include for production
29
if
(
iter_defined
())
30
throw
Exception
(
"BufferComposed::Complete: residual data"
);
31
#endif
32
BufferPtr
ret
=
bc
.
bv
.
join
();
33
bc
.
bv
.clear();
34
return
ret
;
35
}
36
37
private
:
38
friend
class
BufferComposed
;
39
40
Complete
(
BufferComposed
&bc_arg)
41
:
bc
(bc_arg),
42
iter
(
bc
.
bv
.cbegin())
43
{
44
next_buffer_impl
();
45
}
46
47
bool
iter_defined
()
48
{
49
return
iter
!=
bc
.
bv
.end();
50
}
51
52
virtual
void
next_buffer
()
override
53
{
54
next_buffer_impl
();
55
}
56
57
// Both ctor and next_buffer delegate here
58
void
next_buffer_impl
()
59
{
60
if
(
iter_defined
())
61
reset_buf
(**
iter
++);
62
else
63
reset_buf
();
64
}
65
66
BufferComposed
&
bc
;
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
80
Complete
complete
()
81
{
82
return
Complete
(*
this
);
83
}
84
85
private
:
86
BufferVector
bv
;
87
};
88
}
// namespace openvpn
89
90
#endif
bufcomplete.hpp
buflist.hpp
openvpn::BufferComplete
Definition
bufcomplete.hpp:23
openvpn::BufferComplete::reset_buf
void reset_buf()
Definition
bufcomplete.hpp:82
openvpn::BufferComposed::Complete
Definition
bufcomposed.hpp:24
openvpn::BufferComposed::Complete::next_buffer
virtual void next_buffer() override
Definition
bufcomposed.hpp:52
openvpn::BufferComposed::Complete::iter
BufferVector::const_iterator iter
Definition
bufcomposed.hpp:67
openvpn::BufferComposed::Complete::bc
BufferComposed & bc
Definition
bufcomposed.hpp:66
openvpn::BufferComposed::Complete::iter_defined
bool iter_defined()
Definition
bufcomposed.hpp:47
openvpn::BufferComposed::Complete::Complete
Complete(BufferComposed &bc_arg)
Definition
bufcomposed.hpp:40
openvpn::BufferComposed::Complete::next_buffer_impl
void next_buffer_impl()
Definition
bufcomposed.hpp:58
openvpn::BufferComposed::Complete::get
BufferPtr get()
Definition
bufcomposed.hpp:26
openvpn::BufferComposed
Definition
bufcomposed.hpp:21
openvpn::BufferComposed::complete
Complete complete()
Definition
bufcomposed.hpp:80
openvpn::BufferComposed::size
size_t size() const
Definition
bufcomposed.hpp:70
openvpn::BufferComposed::bv
BufferVector bv
Definition
bufcomposed.hpp:86
openvpn::BufferComposed::put
void put(BufferPtr bp)
Definition
bufcomposed.hpp:75
openvpn::Exception
Definition
exception.hpp:38
openvpn::RCPtr< BufferAllocatedRc >
exception.hpp
openvpn
Definition
ovpncli.cpp:97
openvpn::BufferCollection< std::vector >
openvpn::BufferCollection::join_size
size_t join_size() const
Definition
buflist.hpp:64
openvpn::BufferCollection::join
BufferPtr join(const size_t headroom, const size_t tailroom, const bool size_1_optim) const
Definition
buflist.hpp:32
ret
std::string ret
Definition
test_capture.cpp:268
openvpn
buffer
bufcomposed.hpp
Generated by
1.9.8