/[mdap]/mdap-server.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /mdap-server.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 41 by dpavlin, Fri Nov 16 10:25:01 2007 UTC revision 49 by dpavlin, Fri Nov 16 16:21:45 2007 UTC
# Line 6  use IO::Socket::Multicast; Line 6  use IO::Socket::Multicast;
6  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
7  use Getopt::Long;  use Getopt::Long;
8    
9    use lib './lib';
10    use MDAP;
11    
12  my $GROUP = '224.0.0.103';  my $GROUP = '224.0.0.103';
13  my $PORT  = '3235';  my $PORT  = '3235';
14    
# Line 14  my $quiet = 1; Line 17  my $quiet = 1;
17  my $verbose = 0;  my $verbose = 0;
18  my $credentials = 0;  my $credentials = 0;
19    
20    my $plugins = 1;
21    
22  my $resend_search_delay = 3;  my $resend_search_delay = 3;
23  my $tftp_path = '/srv/tftp/';  my $tftp_path = '/srv/tftp/';
24    
# Line 29  GetOptions( Line 34  GetOptions(
34          "tftp=s"        => \$tftp_path,          "tftp=s"        => \$tftp_path,
35          "credentials"   => \$credentials,          "credentials"   => \$credentials,
36          "exec=s"        => \$flashed_cmd,          "exec=s"        => \$flashed_cmd,
37            'plugins!'      => \$plugins,
38  );  );
39    
40  $quiet = 0 if $verbose;  $quiet = 0 if $verbose;
# Line 205  while (1) { Line 211  while (1) {
211                  next if ( $type =~ m#^(INFO|ANT-SEARCH|EXEC-CLI)# );                  next if ( $type =~ m#^(INFO|ANT-SEARCH|EXEC-CLI)# );
212    
213                  my $ant = $h->{'ANT-ID'} || die "no ANT-ID in ", dump( $h );                  my $ant = $h->{'ANT-ID'} || die "no ANT-ID in ", dump( $h );
214                  my $seq_nr = $h->{'SEQ-NR'};                  my $seq_nr = $1 if (defined $h->{'SEQ-NR'} && $h->{'SEQ-NR'} =~ m/^-*(\d)+/);
215                  #warn "SEQ-NR: $seq_nr ok: ",$ant_ok_password->{$ant},"\n" if ($seq_nr);                  #warn "SEQ-NR: $seq_nr ok: ",$ant_ok_password->{$ant},"\n" if ($seq_nr);
216    
217                  my ($user_id,$user_pwd) = ant_credentials( $ant );                  my ($user_id,$user_pwd) = ant_credentials( $ant );
# Line 262  while (1) { Line 268  while (1) {
268                          } else {                          } else {
269                                  once "!! NO FIRMWARE for $board in $tftp_path for ant $ant, skipping update\n";                                  once "!! NO FIRMWARE for $board in $tftp_path for ant $ant, skipping update\n";
270                          }                          }
271    
272                            if ( $plugins ) {
273                                    foreach my $plugin ( MDAP->plugins ) {
274                                            warn "## calling $plugin\n" if $debug;
275                                            if ( my $command = $plugin->check( $h ) ) {
276                                                    warn "## plugin $plugin sending $command to $ant\n";
277                                                    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");              }
278                                    }
279                            }
280    
281                  } elsif ( $type eq 'REPLY-EXEC-CLI' ) {                  } elsif ( $type eq 'REPLY-EXEC-CLI' ) {
282                          print "+ $type\n$data\n" if ($verbose);                          print "+ $type\n$data\n" if ($verbose);
283                          if ( $seq_nr == 1 ) {                          if ( $seq_nr == 1 ) {
284                                  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");                                  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");
285                                  forget_ant( $ant ) if ( $ant_flashing->{$ant} );                                  forget_ant( $ant ) if ( $ant_flashing->{$ant} );
286                            } elsif ( $seq_nr < 0 ) {
287                                    warn "EXEC-CLI failed\n";
288                          }                          }
289    
290                  } else {                  } else {

Legend:
Removed from v.41  
changed lines
  Added in v.49

  ViewVC Help
Powered by ViewVC 1.1.26