=================================================================== RCS file: /cvs/trango/Net-Telnet-Trango/lib/Net/Telnet/Trango.pm,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- trango/Net-Telnet-Trango/lib/Net/Telnet/Trango.pm 2007/02/01 17:10:07 1.28 +++ trango/Net-Telnet-Trango/lib/Net/Telnet/Trango.pm 2007/02/01 17:58:33 1.29 @@ -1,5 +1,5 @@ package Net::Telnet::Trango; -# $RedRiver: Trango.pm,v 1.27 2007/01/31 18:53:29 mike Exp $ +# $RedRiver: Trango.pm,v 1.28 2007/02/01 17:10:07 mike Exp $ use strict; use warnings; use base 'Net::Telnet'; @@ -380,6 +380,7 @@ last_lines last_vals last_error + Decode ); sub AUTOLOAD @@ -428,7 +429,7 @@ unless ( $self->SUPER::open(@_) ) { $self->last_error("Couldn't connect to " . $self->host . ": $!"); - return undef; + return; } ## Get to login prompt @@ -438,7 +439,7 @@ ) ) { $self->last_error("problem connecting to host (" . $self->host . "): " . $self->lastline); - return undef; + return; } $self->parse_login_banner($self->lastline); @@ -464,7 +465,7 @@ my $self = shift; unless ($self->is_connected) { - $self->open or return undef; + $self->open or return; } my $password = shift; @@ -475,7 +476,7 @@ -errmode => "return", ) ) { $self->last_error("login ($self->host) failed: " . $self->lastline); - return undef; + return; } $self->logged_in(1); @@ -540,7 +541,7 @@ unless (defined $new_pass) { $self->last_error("No new password"); - #return undef; + #return; } return $self->cmd(String => 'su password ' . @@ -575,19 +576,19 @@ if ($suid =~ /\D/) { $self->last_error("Invalid suid '$suid'"); - return undef; + return; } unless ($new_ip) { $self->last_error("no new_ip passed"); - return undef; + return; } unless ($new_subnet) { $self->last_error("no new_subnet passed"); - return undef; + return; } unless ($new_gateway) { $self->last_error("no new_gateway passed"); - return undef; + return; } # su ipconfig @@ -615,16 +616,16 @@ { my $self = shift; - my @lines = $self->cmd( String => 'sudb view', expect => $success ); + my $lines = $self->cmd( String => 'sudb view', expect => $success ) || []; - return undef unless @lines; + return unless @{ $lines }; unless ($PRIVATE{'Decode'}) { - return \@lines; + return $lines; } my @sus; - foreach (@lines) { + foreach (@{ $lines }) { next unless $_; if (/^\[(\d+)\]\s+(\d+)\s+(\d+)\s+(\d+)\s+([0-9A-Fa-f\s]+)$/) { my %s = ( @@ -677,29 +678,29 @@ if ($suid =~ /\D/) { $self->last_error("Invalid suid '$suid'"); - return undef; + return; } unless (lc($type) eq 'reg' || lc($type) eq 'pr') { $self->last_error("Invalid type '$type'"); - return undef; + return; } if ($cir =~ /\D/) { $self->last_error("Invalid CIR '$cir'"); - return undef; + return; } if ($mir =~ /\D/) { $self->last_error("Invalid MIR '$mir'"); - return undef; + return; } my $new_mac = $mac; $new_mac =~ s/[^0-9A-Fa-f]//; unless (length $new_mac == 12) { $self->last_error("Invalid MAC '$mac'"); - return undef; + return; } $new_mac = join ' ', $new_mac =~ /../g; @@ -736,7 +737,7 @@ #if (lc($suid) ne 'all' || $suid =~ /\D/) { if ($suid =~ /\D/) { $self->last_error("Invalid suid '$suid'"); - return undef; + return; } return $self->cmd( String => 'sudb delete ' . $suid, expect => $success ); @@ -770,22 +771,22 @@ if ($suid =~ /\D/) { $self->last_error("Invalid suid '$suid'"); - return undef; + return; } if (lc($opt) eq 'cir' or lc($opt) eq 'mir') { if ($value =~ /\D/) { $self->last_error("Invalid $opt '$value'"); - return undef; + return; } } elsif (lc($opt) eq 'su2su') { if ($value =~ /[^0-9A-Za-f]/) { $self->last_error("Invalid MAC '$value'"); - return undef; + return; } } else { $self->last_error("Invalid option '$opt'"); - return undef; + return; } my $string = 'sudb modify ' . $suid . ' ' . $opt . ' ' . $value; @@ -812,7 +813,7 @@ if ($vals->{'Tftpd'} eq 'listen') { return $vals; } else { - return undef; + return; } } @@ -835,7 +836,7 @@ if (ref $vals eq 'HASH' && $vals->{'Tftpd'} eq 'disabled') { return $vals; } else { - return undef; + return; } } @@ -914,17 +915,17 @@ unless ($cfg{'String'}) { $self->last_error("No command passed"); - return undef; + return; } unless ($self->is_connected) { $self->last_error("Not connected"); - return undef; + return; } unless ($self->logged_in) { $self->last_error("Not logged in"); - return undef; + return; } @@ -979,7 +980,7 @@ } } else { $self->last_error("Error with command ($cfg{'String'}): $last"); - return undef; + return; } } @@ -1157,7 +1158,7 @@ return \@decoded; } else { # XXX we should have a way to set last error, not sure why we don't - return undef; + return; } }