Prereq: 1.45
Index: CampusIO.pm
*** CampusIO.pm	2000/10/18 21:10:57	1.45
--- CampusIO.pm	2000/10/24 13:02:45	1.46
***************
*** 15,21 ****
  #  along with this program; if not, write to the Free Software
  #  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  
! # $Id: CampusIO.pm,v 1.45 2000/10/18 21:10:57 dplonka Exp $
  # Dave Plonka <plonka@doit.wisc.edu>
  
  use strict;
--- 15,21 ----
  #  along with this program; if not, write to the Free Software
  #  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  
! # $Id: CampusIO.pm,v 1.46 2000/10/24 13:02:45 dplonka Exp $
  # Dave Plonka <plonka@doit.wisc.edu>
  
  use strict;
***************
*** 28,34 ****
  
  @CampusIO::ISA=qw(FlowScan Exporter);
  # convert the RCS revision to a reasonable Exporter VERSION:
! '$Revision: 1.45 $' =~ m/(\d+)\.(\d+)/ && (( $CampusIO::VERSION ) = sprintf("%d.%03d", $1, $2));
  
  =head1 NAME
  
--- 28,34 ----
  
  @CampusIO::ISA=qw(FlowScan Exporter);
  # convert the RCS revision to a reasonable Exporter VERSION:
! '$Revision: 1.46 $' =~ m/(\d+)\.(\d+)/ && (( $CampusIO::VERSION ) = sprintf("%d.%03d", $1, $2));
  
  =head1 NAME
  
***************
*** 98,108 ****
  die unless ref($CampusIO::hops_ptrie);
  
  my $hop;
  foreach $hop (split(m/\s*,\s*/, $c->value('NextHops'))) {
!    push(@CampusIO::hops, unpack("N", inet_aton($hop)));
!    if (!$CampusIO::hops_ptrie->add_string($hop)) {
!       warn "hops_ptrie->add of $hop failed!\n"
     }
  }
  
  if (!@CampusIO::output_if && !@CampusIO::hops) {
--- 98,116 ----
  die unless ref($CampusIO::hops_ptrie);
  
  my $hop;
+ my $addr_length = length pack("N"); # remember the length of an IPv4 address
  foreach $hop (split(m/\s*,\s*/, $c->value('NextHops'))) {
!    my $n = inet_aton($hop);
!    die "invalid NextHop: \"$hop\"\n" if $addr_length != length($n);
!    my $i = unpack("N", inet_aton($hop));
!    die "invalid NextHop: \"$hop\"" if 0 == $i;
!    my $ihop = inet_ntoa($n); # convert the $hop to an IP address
!    my $rv;
!    eval '$rv = $CampusIO::hops_ptrie->add_string($ihop)';
!    if ($rv ne $ihop || $@) {
!       die "hops_ptrie->add(\"$ihop\") failed for \"$hop\": $@\n"
     }
+    push(@CampusIO::hops, $i)
  }
  
  if (!@CampusIO::output_if && !@CampusIO::hops) {
***************
*** 113,120 ****
  die unless ref($CampusIO::localhops_ptrie);
  
  foreach $hop (split(m/\s*,\s*/, $c->value('LocalNextHops'))) {
!    if (!$CampusIO::localhops_ptrie->add_string($hop)) {
!       warn "localhops_ptrie->add of $hop failed!\n"
     }
  }
  
--- 121,135 ----
  die unless ref($CampusIO::localhops_ptrie);
  
  foreach $hop (split(m/\s*,\s*/, $c->value('LocalNextHops'))) {
!    my $n = inet_aton($hop);
!    die "invalid LocalNextHop: \"$hop\"\n" if $addr_length != length($n);
!    my $i = unpack("N", inet_aton($hop));
!    die "invalid LocalNextHop: \"$hop\"" if 0 == $i;
!    my $ihop = inet_ntoa($n); # convert the $hop to an IP address
!    my $rv;
!    eval '$rv = $CampusIO::localhops_ptrie->add_string($ihop)';
!    if ($rv ne $ihop || $@) {
!       die "localhops_ptrie->add(\"$ihop\") failed for \"$hop\": $@\n"
     }
  }
  
***************
*** 1151,1157 ****
  
  =head1 VERSION
  
! The version number is the module file RCS revision number (B<$Revision: 1.45 $>)
  with the minor number printed right justified with leading zeroes to 3
  decimal places.  For instance, RCS revision 1.1 would yield a package version
  number of 1.001.
--- 1166,1172 ----
  
  =head1 VERSION
  
! The version number is the module file RCS revision number (B<$Revision: 1.46 $>)
  with the minor number printed right justified with leading zeroes to 3
  decimal places.  For instance, RCS revision 1.1 would yield a package version
  number of 1.001.
