directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Damjan Jovanovic" <>
Subject Re: DHCP protocol
Date Mon, 25 Feb 2008 13:48:40 GMT
On Feb 18, 2008 1:25 PM, Jörg Henne <> wrote:
> Damjan Jovanovic schrieb:
> > There is a few other possibilities.
> >
> > You can bind to and attach the socket to a device using
> > SO_BINDTODEVICE, then you'll only receive UDP broadcasts from that
> > device; unfortunately that option can be set by root only, but that's
> > not a problem since you need to be root to open ports under 1024 that
> > LDAP, DNS, NTP and DHCP use.
> >
> The problem with this solution is that it doesn't properly work under
> Windows. We tried that :-/

In my books, the less works under Windows the better :-).

> Plus: one needs JNI for SO_BINDTODEVICE, although JNA does the trick
> rather painlessly.
> The solution we currently use is to have several front-end
> implementations depending on the underlying OS.
> > Java 7 is supposed to be able to tell you where the packet came from,
> > at least for Windows >= XP. But I see that bug is still open, guess
> > Sun hasn't gotten around to it yet.
> >
> > I'll have to see.

Well I've thought about it, and...

Raw sockets are a nightmare - too platform-specific, quirky,
inefficient (you get many packets you don't need to see) and require
root access. But, it's the only way to unicast to a particular MAC
address like the RFC says we should in some cases.

Moving on - SO_BINDTODEVICE is also platform-specific and seems a bit
of a hack (it changes how routing is done). Plus you need a socket per
interface, which means you use more sockets, and if network interfaces
are created or destroyed while the DHCP server is running it has to
deal with it.

Using recvmsg() seems nice, it's only 1 socket, and it tells you where
the packet came from.

> I have little hope that this will make it into the release...

Little hope? When last I checked, Sun was accepting patches to Java :-).

I've mailed the appropriate mailing list and offered to patch
DatagramPacket and co to provide the packet's destination address and
the NetworkInterface it came through, and they've sent me some
preliminary code I can carry on from. So, luck witholding, it will
make it into not just Java 7, but maybe even some of the prerelease

> > What DHCP server does use?
> >
> We don't do DHCP but PXE, which is a protocol used to inject network
> boot configuration and is based on DHCP. For DHCP there is a
> proof-of-concept implementation, but no backend. The code
> uses is based on the ADS DHCP code, but has been
> extended to make it actually work :-)

The bigbang branch seems much further ahead than trunk, I'm not sure
there is much for me to do any more.

> Joerg Henne


View raw message