--- mdap-server.pl 2007/05/07 19:29:05 39 +++ mdap-server.pl 2007/11/16 16:21:45 49 @@ -1,10 +1,14 @@ #!/usr/bin/perl +use warnings; use strict; use IO::Socket::Multicast; use Data::Dump qw/dump/; use Getopt::Long; +use lib './lib'; +use MDAP; + my $GROUP = '224.0.0.103'; my $PORT = '3235'; @@ -13,6 +17,8 @@ my $verbose = 0; my $credentials = 0; +my $plugins = 1; + my $resend_search_delay = 3; my $tftp_path = '/srv/tftp/'; @@ -28,6 +34,7 @@ "tftp=s" => \$tftp_path, "credentials" => \$credentials, "exec=s" => \$flashed_cmd, + 'plugins!' => \$plugins, ); $quiet = 0 if $verbose; @@ -204,7 +211,7 @@ next if ( $type =~ m#^(INFO|ANT-SEARCH|EXEC-CLI)# ); my $ant = $h->{'ANT-ID'} || die "no ANT-ID in ", dump( $h ); - my $seq_nr = $h->{'SEQ-NR'}; + my $seq_nr = $1 if (defined $h->{'SEQ-NR'} && $h->{'SEQ-NR'} =~ m/^-*(\d)+/); #warn "SEQ-NR: $seq_nr ok: ",$ant_ok_password->{$ant},"\n" if ($seq_nr); my ($user_id,$user_pwd) = ant_credentials( $ant ); @@ -261,11 +268,23 @@ } else { once "!! NO FIRMWARE for $board in $tftp_path for ant $ant, skipping update\n"; } + + if ( $plugins ) { + foreach my $plugin ( MDAP->plugins ) { + warn "## calling $plugin\n" if $debug; + if ( my $command = $plugin->check( $h ) ) { + warn "## plugin $plugin sending $command to $ant\n"; + mdap_send("EXEC-CLI MDAP/$mdap_ver\r\nCLI-CMD:$command\r\nSEQ-NR:1\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n"); } + } + } + } elsif ( $type eq 'REPLY-EXEC-CLI' ) { print "+ $type\n$data\n" if ($verbose); if ( $seq_nr == 1 ) { mdap_send("EXEC-CLI MDAP/$mdap_ver\r\nSEQ-NR:2\r\nTO-ANT:$ant\r\nUSER-ID:$user_id\r\nUSER-PWD:$user_pwd\r\n"); forget_ant( $ant ) if ( $ant_flashing->{$ant} ); + } elsif ( $seq_nr < 0 ) { + warn "EXEC-CLI failed\n"; } } else {