1#ifndef PACKET_BUFFER_HPP_U97KIBQC
2#define PACKET_BUFFER_HPP_U97KIBQC
4#include <vanetza/common/clock.hpp>
5#include <vanetza/geonet/packet.hpp>
6#include <vanetza/geonet/pdu.hpp>
7#include <vanetza/geonet/timestamp.hpp>
8#include <vanetza/net/mac_address.hpp>
17namespace packet_buffer
23 Expiry(
Clock::time_point now,
Clock::duration lifetime);
24 bool is_expired(
Clock::time_point now)
const;
25 Clock::time_point buffered_since()
const {
return m_buffered_since; }
26 Clock::time_point expires_at()
const {
return m_expires_at; }
29 Clock::time_point m_buffered_since;
30 Clock::time_point m_expires_at;
37
38
39
40 virtual std::size_t
length()
const = 0;
43
44
45
46
50
51
52
62
63
67 typedef std::unique_ptr<packet_buffer::Data> data_ptr;
70
71
72
76
77
78
79
80
81 bool push(data_ptr packet,
Clock::time_point t);
84
85
86
87
91 typedef packet_buffer::
Expiry expiry_type;
92 typedef std::tuple<expiry_type, data_ptr> node_type;
94 std::size_t free()
const {
return m_capacity - m_stored; }
95 std::size_t capacity()
const {
return m_capacity; }
98
99
100
101
102
103 void push(expiry_type&& expiry, data_ptr packet);
106
107
108
112
113
114
118
119
120
121
122
123 bool drop(std::size_t bytes);
125 std::list<node_type> m_nodes;
126 std::size_t m_capacity;
127 std::size_t m_stored;
PacketBuffer(std::size_t capacity)
bool drop(std::size_t bytes)
void push(expiry_type &&expiry, data_ptr packet)
void flush(Clock::time_point t)
void drop_expired(Clock::time_point t)
bool push(data_ptr packet, Clock::time_point t)
virtual std::size_t length() const =0
virtual Clock::duration reduce_lifetime(Clock::duration d)=0