Re: Porting Winsock DHCP Server; is OS/X ignoring Broadcast UDP in recvall()?
Re: Porting Winsock DHCP Server; is OS/X ignoring Broadcast UDP in recvall()?
- Subject: Re: Porting Winsock DHCP Server; is OS/X ignoring Broadcast UDP in recvall()?
- From: "Hostile Fork" <email@hidden>
- Date: Wed, 30 Jan 2008 21:02:08 -0800
Hello Peter...
Compared to other network stacks (like Mentat/TCP) which just work,
broadcast is kind of broken in the BSD stack. It's common practice to
use libpcap for receive and bpftransmit for send when implementing
DHCP servers or clients.
Thanks for the tip! After quickly getting to know libpcap, I did indeed manage to cobble together a way to grab these packets. My current implementation is a very simple loop using pcap_next as a replacement for the recv calls, and I should probably use the more sophisticated filtering functions, but it works for the moment. So that's great! Once I evolve it a little more I'll put it on
hostilefork.com ...
Now I've hit the problem that the outgoing broadcasts to
255.255.255.255 don't show up in the sniffer (although broadcasts to A.B.C.255 do appear, but it seems the devices on A.B.C subnet do not accept these as an adequate signal to "do their DHCP thing"). I thought I'd cheat and loop through and send the DHCP packets to each individual address. But for some reason my outgoing UDP packets aren't showing up in the packet sniffer when I send them to specific addresses (unless that specific address is A.B.C.255!) I tried turning off the SO_BROADCAST option on the socket and a bunch of other things that have had no effect... I'm new to sockets so I may be missing something obvious somewhere.
While I ponder why THAT's going on, I thought I'd follow up on your bpftransmit suggestion. Unfortunately, documentation on Berkeley Packet Filters isn't very widespread... so I'm having trouble constructing a simple series of lines of code that will build a broadcast UDP packet and put it onto the ethernet card. Could you by any chance point me at a sample I might adapt?
Again, thanks so much for the help! This seems like something that should be in the documentation... I swear, everything needs to be a wiki... (!)
---
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden