From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12696 invoked by alias); 15 Jun 2009 22:14:35 -0000 Received: (qmail 12688 invoked by uid 22791); 15 Jun 2009 22:14:34 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RCVD_NUMERIC_HELO,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 15 Jun 2009 22:14:28 +0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MGKRd-0007YM-B8 for ecos-discuss@sources.redhat.com; Mon, 15 Jun 2009 22:14:25 +0000 Received: from 69.34.67.62 ([69.34.67.62]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 15 Jun 2009 22:14:25 +0000 Received: from grante by 69.34.67.62 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 15 Jun 2009 22:14:25 +0000 To: ecos-discuss@sources.redhat.com From: Grant Edwards Date: Mon, 15 Jun 2009 22:14:00 -0000 Message-ID: References: <20090615203631.GA9795@ubuntu.local> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: slrn/pre0.9.9-102 (Linux) X-IsSubscribed: yes Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: [ECOS] Re: How to send UDP broadcast to 255.255.255.255? X-SW-Source: 2009-06/txt/msg00072.txt.bz2 On 2009-06-15, Sergei Gavrikov 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