Index: fedkit/Makefile
===================================================================
--- fedkit/Makefile	(revision 4e9719bb94eafda2b19c6adf8549c315a68a2b15)
+++ fedkit/Makefile	(revision dc803a7e0d75d04bb0a1aec1f88bac4810b722a6)
@@ -3,14 +3,18 @@
 	 config_from_tunnelip.pl active_config.pl combo.pl \
 	 prep_gateway.pl port_forward.pl setup_bridge.pl import_key.pl \
-	 protogeni_routing.pl start_seer.pl
+	 gated_routing.pl start_seer.pl ospf_routing.pl
 
 LIBRARIES=gateway_lib.pm 
 
-fedkit.tgz:	${LIBRARIES} ${BINARIES} ${PATCHES}
+PACKAGES=libevent-1.3b.tbz openospfd-4.0.tbz
+
+fedkit.tgz:	${LIBRARIES} ${BINARIES} ${PATCHES} ${PACKAGES}
 	mkdir -p /tmp/fedkit/local/federation/bin
 	mkdir -p /tmp/fedkit/local/federation/lib
 	mkdir -p /tmp/fedkit/local/federation/etc
+	mkdir -p /tmp/fedkit/local/federation/pkg
 	cp ${BINARIES} /tmp/fedkit/local/federation/bin
 	cp ${LIBRARIES} /tmp/fedkit/local/federation/lib
+	cp ${PACKAGES} /tmp/fedkit/local/federation/pkg
 	tar czf fedkit.tgz -C /tmp/fedkit local
 	rm -rf /tmp/fedkit
Index: fedkit/config_from_tunnelip.pl
===================================================================
--- fedkit/config_from_tunnelip.pl	(revision 4e9719bb94eafda2b19c6adf8549c315a68a2b15)
+++ fedkit/config_from_tunnelip.pl	(revision dc803a7e0d75d04bb0a1aec1f88bac4810b722a6)
@@ -2,4 +2,5 @@
 
 use strict;
+use IO::File;
 use IO::Pipe;
 use Getopt::Long;
@@ -19,4 +20,5 @@
 my $router;			# Router for the internet
 my $routedest;			# Add host route to this address (if given)
+my $recordfile;			# Record interfaces
 
 # Linux and FreeBSD use slightly different route syntax, so get the OS
@@ -25,5 +27,5 @@
 
 # Option parsing, --destination sets $routedest
-GetOptions('destination=s' => \$routedest);
+GetOptions('destination=s' => \$routedest, "record=s" => \$recordfile);
 
 # Parse out the info about tunnelips
@@ -71,3 +73,10 @@
 }
 else { warn "Destination but no router\n" if $routedest; }
+if ($recordfile) {
+    $netmask = "255.255.255.0" unless $netmask;
+    my $rf = new IO::File(">>$recordfile") || 
+	die "Can't open $recordfile:$!\n";
+    print $rf "$ip:$interface:$mac:$netmask\n";
+    $rf->close();
+}
 exit(0);
Index: fedkit/federate.pl
===================================================================
--- fedkit/federate.pl	(revision 4e9719bb94eafda2b19c6adf8549c315a68a2b15)
+++ fedkit/federate.pl	(revision dc803a7e0d75d04bb0a1aec1f88bac4810b722a6)
@@ -123,15 +123,21 @@
 copy("/tmp/hosts", "/etc/hosts");
 
