2021-06-27 17:56:28 +00:00
|
|
|
#include "configuration.h"
|
2022-02-27 08:18:35 +00:00
|
|
|
#include "RoutingModule.h"
|
2021-02-17 05:06:23 +00:00
|
|
|
#include "MeshService.h"
|
|
|
|
#include "NodeDB.h"
|
|
|
|
#include "Router.h"
|
|
|
|
#include "main.h"
|
|
|
|
|
2022-02-27 10:21:02 +00:00
|
|
|
RoutingModule *routingModule;
|
2021-02-17 05:06:23 +00:00
|
|
|
|
2022-02-27 10:21:02 +00:00
|
|
|
bool RoutingModule::handleReceivedProtobuf(const MeshPacket &mp, Routing *r)
|
2021-02-17 05:06:23 +00:00
|
|
|
{
|
2021-03-05 03:44:45 +00:00
|
|
|
printPacket("Routing sniffing", &mp);
|
2021-02-21 04:59:47 +00:00
|
|
|
router->sniffReceived(&mp, r);
|
|
|
|
|
2022-02-27 08:29:05 +00:00
|
|
|
// FIXME - move this to a non promsicious PhoneAPI module?
|
2021-03-05 03:44:45 +00:00
|
|
|
// Note: we are careful not to send back packets that started with the phone back to the phone
|
|
|
|
if ((mp.to == NODENUM_BROADCAST || mp.to == nodeDB.getNodeNum()) && (mp.from != 0)) {
|
2021-02-21 04:59:47 +00:00
|
|
|
printPacket("Delivering rx packet", &mp);
|
|
|
|
service.handleFromRadio(&mp);
|
|
|
|
}
|
2021-03-23 03:44:51 +00:00
|
|
|
|
2021-02-17 05:06:23 +00:00
|
|
|
return false; // Let others look at this message also if they want
|
|
|
|
}
|
|
|
|
|
2022-02-27 10:21:02 +00:00
|
|
|
MeshPacket *RoutingModule::allocReply()
|
2021-02-17 05:06:23 +00:00
|
|
|
{
|
2021-02-23 06:35:34 +00:00
|
|
|
assert(currentRequest);
|
|
|
|
|
|
|
|
// We only consider making replies if the request was a legit routing packet (not just something we were sniffing)
|
2021-03-23 03:44:51 +00:00
|
|
|
if (currentRequest->decoded.portnum == PortNum_ROUTING_APP) {
|
2021-02-23 06:35:34 +00:00
|
|
|
assert(0); // 1.2 refactoring fixme, Not sure if anything needs this yet?
|
|
|
|
// return allocDataProtobuf(u);
|
|
|
|
}
|
2021-02-17 05:06:23 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-02-27 10:21:02 +00:00
|
|
|
void RoutingModule::sendAckNak(Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex)
|
2021-02-17 05:06:23 +00:00
|
|
|
{
|
2021-03-23 03:44:51 +00:00
|
|
|
auto p = allocAckNak(err, to, idFrom, chIndex);
|
2021-02-17 05:06:23 +00:00
|
|
|
|
|
|
|
router->sendLocal(p); // we sometimes send directly to the local node
|
|
|
|
}
|
|
|
|
|
2022-03-09 08:01:43 +00:00
|
|
|
RoutingModule::RoutingModule() : ProtobufModule("routing", PortNum_ROUTING_APP, Routing_fields)
|
2021-02-17 05:06:23 +00:00
|
|
|
{
|
|
|
|
isPromiscuous = true;
|
|
|
|
}
|