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">);
 
Index: trunk/fb-assign.html
===================================================================
--- trunk/fb-assign.html	(revision 21)
+++ trunk/fb-assign.html	(revision 21)
@@ -0,0 +1,77 @@
+<div class="indent">
+<div class="heading">Assign IPs</div><br>
+<table class="regular" bgcolor="black" cellspacing="1" cellpadding="1">
+<form method="POST" action="main.cgi" class="regular">
+<tr class="color1"><td>Free block selected for assignment:&nbsp</td><td>$$BLOCK$$<input type=hidden name=block value="$$BLOCK$$"></td></tr>
+<tr class="color1">
+<td>City:&nbsp</td><td>
+<select name="city"><option selected>-</option>
+<option>Barrie</option>
+<option>Blind River</option>
+<option>Brockville</option>
+<option>Bracebridge</option>
+<option>Burk's Falls</option>
+<option>Burlington</option>
+<option>Chapleau</option>
+<option>Espanola</option>
+<option>Elliot Lake</option>
+<option>Hamilton</option>
+<option>Huntsville</option>
+<option>Ingresoll</option>
+<option>Gravenhurst</option>
+<option>Guelph</option>
+<option>Kapuskasing</option>
+<option>Kingston</option>
+<option>Kirkland Lake</option>
+<option>Little Current</option>
+<option>London</option>
+<option>Marathon</option>
+<option>Manitoulin</option>
+<option>Newmarket</option>
+<option>North Bay</option>
+<option>Oakville</option>
+<option>Oshawa</option>
+<option>Ottawa</option>
+<option>Parry Sound</option>
+<option>Peel</option>
+<option>Peterborough</option>
+<option>Pembroke</option>
+<option>Sault Ste. Marie</option>
+<option>Sturgeon Falls</option>
+<option>Sudbury</option>
+<option>Timmins</option>
+<option>Thessalon</option>
+<option>Thunder Bay</option>
+<option>Toronto</option>
+<option>Wawa</option>
+<option>Windsor</option>
+</select>
+</td>
+</tr>
+<tr class="color2">
+<td>Allocation type:</td><td>
+<select name="alloctype"><option value="cn" selected>Customer netblock</option>
+<option value="cp">Pool - Cable</option>
+<option value="dp">Pool - DSL</option>
+<option value="mp">Pool - Static Dialup</option>
+<option value="sp">Pool - Servers</option>
+<option value="ee">End-use netblock</option>
+<option value="dn">Dialup netblock</option>
+<option value="dy">Dynamic DSL block</option>
+<option value="dc">Dynamic cable block</option>
+</select>
+<input type="button" value=" ? " onclick="helpAllocTypes()" class="regular">
+</td>
+</tr><tr class="color1">
+<td>Customer ID:&nbsp</td><td><input type="text" name="custid" size="15" maxlength="15"> (Only required for Customer allocations)</td>
+</tr><tr class="color1">
+<td valign="top">Description/Name:&nbsp</td><td><input name="desc" size=40></td>
+</tr><tr class="color2">
+<td>Notes:&nbsp;</td><td><textarea name="notes" rows="3" cols="40"></textarea></td>
+</tr><tr class="color1">
+<td class="center" colspan="2"><input type="submit" value="  Assign  "></td>
+<input type="hidden" name="action" value="confirm">
+<input type="hidden" name=fbassign value=y>
+</tr>
+</table>
+</div>
