Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCP sendto removal + error when UDP for hostnames #2414

Merged
merged 1 commit into from
Oct 5, 2024

Conversation

unjambonakap
Copy link
Contributor

  • UDP inet_pton(remote_ip)'s result is not checked -> the server ends up sending packets to the null address when a hostname is given instead of a IPv4 address. A error is now raised

  • TCP is using sendto() instead of send(). We can thus remove a useless inet_pton() call (which moreover differs from the gethostbyaddr used in setup_port() - possible issues when using hostnames)

Before the change:

$ mavsdk_server udpout://localhost:12345
[09:09:33|Info ] MAVSDK version: v2.12.2-108-g2328ed69 (mavsdk_impl.cpp:28)
[09:09:33|Info ] Waiting to discover system on udpout://localhost:12345... (connection_initiator.h:20)
Sits there quietly

After:

$ mavsdk_server udpout://localhost:12345
[09:10:33|Info ] MAVSDK version: v2.12.2-108-g2328ed69 (mavsdk_impl.cpp:28)
[09:10:33|Info ] Waiting to discover system on udpout://localhost:12345... (connection_initiator.h:20)
[09:10:33|Error] inet_pton failure for address: localhost (udp_connection.cpp:136)
[09:10:33|Error] Sending message failed (mavsdk_impl.cpp:480)
[09:10:34|Error] inet_pton failure for address: localhost (udp_connection.cpp:136)
[09:10:34|Error] Sending message failed (mavsdk_impl.cpp:480)
[09:10:35|Error] inet_pton failure for address: localhost (udp_connection.cpp:136)
[09:10:35|Error] Sending message failed (mavsdk_impl.cpp:480)

- UDP inet_pton(remote_ip)'s result is not checked -> the server ends up
  sending packets to the null address when a hostname is given instead
of a IPv4 address. A error is now raised

- TCP is using sendto() instead of send(). We can thus remove a useless
inet_pton() call (which moreover differs from the gethostbyaddr used in
setup_port() - possible issues when using hostnames)

Signed-off-by: Benoit Maurin <[email protected]>
Copy link

sonarcloud bot commented Oct 4, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

Copy link
Collaborator

@JonasVautherin JonasVautherin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Collaborator

@julianoes julianoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@julianoes julianoes merged commit 27c5c30 into mavlink:main Oct 5, 2024
34 of 36 checks passed
@unjambonakap
Copy link
Contributor Author

@julianoes
Copy link
Collaborator

Feel free to make another PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants