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

83 lines
2.3 KiB
C++

#ifndef PACKET_VARIANT_HPP_LILZ0UWN
#define PACKET_VARIANT_HPP_LILZ0UWN
#include <vanetza/common/byte_view.hpp>
#include <vanetza/common/serialization.hpp>
#include <vanetza/net/chunk_packet.hpp>
#include <vanetza/net/cohesive_packet.hpp>
#include <boost/variant.hpp>
namespace vanetza
{
using PacketVariant = boost::variant<ChunkPacket, CohesivePacket>;
inline std::size_t
size(const CohesivePacket& packet, OsiLayer from, OsiLayer to)
{
return packet.size(from, to);
}
inline std::size_t
size(const CohesivePacket& packet, OsiLayer layer)
{
return packet.size(layer);
}
inline std::size_t
size(const ChunkPacket& packet, OsiLayer from, OsiLayer to)
{
return packet.size(from, to);
}
inline std::size_t
size(const ChunkPacket& packet, OsiLayer layer)
{
return packet[layer].size();
}
/**
* Create a view of a packet's bytes assigned to a certain layer
* \param packet
* \param layer
* \return a byte view, possibly empty
*/
byte_view_range create_byte_view(const ChunkPacket&, OsiLayer);
byte_view_range create_byte_view(const CohesivePacket&, OsiLayer);
/**
* Create a byte view for a sub-range of layers
* \param packet
* \param from first byte will be from this layer
* \param to last byte will be from this layer
* \return a byte view
*/
byte_view_range create_byte_view(const ChunkPacket& packet, OsiLayer from, OsiLayer to);
byte_view_range create_byte_view(const CohesivePacket& packet, OsiLayer from, OsiLayer to);
/**
* Serialize a whole packet from physical to application layer
* \param archive destination archive
* \param packet source packet
*/
void serialize(OutputArchive&, const ChunkPacket&);
void serialize(OutputArchive&, const CohesivePacket&);
} // namespace vanetza
namespace boost
{
// PacketVariant is only a type alias, so we need this quirk for proper name lookup
std::size_t size(const vanetza::PacketVariant&, vanetza::OsiLayer from, vanetza::OsiLayer to);
std::size_t size(const vanetza::PacketVariant&, vanetza::OsiLayer);
std::size_t size(const vanetza::PacketVariant&);
vanetza::byte_view_range create_byte_view(const vanetza::PacketVariant&, vanetza::OsiLayer);
vanetza::byte_view_range create_byte_view(const vanetza::PacketVariant&, vanetza::OsiLayer from, vanetza::OsiLayer to);
void serialize(vanetza::OutputArchive&, const vanetza::PacketVariant&);
} // namespace boost
#endif /* PACKET_VARIANT_HPP_LILZ0UWN */