fix up times and move things around for pc92
authorminima <minima>
Sat, 6 Jan 2007 21:50:41 +0000 (21:50 +0000)
committerminima <minima>
Sat, 6 Jan 2007 21:50:41 +0000 (21:50 +0000)
perl/DXProt.pm
perl/DXProtHandle.pm
perl/DXProtout.pm
perl/Route/Node.pm

index aaa070480ac3808b65f8dab29ce342b42ae06f06..080b421a2418842cef72e56887841f3ea2525812 100644 (file)
@@ -32,7 +32,6 @@ use DXHash;
 use Route;
 use Route::Node;
 use Script;
-use Investigate;
 use RouteDB;
 use DXProtHandle;
 
index 5d7aee9a73cfe519c95a080dc5d128d725959b15..26781885eb318f38292b2a9d1858c6549614ddc1 100644 (file)
@@ -32,7 +32,6 @@ use DXHash;
 use Route;
 use Route::Node;
 use Script;
-use Investigate;
 use RouteDB;
 
 
@@ -1332,6 +1331,43 @@ sub _del_thingy
        return @rout;
 }
 
+my $_last_time;
+my $_last_occurs;
+
+sub gen_pc9x_t
+{
+       if (!$_last_time || $_last_time != $main::systime) {
+               $_last_time = $main::systime;
+               $_last_occurs = 0;
+               return $_last_time;
+       } else {
+               $_last_occurs++;
+               return sprintf "$_last_time.%02d", $_last_occurs;
+       }
+}
+
+sub check_pc9x_t
+{
+       my $call = shift;
+       my $t = shift;
+       my $pc = shift;
+       my $create = shift;
+       
+       my $parent = ref $call ? $call : Route::Node::get($call);
+       if ($parent) {
+               my $lastid = $parent->lastid->{$pc} || 0;
+               if ($lastid >= $t) {
+                       dbg("PCPROT: dup / old id on $call <= $lastid, ignored") if isdbg('chanerr');
+                       return;
+               }
+       } elsif ($create) {
+               $parent = Route::Node->new($call);
+       }
+       $parent->lastid->{$pc} = $t;
+       return $parent;
+}
+
 # DXSpider routing entries
 sub handle_92
 {
@@ -1357,35 +1393,33 @@ sub handle_92
                return;
        }
 
-       my $parent = Route::Node::get($pcall);
-       if ($parent) {
-               my $lastid = $parent->lastid->{92} || 0;
-               if ($lastid > $t) {
-                       dbg("PCPROT: dup / old id <= $lastid, ignored") if isdbg('chanerr');
-                       return;
-               }
-       } else {
-               $parent = Route::Node->new($pcall);
-       }
+       my $parent = check_pc9x_t($pcall, $t, 92, 1);
+       
        $parent->lastid->{92} = $t;
+       $parent->do_pc92(1);
 
        if (@ent) {
+
+               # look at the first one which will always be a node of some sort
+               # and update any information that needs to be done. 
                my ($call, $is_node, $is_extnode, $here, $version, $build) = _decode_pc92_call($ent[0]);
-               if ($call && $is_node && $call eq $pcall) {
-                       $parent->here(Route::here($here));
-                       $parent->version($version) if $version;
-                       $parent->build($build) if $build;
-               } elsif ($is_extnode) {
-                       # reparent to external node (note that we must have received a 'C' or 'A' record
-                       # from the true parent node for this external before we get one for the this node
-                       unless ($parent = Route::Node::get($call)) {
-                               dbg("PCPROT: no previous C or A for this external node received, ignored") if isdbg('chanerr');
-                               return;
+               if ($call && $is_node) {
+                       if ($is_extnode) {
+                               # reparent to external node (note that we must have received a 'C' or 'A' record
+                               # from the true parent node for this external before we get one for the this node
+                               unless ($parent = Route::Node::get($call)) {
+                                       dbg("PCPROT: no previous C or A for this external node received, ignored") if isdbg('chanerr');
+                                       return;
+                               }
+                               my $parent = check_pc9x_t($call, $t, 92) || return;
                        }
                } else {
                        dbg("PCPROT: must be mycall or external node as first entry, ignored") if isdbg('chanerr');
                        return;
                }
+               $parent->here(Route::here($here));
+               $parent->version($version) if $version && $version > $parent->version;
+               $parent->build($build) if $build && $build > $parent->build;
                shift @ent;
        }
 
@@ -1466,3 +1500,5 @@ sub handle_default
                }
        }
 }
+
+1;
index 0ba94dc634c5789f0b4f35c3b46489d60e944091..6b06fb13440d615f40f9cba4d16702bc7be8000b 100644 (file)
@@ -377,27 +377,12 @@ sub pc85
 # spider route broadcasts
 #
 
-my $_last_time;
-my $_last_occurs;
-
-sub _gen_time
-{
-       if (!$_last_time || $_last_time != $main::systime) {
-               $_last_time = $main::systime;
-               $_last_occurs = 0;
-               return $_last_time;
-       } else {
-               $_last_occurs++;
-               return sprintf "$_last_time.%02d", $_last_occurs;
-       }
-}
 
 sub _gen_pc92
 {
        my $sort = shift;
-#      my $ext = $sort eq 'C';
-       my $ext = 1;
-       my $s = "PC92^$main::mycall^" . _gen_time . "^$sort";
+       my $ext = shift;
+       my $s = "PC92^$main::mycall^" . gen_pc9x_t() . "^$sort";
        for (@_) {
                $s .= "^" . _encode_pc92_call($_, $ext);
        }
@@ -420,19 +405,19 @@ sub gen_pc92_with_time
 # add a local one
 sub pc92a
 {
-       return _gen_pc92('A', @_);
+       return _gen_pc92('A', 0, @_);
 }
 
 # delete a local one
 sub pc92d
 {
-       return _gen_pc92('D', @_);
+       return _gen_pc92('D', 0, @_);
 }
 
 # send a config
 sub pc92c
 {
-       return _gen_pc92('C', @_);
+       return _gen_pc92('C', 1, @_);
 }
 
 1;
index 67e32a00eac1197a581599b308a935dd7f86f32b..d1b0b1647fd304ff048ab4b7e150d64fa48e6e2d 100644 (file)
@@ -32,6 +32,7 @@ use vars qw(%list %valid @ISA $max $filterdef);
                  handle_xml => '0,Using XML,yesno',
                  lastmsg => '0,Last Route Msg,atime',
                  lastid => '0,Last Route MsgID',
+                 do_pc92 => '0,Uses pc92,yesno',
 );
 
 $filterdef = $Route::filterdef;