Skip to content

Level 2 child nodes unable to process Logical Addresses provided by Master node #48

Closed
@Hypecta

Description

@Hypecta

Hi I've been playing around with the RF24Mesh package and found a possible issue relating to the level 2 child nodes.

Issue: Level 2 child nodes are not able to verify that the provided address from the master node is legitimate as the test_addr variable will always be 0.

File Name: rf24_mesh.py
Code Line: 202
Code: level = 0 if contact < 7 else len(oct(contact)[2:])

If level 2 child nodes (e.g. 6th/7th mesh network) were to request for an address from a level 1 child node, the bit-shifting algorithm done to derive test_addr will always be 0 as level will be 0 when contact is less than 7 (master node 0o0 & child nodes 0o1 to 0o5)

new_addr = struct.unpack("<H", self.frame_buf.message[:2])[0]
level = 0 if contact < 7 else len(oct(contact)[2:])
test_addr = new_addr & ~(0xFFFF << (level * 3))

Output of self.frame_buf.header, self.frame_buf.message, and code variables.

=== Frame ===
Header: from 0o4 to 0o4444 type 128 id 1 reserved 8
Message (Encoded): bytearray(b'$\x00')
Message (Decoded): 44

=== Variables ===
contact: 0o4
new_addr: 0o44
level: 0
test_addr: 0o0

If Line 202 of rf24_mesh.py is modified so that level is 1 for contact within the range of 1 - 7, it will allow test_addr to reflect the correct address accordingly for bit shifting to verify the address provided:

level = 0 if contact == 0 else (1 if 0 < contact < 7 else len(oct(contact)[2:]))

Output of self.frame_buf.header, self.frame_buf.message, and code variables.

=== Frame ===
Header: from 0o4 to 0o4444 type 128 id 1 reserved 8
Message (Encoded): bytearray(b'$\x00')
Message (Decoded): 44

=== Variables ===
contact: 0o4
new_addr: 0o44
level: 1
test_addr: 0o4

Do let me know if I need to provide more evidence or outputs to support this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions