Files
MicrOBU/microbu-esp32c5/external/vanetza-idf/vanetza/security/peer_request_tracker.hpp
T
Ashin Walpola 0e9525162d Keep the colleague's microbu-esp32c5 tree in this repository
obu-firmware builds against vanetza-idf from microbu-esp32c5/external, but
that tree was gitignored, so a clone of this repository could not build the
firmware it ships. It is now committed here as ordinary files in its own
folder, microbu-esp32c5/: the colleague's commit cf4b99f plus the V2X2MAP
bridge's signature verification (--trust) used on the bench. Nothing is
fetched from or pushed to the colleague's repository; this repository and
its remotes carry everything. The folder's own .gitignore keeps build output,
downloaded components and private key material out, as it did there; the
committed file set is identical to that repository's tracked files.

The ESP32-C5 is still flashed from obu-firmware/, which only takes
vanetza-idf from microbu-esp32c5/, so the two stay separate folders.
FLASHING.md says how to take a newer version of the colleague's tree (copy
it over the folder, rebuild, test, commit).
2026-09-23 17:46:40 +02:00

75 lines
1.7 KiB
C++

#ifndef A5037FF9_14E0_4DA9_8027_6C0692B1462B
#define A5037FF9_14E0_4DA9_8027_6C0692B1462B
#include <vanetza/security/hashed_id.hpp>
#include <boost/optional/optional.hpp>
#include <list>
#include <unordered_map>
namespace vanetza
{
namespace security
{
class PeerRequestTracker
{
public:
explicit PeerRequestTracker(std::size_t limit = 16);
/**
* Add a certificate request to the tracker.
*
* \param id hash of requested certificate
*/
void add_request(const HashedId3&);
/**
* Discard a pending certificate request.
*
* \param id hash of certificate
*/
void discard_request(const HashedId3&);
/**
* Check if a certificate request is pending.
*
* \param id hash of certificate
* \return true if request of this certificate is pending
*/
bool is_pending(const HashedId3&) const;
/**
* Determine which request shall be handled next and remove it from the queue.
*
* \return hash of requested certificate if any
*/
boost::optional<HashedId3> next_one();
/**
* Retrieve next n pending requests from tracker.
*
* \return list of up to n certificate hashes
*/
std::list<HashedId3> next_n(std::size_t max);
/**
* Retrieve all pending requests from tracker.
*
* \return list of all pending certificate hashes
*/
std::list<HashedId3> all();
private:
using FifoQueue = std::list<HashedId3>;
using LookupMap = std::unordered_map<HashedId3, FifoQueue::iterator>;
std::size_t m_limit;
FifoQueue m_fifo;
LookupMap m_lookup;
};
} // namespace security
} // namespace vanetza
#endif /* A5037FF9_14E0_4DA9_8027_6C0692B1462B */