#!/usr/bin/perl use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); use NetAddr::IP; use CommonWeb qw(:ALL);; #file snCalc.cgi little subnet calculator app my %webvar = parse_post(); my $input; print "Content-Type: text/html\n\n"; open(HTML, "../startsn.html")|| die "Could not open startsn.html :$!"; my $start = join('', ); close(HTML); print $start; # Clean up input so we don't divide by zero or something equally silly if ($webvar{input} =~ m/(\d+)/) { $input = 1*$1; $input = 3 if $input < 3; $input = 29 if $input > 29; # Not doing IPv6 yet... } else { $input = 29; } my $ltinput = $input - 1; my $gtinput = $input + 1; my $prenet = new NetAddr::IP "0.0.0.0/$ltinput"; my $net = new NetAddr::IP "0.0.0.0/$input"; my $postnet = new NetAddr::IP "0.0.0.0/$gtinput"; print qq(
Results for /$ltinput | Results for /$input | Results for /$gtinput |
\n).
qq( ).$prenet->mask." \n".
qq( ).$prenet->wildcard." \n".
getranges($ltinput).
qq( | \n\n).
qq( ).$net->mask." \n".
qq( ).$net->wildcard." \n".
getranges($input).
qq( | \n).
qq( ).$postnet->mask." \n".
qq( ).$postnet->wildcard." \n".
getranges($gtinput);
print " |