public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Grant Edwards <grante@visi.com>
To: ecos-discuss@sources.redhat.com
Subject: [ECOS]  Re: How to send UDP broadcast to 255.255.255.255?
Date: Mon, 15 Jun 2009 22:14:00 -0000	[thread overview]
Message-ID: <h16h3l$5uo$1@ger.gmane.org> (raw)
In-Reply-To: <20090615203631.GA9795@ubuntu.local>

On 2009-06-15, Sergei Gavrikov <sergei.gavrikov@gmail.com> wrote:
> Grant Edwards wrote:
>> I've been asked by one of my internal customers how to send a
>> UDP broadcast packet to IP address 255.255.255.255.
>> 
>> I tried setting the SO_BROADCAST option on the socket and then
>> using sendto() with a destination address of 255.255.255.255,
>> but it sends to the subnet broadcast address (in my case
>> 10.255.255.255) not to the global broadcast address of
>> 255.255.255.255 that I specified in the sendto() call.
>
> [snip]
>
>>   if ((bytesSent = sendto(socket_fd, send_buf, packetSize, 0, (struct sockaddr *)&encoder_addr, sizeof encoder_addr)) == -1)
>
> Hi,
>
> I noticed one thing only. What's about sendto's flags? they talk about
> `MSG_DONTROUTE' sendto flag for your needs:
>
> packages/net/tcpip/current/doc/sendto.html
>
> perhaps, that's it.

I just tried it, and it doesn't change the behavior of
broadcasts. Specifying a destination address of 255.255.255.255
still produces a packet that's addressed to 10.255.255.255.

The description of MSG_DONTROUTE is

       Bypasses the usual routing table lookup and sends the
       packet directly to the interface described by the
       destination address. This is usually used only by
       diagnostic or routing programs.

In my case, the destination doesn't describe a particular
interface.  One might presume a broadcast sent to
255.255.255.255 would be sent out on all interfaces.
       
Google did find me a posting to a BSD mailing list that seemed
to claim that the option IP_ONESBCAST would do what I wanted to
do. I looked at the ip(4) man page on a FreeBSD 6.1 system, and
the description of IP_ONESBCAST didn't agree with what the
mailing list posting said.  I tested it on FreeBSD 6.1, and it
doesn't do anything relevent.  eCos doesn't have the
IP_ONESBCAST option anyway....

-- 
Grant Edwards                   grante             Yow! I own seven-eighths of
                                  at               all the artists in downtown
                               visi.com            Burbank!


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

  reply	other threads:[~2009-06-15 22:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-15 17:42 [ECOS] " Grant Edwards
2009-06-15 20:36 ` Sergei Gavrikov
2009-06-15 22:14   ` Grant Edwards [this message]
2009-06-16  6:44 ` Andrew Lunn
2009-06-16 14:23   ` [ECOS] " Grant Edwards
2009-06-16 16:14 Jay Foster
2009-06-16 19:01 ` Grant Edwards
2009-06-16 19:56   ` Gary Thomas
2009-06-16 20:26     ` Grant Edwards
2009-08-11 13:32 Stanislav Meduna
2009-08-12  5:02 ` Mandeep Sandhu
2009-08-12 13:19   ` Mandeep Sandhu
2009-08-13  5:54     ` Mandeep Sandhu
2009-08-12 13:25   ` Stanislav Meduna

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='h16h3l$5uo$1@ger.gmane.org' \
    --to=grante@visi.com \
    --cc=ecos-discuss@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).