corrected pc50 so that it always goes every $pc50_interval
authordjk <djk>
Mon, 22 Jun 1998 21:05:12 +0000 (21:05 +0000)
committerdjk <djk>
Mon, 22 Jun 1998 21:05:12 +0000 (21:05 +0000)
added incoming pc51 ping handling

perl/DXChannel.pm
perl/DXProt.pm

index fc0305a7208cc5dc789a60bb9f79f2716b1f78a9..2b7573bb89c7a1ece843c9ddc66c8336093998e8 100644 (file)
@@ -40,6 +40,7 @@ my %valid = (
   user => '9,DXUser ref',
   startt => '0,Start Time,atime',
   t => '9,Time,atime',
+  pc50_t => '9,Last PC50 Time,atime',
   priv => '9,Privilege',
   state => '0,Current State',
   oldstate => '5,Last State',
index 3001d263f5dc60878ec65a91a6ea733601b5989f..3b7bc514fa6f77c4bf1e9a68736f3d07450bc4db 100644 (file)
@@ -49,7 +49,8 @@ sub start
   # send initialisation string
   $self->send($self->pc38()) if DXNode->get_all();
   $self->send($self->pc18());
-  $self->{state} = 'incoming';
+  $self->state('normal');
+  $self->pc50_t(time);
 }
 
 #
@@ -92,7 +93,7 @@ sub normal
                $self->send($out);
          }
          $self->send($self->pc22());
-         last SWITCH;
+         return;
        }
     if ($pcno == 21) {last SWITCH;}
     if ($pcno == 22) {last SWITCH;}
@@ -123,8 +124,22 @@ sub normal
     if ($pcno == 47) {last SWITCH;}
     if ($pcno == 48) {last SWITCH;}
     if ($pcno == 49) {last SWITCH;}
-    if ($pcno == 50) {last SWITCH;}
-    if ($pcno == 51) {last SWITCH;}
+    if ($pcno == 50) {
+         last SWITCH;
+       }
+    if ($pcno == 51) {              # incoming ping requests/answers
+         
+         # is it for us?
+         if ($field[1] eq $main::mycall) {
+           my $flag = $field[3];
+           $flag ^= 1;
+           $self->send($self->pc51($field[2], $field[1], $flag));
+         } else {
+           # route down an appropriate thingy
+               $self->route($field[1], $line);
+         }
+         return;
+       }
   }
   
   # if get here then rebroadcast the thing with its Hop count decremented (if
@@ -162,9 +177,9 @@ sub process
     next if !$chan->is_ak1a();
 
     # send a pc50 out on this channel
-    if ($t >= $chan->t + $DXProt::pc50_interval) {
+    if ($t >= $chan->pc50_t + $DXProt::pc50_interval) {
       $chan->send(pc50());
-         $chan->t($t);
+         $chan->pc50_t($t);
        }
   }
 }
@@ -216,6 +231,16 @@ sub delnode
 # some active measures
 #
 
+#
+# route a message down an appropriate interface for a callsign
+#
+# expects $self to indicate 'from' and is called $self->route(from, pcline);
+#
+sub route
+{
+
+}
+
 # broadcast a message to all clusters [except those mentioned after buffer]
 sub broadcast
 {
@@ -351,11 +376,18 @@ sub pc38
   return "PC38^" . join(',', @nodes) . "^~";
 }
 
+# periodic update of users, plus keep link alive device (always H99)
 sub pc50
 {
   my $n = DXNodeuser->count;
   return "PC50^$main::mycall^$n^H99^";
 }
 
+# generate pings
+sub pc51
+{
+  my ($self, $to, $from, $val) = @_;
+  return "PC51^$to^$from^$val^";
+}
 1;
 __END__