-# Ick.  at least one of our images has gated in the wrong place (sigh).  If
-# so, fix it and restart routing.  
-if (!-x "/usr/sbin/gated" && -x "/sbin/gated" ) {
-    print "Linking to /sbin/gated and starting routing\n";
-    symlink("/sbin/gated", "/usr/sbin/gated");
-    system("$RC_ROUTE boot") if -x $RC_ROUTE;
-}
-
-# If there are tunnelip interfaces to bring up, bring 'em
+
+# If there are tunnelip interfaces to bring up, bring 'em up.  Record any such
+# interfaces in /usr/local/federation/interfaces, so SEER can find them later.
 system("$perl -I/usr/local/federation/lib " . 
-    "/usr/local/federation/bin/config_from_tunnelip.pl");
+    "/usr/local/federation/bin/config_from_tunnelip.pl " . 
+    "--record=/usr/local/federation/etc/interfaces");
+
+if ($uname =~ /Linux/ ) {
+    system("$perl /usr/local/federation/bin/gated_routing.pl")
+	if -r "/usr/local/federation/bin/gated_routing.pl";
+}
+elsif ($uname =~/FreeBSD/ ) {
+    # FreeBSD needs to have ospfs installed and a router config created and
+    # run.
+    system("$perl /usr/local/federation/bin/ospf_routing.pl")
+	if -r "/usr/local/federation/bin/ospf_routing.pl";
+}
 
 
Index: fedkit/gated_routing.pl
===================================================================
--- fedkit/gated_routing.pl	(revision dc803a7e0d75d04bb0a1aec1f88bac4810b722a6)
+++ fedkit/gated_routing.pl	(revision dc803a7e0d75d04bb0a1aec1f88bac4810b722a6)
@@ -0,0 +1,61 @@
+#!/usr/bin/perl
+
+use strict;
+use IO::File;
+use IO::Pipe;
+
+my $IFCONFIG = "/sbin/ifconfig";
+my @GATEDS= ("/usr/sbin/gated", "/sbin/gated" );
+my $GATED;
+
+my $fn = "/usr/local/federation/etc/gated.conf";
+my @live_ones;
+
+chomp (my $cif = `/usr/local/etc/emulab/control_interface`);
+
+my $ifp = new IO::Pipe();
+$ifp->reader("$IFCONFIG");
+while (<$ifp>) {
+    /^(eth\d+)/ && do {
+	push(@live_ones, $1) unless $1 eq $cif;
+    };
+}
+$ifp->close();
+
+foreach my $g (@GATEDS) {
+    if (-x $g ) {
+	$GATED = $g;
+	last;
+    }
+}
+
+die "Can't find gated in " . join(",", @GATEDS) . "\n" unless $GATED;
+
+my $f = new IO::File(">$fn") || die "Can't open $fn: $!\n";
+print $f <<END;
+smux off;
+rip off;
+ospf on {
+    backbone {
+END
+print $f "\tinterface $cif { passive; };\n";
+print $f <<END;
+    };
+    area 0.0.0.2 {
+	authtype none;
+END
+foreach my $i (@live_ones) {
+    print $f "\tinterface $i { priority 1; };\n";
+}
+print $f <<END;
+    };
+};
+END
+$f->close();
+
+$f = new IO::File(">/proc/sys/net/ipv4/ip_forward") || 
+    die "Can't open sys forwarding file:$!\n";
+print $f "1\n";
+$f->close();
+system("$GATED -f $fn");
+
Index: fedkit/ospf_routing.pl
===================================================================
--- fedkit/ospf_routing.pl	(revision dc803a7e0d75d04bb0a1aec1f88bac4810b722a6)
+++ fedkit/ospf_routing.pl	(revision dc803a7e0d75d04bb0a1aec1f88bac4810b722a6)
@@ -0,0 +1,54 @@
+#!/usr/bin/perl
+
+use strict;
+use IO::File;
+use IO::Pipe;
+
+my $IFCONFIG = "/sbin/ifconfig";
+my $OSPFD= "/usr/local/sbin/ospfd";
+my $SYSCTL= "/sbin/sysctl";
+my $PKG_ADD="/usr/sbin/pkg_add";
+
+my $fn = "/usr/local/federation/etc/ospfd.conf";
+my @pkgs = ('/usr/local/federation/pkg/libevent-1.3b.tbz', 
+    '/usr/local/federation/pkg/openospfd-4.0.tbz');
+my @live_ones;
+
+for my $p (@pkgs) {
+    die "No such package $p\n" unless -r $p;
+}
+
+system("$PKG_ADD " . join(" ", @pkgs));
+
+chomp (my $cif = `/usr/local/etc/emulab/control_interface`);
+
+my $ifp = new IO::Pipe();
+$ifp->reader("$IFCONFIG");
+while (<$ifp>) {
+    /^(\S+):.*UP/ && do {
+	push(@live_ones, $1) unless $1 eq $cif || $1 eq "lo0";
+    };
+}
+$ifp->close();
+
+my $f = new IO::File(">$fn") || die "Can't open $fn: $!\n";
+print $f <<END;
+area 0.0.0.1 {
+    interface $cif {
+	passive 
+    }
+}
+END
+print $f <<END;
+area 0.0.0.2 {
+    auth-type none
+END
+foreach my $i (@live_ones) {
+    print $f "\tinterface $i {\n\t}\n";
+}
+print $f "}\n";
+$f->close();
+system("chmod 600 $fn");
+system("$SYSCTL -w net.inet.ip.forwarding=1");
+system("$OSPFD -f $fn");
+
Index: fedkit/protogeni_routing.pl
===================================================================
--- fedkit/protogeni_routing.pl	(revision 4e9719bb94eafda2b19c6adf8549c315a68a2b15)
+++ 	(revision )
@@ -1,51 +1,0 @@
-#!/usr/bin/perl
-
-use strict;
-use IO::File;
-use IO::Pipe;
-
-my $IFCONFIG = "/sbin/ifconfig";
-my $GATED= "/usr/sbin/gated";
-
-my $fn = "/usr/local/federation/etc/gated.conf";
-my @live_ones;
-
-chomp (my $cif = `/usr/local/etc/emulab/control_interface`);
-
-my $ifp = new IO::Pipe();
-$ifp->reader("$IFCONFIG");
-while (<$ifp>) {
-    /^(eth\d+)/ && do {
-	push(@live_ones, $1) unless $1 eq $cif;
-    };
-}
-$ifp->close();
-
-my $f = new IO::File(">$fn") || die "Can't open $fn: $!\n";
-print $f <<END;
-smux off;
-rip off;
-ospf on {
-    backbone {
-END
-print $f "\tinterface $cif { passive; };\n";
-print $f <<END;
-    };
-    area 0.0.0.2 {
-	authtype none;
-END
-foreach my $i (@live_ones) {
-    print $f "\tinterface $i { priority 1; };\n";
-}
-print $f <<END;
-    };
-};
-END
-$f->close();
-
-$f = new IO::File(">/proc/sys/net/ipv4/ip_forward") || 
-    die "Can't open sys forwarding file:$!\n";
-print $f "1\n";
-$f->close();
-system("$GATED -f $fn");
-
