mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
* companion: fix for importContact(). Now removes the packet-hash from table, before 'replaying'
This commit is contained in:
parent
1680eb29aa
commit
b11f43987b
3 changed files with 26 additions and 0 deletions
|
|
@ -16,6 +16,7 @@ public:
|
||||||
class MeshTables {
|
class MeshTables {
|
||||||
public:
|
public:
|
||||||
virtual bool hasSeen(const Packet* packet) = 0;
|
virtual bool hasSeen(const Packet* packet) = 0;
|
||||||
|
virtual void clear(const Packet* packet) = 0; // remove this packet hash from table
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -373,6 +373,7 @@ bool BaseChatMesh::importContact(const uint8_t src_buf[], uint8_t len) {
|
||||||
if (pkt) {
|
if (pkt) {
|
||||||
if (pkt->readFrom(src_buf, len) && pkt->getPayloadType() == PAYLOAD_TYPE_ADVERT) {
|
if (pkt->readFrom(src_buf, len) && pkt->getPayloadType() == PAYLOAD_TYPE_ADVERT) {
|
||||||
pkt->header |= ROUTE_TYPE_FLOOD; // simulate it being received flood-mode
|
pkt->header |= ROUTE_TYPE_FLOOD; // simulate it being received flood-mode
|
||||||
|
getTables()->clear(pkt); // remove packet hash from table, so we can receive/process it again
|
||||||
_pendingLoopback = pkt; // loop-back, as if received over radio
|
_pendingLoopback = pkt; // loop-back, as if received over radio
|
||||||
return true; // success
|
return true; // success
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,30 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clear(const mesh::Packet* packet) override {
|
||||||
|
if (packet->getPayloadType() == PAYLOAD_TYPE_ACK) {
|
||||||
|
uint32_t ack;
|
||||||
|
memcpy(&ack, packet->payload, 4);
|
||||||
|
for (int i = 0; i < MAX_PACKET_ACKS; i++) {
|
||||||
|
if (ack == _acks[i]) {
|
||||||
|
_acks[i] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
uint8_t hash[MAX_HASH_SIZE];
|
||||||
|
packet->calculatePacketHash(hash);
|
||||||
|
|
||||||
|
uint8_t* sp = _hashes;
|
||||||
|
for (int i = 0; i < MAX_PACKET_HASHES; i++, sp += MAX_HASH_SIZE) {
|
||||||
|
if (memcmp(hash, sp, MAX_HASH_SIZE) == 0) {
|
||||||
|
memset(sp, 0, MAX_HASH_SIZE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t getNumDirectDups() const { return _direct_dups; }
|
uint32_t getNumDirectDups() const { return _direct_dups; }
|
||||||
uint32_t getNumFloodDups() const { return _flood_dups; }
|
uint32_t getNumFloodDups() const { return _flood_dups; }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue