Index: trunk/cgi-bin/main.cgi
===================================================================
--- trunk/cgi-bin/main.cgi	(revision 20)
+++ trunk/cgi-bin/main.cgi	(revision 21)
@@ -694,5 +694,6 @@
     my $cidr = new NetAddr::IP $data[0];
     if ($master->contains($cidr)) {
-      my @row = ("$cidr", $cidr->range);
+      my @row = ("<a href=\"/ip/cgi-bin/main.cgi?action=assign&block=$cidr\">$cidr</a>",
+	$cidr->range);
       printRow(\@row, 'color1') if ($count%2 == 0);
       printRow(\@row, 'color2') if ($count%2 != 0);
@@ -766,8 +767,21 @@
   printHeader('');
 
-  open HTML, "../assign.html"
+  my $html;
+
+  # New special case- block to assign is specified
+  if ($webvar{block} ne '') {
+    open HTML, "../fb-assign.html"
+	or croak "Could not open fb-assign.html: $!";
+    $html = join('',<HTML>);
+    close HTML;
+    my $block = new NetAddr::IP $webvar{block};
+    $html =~ s|\$\$BLOCK\$\$|$block|g;
+    $html =~ s|\$\$MASKBITS\$\$|$block->masklen|;
+  } else {
+    open HTML, "../assign.html"
 	or croak "Could not open assign.html: $!";
-  my $html = join('',<HTML>);
-  close(HTML);
+    $html = join('',<HTML>);
+    close HTML;
+  }
 
   print $html;
@@ -830,41 +844,48 @@
 
   } else { # end show pool options
-    if (!$webvar{maskbits}) {
-      printAndExit("Please specify a CIDR mask length.");
-    }
-    my $sql;
-    my $city;
-    my $failmsg;
-    if ($webvar{alloctype} eq 'rr') {
-      $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'".
-	" order by maskbits desc";
-      $failmsg = "No suitable free block found.<br>\nWe do not have a free".
-	" routeable block of that size.<br>\nYou will have to either route".
-	" a set of smaller netblocks or a single smaller netblock.";
-    } else {
-      if ($webvar{alloctype} =~ /^[sd]p$/) {
-	if (($webvar{city} !~ /^(Sudbury|North Bay)$/) && ($webvar{alloctype} eq 'dp')) {
-	  printAndExit("You must chose Sudbury or North Bay for DSL pools."); }
-	if ($webvar{alloctype} eq 'sp') { $city = "Sudbury"; } else { $city = $webvar{city}; }
-	$failmsg = "No suitable free block found.<br>\nYou will have to route another".
-	  " superblock <br>\nfrom one of the master blocks in Sudbury or chose a smaller".
-	  " block size for the pool.";
+
+    if ($webvar{fbassign} eq 'y') {
+      $cidr = new NetAddr::IP $webvar{block};
+      $webvar{maskbits} = $cidr->masklen;
+    } else { # done with direct freeblocks assignment
+
+      if (!$webvar{maskbits}) {
+        printAndExit("Please specify a CIDR mask length.");
+      }
+      my $sql;
+      my $city;
+      my $failmsg;
+      if ($webvar{alloctype} eq 'rr') {
+	$sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'".
+	  " order by maskbits desc";
+	$failmsg = "No suitable free block found.<br>\nWe do not have a free".
+	  " routeable block of that size.<br>\nYou will have to either route".
+	  " a set of smaller netblocks or a single smaller netblock.";
       } else {
-	$city = $webvar{pop};
-	$failmsg = "No suitable free block found.<br>\nYou will have to route another".
-	  " superblock to $webvar{city}<br>\nfrom one of the master blocks in Sudbury or".
-	  " chose a smaller blocksize.";
-      }
-      $sql = "select * from freeblocks where city='$city' and maskbits<=$webvar{maskbits}".
-	" and routed='y' order by cidr,maskbits desc";
-    }
-    $sth = $ip_dbh->prepare($sql);
-    $sth->execute;
-    my @data = $sth->fetchrow_array();
-    if ($data[0] eq "") {
-      printAndExit($failmsg);
-    }
-
-    $cidr = new NetAddr::IP $data[0];
+	if ($webvar{alloctype} =~ /^[sd]p$/) {
+	  if (($webvar{city} !~ /^(Sudbury|North Bay)$/) && ($webvar{alloctype} eq 'dp')) {
+	    printAndExit("You must chose Sudbury or North Bay for DSL pools."); }
+	  if ($webvar{alloctype} eq 'sp') { $city = "Sudbury"; } else { $city = $webvar{city}; }
+	  $failmsg = "No suitable free block found.<br>\nYou will have to route another".
+	    " superblock <br>\nfrom one of the master blocks in Sudbury or chose a smaller".
+	    " block size for the pool.";
+	} else {
+	  $city = $webvar{pop};
+	  $failmsg = "No suitable free block found.<br>\nYou will have to route another".
+	    " superblock to $webvar{city}<br>\nfrom one of the master blocks in Sudbury or".
+	    " chose a smaller blocksize.";
+	}
+	$sql = "select * from freeblocks where city='$city' and maskbits<=$webvar{maskbits}".
+	  " and routed='y' order by cidr,maskbits desc";
+      }
+      $sth = $ip_dbh->prepare($sql);
+      $sth->execute;
+      my @data = $sth->fetchrow_array();
+      if ($data[0] eq "") {
+	printAndExit($failmsg);
+      }
+      $cidr = new NetAddr::IP $data[0];
+    } # check for freeblocks assignment or IPDB-controlled assignment
+
     $alloc_from = qq($cidr<input type=hidden name=alloc_from value="$cidr">);
 
