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


Ignore:
Timestamp:
01/06/05 15:03:33 (19 years ago)
Author:
Kris Deugau
Message:

/trunk

SQL cleanup:

  • Made liberal use of "<<=" operator and "where" for DBMS-layer CIDR comparisons
  • Made liberal use of "select count(*) from ... where ..." in place of much more cumbersome "select * from ..." constructs

General code cleanup:

  • Better SQL allowed removal of a number of "if $cidr->contains($block)" constructs
  • Removed some unnecessary code originally added to fit existing legacy code
  • Cleaned up comments (indenation consistency, notes on DB fields)
  • Added a few ##fixme tags where the intended function and execution aren't clear, or don't quite work correctly in some odd edge cases
  • Moved %allocated, %free, %routed, %bigfree hashes to IPDB.pm as globals
File:
1 edited

Legend:

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

    r108 r118  
    2323@EXPORT_OK    = qw(
    2424        %disp_alloctypes %list_alloctypes @citylist @poplist @masterblocks
     25        %allocated %free %routed %bigfree
    2526        &initIPDBGlobals &connectDB &finish &checkDBSanity &allocateBlock &deleteBlock
    2627        &mailNotify
     
    3031%EXPORT_TAGS    = ( ALL => [qw(
    3132                %disp_alloctypes %list_alloctypes @citylist @poplist @masterblocks
     33                %allocated %free %routed %bigfree
    3234                &initIPDBGlobals &connectDB &finish &checkDBSanity &allocateBlock
    3335                &deleteBlock &mailNotify
     
    4345our @poplist;
    4446our @masterblocks;
     47our %allocated;
     48our %free;
     49our %routed;
     50our %bigfree;
    4551
    4652# Let's initialize the globals.
     
    7783  for (my $i=0; my @data = $sth->fetchrow_array(); $i++) {
    7884    $masterblocks[$i] = new NetAddr::IP $data[0];
     85    $allocated{"$masterblocks[$i]"} = 0;
     86    $free{"$masterblocks[$i]"} = 0;
     87    $bigfree{"$masterblocks[$i]"} = 128; # Larger number means smaller block.
     88                                        # Set to 128 to prepare for IPv6
     89    $routed{"$masterblocks[$i]"} = 0;
    7990  }
    8091  return (undef,$sth->errstr) if $sth->err;
Note: See TracChangeset for help on using the changeset viewer.