1#ifndef CBF_PACKET_BUFFER_HPP_MU3RK5V1
2#define CBF_PACKET_BUFFER_HPP_MU3RK5V1
4#include <vanetza/common/clock.hpp>
5#include <vanetza/geonet/cbf_packet_identifier.hpp>
6#include <vanetza/geonet/packet.hpp>
7#include <vanetza/geonet/pending_packet.hpp>
8#include <vanetza/geonet/pdu_variant.hpp>
9#include <boost/bimap/bimap.hpp>
10#include <boost/bimap/multiset_of.hpp>
11#include <boost/bimap/unordered_set_of.hpp>
12#include <boost/optional/optional.hpp>
30
31
32
43
44
45
49
50
51
55
56
57
61
62
63
64
68
69
70
71 std::size_t
length()
const;
73 PendingPacket<GbcPdu> packet() && {
return std::move(m_packet); }
82
83
87 using TimerCallback = std::function<
void(
PendingPacket<GbcPdu>&&)>;
88 using Identifier = CbfPacketIdentifier;
91
92
93
94
95
96
101
102
103
104
108
109
110
111
112 bool remove(
const Identifier& id);
115
116
117
118
119 void update(
const Identifier& id,
Clock::duration timeout);
122
123
124
125
126
127
128
129
133
134
135
136
140
141
142
143
144
145 std::size_t
counter(
const Identifier& packet)
const;
152 Timer(
const Timer&) =
default;
154 bool operator<(
const Timer&)
const;
156 Clock::time_point expiry;
157 Clock::time_point start;
167
168
172
173
177
178
182
183
184
185
186
189 std::list<CbfPacket> m_packets;
190 timer_bimap m_timers;
192 std::unique_ptr<CbfCounter> m_counter;
193 const std::size_t m_capacity_bytes;
194 std::size_t m_stored_bytes;
195 TimerCallback m_timer_callback;
virtual void cancel(const void *scope)=0
virtual Clock::time_point now() const =0
std::size_t counter(const Identifier &packet) const
boost::optional< CbfPacket > fetch(const Identifier &id)
void remove_timer(typename timer_bimap::left_map::iterator)
bool remove(const Identifier &id)
CbfPacketBuffer(Runtime &rt, TimerCallback cb, std::unique_ptr< CbfCounter > cnt, std::size_t bytes)
void update(const Identifier &id, Clock::duration timeout)
void add(CbfPacket &&packet, Clock::duration timeout)
const CbfPacket * find(const Identifier &id) const
bool reduce_lifetime(const Timer &, CbfPacket &) const
std::size_t length() const
Clock::duration reduce_lifetime(Clock::duration d)
const MacAddress & sender() const
SequenceNumber sequence_number() const
const Address & source() const