mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-01 07:30:33 +00:00
Initial NODENUM_BROADCAST_NO_LORA implementation with NeighborInfo module (#5087)
* Initial NODENUM_BROADCAST_NO_LORA implementation with NeighborInfo module * isBroadcast * Trunkt
This commit is contained in:
@@ -44,7 +44,7 @@ bool FloodingRouter::isRebroadcaster()
|
||||
void FloodingRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Routing *c)
|
||||
{
|
||||
bool isAckorReply = (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) && (p->decoded.request_id != 0);
|
||||
if (isAckorReply && !isToUs(p) && p->to != NODENUM_BROADCAST) {
|
||||
if (isAckorReply && !isToUs(p) && !isBroadcast(p->to)) {
|
||||
// do not flood direct message that is ACKed or replied to
|
||||
LOG_DEBUG("Rxd an ACK/reply not for me, cancel rebroadcast.");
|
||||
Router::cancelSending(p->to, p->decoded.request_id); // cancel rebroadcast for this DM
|
||||
|
||||
@@ -86,7 +86,7 @@ void MeshModule::callModules(meshtastic_MeshPacket &mp, RxSource src)
|
||||
|
||||
// Was this message directed to us specifically? Will be false if we are sniffing someone elses packets
|
||||
auto ourNodeNum = nodeDB->getNodeNum();
|
||||
bool toUs = mp.to == NODENUM_BROADCAST || isToUs(&mp);
|
||||
bool toUs = isBroadcast(mp.to) || isToUs(&mp);
|
||||
|
||||
for (auto i = modules->begin(); i != modules->end(); ++i) {
|
||||
auto &pi = **i;
|
||||
|
||||
@@ -57,4 +57,6 @@ bool isFromUs(const meshtastic_MeshPacket *p);
|
||||
bool isToUs(const meshtastic_MeshPacket *p);
|
||||
|
||||
/* Some clients might not properly set priority, therefore we fix it here. */
|
||||
void fixPriority(meshtastic_MeshPacket *p);
|
||||
void fixPriority(meshtastic_MeshPacket *p);
|
||||
|
||||
bool isBroadcast(uint32_t dest);
|
||||
@@ -222,6 +222,11 @@ bool isToUs(const meshtastic_MeshPacket *p)
|
||||
return p->to == nodeDB->getNodeNum();
|
||||
}
|
||||
|
||||
bool isBroadcast(uint32_t dest)
|
||||
{
|
||||
return dest == NODENUM_BROADCAST || dest == NODENUM_BROADCAST_NO_LORA;
|
||||
}
|
||||
|
||||
bool NodeDB::resetRadioConfig(bool factory_reset)
|
||||
{
|
||||
bool didFactoryReset = false;
|
||||
|
||||
@@ -467,7 +467,10 @@ void RadioLibInterface::setStandby()
|
||||
void RadioLibInterface::startSend(meshtastic_MeshPacket *txp)
|
||||
{
|
||||
printPacket("Starting low level send", txp);
|
||||
if (disabled || !config.lora.tx_enabled) {
|
||||
if (txp->to == NODENUM_BROADCAST_NO_LORA) {
|
||||
LOG_DEBUG("Drop Tx packet because dest is broadcast no-lora");
|
||||
packetPool.release(txp);
|
||||
} else if (disabled || !config.lora.tx_enabled) {
|
||||
LOG_WARN("Drop Tx packet because LoRa Tx disabled");
|
||||
packetPool.release(txp);
|
||||
} else {
|
||||
|
||||
@@ -181,7 +181,7 @@ ErrorCode Router::sendLocal(meshtastic_MeshPacket *p, RxSource src)
|
||||
} else {
|
||||
// If we are sending a broadcast, we also treat it as if we just received it ourself
|
||||
// this allows local apps (and PCs) to see broadcasts sourced locally
|
||||
if (p->to == NODENUM_BROADCAST) {
|
||||
if (isBroadcast(p->to)) {
|
||||
handleReceived(p, src);
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ ErrorCode Router::send(meshtastic_MeshPacket *p)
|
||||
// assert
|
||||
|
||||
// Never set the want_ack flag on broadcast packets sent over the air.
|
||||
if (p->to == NODENUM_BROADCAST)
|
||||
if (isBroadcast(p->to))
|
||||
p->want_ack = false;
|
||||
|
||||
// Up until this point we might have been using 0 for the from address (if it started with the phone), but when we send over
|
||||
@@ -328,7 +328,7 @@ bool perhapsDecode(meshtastic_MeshPacket *p)
|
||||
memcpy(ScratchEncrypted, p->encrypted.bytes, rawSize);
|
||||
#if !(MESHTASTIC_EXCLUDE_PKI)
|
||||
// Attempt PKI decryption first
|
||||
if (p->channel == 0 && isToUs(p) && p->to > 0 && p->to != NODENUM_BROADCAST && nodeDB->getMeshNode(p->from) != nullptr &&
|
||||
if (p->channel == 0 && isToUs(p) && p->to > 0 && !isBroadcast(p->to) && nodeDB->getMeshNode(p->from) != nullptr &&
|
||||
nodeDB->getMeshNode(p->from)->user.public_key.size > 0 && nodeDB->getMeshNode(p->to)->user.public_key.size > 0 &&
|
||||
rawSize > MESHTASTIC_PKC_OVERHEAD) {
|
||||
LOG_DEBUG("Attempting PKI decryption");
|
||||
@@ -493,7 +493,7 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
|
||||
// Don't use PKC if it's not explicitly requested and a non-primary channel is requested
|
||||
!(p->pki_encrypted != true && p->channel > 0) &&
|
||||
// Check for valid keys and single node destination
|
||||
config.security.private_key.size == 32 && p->to != NODENUM_BROADCAST && node != nullptr &&
|
||||
config.security.private_key.size == 32 && !isBroadcast(p->to) && node != nullptr &&
|
||||
// Check for a known public key for the destination
|
||||
(node->user.public_key.size == 32) &&
|
||||
// Some portnums either make no sense to send with PKC
|
||||
@@ -615,7 +615,7 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src)
|
||||
#if !MESHTASTIC_EXCLUDE_MQTT
|
||||
// Mark as pki_encrypted if it is not yet decoded and MQTT encryption is also enabled, hash matches and it's a DM not to
|
||||
// us (because we would be able to decrypt it)
|
||||
if (!decoded && moduleConfig.mqtt.encryption_enabled && p->channel == 0x00 && p->to != NODENUM_BROADCAST && !isToUs(p))
|
||||
if (!decoded && moduleConfig.mqtt.encryption_enabled && p->channel == 0x00 && !isBroadcast(p->to) && !isToUs(p))
|
||||
p_encrypted->pki_encrypted = true;
|
||||
// After potentially altering it, publish received message to MQTT if we're not the original transmitter of the packet
|
||||
if ((decoded || p_encrypted->pki_encrypted) && moduleConfig.mqtt.enabled && !isFromUs(p) && mqtt)
|
||||
|
||||
Reference in New Issue
Block a user