-
Notifications
You must be signed in to change notification settings - Fork 3k
Feature lwip broadcast #3491
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
Feature lwip broadcast #3491
Conversation
Any tests for this addition? cc @geky @kjbracey-arm |
This looks good. Raises the question of what other commonly used option should we lift up into the C++ interface. Is this an alternative to #3482? |
@@ -112,6 +112,8 @@ class UDPSocket : public Socket { | |||
nsapi_size_or_error_t recvfrom(SocketAddress *address, | |||
void *data, nsapi_size_t size); | |||
|
|||
nsapi_error_t set_broadcast(bool broadcast); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you be able to add the appropriate doxygen documentation to this function? You can use the neighboring function's documentation as a template
https://github.com/ARMmbed/mbed-os/blob/master/features/netsocket/Socket.h#L109-L120
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, I'll add the documentation.
@geky, I'm also interested in multicast socket options but i'm not familiar with it. also SO_REUSEADDR would be great. No test for this addition. |
Thanks for adding the docs, it looks great 👍 |
@WillyKaze Please rebase @kjbracey-arm Can you have a look? |
@WillyKaze bump |
The "receive broadcast" thing is non-standard, and is (to my knowledge) specific to lwIP built with a specific build flag. The POSIX option SO_BROADCAST only controls ability to /transmit/ broadcasts. I would argue that having SO_BROADCAST control reception is a bug rather than a feature, and lwIP has to be configured with that BROADCAST_RECV build option off to be used by the abstraction layer. Other stacks will not implement a receive block. So this doesn't totally replace #3482. If this were reworded to be "transmit broadcasts", it could be fine, but some stack adaptation could permit you to send broadcasts even without this being called. That's the sort of thing that leads to annoying bugs - you find out later that some other stack you didn't test with needs this called. At a minimum I'd like the documentation to make clear that some stacks may ignore the option/call - or do we require all stacks to implement a broadcast block? (Can they definitely do this, if autoconfigured? Can we assume things like the ESP8266 know the netmask?) A counter-suggestion would be for there to be no special requirement for broadcast transmission - it should just always be permitted by NSAPI, and the abstraction implementations do whatever to make that work (eg calling setsockopt(SO_BROADCAST) if necessary). Note that IPv6 does not require any special option to permit all-hosts-multicast. So the use of SO_BROADCAST by IPv4 feels a little legacy. But I guess the counter-argument is that IPv4 broadcast addresses aren't obviously distinct from unicast ones so it's easier to broadcast by mistake. |
@0xc0170 I'm having troubles rebasing the branch. EDIT: I have found a solution. |
cf111ba
to
c44b3ec
Compare
c44b3ec
to
6849ba9
Compare
I'm feeling we should be going with a derivative of #3482 rather than this - see discussion there. |
Description
Implement to SO_BROADCAST socket option and provide a UDPSocket::set_broadcast(bool) method.
Fix #3395.
Status
READY