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

UDP: send with source address #40

Open
chrysn opened this issue Jan 11, 2021 · 2 comments
Open

UDP: send with source address #40

chrysn opened this issue Jan 11, 2021 · 2 comments

Comments

@chrysn
Copy link
Contributor

chrysn commented Jan 11, 2021

If a UDP server is bound to more than a single address (typically because it's bound to the unspecified address) and the system can have more than a single address at an interface (not uncommon at IPv6), then an unconnected UDP server's send function needs a function that allows setting the source address (basically to the .1 of the result of a receive call). Otherwise, the OS will fill in that information -- and if the peer is picky about addresses (as CoAP is), it may guess wrong. (For example, Linux will pick the most recent address).

Adding support for this in a fully reliable way would probably mean adding a trait with an ugly name (UdpServerMultiaddress::send_to_from?). A more compatible, softer but prone-to-silent-misbehavior way forward would be to introduce UdpSever::send_to_from with a default implementation that disregards the from address (which is an OK behavior in the may cases when there is only one legal value anyway). Ideally, that default implementation would go away with the next incompatible version bump. (We can't have Rust show deprecation warnings when relying on a default implementation, can we?)

I'm happy to do a PR for this (just can't do it right now), but it would be good to have some initial feedback first.

@chrysn
Copy link
Contributor Author

chrysn commented Feb 2, 2021

Starting to use the embedded-nal server side, I noted that the bind function doesn't even take an address. This eliminates the workaround I'd otherwise have used here (to only ever bind a socket to a single unicast address).

@chrysn
Copy link
Contributor Author

chrysn commented Aug 30, 2024

This was fixed from the onset in the async traits which have that address accessible unconditionally.

The issue is low priority for me now because my use cases more and more use async; still, having feature parity would be nice.

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

No branches or pull requests

1 participant