Browse Source
Fix `recv_pkt_region` incorrect usage
The `recv_pkt_region` is set when processing a flood packet in `filterRecvFloodPacket`
but direct/non-flood packets would never pass through that function, so the pointer was
not cleared for them.
`sendFloodReply` would then later use it blindly, which meant that the response would
either inherit the region from the last flood packet, or refer to a non-initialised pointer
if no region floods had been received yet.
pull/2874/head
Neil Alexander
7 days ago
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
4 changed files with
8 additions and
10 deletions
examples/simple_repeater/MyMesh.cpp
examples/simple_repeater/MyMesh.h
examples/simple_room_server/MyMesh.cpp
examples/simple_room_server/MyMesh.h
@ -549,8 +549,7 @@ uint32_t MyMesh::getDirectRetransmitDelay(const mesh::Packet *packet) {
return getRNG ( ) - > nextInt ( 0 , 5 * t + 1 ) ;
}
bool MyMesh : : filterRecvFloodPacket ( mesh : : Packet * pkt ) {
// just try to determine region for packet (apply later in allowPacketForward())
mesh : : DispatcherAction MyMesh : : onRecvPacket ( mesh : : Packet * pkt ) {
if ( pkt - > getRouteType ( ) = = ROUTE_TYPE_TRANSPORT_FLOOD ) {
recv_pkt_region = region_map . findMatch ( pkt , REGION_DENY_FLOOD ) ;
} else if ( pkt - > getRouteType ( ) = = ROUTE_TYPE_FLOOD ) {
@ -562,8 +561,7 @@ bool MyMesh::filterRecvFloodPacket(mesh::Packet* pkt) {
} else {
recv_pkt_region = NULL ;
}
// do normal processing
return false ;
return Mesh : : onRecvPacket ( pkt ) ;
}
void MyMesh : : onAnonDataRecv ( mesh : : Packet * packet , const uint8_t * secret , const mesh : : Identity & sender ,
@ -867,6 +865,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
set_radio_at = revert_radio_at = 0 ;
_logging = false ;
region_load_active = false ;
recv_pkt_region = NULL ;
# if MAX_NEIGHBOURS
memset ( neighbours , 0 , sizeof ( neighbours ) ) ;
@ -166,7 +166,7 @@ protected:
}
# endif
bool filterRecvFlood Packet( mesh : : Packet * pkt ) override ;
mesh : : DispatcherAction onRecv Packet( 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 ;
@ -290,8 +290,7 @@ bool MyMesh::allowPacketForward(const mesh::Packet *packet) {
return true ;
}
bool MyMesh : : filterRecvFloodPacket ( mesh : : Packet * pkt ) {
// just try to determine region for packet (apply later in allowPacketForward())
mesh : : DispatcherAction MyMesh : : onRecvPacket ( mesh : : Packet * pkt ) {
if ( pkt - > getRouteType ( ) = = ROUTE_TYPE_TRANSPORT_FLOOD ) {
recv_pkt_region = region_map . findMatch ( pkt , REGION_DENY_FLOOD ) ;
} else if ( pkt - > getRouteType ( ) = = ROUTE_TYPE_FLOOD ) {
@ -303,8 +302,7 @@ bool MyMesh::filterRecvFloodPacket(mesh::Packet* pkt) {
} else {
recv_pkt_region = NULL ;
}
// do normal processing
return false ;
return Mesh : : onRecvPacket ( pkt ) ;
}
void MyMesh : : onAnonDataRecv ( mesh : : Packet * packet , const uint8_t * secret , const mesh : : Identity & sender ,
@ -627,6 +625,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
_logging = false ;
region_load_active = false ;
set_radio_at = revert_radio_at = 0 ;
recv_pkt_region = NULL ;
// defaults
memset ( & _prefs , 0 , sizeof ( _prefs ) ) ;
@ -154,7 +154,7 @@ protected:
return _prefs . multi_acks ;
}
bool filterRecvFlood Packet( mesh : : Packet * pkt ) override ;
mesh : : DispatcherAction onRecv Packet( mesh : : Packet * pkt ) override ;
bool allowPacketForward ( const mesh : : Packet * packet ) override ;
void onAnonDataRecv ( mesh : : Packet * packet , const uint8_t * secret , const mesh : : Identity & sender , uint8_t * data , size_t len ) override ;