Vanetza
Loading...
Searching...
No Matches
peer_request_tracker.hpp
1
#
ifndef
A5037FF9_14E0_4DA9_8027_6C0692B1462B
2
#
define
A5037FF9_14E0_4DA9_8027_6C0692B1462B
3
4
#
include
<
vanetza
/
security
/
hashed_id
.
hpp
>
5
#
include
<
boost
/
optional
/
optional
.
hpp
>
6
#
include
<
list
>
7
#
include
<
unordered_map
>
8
9
namespace
vanetza
10
{
11
namespace
security
12
{
13
14
class
PeerRequestTracker
15
{
16
public
:
17
explicit
PeerRequestTracker(std::size_t limit = 16);
18
19
/**
20
* Add a certificate request to the tracker.
21
*
22
* \param id hash of requested certificate
23
*/
24
void
add_request
(
const
HashedId3&);
25
26
/**
27
* Discard a pending certificate request.
28
*
29
* \param id hash of certificate
30
*/
31
void
discard_request
(
const
HashedId3&);
32
33
/**
34
* Check if a certificate request is pending.
35
*
36
* \param id hash of certificate
37
* \return true if request of this certificate is pending
38
*/
39
bool
is_pending
(
const
HashedId3&)
const
;
40
41
/**
42
* Determine which request shall be handled next and remove it from the queue.
43
*
44
* \return hash of requested certificate if any
45
*/
46
boost::optional<HashedId3>
next_one
();
47
48
/**
49
* Retrieve next n pending requests from tracker.
50
*
51
* \return list of up to n certificate hashes
52
*/
53
std
::
list
<
HashedId3
>
next_n
(std::size_t max);
54
55
/**
56
* Retrieve all pending requests from tracker.
57
*
58
* \return list of all pending certificate hashes
59
*/
60
std
::
list
<
HashedId3
>
all
();
61
62
private
:
63
using
FifoQueue
=
std
::
list
<
HashedId3
>;
64
using
LookupMap
=
std
::
unordered_map
<
HashedId3
,
FifoQueue
::
iterator
>;
65
66
std::size_t m_limit;
67
FifoQueue m_fifo;
68
LookupMap m_lookup;
69
};
70
71
}
// namespace security
72
}
// namespace vanetza
73
74
#
endif
/* A5037FF9_14E0_4DA9_8027_6C0692B1462B */
vanetza::security::PeerRequestTracker
Definition
peer_request_tracker.hpp:15
vanetza::security::PeerRequestTracker::discard_request
void discard_request(const HashedId3 &)
Definition
peer_request_tracker.cpp:29
vanetza::security::PeerRequestTracker::next_n
std::list< HashedId3 > next_n(std::size_t max)
Definition
peer_request_tracker.cpp:58
vanetza::security::PeerRequestTracker::add_request
void add_request(const HashedId3 &)
Definition
peer_request_tracker.cpp:13
vanetza::security::PeerRequestTracker::is_pending
bool is_pending(const HashedId3 &) const
Definition
peer_request_tracker.cpp:40
vanetza::security::PeerRequestTracker::next_one
boost::optional< HashedId3 > next_one()
Definition
peer_request_tracker.cpp:45
vanetza::security::PeerRequestTracker::all
std::list< HashedId3 > all()
Definition
peer_request_tracker.cpp:77
vanetza
security
peer_request_tracker.hpp
Generated on
for Vanetza by
1.16.1