I've posted a draft of instructions on getting ISC DHCP working with
omapd on my blog:
http://nixtrix.blogspot.com/2010/05/if-map-with-isc-dhcp-and-omapd.html
The full
publish-ip-mac.pl script doesn't play nicely with the
blogging software, so I didn't post that on the blog, but I'll post it
here.
A couple things to note:
I haven't solved the "no MAC address with 'on expiry'" problem yet...
so lease expirations won't trigger a proper cleanup.
The script is less than adequate right now because it calls out to
curl to do the publish and delete. I plan on fixing this and using a
pure SOAP API, but this should get people by for the short term.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper qw(Dumper);
use SOAP::Lite
# Set a default action handler that is .NET friendly
# otherwise, we'll get errors from the server as
# SOAP::Lite defaults to sending an incompatible SOAPAction
# header. (%s#%s but we need %s%s)
# on_action => sub {sprintf '%s%s', @_},
# For debugging
+trace=>'all';
my $type = shift;
my $ip = shift;
my $mac = shift;
my $ifmapServer = "
https://127.0.0.1:8081";
# Fork so we can return control
# to the dhcp server ASAP.
my $pid = fork();
# If we're the child them
# attempt to publish this
# information to the MAP
# server.
if($pid == 0) {
my $soap = SOAP::Lite
->readable(1)
->ns('file:ifmap.wsdl')
->proxy('https://127.0.0.1:8081');
# Use the below with the WSDL interface.
# and remove the proxy line.
#->service('file:ifmap.wsdl')
#->endpoint("
https://127.0.0.1:8081");
my $serializer = $soap->serializer();
$serializer->register_ns('
http://www.trustedcomputinggroup.org/
2006/IFMAP/1', 'ifmap');
$serializer->register_ns('
http://www.trustedcomputinggroup.org/
2006/IFMAP-METADATA/1', 'meta');
my $newSession = SOAP::Data->name("ifmap:new-session");
my $soapReply = $soap->call($newSession);
my $sessionId = $soapReply->valueof('//session-id');
my $publisherId = $soapReply->valueof('//publisher-id');
printf("Session ID: $sessionId\n");
printf("Publisher ID: $publisherId\n");
my $sessionHeader =
SOAP::Header
->name("ifmap:session-id")
->value($sessionId);
if($type eq "commit") {
my $publishCommand = <<END;
curl --insecure -X POST -H 'Content-type: text/xml' -d '<?xml
version="1.0"?>
<env:Envelope
xmlns:env="
http://www.w3.org/2003/05/soap-envelope"
xmlns:ifmap="
http://www.trustedcomputinggroup.org/2006/IFMAP/1"
xmlns:meta="
http://www.trustedcomputinggroup.org/2006/IFMAP-METADATA/
1">
<env:Header>
<ifmap:session-id>$sessionId</ifmap:session-id>
</env:Header>
<env:Body>
<ifmap:publish>
<update name="ISC DHCP $ip">
<link>
<identifier>
<mac-address value="$mac"/>
</identifier>
<identifier>
<ip-address value="$ip" type="IPv4"/>
</identifier>
</link>
<metadata>
<meta:ip-mac cardinality="singleValue"/>
</metadata>
</update>
</ifmap:publish>
</env:Body>
</env:Envelope>' $ifmapServer
END
`$publishCommand`;
} elsif($type eq "release") {
my $publishCommand = <<END;
curl --insecure -X POST -H 'Content-type: text/xml' -d '<?xml
version="1.0"?>
<env:Envelope
xmlns:env="
http://www.w3.org/2003/05/soap-envelope"
xmlns:ifmap="
http://www.trustedcomputinggroup.org/2006/IFMAP/1"
xmlns:meta="
http://www.trustedcomputinggroup.org/2006/IFMAP-METADATA/
1">
<env:Header>
<ifmap:session-id>$sessionId</ifmap:session-id>
</env:Header>
<env:Body>
<ifmap:publish>
<delete>
<link>
<identifier>
<mac-address value="$mac"/>
</identifier>
<identifier>
<ip-address value="$ip" type="IPv4"/>
</identifier>
</link>
</delete>
</ifmap:publish>
</env:Body>
</env:Envelope>' $ifmapServer
END
print "Command: $publishCommand\n";
print `$publishCommand`;
} elsif($type eq "expiry") {
# This doesn't work yet - need MAC address
}
}