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,86 @@
|
||||
#ifndef PORT_DISPATCHER_HPP_YZ0UTAUF
|
||||
#define PORT_DISPATCHER_HPP_YZ0UTAUF
|
||||
|
||||
#include <vanetza/btp/data_interface.hpp>
|
||||
#include <vanetza/btp/header.hpp>
|
||||
#include <vanetza/common/hook.hpp>
|
||||
#include <vanetza/geonet/transport_interface.hpp>
|
||||
#include <vanetza/net/packet.hpp>
|
||||
#include <list>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace vanetza
|
||||
{
|
||||
|
||||
namespace btp
|
||||
{
|
||||
|
||||
class PortDispatcher : public geonet::TransportInterface
|
||||
{
|
||||
public:
|
||||
class PromiscuousHook
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Called when a BTP packet is received, regardless of its destination port
|
||||
* \param indication BTP data indication
|
||||
* \param packet Read-only view of packet
|
||||
*/
|
||||
virtual void tap_packet(const DataIndication&, const UpPacket&) = 0;
|
||||
virtual ~PromiscuousHook() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Register a handler for incoming BTP-A (interactive) packets
|
||||
* \param port BTP-A destination port
|
||||
* \param interface Handler for given destination port
|
||||
* \note Use a nullptr as handler to disable dispatching of destination port
|
||||
* \note Only one handler can be registered per port
|
||||
*/
|
||||
void set_interactive_handler(port_type, IndicationInterface*);
|
||||
|
||||
/**
|
||||
* Register a handler for incoming BTP-B (non-interactive) packets
|
||||
* \param port BTP-B destination port
|
||||
* \param interface Handler for given destination port
|
||||
* \note Use a nullptr as handler to disable dispatching of destination port
|
||||
* \note Only one handler can be registered per port
|
||||
*/
|
||||
void set_non_interactive_handler(port_type, IndicationInterface*);
|
||||
|
||||
/**
|
||||
* Add a hook listening for all incoming BTP packets
|
||||
* \param hook A hook implementing the promiscuous hook interface
|
||||
* \note Each registered hook is invoked only once per indication
|
||||
*/
|
||||
void add_promiscuous_hook(PromiscuousHook* hook);
|
||||
|
||||
/**
|
||||
* Remove promiscuous hook
|
||||
* \param hook pointer to previously added hook
|
||||
*/
|
||||
void remove_promiscuous_hook(PromiscuousHook*);
|
||||
|
||||
// Implementation of geonet::TransportInterface
|
||||
void indicate(const geonet::DataIndication&, std::unique_ptr<UpPacket>) override;
|
||||
|
||||
/**
|
||||
* Hook invoked for all indicated but undispatched packets
|
||||
* \note BTP data indication can be nullptr
|
||||
*/
|
||||
Hook<const geonet::DataIndication&, const btp::DataIndication*> hook_undispatched;
|
||||
|
||||
private:
|
||||
typedef std::unordered_map<port_type, IndicationInterface*> port_map;
|
||||
typedef std::list<PromiscuousHook*> hook_list;
|
||||
|
||||
port_map m_interactive_handlers;
|
||||
port_map m_non_interactive_handlers;
|
||||
hook_list m_promiscuous_hooks;
|
||||
};
|
||||
|
||||
} // namespace btp
|
||||
} // namespace vanetza
|
||||
|
||||
#endif /* PORT_DISPATCHER_HPP_YZ0UTAUF */
|
||||
|
||||
Reference in New Issue
Block a user