Changeset 187 for trunk/cgi-bin/IPDB.pm


Ignore:
Timestamp:
03/04/05 18:12:54 (19 years ago)
Author:
Kris Deugau
Message:

/trunk

Another herd of changes to alloctypes. This cleaned up the
corner-case messes left by the introduction of subblocks in
/trunk r186, and fixed some other problems related to alloctype
handling. Note that the code changes REQUIRE changes to the
alloctypes table data!!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/IPDB.pm

    r186 r187  
    234234      eval {
    235235        $msg = "Unable to allocate $cidr as '$disp_alloctypes{$type}'";
    236         if ($type eq 'rr') {
     236        if ($type eq 'rm') {
    237237          $sth = $dbh->prepare("update freeblocks set routed='y',city='$city'".
    238238            " where cidr='$cidr'");
     
    244244          # common stuff for end-use, dialup, dynDSL, pools, etc, etc.
    245245
    246           # special case - block is a container/"reserve" block - alloctype begins with 'r'
    247           if ($type =~ /^r.$/) {
    248             $sth = $dbh->prepare("update freeblocks set routed='r' where cidr='$cidr'");
     246          # special case - block is a container/"reserve" block
     247          if ($type =~ /^(.)c$/) {
     248            $sth = $dbh->prepare("update freeblocks set routed='$1' where cidr='$cidr'");
    249249            $sth->execute;
    250250          } else {
     
    312312
    313313        # now we have to do some magic for routing blocks
    314         if ($type eq 'rr') {
     314        if ($type eq 'rm') {
    315315
    316316          # Insert the new freeblocks entries
     
    336336          # Insert the new freeblocks entries
    337337          # Along with some more HairyPerl(TM) in case we're inserting a
    338           # subblock (l.) allocation
     338          # subblock (.r) allocation
    339339          $sth = $dbh->prepare("insert into freeblocks (cidr,maskbits,city,routed)".
    340340                " values (?, ?, (select city from routed where cidr >>= '$cidr'),'".
    341                 (($type =~ /^l.$/) ? 'r' : 'y')."')");
     341                (($type =~ /^(.)r$/) ? '$1' : 'y')."')");
    342342          foreach my $block (@newfreeblocks) {
    343343            $sth->execute("$block", $block->masklen);
    344344          }
    345           # special-case for reserve/"container" blocks
    346           if ($type =~ /^r.$/) {
     345          # Special-case for reserve/"container" blocks - generate
     346          # the "extra" freeblocks entry for the container
     347          if ($type =~ /^(.)c$/) {
    347348            $sth = $dbh->prepare("insert into freeblocks (cidr,maskbits,city,routed)".
    348                 " values ('$cidr',".$cidr->masklen.",'$city','r')");
     349                " values ('$cidr',".$cidr->masklen.",'$city','$1')");
    349350            $sth->execute;
    350351          }
     
    500501    eval {
    501502
    502       if ($type eq 'rr') {
     503      if ($type eq 'rm') {
    503504        $msg = "Unable to remove routing allocation $cidr";
    504505        $sth = $dbh->prepare("delete from routed where cidr='$cidr'");
     
    531532                "(select cidr from routed where cidr >>= '$cidr') ".
    532533                " and maskbits<=".$cidr->masklen.
    533                 " and routed='".(($type =~ /^l.$/) ? 'r' : 'y').
     534                " and routed='".(($type =~ /^(.)r$/) ? '$1' : 'y').
    534535                "' order by maskbits desc");
    535536
     
    569570
    570571      # insert "new" freeblocks entry
    571       if ($type eq 'rr') {
     572      if ($type eq 'rm') {
    572573        $sth = $dbh->prepare("insert into freeblocks (cidr,maskbits,city)".
    573574                " values ('$cidr',".$cidr->masklen.",'<NULL>')");
     
    576577                " values ('$cidr',".$cidr->masklen.
    577578                ",(select city from routed where cidr >>= '$cidr'),'".
    578                 (($type =~ /^l.$/) ? 'r' : 'y')."')");
     579                (($type =~ /^(.)r$/) ? '$1' : 'y')."')");
    579580      }
    580581      $sth->execute;
Note: See TracChangeset for help on using the changeset viewer.