summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/addr_range.html
blob: 5df05596e92a82377dd024544767e3fe3be114a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<& elements/process.html,
  'table'           => 'addr_range',
  'popup_reload'    => 'Address range changed',
  'precheck_callback' => sub {
    my ($cgi) = @_;
    my $start = NetAddr::IP->new($cgi->param('start'), 0)
      or return 'Illegal or empty (IP address) start: '.$cgi->param('start');
    if ( length($cgi->param('end')) ) {
      my $end = NetAddr::IP->new($cgi->param('end'), 0)
        or return 'Illegal or empty (IP address) end: '.$cgi->param('end');
      if ( $end < $start ) {
        ($start, $end) = ($end, $start);
        $cgi->param('end', $end->addr);
        $cgi->param('start', $start->addr);
      }
      if ( $start + 0x7FFFFFFF <= $end ) {
        # then this is going to overflow
        return "Address ranges must be < 2^31 - 1 addresses long."
      }

      $cgi->param('length', $end - $start + 1);
    } else {
      $cgi->param('length', 1);
    }
    '';
  },
&>