Net-Telnet-Trango
view release on metacpan or search on metacpan
scripts/su.cgi view on Meta::CPAN
$aps{$ap_name} = \%cur_host;
}
}
}
else {
$aps{$ap} = $conf->{$ap};
push @hosts, $h;
}
}
if ( ref $conf->{default} eq 'HASH' ) {
foreach my $ap ( keys %aps ) {
foreach my $k ( keys %{ $conf->{default} } ) {
$aps{$ap}{$k} ||= $conf->{default}->{$k};
}
}
}
return \%aps;
return {
'rrlhcwap0000' => {
group => 'Trango',
version => 1,
name => '192.168.1.1',
port => 161,
Read_Community => 'private',
Write_Community => 'private',
}
};
}
sub show_form {
my $aps = shift;
my %cache = ();
my @ap_names = sort {
my @a = $a =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/;
my @b = $b =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/;
if (@a) {
$cache{$a} ||= pack( 'C4' => @a );
}
else {
$cache{$a} ||= lc($a);
}
if (@b) {
$cache{$b} ||= pack( 'C4' => @b );
}
else {
$cache{$b} ||= lc($b);
}
$cache{$a} cmp $cache{$b};
} keys %{$aps};
print p(
start_form( -method => 'GET' ),
'AP: ',
popup_menu( -name => 'AP', -values => \@ap_names ),
br,
'SUMAC: ',
textfield( -name => 'sumac', -default => $default_mac ),
br,
'SUID: ',
textfield( -name => 'suid', -default => $default_suid ),
br,
'Test Type: ',
radio_group(
-name => 'test_type',
-values => [ 'su testrflink', 'linktest' ],
-default => 'su testrflink',
),
br, submit, end_form
);
print p(
'Fill in the SUMAC if you wish to add an SU ',
'or fill in the SUID to run an RF link test. ',
'If you enter both a valid SUMAC and a numeric SUID, ',
'the SU will be added with that SUID. ',
'If the SUID is already in the AP, it will be deleted ',
'before the new SU is added. '
);
return 1;
}
sub login {
my $host = shift;
my $password = shift;
my $t = new Net::Telnet::Trango( Timeout => $default_timeout );
#$t->input_log('/tmp/telnet_log');
#$t->dump_log('/tmp/telnet_log');
unless ( $t->open( Host => $host ) ) {
print h3("Error connecting!");
$t->close;
return undef;
}
unless ( $t->login($password) ) {
print h3("Couldn't log in: $!");
$t->exit;
$t->close;
return undef;
}
return $t;
}
sub add_su {
my ( $ap, $sumac, $suid ) = @_;
my $t = login( $ap->{'name'}, $ap->{'Telnet_Password'} );
my $cur_sus = $t->sudb_view;
( run in 2.160 seconds using v1.01-cache-2.11-cpan-364913b4093 )