Files
Ashin Walpola d107534eb2 Keep vanetza-idf in obu-firmware, so a plain clone builds the firmware
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.
2026-09-24 10:56:05 +02:00

58 lines
1.5 KiB
C++

#include "proxy_header.hpp"
#include <vanetza/common/byte_order.hpp>
#include <cassert>
namespace vanetza
{
double get_signal_power(const ProxyHeader& header)
{
double power = ntoh(header.signal_power);
power /= 256.0;
return power;
}
void set_signal_power(ProxyHeader& header, double dbm)
{
auto power = static_cast<decltype(ProxyHeader::signal_power)>(dbm * 256.0);
header.signal_power = hton(power);
}
access::AccessCategory get_access_category(const ProxyHeader& header)
{
return static_cast<access::AccessCategory>(header.access_category & 0x07);
}
void set_access_category(ProxyHeader& header, access::AccessCategory ac)
{
header.access_category = static_cast<uint8_t>(ac);
}
boost::iterator_range<const uint8_t*> get_payload(const ProxyHeader& header, std::size_t size)
{
const auto payload_offset = ntoh(header.payload_offset);
const auto payload_size = ntoh(header.payload_size);
assert(size >= payload_offset + payload_size);
assert(payload_offset >= sizeof(ProxyHeader));
const uint8_t* begin = reinterpret_cast<const uint8_t*>(&header);
const uint8_t* end = begin;
if (size >= payload_offset + payload_size) {
begin += payload_offset;
end = begin + payload_size;
}
return boost::make_iterator_range(begin, end);
}
void set_payload(ProxyHeader& header, std::size_t size)
{
header.payload_offset = hton<decltype(header.payload_offset)>(sizeof(ProxyHeader));
header.payload_size = hton<decltype(header.payload_size)>(size);
}
} // namespace vanetza