mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
* setting up framework for Regions, TransportKeys, etc
This commit is contained in:
parent
5b4544b9fe
commit
03fc949014
6 changed files with 166 additions and 2 deletions
|
|
@ -404,6 +404,23 @@ uint32_t MyMesh::getDirectRetransmitDelay(const mesh::Packet *packet) {
|
|||
return getRNG()->nextInt(0, 5*t + 1);
|
||||
}
|
||||
|
||||
mesh::DispatcherAction MyMesh::onRecvPacket(mesh::Packet* pkt) {
|
||||
if (pkt->getRouteType() == ROUTE_TYPE_TRANSPORT_FLOOD) {
|
||||
auto region = region_map.findMatch(pkt, REGION_ALLOW_FLOOD);
|
||||
if (region == NULL) {
|
||||
MESH_DEBUG_PRINTLN("onRecvPacket: unknown transport code for FLOOD packet");
|
||||
return ACTION_RELEASE;
|
||||
}
|
||||
} else if (pkt->getRouteType() == ROUTE_TYPE_FLOOD) {
|
||||
if ((region_map.getWildcard().flags & REGION_ALLOW_FLOOD) == 0) {
|
||||
MESH_DEBUG_PRINTLN("onRecvPacket: wildcard FLOOD packet not allowed");
|
||||
return ACTION_RELEASE;
|
||||
}
|
||||
}
|
||||
// otherwise do normal processing
|
||||
return mesh::Mesh::onRecvPacket(pkt);
|
||||
}
|
||||
|
||||
void MyMesh::onAnonDataRecv(mesh::Packet *packet, const uint8_t *secret, const mesh::Identity &sender,
|
||||
uint8_t *data, size_t len) {
|
||||
if (packet->getPayloadType() == PAYLOAD_TYPE_ANON_REQ) { // received an initial request by a possible admin
|
||||
|
|
@ -593,7 +610,7 @@ bool MyMesh::onPeerPathRecv(mesh::Packet *packet, int sender_idx, const uint8_t
|
|||
MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondClock &ms, mesh::RNG &rng,
|
||||
mesh::RTCClock &rtc, mesh::MeshTables &tables)
|
||||
: mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables),
|
||||
_cli(board, rtc, sensors, &_prefs, this), telemetry(MAX_PACKET_PAYLOAD - 4)
|
||||
_cli(board, rtc, sensors, &_prefs, this), telemetry(MAX_PACKET_PAYLOAD - 4), region_map(key_store)
|
||||
#if defined(WITH_RS232_BRIDGE)
|
||||
, bridge(&_prefs, WITH_RS232_BRIDGE, _mgr, &rtc)
|
||||
#endif
|
||||
|
|
@ -652,8 +669,9 @@ void MyMesh::begin(FILESYSTEM *fs) {
|
|||
_fs = fs;
|
||||
// load persisted prefs
|
||||
_cli.loadPrefs(_fs);
|
||||
|
||||
acl.load(_fs);
|
||||
// TODO: key_store.begin();
|
||||
region_map.load(_fs);
|
||||
|
||||
#if defined(WITH_BRIDGE)
|
||||
if (_prefs.bridge_enabled) {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include <helpers/StaticPoolPacketManager.h>
|
||||
#include <helpers/StatsFormatHelper.h>
|
||||
#include <helpers/TxtDataHelpers.h>
|
||||
#include <helpers/RegionMap.h>
|
||||
|
||||
#ifdef WITH_BRIDGE
|
||||
extern AbstractBridge* bridge;
|
||||
|
|
@ -87,6 +88,8 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
|
|||
CommonCLI _cli;
|
||||
uint8_t reply_data[MAX_PACKET_PAYLOAD];
|
||||
ClientACL acl;
|
||||
TransportKeyStore key_store;
|
||||
RegionMap region_map;
|
||||
unsigned long dirty_contacts_expiry;
|
||||
#if MAX_NEIGHBOURS
|
||||
NeighbourInfo neighbours[MAX_NEIGHBOURS];
|
||||
|
|
@ -144,6 +147,8 @@ protected:
|
|||
}
|
||||
#endif
|
||||
|
||||
mesh::DispatcherAction onRecvPacket(mesh::Packet* pkt) override;
|
||||
|
||||
void onAnonDataRecv(mesh::Packet* packet, const uint8_t* secret, const mesh::Identity& sender, uint8_t* data, size_t len) override;
|
||||
int searchPeersByHash(const uint8_t* hash) override;
|
||||
void getPeerSharedSecret(uint8_t* dest_secret, int peer_idx) override;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue