OpenVPN 3 Core Library
Loading...
Searching...
No Matches
memq.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
// A queue of buffers, implemented as std::deque<BufferPtr>.
13
14
#ifndef OPENVPN_BUFFER_MEMQ_H
15
#define OPENVPN_BUFFER_MEMQ_H
16
17
#include <deque>
18
19
#include <
openvpn/common/size.hpp
>
20
#include <
openvpn/buffer/buffer.hpp
>
21
22
namespace
openvpn
{
23
24
class
MemQBase
25
{
26
public
:
27
MemQBase
()
28
:
length
(0)
29
{
30
}
31
32
size_t
size
()
const
33
{
34
return
q
.size();
35
}
36
37
bool
empty
()
const
38
{
39
return
q
.empty();
40
}
41
42
size_t
total_length
()
const
43
{
44
return
length
;
45
}
46
47
void
clear
()
48
{
49
while
(!
q
.empty())
50
q
.pop_back();
51
length
= 0;
52
}
53
54
void
write_buf
(
const
BufferPtr
&bp)
55
{
56
q
.push_back(bp);
57
length
+= bp->size();
58
}
59
60
BufferPtr
read_buf
()
61
{
62
BufferPtr
ret
=
q
.front();
63
q
.pop_front();
64
length
-=
ret
->size();
65
return
ret
;
66
}
67
68
BufferPtr
&
peek
()
69
{
70
return
q
.front();
71
}
72
73
void
pop
()
74
{
75
length
-=
q
.front()->size();
76
q
.pop_front();
77
}
78
79
void
resize
(
const
size_t
cap)
80
{
81
q
.resize(cap);
82
}
83
84
protected
:
85
typedef
std::deque<BufferPtr>
q_type
;
86
size_t
length
;
87
q_type
q
;
88
};
89
90
}
// namespace openvpn
91
92
#endif
// OPENVPN_BUFFER_MEMQ_H
buffer.hpp
openvpn::MemQBase
Definition
memq.hpp:25
openvpn::MemQBase::pop
void pop()
Definition
memq.hpp:73
openvpn::MemQBase::empty
bool empty() const
Definition
memq.hpp:37
openvpn::MemQBase::q
q_type q
Definition
memq.hpp:87
openvpn::MemQBase::MemQBase
MemQBase()
Definition
memq.hpp:27
openvpn::MemQBase::total_length
size_t total_length() const
Definition
memq.hpp:42
openvpn::MemQBase::size
size_t size() const
Definition
memq.hpp:32
openvpn::MemQBase::resize
void resize(const size_t cap)
Definition
memq.hpp:79
openvpn::MemQBase::clear
void clear()
Definition
memq.hpp:47
openvpn::MemQBase::length
size_t length
Definition
memq.hpp:86
openvpn::MemQBase::read_buf
BufferPtr read_buf()
Definition
memq.hpp:60
openvpn::MemQBase::q_type
std::deque< BufferPtr > q_type
Definition
memq.hpp:85
openvpn::MemQBase::write_buf
void write_buf(const BufferPtr &bp)
Definition
memq.hpp:54
openvpn::MemQBase::peek
BufferPtr & peek()
Definition
memq.hpp:68
openvpn::RCPtr< BufferAllocatedRc >
openvpn
Definition
ovpncli.cpp:97
size.hpp
ret
std::string ret
Definition
test_capture.cpp:268
openvpn
buffer
memq.hpp
Generated by
1.9.8