Howto send a limited broadcast?

tmm tmm at fastmail.fm
Sat Apr 12 16:42:44 UTC 2008


Hi.

I'm using the FreeBSD network stack (on top of the eCos embedded OS), 
and I want to send a limited broadcast (a broadcast with destination IP 
of 255.255.255.255).

Normally (I believe) the stack will only send a broadcast like this if 
there is no subnet mask set on the interface, or an all zeros mask (this 
is how bootp/dhcp work). Once I set a normal subnet mask, the stack will 
change my broadcasts into subnet broadcasts, eg. 192.168.0.255. In my 
situation the interface is active, so I can't just remove the netmask - 
I must find another way to send the limited broadcast.

When the interface gets setup with IP and netmask it creates a default 
broadcast address. If I override this and set it to 255.255.255.255 
(using SIOCSIFBRDADDR), then it will try to send my limited broadcast as 
is, rather then changing it into a subnet braodcast. Unforunately this 
fails, because there is no route available that matches this destination.

Okay, so just add a route? But when I try to add a route that would 
match 255.255.255.255 it gets rejected – it is not valid for the 
interface as currently configured.

The next step – which I would rather avoid - is modify the ip code. If 
the SO_DONTROUTE/IP_ROUTETOIF flag is set then you only need a route in 
order to pick an interface, not for any actual routing. So, I could add 
some code to manually pick an interface (even though none really match 
my destination address). But I’d rather avoid changing the code.

So, can anyone suggest how I can send a limited broadcast (on an 
interface that has been initalized with an IP and a subnet)?

Thanks for any suggestions.
Tom.


More information about the freebsd-net mailing list