Changeset 572
- Timestamp:
- 12/21/12 17:33:03 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/IPDB.pm
r565 r572 587 587 588 588 my $plist = $dbh->selectall_arrayref( 589 "SELECT (SELECT city FROM allocations WHERE cidr=poolips.pool) AS poolcit, ". 590 "poolips.pool AS poolblock, COUNT(*) AS poolfree FROM poolips,allocations ". 591 "WHERE poolips.available='y' AND poolips.pool=allocations.cidr ". 592 "AND allocations.city = ? AND poolips.type LIKE ? ". 593 "GROUP BY pool", { Slice => {} }, ($pcity, $ptype) ); 589 "SELECT count(*) AS poolfree,p.pool AS poolblock, a.city AS poolcit, a.rdepth AS poolrdepth ". 590 "FROM poolips p ". 591 "JOIN allocations a ON p.pool=a.cidr ". 592 "WHERE p.available='y' AND a.city = ? AND p.type LIKE ? ". 593 "GROUP BY p.pool,a.city,a.rdepth", 594 { Slice => {} }, ($pcity, $ptype) ); 594 595 return $plist; 595 596 } # end getPoolSelect() … … 620 621 ## Also populate a value list for the DBI call. 621 622 622 my @vallist = ($maskbits, ($type eq 'rm' ? 'n' : ($type =~ /^(.)r$/ ? "$1" : 'y')) ); 623 my $sql = "SELECT cidr FROM freeblocks WHERE maskbits <= ? AND routed = ?"; 623 my @vallist = ($maskbits); 624 my $sql = "SELECT cidr,rdepth FROM freeblocks WHERE masklen(cidr) <= ?"; 625 626 # cases, strict rules 627 # .c -> container type 628 # requires a routing container, fbtype r 629 # .d -> DHCP/"normal-routing" static pool 630 # requires a routing container, fbtype r 631 # .e -> Dynamic-assignment connectivity 632 # requires a routing container, fbtype r 633 # .i -> error, can't allocate static IPs this way? 634 # mm -> error, master block 635 # rm -> routed block 636 # requires master block, fbtype m 637 # .n -> Miscellaneous usage 638 # requires a routing container, fbtype r 639 # .p -> PPP(oE) static pool 640 # requires a routing container, fbtype r 641 # .r -> contained type 642 # requires a matching container, fbtype $1 643 ##fixme: strict-or-not flag 644 645 if ($type =~ /^(.)r$/) { 646 push @vallist, $1; 647 $sql .= " AND routed = ?"; 648 } elsif ($type eq 'rm') { 649 $sql .= " AND routed = 'm'"; 650 } else { 651 $sql .= " AND routed = 'r'"; 652 } 624 653 625 654 # for PPP(oE) and container types, the POP city is the one attached to the pool. … … 651 680 $sql .= " ORDER BY maskbits DESC,cidr LIMIT 1"; 652 681 653 my ($fbfound ) = $dbh->selectrow_array($sql, undef, @vallist);654 return $fbfound ;682 my ($fbfound,$fbdepth) = $dbh->selectrow_array($sql, undef, @vallist); 683 return $fbfound,$fbdepth; 655 684 } # end findAllocateFrom() 656 685
Note:
See TracChangeset
for help on using the changeset viewer.