I am porting a WinSock DHCP-like server to OS/X, and have run into a
wall. After using packet sniffers I've found a smoking gun that OS/X
may be ignoring broadcast UDP packets that are sent from the serviced
network to 255.255.255.255 to the serviced port #8567. (FYI: This
machine has two network cards, and the devices that are making DHCP
requests are connected on a network through the second card which has
a static IP address... the first card is used for plain ol' internet
access.) It's a little complicated, but I'll point out that send()s
to that static IP subnet are seeming to work and get a reaction, so
the connection is at least somewhat "alive".
The evidence that I have that packets are being ignored is that
running netcat directly to the IP address with a UDP packet unblocks
my recvall() call, while packets sent to the same port but broadcast
to 255.255.255.255 from 0.0.0.0 will not unblock the recvall(). The
packet sniffer shows that the mac is receiving these broadcast
packets. And curiously, it works to run the Windows version of the
DHCP server under VMWare if the two network cards are bridged as
virtual devices for Windows. Under VMWare, Windows will unblock the
recv call in response to the 255.255.255.255 message that shows up in
the sniffer!
The OS/X firewall is turned off and there is no other firewall running
that I know of, so that isn't likely to be the problem the way it was
here:
I'm using Berkeley sockets API, so the best I can say is that my
bind() call is using INADDR_ANY, which is 0.0.0.0. I also took the
precaution of adding SO_BROADCAST to the sockoptions, even though it
wasn't in the Windows code and I'm not certain it affects receivers.
I added it anyway because this UNIX page says that when SO_BROADCAST
is enabled, "datagram sockets receive packets sent to a broadcast
address and they are allowed to send packets to a broadcast address.":
I'm kind of at a loss for what I might test next...this is pretty much
blocking me, no pun intended. Does anyone have any ideas? Something
I could try to generate more information? I've attached some data
about the ignored packet, if that helps. Thanks muchly...!
[HERE'S THE PACKET THAT WOULD NOT BUMP THE recvall() OUT OF BLOCK
STATE, EVEN THOUGH NETCAT OF UDP PACKETS TO PORT 8567 ON THIS MACHINE
WORKED FINE]