Subject: Broadcasting to 255.255.255.255
To: None <netbsd-users@netbsd.org>
From: Anders Dinsen <anders@dinsen.net>
List: netbsd-users
Date: 10/11/2001 20:48:19
How do I send UDP datagrams to 255.255.255.255 on NetBSD?
I'm trying to port a Linux app that broadcasts on that address in order to
discover an unconfigured network appliance. It does so by:
setsockopt(lsendsock, SOL_SOCKET, SO_BROADCAST, &dummy, sizeof(dummy))
and then
dst.sin_addr.s_addr = 0xffffffff;
dst.sin_port = htons(EUCP_SERVERPORT);
dst.sin_family = AF_INET;
sendto(lsendsock, packet, len, 0, (struct sockaddr *)&dst, sizeof(dst)))
But tcpdump tells me that NetBSD makes the broadcast network specific:
20:20:28.196043 kvik.lan.dinsen.net.62476 > 192.168.1.255.30292: udp 16
But the box is unconfigured, so it doesn't know that it's part of this
network, and doesn't answer.
Stevens Network Programming vol 1 says in section 18.2 Broadcast Addresses
(p. 471):
"Most hosts allow [sending a UDP datagram to 255.255.255.255] [...] and
convert the address to the subnet-directed broadcast address of the
outgoing interface. BSD/OS has [...] IP_ONESBCAST, and when set, the
destination IP address for broadcasts is 255.255.255.255 [...]"
NetBSD doesn't have this option, so how do we do it?
--
Anders Dinsen
anders@dinsen.net
http://dinsen.net/anders/