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;
40 virtual std::size_t
length()
const = 0;
67 typedef std::unique_ptr<packet_buffer::Data> data_ptr;
81 bool push(data_ptr packet, Clock::time_point t);
88 void flush(Clock::time_point t);
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; }
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;
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