reduce the number of duplicate PC92 for Ext Nodes
[spider.git] / perl / DXProt.pm
index 7ad886fd16bc9f1cc8462077395fb32ec49c14fc..e9fa42b6d4384418b84da43f319aa738638cf1bf 100644 (file)
@@ -45,7 +45,7 @@ use vars qw($pc11_max_age $pc23_max_age $last_pc50 $eph_restime $eph_info_restim
                        $allowzero $decode_dk0wcy $send_opernam @checklist
                        $eph_pc15_restime $pc92_update_period $pc92_obs_timeout
                        %pc92_find $pc92_find_timeout $pc92_short_update_period
-                       $next_pc92_obs_timeout
+                       $next_pc92_obs_timeout $pc92_slug_changes $last_pc92_slug
                   );
 
 $pc11_max_age = 1*3600;                        # the maximum age for an incoming 'real-time' pc11
@@ -72,7 +72,7 @@ $obscount = 2;
 $chatdupeage = 20 * 60;
 $chatimportfn = "$main::root/chat_import";
 $investigation_int = 12*60*60; # time between checks to see if we can see this node
-$pc19_version = 5466;                  # the visible version no for outgoing PC19s generated from pc59
+$pc19_version = 5454;                  # the visible version no for outgoing PC19s generated from pc59
 $pc92_update_period = 60*60;   # the period between outgoing PC92 C updates
 $pc92_short_update_period = 15*60; # shorten the update period after a connection
 %pc92_find = ();                               # outstanding pc92 find operations
@@ -82,7 +82,6 @@ $pc92_obs_timeout = 60*60; # the time between obscount for incoming countdowns
 $next_pc92_obs_timeout = $main::systime + 60*60; # the time between obscount countdowns
 
 
-
 @checklist =
 (
  [ qw(i c c m bp bc c) ],                      # pc10
@@ -165,7 +164,10 @@ $next_pc92_obs_timeout = $main::systime + 60*60; # the time between obscount cou
  undef,
  undef,
  undef,
- [ qw(i c n) ],                                        # pc90
+ undef,                                                        # pc90
+ undef,
+ [ qw(i c f l)],                               # pc92
+ [ qw(i c f *m c *c m)],                                       # pc93
 );
 
 # use the entry in the check list to check the field list presented
@@ -182,7 +184,8 @@ sub check
        for ($i = 1; $i < @$ref; $i++) {
                my ($blank, $act) = $$ref[$i] =~ /^(b?)(\w)$/;
                return 0 unless $act;
-               next if $blank && $_[$i] =~ /^[ \*]$/;
+               next if $blank eq 'b' && $_[$i] =~ /^[ \*]$/;
+               next if $blank eq '*' && $_[$i] =~ /^\*$/;
                if ($act eq 'c') {
                        return $i unless is_callsign($_[$i]);
                } elsif ($act eq 'i') {
@@ -201,6 +204,8 @@ sub check
                        return $i unless $_[$i] =~ /^\s*\d+-\w\w\w-[12][90]\d\d$/;
                } elsif ($act eq 't') {
                        return $i unless $_[$i] =~ /^[012]\d[012345]\dZ$/;
+               } elsif ($act eq 'l') {
+                       return $i unless $_[$i] =~ /^[A-Z]$/;
                }
        }
        return 0;
@@ -476,14 +481,30 @@ sub process
                        next unless $dxchan->is_node;
 
                        # send out a PC92 config record if required for me and
-                       # all my non pc9x dependent nodes.
+                       # all my non pc9x dependent nodes. But for dependent nodes we only do
+                       # this if we have not seen any from anyone else for at least half
+                       # of one update period. This should stop quite a bit of excess C
+                       # records. Someone will win, it does not really matter who, because
+                       # we always believe "us".
                        if ($main::systime >= $dxchan->{next_pc92_update}) {
                                dbg("ROUTE: pc92 broadcast candidate: $dxchan->{call}") if isdbg('obscount');
                                if ($dxchan == $main::me || !$dxchan->{do_pc9x}) {
-                                       $dxchan->broadcast_pc92_update($dxchan->{call});
+                                       my $ref = Route::Node::get($dxchan->{call});
+                                       if ($dxchan == $main::me || ($ref && ($ref->measure_pc9x_t($main::systime-$main::systime_daystart)) >= $pc92_update_period/2)) {
+                                               $dxchan->broadcast_pc92_update($dxchan->{call});
+                                       } else {
+                                               $dxchan->update_pc92_next($pc92_update_period - rand(60));
+                                       }
                                }
                        }
                }
+
+               if ($pc92_slug_changes && $main::systime >= $last_pc92_slug + $pc92_slug_changes) {
+                       my ($add, $del) = gen_pc92_changes();
+                       $main::me->route_pc92d($main::mycall, undef, $main::routeroot, @$del) if @$del;
+                       $main::me->route_pc92a($main::mycall, undef, $main::routeroot, @$add) if @$add;
+                       clear_pc92_changes();
+               }
        }
 
        if ($main::systime - 3600 > $last_hour) {
@@ -866,6 +887,7 @@ sub gen_my_pc92_config
        my $node = shift;
 
        if ($node->{call} eq $main::mycall) {
+               clear_pc92_changes();           # remove any slugged data, we are generating it as now
                my @dxchan = grep { $_->call ne $main::mycall && !$_->{isolate} } DXChannel::get_all();
                dbg("ROUTE: all dxchan: " . join(',', map{$_->{call}} @dxchan)) if isdbg('routelow');
                my @localnodes = map { my $r = Route::get($_->{call}); $r ? $r : () } @dxchan;
@@ -912,6 +934,7 @@ sub broadcast_pc92_update
                return;
        }
        my $l = $nref->last_PC92C(gen_my_pc92_config($nref));
+       $nref->lastid(last_pc9x_id());
        $main::me->broadcast_route_pc9x($main::mycall, undef, $l, 0);
        $self->update_pc92_next($pc92_update_period);
 }
@@ -1187,7 +1210,7 @@ sub disconnect
 
        # here we determine what needs to go out of the routing table
        my @rout;
-       if ($node) {
+       if ($node && $pc39flag != 2) {
                dbg('%Route::Node::List = ' . join(',', sort keys %Route::Node::list)) if isdbg('routedisc');
 
                @rout = $node->del($main::routeroot);