From owner-freebsd-questions@FreeBSD.ORG Thu Jan 8 16:23:25 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A90C410656C7 for ; Thu, 8 Jan 2009 16:23:25 +0000 (UTC) (envelope-from psteele@maxiscale.com) Received: from arcturus.maxiscale.com (arcturus.maxiscale.com [76.231.178.136]) by mx1.freebsd.org (Postfix) with ESMTP id 8782B8FC16 for ; Thu, 8 Jan 2009 16:23:25 +0000 (UTC) (envelope-from psteele@maxiscale.com) X-ASG-Debug-ID: 1231431719-733500010000-jLrpzn X-Barracuda-URL: http://10.100.1.25:8000/cgi-bin/mark.cgi Received: from polaris.maxiscale.com (localhost [127.0.0.1]) by arcturus.maxiscale.com (Spam Firewall) with ESMTP id 09CF6364D1 for ; Thu, 8 Jan 2009 08:21:59 -0800 (PST) Received: from polaris.maxiscale.com (polaris.maxiscale.com [10.100.1.24]) by arcturus.maxiscale.com with ESMTP id BoJnzrBPlNtGe8fp for ; Thu, 08 Jan 2009 08:21:59 -0800 (PST) X-ASG-Whitelist: Client X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-ASG-Orig-Subj: RE: Do UDP broadcasts work in FreeBSD? Date: Thu, 8 Jan 2009 08:21:56 -0800 Message-ID: <2ACA3DE8F9758A48B8BE2C7A847F91F2479F8A@polaris.maxiscale.com> In-Reply-To: <200901081010.45049.pieter@degoeje.nl> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Do UDP broadcasts work in FreeBSD? Thread-Index: AclxcQyMj1CPVjIVR1WJb5+wNsel0gAOScnA References: <2ACA3DE8F9758A48B8BE2C7A847F91F2479DF3@polaris.maxiscale.com> <200901081010.45049.pieter@degoeje.nl> From: "Peter Steele" To: "Pieter de Goeje" , X-Barracuda-Connect: polaris.maxiscale.com[10.100.1.24] X-Barracuda-Start-Time: 1231431720 X-Barracuda-Virus-Scanned: by Barracuda Spam Firewall at maxiscale.com Cc: Subject: RE: Do UDP broadcasts work in FreeBSD? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jan 2009 16:23:26 -0000 >Did you enable SO_BROADCAST and IP_ONESBCAST on the socket? I remember needing=20 >this on FreeBSD but not on Linux. Yes we did, but... >I know UDP broadcasting works fine, but is=20 >somewhat more involved: > >addr.sin_family =3D AF_INET; >addr.sin_addr.s_addr =3D inet_addr("130.89.191.255"); >addr.sin_port =3D htons(UDP_PORT_ET); You are using a subnet broadcast here. We are dealing with systems that do not have IPs assigned, and as a result we have to send our broadcasts to 255.255.255.255. This works fine on other operating systems but for some reason the implementation is different on FreeBSD. It appears that the only way this kind of broadcast can be sent on FreeBSD is using raw sockets. This is how the FreeBSD DHCP client/server is written, so we're taking that approach as well...