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).
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
#ifndef OSI_LAYER_HPP_C4VTEZJP
|
||||
#define OSI_LAYER_HPP_C4VTEZJP
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
|
||||
namespace vanetza
|
||||
{
|
||||
|
||||
enum class OsiLayer : uint8_t
|
||||
{
|
||||
Physical = 1,
|
||||
Link = 2,
|
||||
Network = 3,
|
||||
Transport = 4,
|
||||
Session = 5,
|
||||
Presentation = 6,
|
||||
Application = 7
|
||||
};
|
||||
|
||||
constexpr OsiLayer min_osi_layer() { return OsiLayer::Physical; }
|
||||
constexpr OsiLayer max_osi_layer() { return OsiLayer::Application; }
|
||||
|
||||
constexpr std::array<OsiLayer, 7> osi_layers {{
|
||||
OsiLayer::Physical,
|
||||
OsiLayer::Link,
|
||||
OsiLayer::Network,
|
||||
OsiLayer::Transport,
|
||||
OsiLayer::Session,
|
||||
OsiLayer::Presentation,
|
||||
OsiLayer::Application
|
||||
}};
|
||||
|
||||
/**
|
||||
* Calculate distance between layers
|
||||
* \param from start counting at this layer
|
||||
* \param to stop counting here
|
||||
* \return 0 if equal layers, positive if "to" is a higher layer, negative if "to" is below "from"
|
||||
*/
|
||||
constexpr int distance(OsiLayer from, OsiLayer to)
|
||||
{
|
||||
return static_cast<int>(to) - static_cast<int>(from);
|
||||
}
|
||||
|
||||
constexpr std::size_t num_osi_layers(OsiLayer from, OsiLayer to)
|
||||
{
|
||||
return (from <= to ? distance(from, to) + 1 : 0);
|
||||
}
|
||||
|
||||
template<OsiLayer FROM, OsiLayer TO>
|
||||
std::array<OsiLayer, num_osi_layers(FROM, TO)> osi_layer_range()
|
||||
{
|
||||
static_assert(FROM <= TO, "FROM layer is above TO layer");
|
||||
typedef typename std::underlying_type<OsiLayer>::type num_type;
|
||||
|
||||
num_type num = static_cast<num_type>(FROM);
|
||||
std::array<OsiLayer, num_osi_layers(FROM, TO)> layers;
|
||||
for (auto& layer : layers) {
|
||||
layer = static_cast<OsiLayer>(num++);
|
||||
}
|
||||
return layers;
|
||||
}
|
||||
|
||||
inline boost::iterator_range<decltype(osi_layers)::const_iterator>
|
||||
osi_layer_range(OsiLayer from, OsiLayer to)
|
||||
{
|
||||
if (from <= to) {
|
||||
auto begin = osi_layers.cbegin() + distance(min_osi_layer(), from);
|
||||
auto end = osi_layers.cend() - distance(to, max_osi_layer());
|
||||
return boost::make_iterator_range(begin, end);
|
||||
} else {
|
||||
return boost::make_iterator_range(osi_layers.cend(), osi_layers.cend());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace vanetza
|
||||
|
||||
#endif /* OSI_LAYER_HPP_C4VTEZJP */
|
||||
|
||||
Reference in New Issue
Block a user