Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Oct 2003 20:00:19 +0100
From:      Bruce M Simpson <bms@spc.org>
To:        sarat chandra Annadata <saratchandra_a@yahoo.com>
Cc:        julian@elischer.org
Subject:   Re: Help Broadcasting a UDP packet on the LAN:URGENT
Message-ID:  <20031020190019.GD8721@saboteur.dek.spc.org>
In-Reply-To: <20031020174751.60464.qmail@web20805.mail.yahoo.com>
References:  <20031020174751.60464.qmail@web20805.mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Oct 20, 2003 at 10:47:51AM -0700, sarat chandra Annadata wrote:
> I am need of some urgent techinical help to pull me out of a little problem. I have been 
> trying to broadcast a UDP packet(actually it is a DHCP offer packet) but 
> havent' successfully done it sofar. The following is the descripttion 
> about how I have been trying to do it.
>  1) I am creating a socket with sock_dgram option.
>  2)Next I am filling up the sockaddr_in structure, with IP address 
> 255.255.255.255 and port number as DHCP client port number.
[snip]

Undirected broadcasts will only work if you do the following:-

 1) Use a version of FreeBSD which supports the IP_ONESBCAST socket
    option. I committed this to HEAD and RELENG_4 branches somewhat over
    a month ago. Backporting the patch shouldn't be too difficult.

 2) Enable the IP_ONESBCAST and SO_BROADCAST ip/socket level options.

 3) Discover the IP broadcast address corresponding to the interface upin
    which you wish to send the datagram.

 4) Use the sendto() or send() socket calls to send the datagram, *with
    the interface's IP broadcast address set as the destination*.

The directed broadcast address is substituted with 255.255.255.255 at
send time, after routing takes place, and before the datagram is handed off
to the lower-layer network card drivers.

BMS



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031020190019.GD8721>