obu-firmware builds against the vanetza-idf C-ITS library, which until now came from the colleague's microbu-esp32c5 tree beside the repository and was not tracked here, so a clone of this repository could not build the firmware it ships. The library alone is now part of obu-firmware, as obu-firmware/external/vanetza-idf: their external/vanetza-idf at commit cf4b99f, unchanged (9775 files; see its PROVENANCE.md). CMake takes it from there by default; -DVANETZA_IDF_DIR still points the build elsewhere. The rest of the colleague's tree (their own VAM firmware, PKI tooling, station-link Python tools, the V2X2MAP bridge) stays out of this repository and gitignored; nothing is pushed to their repository. NOTES.md, docs/06, TODO.md and the pcap verifier's usage line point at the new location.
53 lines
1.4 KiB
C++
53 lines
1.4 KiB
C++
#include <vanetza/geonet/gbc_memory.hpp>
|
|
|
|
namespace vanetza
|
|
{
|
|
namespace geonet
|
|
{
|
|
|
|
void GbcMemory::capacity(std::size_t num)
|
|
{
|
|
m_capacity = num < 1 ? 1 : num;
|
|
|
|
// remove excessive identifiers
|
|
auto& by_queue_index = m_identifiers.get<by_queue>();
|
|
while (by_queue_index.size() > m_capacity) {
|
|
by_queue_index.pop_front();
|
|
}
|
|
}
|
|
|
|
std::size_t GbcMemory::size() const
|
|
{
|
|
return m_identifiers.size();
|
|
}
|
|
|
|
bool GbcMemory::remember(const PacketIdentifier& id)
|
|
{
|
|
auto& by_packet_index = m_identifiers.get<by_packet>();
|
|
auto found_packet = by_packet_index.find(id);
|
|
if (found_packet == by_packet_index.end()) {
|
|
// make space for one identifier
|
|
auto& by_queue_index = m_identifiers.get<by_queue>();
|
|
while (!by_queue_index.empty() && by_queue_index.size() >= m_capacity) {
|
|
by_queue_index.pop_front();
|
|
}
|
|
|
|
by_queue_index.push_back(id);
|
|
return false;
|
|
} else {
|
|
// packet is already known, just move it to end of queue
|
|
auto found_queue = m_identifiers.project<by_queue>(found_packet);
|
|
auto& by_queue_index = m_identifiers.get<by_queue>();
|
|
by_queue_index.relocate(by_queue_index.end(), found_queue);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
bool GbcMemory::knows(const PacketIdentifier& id) const
|
|
{
|
|
return m_identifiers.get<by_packet>().find(id) != m_identifiers.get<by_packet>().end();
|
|
}
|
|
|
|
} // namespace geonet
|
|
} // namespace vanetza
|