ws2_32: warn the user if broadcasts are failing because of a missing route to 255.255.255.255

Damjan Jovanovic damjan.jov at gmail.com
Tue Feb 9 14:11:40 CST 2010


On Mon, Feb 8, 2010 at 10:11 PM, Austin English <austinenglish at gmail.com> wrote:
> On Mon, Feb 8, 2010 at 2:07 PM, Damjan Jovanovic <damjan.jov at gmail.com> wrote:
>> Changelog:
>> * ws2_32: warn the user if broadcasts are failing because of a missing
>> route to 255.255.255.255
> diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
> index 9a65cb0..ac55e50 100644
> --- a/dlls/ws2_32/socket.c
> +++ b/dlls/ws2_32/socket.c
> @@ -1430,7 +1431,13 @@ static int WS2_send( int fd, struct ws2_async *wsa )
>     hdr.msg_flags = 0;
>  #endif
>
> -    return sendmsg(fd, &hdr, wsa->flags);
> +    ret = sendmsg(fd, &hdr, wsa->flags);
> +    if (ret < 0 && errno == ENETUNREACH && wsa->addr &&
> wsa->addr->sa_family == AF_INET &&
> +        ((struct WS_sockaddr_in*)wsa->addr)->sin_addr.WS_s_addr == 0xFFFFFFFF)
> +    {
> +        FIXME("broadcast failed, you need to add a route to
> 255.255.255.255\n");
>
> That doesn't look like a WARN() to me. Anyway, it seems an ERR() would
> be more appropriate.

And come to think of think of it, we've got bigger problems: if
there's a default gateway and it's not accessed through the local LAN,
a packet to 255.255.255.255 will be routed only there instead of
failing with an error, which is wrong. I think Windows routes it out
of all network interfaces - something I heard *nix cannot do, since
the network stack never duplicates packets.

References: http://lkml.indiana.edu/hypermail/linux/kernel/0011.0/0367.html

> --
> -Austin
>

Damjan



More information about the wine-devel mailing list