remove pc92 A/D first slot if == $mycall
[spider.git] / perl / DXProtHandle.pm
index 96e62c707f1684d85860361782e567c88c14aa09..cd4cdd44cba2f915374fe220b6ba400803b48ccd 100644 (file)
@@ -49,7 +49,7 @@ use vars qw($pc11_max_age $pc23_max_age $last_pc50 $eph_restime $eph_info_restim
 
 $pc9x_past_age = 62*60;                        # maximum age in the past of a px9x (a config record might be the only
                                                                # thing a node might send - once an hour)
-$pc9x_future_age = 5*60;               # maximum age in the future ditto
+$pc9x_future_age = 2*3600;             # maximum age in the future ditto
 $pc10_dupe_age = 45;                   # just something to catch duplicate PC10->PC93 conversions
 $pc92_slug_changes = 60;               # slug any changes going outward for this long
 $last_pc92_slug = 0;                   # the last time we sent out any delayed add or del PC92s
@@ -1265,6 +1265,8 @@ sub handle_51
        }
 }
 
+sub handle_61 { goto &handle_11; }
+
 # dunno but route it
 sub handle_75
 {
@@ -1483,20 +1485,22 @@ sub check_pc9x_t
                # the id on it is completely unreliable. Besides, only commands
                # originating on this box will go through this code...
                if ($parent->call ne $main::mycall) {
-                       my $lastid = $parent->lastid || 0;
-                       if ($t < $lastid) {
-                               if ($t+86400-$lastid > $pc9x_past_age) {
-                                       dbg("PCPROT: dup id on $t <= $lastid, ignored") if isdbg('chanerr');
-                                       return;
-                               }
-                       } elsif ($t == $lastid) {
-                               dbg("PCPROT: dup id on $t == $lastid, ignored") if isdbg('chanerr');
-                               return;
-                       } else {
-                               # $t > $lastid, check that the timestamp offered isn't too far away from 'now'
-                               if ($t+$main::systime_daystart-$main::systime > $pc9x_future_age ) {
-                                       dbg("PCPROT: id $t too far in the future, ignored") if isdbg('chanerr');
+                       my $lastid = $parent->lastid;
+                       if (defined $lastid) {
+                               if ($t < $lastid) {
+                                       if ($t+86400-$lastid > $pc9x_past_age) {
+                                               dbg("PCPROT: dup id on $t <= lastid $lastid, ignored") if isdbg('chanerr');
+                                               return;
+                                       }
+                               } elsif ($t == $lastid) {
+                                       dbg("PCPROT: dup id on $t == lastid $lastid, ignored") if isdbg('chanerr');
                                        return;
+                               } else {
+                                       # $t > $lastid, check that the timestamp offered isn't too far away from 'now'
+                                       if ($t-$lastid > $pc9x_future_age ) {
+                                               dbg("PCPROT: id $t too far in the future of lastid $lastid, ignored") if isdbg('chanerr');
+                                               return;
+                                       }
                                }
                        }
                }
@@ -1655,10 +1659,11 @@ sub handle_92
                if (@ent) {
                        my $add;
 
-                       ($parent, $add) = $self->pc92_handle_first_slot($ent[0], $parent, $t);
+                       ($parent, $add) = $self->pc92_handle_first_slot(\@ent, $parent, $t);
                        return unless $parent; # dupe
 
                        push @radd, $add if $add;
+                       $parent->reset_obs;
                        dbg("ROUTE: reset obscount on $parent->{call} now " . $parent->obscount) if isdbg('obscount');
                }
        } elsif ($sort eq 'A' || $sort eq 'D' || $sort eq 'C') {
@@ -1672,7 +1677,7 @@ sub handle_92
                # cope with missing duplicate node calls in the first slot for A or D
                my $me = $_[4] || '';
                if (($sort eq 'A' || $sort eq 'D')) {
-                       $me ||= _encode_pc92_call($parent) if !$me ;
+                       $me ||= _encode_pc92_call($parent) unless $me ;
                } else {
                        unless ($me) {
                                dbg("PCPROT: this type of PC92 *must* have a node call in the first slot, ignored") if is_dbg('chanerr');
@@ -1680,7 +1685,7 @@ sub handle_92
                        }
                }
 
-               my @ent = map {[ _decode_pc92_call($_) ]} grep {$_ && /^[0-7]/} $me, @_[5 .. $#_];
+               my @ent = map {my @a = _decode_pc92_call($_); @a ? \@a : ()} grep {$_ && /^[0-7]/} $me, @_[5 .. $#_];
 
                if (@ent) {
 
@@ -1700,7 +1705,7 @@ sub handle_92
                # do a pass through removing any references to either locally connected nodes or mycall
                my @nent;
                for (@ent) {
-                       next unless $_;
+                       next unless $_ && @$_;
                        if ($_->[0] eq $main::mycall || DXChannel::get($_->[0])) {
                                dbg("PCPROT: $_->[0] refers to locally connected node, ignored") if isdbg('chanerr');
                                next;
@@ -1720,6 +1725,7 @@ sub handle_92
                        my (@nodes, @users);
 
                        # we reset obscounts on config records as well as K records
+                       $parent->reset_obs;
                        dbg("ROUTE: reset obscount on $parent->{call} now " . $parent->obscount) if isdbg('obscount');
 
                        #