@@ -55,7 +55,8 @@ DispatcherAction Mesh::onRecvPacket(Packet* pkt) {
5555 uint16_t offset = (uint16_t )pkt->path_len << path_sz;
5656 if (offset >= len) { // TRACE has reached end of given path
5757 onTraceRecv (pkt, trace_tag, auth_code, flags, pkt->path , &pkt->payload [i], len);
58- } else if (self_id.isHashMatch (&pkt->payload [i + offset], 1 << path_sz) && allowPacketForward (pkt) && !_tables->hasSeen (pkt)) {
58+ } else if (self_id.isHashMatch (&pkt->payload [i + offset], 1 << path_sz) && allowPacketForward (pkt) && !_tables->wasSeen (pkt)) {
59+ _tables->markSeen (pkt);
5960 // append SNR (Not hash!)
6061 pkt->path [pkt->path_len ++] = (int8_t ) (pkt->getSNR ()*4 );
6162
@@ -89,14 +90,16 @@ DispatcherAction Mesh::onRecvPacket(Packet* pkt) {
8990 if (pkt->getPayloadType () == PAYLOAD_TYPE_MULTIPART ) {
9091 return forwardMultipartDirect (pkt);
9192 } else if (pkt->getPayloadType () == PAYLOAD_TYPE_ACK ) {
92- if (!_tables->hasSeen (pkt)) { // don't retransmit!
93+ if (!_tables->wasSeen (pkt)) { // don't retransmit!
94+ _tables->markSeen (pkt);
9395 removeSelfFromPath (pkt);
9496 routeDirectRecvAcks (pkt, 0 );
9597 }
9698 return ACTION_RELEASE ;
9799 }
98100
99- if (!_tables->hasSeen (pkt)) {
101+ if (!_tables->wasSeen (pkt)) {
102+ _tables->markSeen (pkt);
100103 removeSelfFromPath (pkt);
101104
102105 uint32_t d = getDirectRetransmitDelay (pkt);
@@ -117,7 +120,8 @@ DispatcherAction Mesh::onRecvPacket(Packet* pkt) {
117120 memcpy (&ack_crc, &pkt->payload [i], 4 ); i += 4 ;
118121 if (i > pkt->payload_len ) {
119122 MESH_DEBUG_PRINTLN (" %s Mesh::onRecvPacket(): incomplete ACK packet" , getLogDateTime ());
120- } else if (!_tables->hasSeen (pkt)) {
123+ } else if (!_tables->wasSeen (pkt)) {
124+ _tables->markSeen (pkt);
121125 onAckRecv (pkt, ack_crc);
122126 action = routeRecvPacket (pkt);
123127 }
@@ -134,7 +138,8 @@ DispatcherAction Mesh::onRecvPacket(Packet* pkt) {
134138 uint8_t * macAndData = &pkt->payload [i]; // MAC + encrypted data
135139 if (i + CIPHER_MAC_SIZE >= pkt->payload_len ) {
136140 MESH_DEBUG_PRINTLN (" %s Mesh::onRecvPacket(): incomplete data packet" , getLogDateTime ());
137- } else if (!_tables->hasSeen (pkt)) {
141+ } else if (!_tables->wasSeen (pkt)) {
142+ _tables->markSeen (pkt);
138143 // NOTE: this is a 'first packet wins' impl. When receiving from multiple paths, the first to arrive wins.
139144 // For flood mode, the path may not be the 'best' in terms of hops.
140145 // FUTURE: could send back multiple paths, using createPathReturn(), and let sender choose which to use(?)
@@ -197,7 +202,8 @@ DispatcherAction Mesh::onRecvPacket(Packet* pkt) {
197202 uint8_t * macAndData = &pkt->payload [i]; // MAC + encrypted data
198203 if (i + 2 >= pkt->payload_len ) {
199204 MESH_DEBUG_PRINTLN (" %s Mesh::onRecvPacket(): incomplete data packet" , getLogDateTime ());
200- } else if (!_tables->hasSeen (pkt)) {
205+ } else if (!_tables->wasSeen (pkt)) {
206+ _tables->markSeen (pkt);
201207 if (self_id.isHashMatch (&dest_hash)) {
202208 Identity sender (sender_pub_key);
203209
@@ -224,7 +230,8 @@ DispatcherAction Mesh::onRecvPacket(Packet* pkt) {
224230 uint8_t * macAndData = &pkt->payload [i]; // MAC + encrypted data
225231 if (i + 2 >= pkt->payload_len ) {
226232 MESH_DEBUG_PRINTLN (" %s Mesh::onRecvPacket(): incomplete data packet" , getLogDateTime ());
227- } else if (!_tables->hasSeen (pkt)) {
233+ } else if (!_tables->wasSeen (pkt)) {
234+ _tables->markSeen (pkt);
228235 // scan channels DB, for all matching hashes of 'channel_hash' (max 4 matches supported ATM)
229236 GroupChannel channels[4 ];
230237 int num = searchChannelsByHash (&channel_hash, channels, 4 );
@@ -255,7 +262,8 @@ DispatcherAction Mesh::onRecvPacket(Packet* pkt) {
255262 MESH_DEBUG_PRINTLN (" %s Mesh::onRecvPacket(): incomplete advertisement packet" , getLogDateTime ());
256263 } else if (self_id.matches (id.pub_key )) {
257264 MESH_DEBUG_PRINTLN (" %s Mesh::onRecvPacket(): receiving SELF advert packet" , getLogDateTime ());
258- } else if (!_tables->hasSeen (pkt)) {
265+ } else if (!_tables->wasSeen (pkt)) {
266+ _tables->markSeen (pkt);
259267 uint8_t * app_data = &pkt->payload [i];
260268 int app_data_len = pkt->payload_len - i;
261269 if (app_data_len > MAX_ADVERT_DATA_SIZE ) { app_data_len = MAX_ADVERT_DATA_SIZE ; }
@@ -282,7 +290,8 @@ DispatcherAction Mesh::onRecvPacket(Packet* pkt) {
282290 break ;
283291 }
284292 case PAYLOAD_TYPE_RAW_CUSTOM : {
285- if (pkt->isRouteDirect () && !_tables->hasSeen (pkt)) {
293+ if (pkt->isRouteDirect () && !_tables->wasSeen (pkt)) {
294+ _tables->markSeen (pkt);
286295 onRawDataRecv (pkt);
287296 // action = routeRecvPacket(pkt); don't flood route these (yet)
288297 }
@@ -300,7 +309,8 @@ DispatcherAction Mesh::onRecvPacket(Packet* pkt) {
300309 tmp.payload_len = pkt->payload_len - 1 ;
301310 memcpy (tmp.payload , &pkt->payload [1 ], tmp.payload_len );
302311
303- if (!_tables->hasSeen (&tmp)) {
312+ if (!_tables->wasSeen (&tmp)) {
313+ _tables->markSeen (&tmp);
304314 uint32_t ack_crc;
305315 memcpy (&ack_crc, tmp.payload , 4 );
306316
@@ -357,7 +367,8 @@ DispatcherAction Mesh::forwardMultipartDirect(Packet* pkt) {
357367 tmp.payload_len = pkt->payload_len - 1 ;
358368 memcpy (tmp.payload , &pkt->payload [1 ], tmp.payload_len );
359369
360- if (!_tables->hasSeen (&tmp)) { // don't retransmit!
370+ if (!_tables->wasSeen (&tmp)) { // don't retransmit!
371+ _tables->markSeen (&tmp);
361372 removeSelfFromPath (&tmp);
362373 routeDirectRecvAcks (&tmp, ((uint32_t )remaining + 1 ) * 300 ); // expect multipart ACKs 300ms apart (x2)
363374 }
@@ -637,7 +648,7 @@ void Mesh::sendFlood(Packet* packet, uint32_t delay_millis, uint8_t path_hash_si
637648 packet->header |= ROUTE_TYPE_FLOOD ;
638649 packet->setPathHashSizeAndCount (path_hash_size, 0 );
639650
640- _tables->hasSeen (packet); // mark this packet as already sent in case it is rebroadcast back to us
651+ _tables->markSeen (packet); // mark this packet as already sent in case it is rebroadcast back to us
641652
642653 uint8_t pri;
643654 if (packet->getPayloadType () == PAYLOAD_TYPE_PATH ) {
@@ -666,7 +677,7 @@ void Mesh::sendFlood(Packet* packet, uint16_t* transport_codes, uint32_t delay_m
666677 packet->transport_codes [1 ] = transport_codes[1 ];
667678 packet->setPathHashSizeAndCount (path_hash_size, 0 );
668679
669- _tables->hasSeen (packet); // mark this packet as already sent in case it is rebroadcast back to us
680+ _tables->markSeen (packet); // mark this packet as already sent in case it is rebroadcast back to us
670681
671682 uint8_t pri;
672683 if (packet->getPayloadType () == PAYLOAD_TYPE_PATH ) {
@@ -699,7 +710,7 @@ void Mesh::sendDirect(Packet* packet, const uint8_t* path, uint8_t path_len, uin
699710 pri = 0 ;
700711 }
701712 }
702- _tables->hasSeen (packet); // mark this packet as already sent in case it is rebroadcast back to us
713+ _tables->markSeen (packet); // mark this packet as already sent in case it is rebroadcast back to us
703714 sendPacket (packet, pri, delay_millis);
704715}
705716
@@ -709,7 +720,7 @@ void Mesh::sendZeroHop(Packet* packet, uint32_t delay_millis) {
709720
710721 packet->path_len = 0 ; // path_len of zero means Zero Hop
711722
712- _tables->hasSeen (packet); // mark this packet as already sent in case it is rebroadcast back to us
723+ _tables->markSeen (packet); // mark this packet as already sent in case it is rebroadcast back to us
713724
714725 sendPacket (packet, 0 , delay_millis);
715726}
@@ -722,7 +733,7 @@ void Mesh::sendZeroHop(Packet* packet, uint16_t* transport_codes, uint32_t delay
722733
723734 packet->path_len = 0 ; // path_len of zero means Zero Hop
724735
725- _tables->hasSeen (packet); // mark this packet as already sent in case it is rebroadcast back to us
736+ _tables->markSeen (packet); // mark this packet as already sent in case it is rebroadcast back to us
726737
727738 sendPacket (packet, 0 , delay_millis);
728739}
0 commit comments