diGriz's Chunk of Web

bash$ :(){ :|:&};:


ISC DHCP OMAPI bits

Here are some ISC DHCP related bits linked to OMAPI, all as a result of my work with Net::LanWarden.

OMAPI::DHCP Notes

The OMAPI interface for ISC DHCP, although crude, is really useful. You can make live queries without having to have something parse the dhcpd.leases file for the information you might be after; plus it's obviously something that does not have to be done from a script running on the DHCP server.

OMAPI::DHCP is a functional Perl frontend however it seems to be no longer maintained. One day I might move to Net::DHCP::Control (if I could get the darn thing to compile) but so far OMAPI::DHCP has met my needs.

One point of worthy note is that ISC DHCP versions earlier than 3.0.4 returned the lease time not in network order which results in a mangled timestamp. Using the OMAPI::DHCP a call to Select_Lease() can be 'fixed' by:

 my $oLease = $omapi->Select_Lease( { 'ip-address' => $ip } );
   return unless ( defined($oLease) && defined($oLease->{'hardware-address'}) );
 
 my $lease = {
       now     => time,
 
       starts  => unpack('N', pack('l', $oLease->{'starts'})),
       ends    => unpack('N', pack('l', $oLease->{'ends'}))
 }; 

OMAPI hwaddr Query Support

Whilst writing code that would give you a web frontend that uses OMAPI to speak to a DHCP server to do MAC address to IP address conversion, I ran into problems.

Using 'omshell', although you could say hey what is the MAC address of the workstation using the IP address w.x.y.z? you could not ask the question the other way round:

 new lease
 set hardware-address = 00:11:22:33:44:55
 set hardware-type = 1
 set state = 2
 open 

This would fail. Turns out I was not the only person so now that I knew I was not at fault I went about tweaking the ISC DHCP sourcecode to add this much needed functionality. The work from this is given below.

Downloads

Thanks

My thanks go to the IT department at SOAS for sponsoring this work, and letting me retain the copyright so that I could release the code under an opensource license; typically the GPL version 2 license unless it is a patch then the license matches the original.