ws2_32: Implement automatic broadcast for UDP sockets on sendto()

Bruno Jesus 00cpxxx at gmail.com
Tue Dec 22 08:09:07 CST 2015


On Tuesday, December 22, 2015, Bruno Jesus <00cpxxx at gmail.com> wrote:

> On Tue, Dec 22, 2015 at 7:58 PM, Hans Leidekker <hans at codeweavers.com
> <javascript:;>> wrote:
> > Hi Bruno,
> >>+        if (wsa->addr->sa_family == WS_AF_INET)
> >>+        {
> >>+            /* When the target IPv4 address ends in 255 we must always
> send it as
> >>+             * a broadcast. Trying to send the packet without setting
> SO_BROADCAST
> >>+             * results in EACCES, to avoid that we will manually enable
> the flag
> >>+             * and send the packet, after that we will restore the
> disabled flag
> >>+             * behavior. This is the most common estimate as the
> broadcast address
> >>+             * should actually be calculated using the netmask for the
> interface. */
> >
> > It should really be calculated using the netmask, sending a broadcast
> packet here
> > is wrong if the user is not in a /24 network.
>
>
> Hi, Hans. Thanks for the reply, I'll update the patch when I have time.
>

Actually I have no idea how to do this because I would have to check every
UDP packet destination against all configured IP broadcast address, this
would slow down too much.

And caching the broadcast addresses would introduce the problem of watching
for network changes.

I believe that the current solution is ok for most use cases and I don't
know if it is an issue to attempt a broadcast to a non broadcast address, I
have to check that.

Or I am missing something obvious that someone will tell me in the next
reply ;-)

Best wishes,
Bruno
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20151222/a3070a82/attachment.html>


More information about the wine-devel mailing list