From owner-freebsd-net@FreeBSD.ORG Mon Oct 20 12:00:34 2003 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9B8EB16A4B3 for ; Mon, 20 Oct 2003 12:00:34 -0700 (PDT) Received: from arginine.spc.org (arginine.spc.org [195.206.69.236]) by mx1.FreeBSD.org (Postfix) with ESMTP id CFE2A43FE9 for ; Mon, 20 Oct 2003 12:00:32 -0700 (PDT) (envelope-from bms@spc.org) Received: from localhost (localhost [127.0.0.1]) by arginine.spc.org (Postfix) with ESMTP id D33A6653D2; Mon, 20 Oct 2003 20:00:30 +0100 (BST) Received: from arginine.spc.org ([127.0.0.1]) by localhost (arginine.spc.org [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 06286-02; Mon, 20 Oct 2003 20:00:30 +0100 (BST) Received: from saboteur.dek.spc.org (unknown [81.3.72.68]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by arginine.spc.org (Postfix) with ESMTP id E0F36653AD; Mon, 20 Oct 2003 20:00:28 +0100 (BST) Received: by saboteur.dek.spc.org (Postfix, from userid 1001) id 9C805D3; Mon, 20 Oct 2003 20:00:19 +0100 (BST) Date: Mon, 20 Oct 2003 20:00:19 +0100 From: Bruce M Simpson To: sarat chandra Annadata Message-ID: <20031020190019.GD8721@saboteur.dek.spc.org> Mail-Followup-To: sarat chandra Annadata , freebsd-net@freebsd.org, mgrooms@shrew.net, julian@elischer.org References: <20031020174751.60464.qmail@web20805.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031020174751.60464.qmail@web20805.mail.yahoo.com> cc: freebsd-net@freebsd.org cc: mgrooms@shrew.net cc: julian@elischer.org Subject: Re: Help Broadcasting a UDP packet on the LAN:URGENT X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Oct 2003 19:00:34 -0000 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