Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Jan 2005 18:56:17 -1000
From:      David Cornejo <dcornejo@gmail.com>
To:        freebsd-net@freebsd.org
Subject:   bind() & how to receive broadcast packets?
Message-ID:  <6b8e8f4f05012920564ac72002@mail.gmail.com>

Next in thread | Raw E-Mail | Index | Archive | Help
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



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?6b8e8f4f05012920564ac72002>