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: Mon, 11 Aug 2008 13:08:38 -0700
Hello list, this is a very late informational followup on a thread
from February.
To make a long story short-- I was trying to port socket-based code
that ran on a Windows machine with two network cards in it. The first
network card connected it to the WAN, and the second to a LAN where it
wanted to be a DHCP server. But OS/X and Linux were dropping the data
addressed to 255.255.255.255 in the socket API... which were crucial
to the DHCP protocol. I saw no way around it other than doing packet-
level programming (though I am still interested if there is another
way).
One of the things you have to be able to do in the DHCP protocol is
construct packets containing the ethernet address of the host
adapter. It was difficult for me to find a cross-platform API to get
the ethernet address of a network card. ether_hostton() looked
promising, but I couldn't get it to work. I got the bright idea of
sending packets to myself with the socket layer, capturing them with
the packet layer, and extracting the ethernet address from that... but
no dice. Each platform had its own way of enumerating the cards and
its own way of extracting the address, which I didn't want to maintain.
Finally I found a layer which seemed to solve many things... libnet:
http://packetfactory.net/projects/libnet/
"Especially important for cross-platform network code dealing with
packets is the libnet library. Not only does it have some APIs that
make it a little less tedious to build various packet types (e.g. by
implementing checksums for you), it can find out the hardware Ethernet
address of an adapter in a cross-platform fashion. Plus, it has
defined structures for every networking struct you can imagine!"
That's an excerpt from an article I wrote about my experiences called
"When Sockets Attack". Comments or corrections appreciated from
networking experts:
http://hostilefork.com/2008/02/20/when-sockets-attack/
But... I hope this helps anyone else who is stuck with a similar
problem. Thanks again to Peter Sichel for his advice!
[[In a separate thread, I'm going to follow up with a question about
raw sockets and OS/X 10.5 that the author of libnet and I are looking
at... but I just used LIBNET_LINK instead of LIBNET_RAW4 for my
project.]]
---
http://hostilefork.com
_______________________________________________
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