version with the 'final' version of PC90 line in it
[spider.git] / perl / DXProt.pm
index e07e3ba04f179a13e7431ceb799cc5a4a556de4c..f68edc275bde45c1afe95bb67346136bcda02d76 100644 (file)
@@ -196,7 +196,9 @@ sub init
        $main::me->{priv} = 9;
        $main::me->{metric} = 0;
        $main::me->{pingave} = 0;
-       
+       $main::me->{version} = $main::version;
+       $main::me->{build} = $main::build;
+               
 #      $Route::Node::me->adddxchan($main::me);
 }
 
@@ -349,6 +351,20 @@ sub normal
                                $to = $field[2];
                        }
 
+                       # if this is a 'nodx' node then ignore it
+                       if ($badnode->in($field[6]) || ($via && $badnode->in($via))) {
+                               dbg("PCPROT: Bad Node, dropped") if isdbg('chanerr');
+                               return;
+                       }
+
+                       # if this is a 'bad spotter' user then ignore it
+                       my $nossid = $from;
+                       $nossid =~ s/-\d+$//;
+                       if ($badspotter->in($nossid)) {
+                               dbg("PCPROT: Bad Spotter, dropped") if isdbg('chanerr');
+                               return;
+                       }
+
                        # if we are converting announces to talk is it a dup?
                        if ($ann_to_talk) {
                                if (AnnTalk::is_talk_candidate($from, $field[3]) && AnnTalk::dup($from, $to, $field[3])) {
@@ -408,7 +424,9 @@ sub normal
                        }
                        
                        # if this is a 'bad spotter' user then ignore it
-                       if ($badspotter->in($field[6])) {
+                       my $nossid = $field[6];
+                       $nossid =~ s/-\d+$//;
+                       if ($badspotter->in($nossid)) {
                                dbg("PCPROT: Bad Spotter, dropped") if isdbg('chanerr');
                                return;
                        }
@@ -549,6 +567,20 @@ sub normal
                                }
                        }
 
+                       # if this is a 'nodx' node then ignore it
+                       if ($badnode->in($field[5])) {
+                               dbg("PCPROT: Bad Node, dropped") if isdbg('chanerr');
+                               return;
+                       }
+
+                       # if this is a 'bad spotter' user then ignore it
+                       my $nossid = $field[1];
+                       $nossid =~ s/-\d+$//;
+                       if ($badspotter->in($nossid)) {
+                               dbg("PCPROT: Bad Spotter, dropped") if isdbg('chanerr');
+                               return;
+                       }
+
                        if ($field[2] eq '*' || $field[2] eq $main::mycall) {
 
 
@@ -709,6 +741,23 @@ sub normal
                if ($pcno == 18) {              # link request
                        $self->state('init');   
 
+                       # record the type and version offered
+                       if ($field[1] =~ /DXSpider Version: (\d+\.\d+) Build: (\d+\.\d+)/) {
+                               $self->version(53 + $1);
+                               $self->user->version(53 + $1);
+                               $self->build(0 + $2);
+                               $self->user->build(0 + $2);
+                               unless ($self->is_spider) {
+                                       $self->user->sort('S');
+                                       $self->user->put;
+                                       $self->sort('S');
+                               }
+                       } else {
+                               $self->version(50.0);
+                               $self->version($field[2] / 100) if $field[2] && $field[2] =~ /^\d+$/;
+                               $self->user->version($self->version);
+                       }
+
                        # first clear out any nodes on this dxchannel
                        my $parent = Route::Node::get($self->{call});
                        my @rout = $parent->del_nodes;
@@ -756,7 +805,7 @@ sub normal
                                my $dxchan = DXChannel->get($call);
                                if ($dxchan && $dxchan != $self) {
                                        dbg("PCPROT: PC19 from $self->{call} trying to alter wrong locally connected $call, ignored!") if isdbg('chanerr');
-                                       return;
+                                       next;
                                }
 
                                # update it if required
@@ -1138,11 +1187,6 @@ sub normal
                                                                        } else {
                                                                                $tochan->{pingave} = $tochan->{pingave} + (($t - $tochan->{pingave}) / 6);
                                                                        }
-#                                                                      my $st;
-#                                                                      for (@{$tochan->{pingtime}}) {
-#                                                                              $st += $_;
-#                                                                      }
-#                                                                      $tochan->{pingave} = $st / @{$tochan->{pingtime}};
                                                                        $tochan->{nopings} = $nopings; # pump up the timer
                                                                }
                                                        } 
@@ -1205,6 +1249,27 @@ sub normal
                if ($pcno == 85) {              # remote command replies
                        $self->process_rcmd_reply($field[1], $field[2], $field[3], $field[4]);
                        
+                       return;
+               }
+               if ($pcno == 90) {              # new style PC16,17,19,21
+                       my $node = $field[1];
+
+                       # mark this node as wanting PC90s
+                       my $parent = Route::Node::get($node);
+                       if ($parent) {
+                               my $t = hex $field[2];
+                               my $last = $parent->lastpc90 || 0;
+                               if ($last < $t) {
+                                       $parent->pc90(1);
+                                       $parent->lastpc90($t); 
+                                       my ($updsort, $n) = unpack "AA*", $field[3];
+                                       for (my $i = 4; $i < $#field; $i++) {
+                                               my ($sort, $flag, $node, $ping) = $field[$i] =~ m{(\w)(\d)([-\w+])(,\d+)?};
+                                               $ping /= 10 if (defined $ping); 
+                                       }
+                               }
+                       }
+                       
                        return;
                }
        }
@@ -1248,8 +1313,12 @@ sub process
                next unless $dxchan->is_node();
                next if $dxchan == $main::me;
 
-               # send the pc50
-               $dxchan->send($pc50s) if $pc50s;
+               # send the pc50 or PC90
+               if ($pc50s && $dxchan->user->wantpc90) {
+                       $dxchan->send_route(\&pc90, 1, $main::me, 'T', @dxchan);
+               } else {
+                       $dxchan->send($pc50s) if $pc50s;
+               }
                
                # send a ping out on this channel
                if ($dxchan->{pingint} && $t >= $dxchan->{pingint} + $dxchan->{lastping}) {
@@ -1285,6 +1354,7 @@ sub process
 # some active measures
 #
 
+
 sub send_dx_spot
 {
        my $self = shift;
@@ -1539,6 +1609,7 @@ sub send_local_config
                unshift @localnodes, $main::routeroot;
        }
        
+
        send_route($self, \&pc19, scalar(@localnodes)+scalar(@remotenodes), @localnodes, @remotenodes);
        
        # get all the users connected on the above nodes and send them out
@@ -1549,6 +1620,7 @@ sub send_local_config
                        dbg("sent a null value") if isdbg('chanerr');
                }
        }
+       $self->send_route(\&pc90, 1, $main::me, 'T', DXChannel::get_all()) if $self->user->wantpc90;
 }
 
 #
@@ -1915,6 +1987,12 @@ sub route_pc50
        broadcast_route($self, \&pc50, 1, @_);
 }
 
+sub route_pc90
+{
+       my $self = shift;
+       broadcast_route($self, \&pc90, 1, @_);
+}
+
 sub in_filter_route
 {
        my $self = shift;