From owner-freebsd-net@FreeBSD.ORG Sun Jan 30 04:56:19 2005 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 5DBE716A4CE for ; Sun, 30 Jan 2005 04:56:19 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.192]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0095043D1D for ; Sun, 30 Jan 2005 04:56:19 +0000 (GMT) (envelope-from dcornejo@gmail.com) Received: by rproxy.gmail.com with SMTP id f1so663754rne for ; Sat, 29 Jan 2005 20:56:18 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=m/d0yTxpZoNZ3HvCe0Sinl5IGXL3B/J/urbGphZSOChLO7si7YHJIeCt1MqKRIS++ZlKH+FgdD7WPAMx1hVfpxmEiatz4jUJ2eXGgkfohfiqtDdYELWnwJdhFiuAKyE1u9PoGA6miRsTX3sz+k7du2PxQxaC+LMw+bbv54wqsAM= Received: by 10.38.165.18 with SMTP id n18mr168298rne; Sat, 29 Jan 2005 20:56:18 -0800 (PST) Received: by 10.38.86.13 with HTTP; Sat, 29 Jan 2005 20:56:17 -0800 (PST) Message-ID: <6b8e8f4f05012920564ac72002@mail.gmail.com> Date: Sat, 29 Jan 2005 18:56:17 -1000 From: David Cornejo To: freebsd-net@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: bind() & how to receive broadcast packets? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: David Cornejo List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jan 2005 04:56:19 -0000 I have a setup where an interface seems to lose broadcast packets somewhere and I'm hoping some kind soul couls lend a hand. This is on 6-CURRENT from within the last few days. One of my interfaces, sis1, is configured with an IP address of 10.0.2.1/24 I'm debugging some code, and in it's original form it binds a socket to 0.0.0.0 and it seems to get the broadcast packets fine. However, if I bind the socket to the actual address of the interface, i no longer receive broadcast packets. This makes some sense I guess, but is there a way to get one socket to receive only packets for its bound address *and* the broadcast address? A more in-depth explanation: A piece of code I am trying to port from Linux has several interfaces on the same box all in the same subnet, though not necessarily connected to each other in any fashion. The code creates a socket per interface and then bind()s them to 0.0.0.0. It then uses SO_BINDTODEVICE to sort out which socket serves which interface. In FreeBSD creating these sockets fail after the first one. My solution was to bind each socket to the IP address of the interface it serves. To direct the output broadcast packets I'm using libnet and this works ok. So I can get the packets out the correct interface, but a select fails to ever fire on broadcast packets received on the interface. I've checked that tcpdump (in non-promiscuous mode) sees them coming in. If anyone has any ideas, I'd appreciate it greatly. thanks, dave c