Changeset 533 for trunk/cgi-bin/main.cgi
- Timestamp:
- 10/31/12 15:47:53 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/main.cgi
r532 r533 405 405 } else { # end show pool options 406 406 407 ##fixme: uninitialized 408 if ($webvar{fbassign} eq 'y') { 407 if ($webvar{fbassign} && $webvar{fbassign} eq 'y') { 409 408 $cidr = new NetAddr::IP $webvar{block}; 410 409 $webvar{maskbits} = $cidr->masklen; … … 415 414 return; 416 415 } 417 my $sql; 418 my $city; 419 my $failmsg; 420 my $extracond = ''; 421 if ($webvar{allocfrom} eq '-') { 422 ##fixme: uninitialized 423 $extracond = ($webvar{allowpriv} eq 'on' ? '' : 424 " and not (cidr <<= '192.168.0.0/16'". 425 " or cidr <<= '10.0.0.0/8'". 426 " or cidr <<= '172.16.0.0/12')"); 427 } 428 my $sortorder; 416 417 ##fixme ick, ew, bleh. gotta handle the failure message generation better. push it into findAllocateFrom()? 418 my $failmsg = "No suitable free block found.<br>\n"; 429 419 if ($webvar{alloctype} eq 'rm') { 430 if ($webvar{allocfrom} ne '-') { 431 $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'". 432 " and cidr <<= '$webvar{allocfrom}'"; 433 $sortorder = "maskbits desc"; 434 } else { 435 $sql = "select * from freeblocks where maskbits<=$webvar{maskbits} and routed='n'"; 436 $sortorder = "maskbits desc"; 437 } 438 $failmsg = "No suitable free block found.<br>\nWe do not have a free". 439 " routeable block of that size.<br>\nYou will have to either route". 440 " a set of smaller netblocks or a single smaller netblock."; 420 $failmsg .= "We do not have a free routeable block of that size.<br>\n". 421 "You will have to either route a set of smaller netblocks or a single smaller netblock."; 441 422 } else { 442 ##fixme443 # This section needs serious Pondering.444 # Pools of most types get assigned to the POP they're "routed from"445 # This includes WAN blocks and other netblock "containers"446 # This does NOT include cable pools.447 423 if ($webvar{alloctype} =~ /^.[pc]$/) { 448 $city = $webvar{city}; 449 $failmsg = "No suitable free block found.<br>\nYou will have to route another". 450 " superblock from one of the<br>\nmaster blocks or chose a smaller". 451 " block size for the pool."; 424 $failmsg .= "You will have to route another superblock from one of the<br>\n". 425 "master blocks or chose a smaller block size for the pool."; 452 426 } else { 453 427 if (!$webvar{pop}) { … … 455 429 return; 456 430 } 457 $city = $webvar{pop}; 458 $failmsg = "No suitable free block found.<br>\nYou will have to route another". 459 " superblock to $webvar{pop}<br>\nfrom one of the master blocks or". 460 " chose a smaller blocksize."; 461 } 462 if (defined $webvar{allocfrom} && $webvar{allocfrom} ne '-') { 463 $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}". 464 " and cidr <<= '$webvar{allocfrom}' and routed='". 465 (($webvar{alloctype} =~ /^(.)r$/) ? "$1" : 'y')."'"; 466 $sortorder = "maskbits desc,cidr"; 467 } else { 468 $sql = "select cidr from freeblocks where city='$city' and maskbits<=$webvar{maskbits}". 469 " and routed='".(($webvar{alloctype} =~ /^(.)r$/) ? "$1" : 'y')."'"; 470 $sortorder = "maskbits desc,cidr"; 431 $failmsg .= "You will have to route another superblock to $webvar{pop}<br>\n". 432 "from one of the master blocks or chose a smaller blocksize."; 471 433 } 472 434 } 473 $sql = $sql.$extracond." order by ".$sortorder; 474 $sth = $ip_dbh->prepare($sql); 475 $sth->execute; 476 my @data = $sth->fetchrow_array(); 477 if ($data[0] eq "") { 435 436 $cidr = findAllocateFrom($ip_dbh, $webvar{maskbits}, $webvar{alloctype}, $webvar{city}, $webvar{pop}, 437 (master => $webvar{allocfrom}, allowpriv => $webvar{allowpriv}) ); 438 if (!$cidr) { 478 439 $page->param(err => $failmsg); 479 440 return; 480 441 } 481 $cidr = new NetAddr::IP $ data[0];442 $cidr = new NetAddr::IP $cidr; 482 443 } # check for freeblocks assignment or IPDB-controlled assignment 483 444
Note:
See TracChangeset
for help on using the changeset viewer.