OpenCyphal / libudpard

A compact implementation of the Cyphal/UDP protocol in C for high-integrity real-time embedded systems
MIT License
10 stars 8 forks source link

Service Responses do not have Node ID (but must) in Multicast IP Address #21

Closed emrainey closed 10 months ago

emrainey commented 1 year ago

In txMakeServiceSessionSpecifier, the Node ID is not being set in the function, resulting in responses being sent to the wrong Multicast IP address.

From https://github.com/OpenCyphal-Garage/libudpard/blob/main/libudpard/udpard.c#L259

((UdpardIPv4Addr) UDPARD_NODE_ID_MASK & (UdpardIPv4Addr) service_id)) | should be ((UdpardIPv4Addr) UDPARD_NODE_ID_MASK & (UdpardIPv4Addr) src_node_id)) |

But this call to construct Service Multicast IP address needs to use the remote Node ID, not the local Node ID. https://github.com/OpenCyphal-Garage/libudpard/blob/main/libudpard/udpard.c#L299

emrainey commented 1 year ago

Looks like there is a unit test but it's also not actually looking at the constructed IP address? https://github.com/OpenCyphal-Garage/libudpard/blob/main/tests/test_private_tx.cpp#LL107C39-L107C119