Skip to content

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

Closed

Conversation

WillyKaze
Copy link

Description

Implement to SO_BROADCAST socket option and provide a UDPSocket::set_broadcast(bool) method.

sock.set_broadcast(true); // Enable reception of broadcast packets

Fix #3395.

Status

READY

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 21, 2016

Any tests for this addition?

cc @geky @kjbracey-arm

@0xc0170 0xc0170 requested review from kjbracey and geky December 21, 2016 15:37
@geky
Copy link
Contributor

geky commented Dec 21, 2016

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);
Copy link
Contributor

@geky geky Dec 21, 2016

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

Copy link
Author

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 geky mentioned this pull request Dec 21, 2016
@WillyKaze
Copy link
Author

WillyKaze commented Dec 22, 2016

@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.

@geky
Copy link
Contributor

geky commented Dec 22, 2016

Thanks for adding the docs, it looks great 👍

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 23, 2016

@WillyKaze Please rebase

@kjbracey-arm Can you have a look?

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 30, 2016

@WillyKaze bump

@kjbracey
Copy link
Contributor

kjbracey commented Jan 2, 2017

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.

@WillyKaze
Copy link
Author

WillyKaze commented Jan 4, 2017

@0xc0170 I'm having troubles rebasing the branch. Do you have a reference tutorial (other than git-scm).

EDIT: I have found a solution.

@kjbracey
Copy link
Contributor

I'm feeling we should be going with a derivative of #3482 rather than this - see discussion there.

@geky
Copy link
Contributor

geky commented Feb 15, 2017

It looks like this is being superseeded by #3482, which provides a simpler solution in regards to user interface.

Let us know if #3482 does not work for you and feel free to reopen if we should reconsider this pr.

@geky geky closed this Feb 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants