3 # This module impliments the protocal mode for a dx cluster
5 # Copyright (c) 1998 Dirk Koopman G1TLH
31 use vars qw($me $pc11_max_age $pc11_dup_age $pc23_dup_age
32 %spotdup %wwvdup $last_hour %pings %rcmds
33 %nodehops @baddx $baddxfn $pc12_dup_age
36 $me = undef; # the channel id for this cluster
37 $pc11_max_age = 1*3600; # the maximum age for an incoming 'real-time' pc11
38 $pc11_dup_age = 24*3600; # the maximum time to keep the spot dup list for
39 $pc23_dup_age = 24*3600; # the maximum time to keep the wwv dup list for
40 $pc12_dup_age = 24*3600; # the maximum time to keep the ann dup list for
41 %spotdup = (); # the pc11 and 26 dup hash
42 %wwvdup = (); # the pc23 and 27 dup hash
43 %anndup = (); # the PC12 dup hash
44 $last_hour = time; # last time I did an hourly periodic update
45 %pings = (); # outstanding ping requests outbound
46 %rcmds = (); # outstanding rcmd requests outbound
47 %nodehops = (); # node specific hop control
48 @baddx = (); # list of illegal spotted callsigns
50 $baddxfn = "$main::data/baddx.pl";
54 my $user = DXUser->get($main::mycall);
55 $DXProt::myprot_version += $main::version*100;
56 $me = DXProt->new($main::mycall, 0, $user);
58 $me->{state} = "indifferent";
59 do "$main::data/hop_table.pl" if -e "$main::data/hop_table.pl";
61 # $me->{sort} = 'M'; # M for me
63 # now prime the spot duplicates file with today's and yesterday's data
64 my @today = Julian::unixtoj(time);
65 my @spots = Spot::readfile(@today);
66 @today = Julian::sub(@today, 1);
67 push @spots, Spot::readfile(@today);
69 my $dupkey = "$_->[0]$_->[1]$_->[2]$_->[3]$_->[4]";
70 $spotdup{$dupkey} = $_->[2];
73 # now prime the wwv duplicates file with just this month's data
74 my @wwv = Geomag::readfile(time);
76 my $dupkey = "$_->[1].$_->[2]$_->[3]$_->[4]";
77 $wwvdup{$dupkey} = $_->[1];
81 do "$baddxfn" if -e "$baddxfn";
86 # obtain a new connection this is derived from dxchannel
91 my $self = DXChannel::alloc(@_);
92 $self->{'sort'} = 'A'; # in absence of how to find out what sort of an object I am
96 # this is how a pc connection starts (for an incoming connection)
97 # issue a PC38 followed by a PC18, then wait for a PC20 (remembering
98 # all the crap that comes between).
101 my ($self, $line, $sort) = @_;
102 my $call = $self->{call};
103 my $user = $self->{user};
105 # remember type of connection
106 $self->{consort} = $line;
107 $self->{outbound} = $sort eq 'O';
108 $self->{priv} = $user->priv;
109 $self->{lang} = $user->lang;
110 $self->{isolate} = $user->{isolate};
111 $self->{consort} = $line; # save the connection type
115 $self->{spotfilter} = Filter::read_in('spots', $call);
116 $self->{wwvfilter} = Filter::read_in('wwv', $call);
117 $self->{annfilter} = Filter::read_in('ann', $call);
119 # set unbuffered and no echo
120 $self->send_now('B',"0");
121 $self->send_now('E',"0");
123 # send initialisation string
124 if (!$self->{outbound}) {
125 $self->send(pc38()) if DXNode->get_all();
128 $self->state('init');
131 Log('DXProt', "$call connected");
135 # This is the normal pcxx despatcher
139 my ($self, $line) = @_;
140 my @field = split /\^/, $line;
141 pop @field if $field[-1] eq '~';
143 # print join(',', @field), "\n";
145 # ignore any lines that don't start with PC
146 return if !$field[0] =~ /^PC/;
149 my ($pcno) = $field[0] =~ /^PC(\d\d)/; # just get the number
151 return if $pcno < 10 || $pcno > 51;
156 $pcr = Local::pcprot($self, $pcno, @field);
158 # dbg('local', "Local::pcprot error $@") if $@;
162 if ($pcno == 10) { # incoming talk
164 # is it for me or one of mine?
165 my $call = ($field[5] gt ' ') ? $field[5] : $field[2];
166 if ($call eq $main::mycall || grep $_ eq $call, get_all_user_calls()) {
169 my $text = unpad($field[3]);
170 Log('talk', $call, $field[1], $field[6], $text);
171 $call = $main::myalias if $call eq $main::mycall;
172 my $ref = DXChannel->get($call);
173 $ref->send("$call de $field[1]: $text") if $ref && $ref->{talk};
175 route($field[2], $line); # relay it on its way
180 if ($pcno == 11 || $pcno == 26) { # dx spot
182 # if this is a 'nodx' node then ignore it
183 last SWITCH if grep $field[7] =~ /^$_/, @DXProt::nodx_node;
185 # convert the date to a unix date
186 my $d = cltounix($field[3], $field[4]);
187 # bang out (and don't pass on) if date is invalid or the spot is too old (or too young)
188 if (!$d || ($pcno == 11 && ($d < $main::systime - $pc11_max_age || $d > $main::systime + 900))) {
189 dbg('chan', "Spot ignored, invalid date or out of range ($field[3] $field[4])\n");
193 # strip off the leading & trailing spaces from the comment
194 my $text = unpad($field[5]);
197 my $spotter = $field[6];
198 $spotter =~ s/-\d+$//o; # strip off the ssid from the spotter
201 my $freq = $field[1] - 0;
202 my $dupkey = "$freq$field[2]$d$text$spotter";
203 if ($spotdup{$dupkey}) {
204 dbg('chan', "Duplicate Spot ignored\n");
208 $spotdup{$dupkey} = $d;
211 if (grep $field[2] eq $_, @baddx) {
212 dbg('chan', "Bad DX spot, ignored");
216 my @spot = Spot::add($freq, $field[2], $d, $text, $spotter, $field[7]);
219 # @spot at this point contains:-
220 # freq, spotted call, time, text, spotter, spotted cc, spotters cc, orig node
221 # then spotted itu, spotted cq, spotters itu, spotters cq
222 # you should be able to route on any of these
228 $r = Local::spot($self, @spot);
230 # dbg('local', "Local::spot1 error $@") if $@;
233 # DON'T be silly and send on PC26s!
234 return if $pcno == 26;
236 # send out the filtered spots
237 send_dx_spot($self, $line, @spot) if @spot;
241 if ($pcno == 12) { # announces
242 # announce duplicate checking
243 my $text = uc unpad($field[3]);
244 my $dupkey = $field[1].$field[2].$text.$field[4].$field[6];
245 if ($anndup{$dupkey}) {
246 dbg('chan', "Duplicate Announce ignored\n");
249 $anndup{$dupkey} = $main::systime;
251 # global ann filtering
252 my ($filter, $hops) = Filter::it($self->{annfilter}, @field[1..6], $self->{call} ) if $self->{annfilter};
253 if ($self->{annfilter} && !$filter) {
254 dbg('chan', "Rejected by filter");
258 if ($field[2] eq '*' || $field[2] eq $main::mycall) {
260 # strip leading and trailing stuff
261 my $text = unpad($field[3]);
266 if ($field[4] eq '*') { # sysops
268 @list = map { $_->priv >= 5 ? $_ : () } get_all_users();
269 } elsif ($field[4] gt ' ') { # speciality list handling
270 my ($name) = split /\./, $field[4];
271 $target = "$name"; # put the rest in later (if bothered)
274 if ($field[6] eq '1') {
278 $target = "All" if !$target;
281 broadcast_list("$to$target de $field[1]: $text", 'ann', undef, @list);
283 broadcast_users("$target de $field[1]: $text", 'ann', undef);
285 Log('ann', $target, $field[1], $text);
287 return if $field[2] eq $main::mycall; # it's routed to me
289 route($field[2], $line);
290 return; # only on a routed one
306 if ($pcno == 16) { # add a user
307 my $node = DXCluster->get_exact($field[1]);
308 last SWITCH if !$node; # ignore if havn't seen a PC19 for this one yet
309 last SWITCH unless $node->isa('DXNode');
310 if ($node->dxchan != $self) {
311 dbg('chan', "LOOP: come in on wrong channel");
317 for ($i = 2; $i < $#field; $i++) {
318 my ($call, $confmode, $here) = $field[$i] =~ /^(\S+) (\S) (\d)/o;
319 next if !$call || length $call < 3 || length $call > 8;
322 next if DXCluster->get_exact($call); # we already have this (loop?)
324 $confmode = $confmode eq '*';
325 DXNodeuser->new($self, $node, $call, $confmode, $here);
327 # add this station to the user database, if required
328 $call =~ s/-\d+$//o; # remove ssid for users
329 my $user = DXUser->get_current($call);
330 $user = DXUser->new($call) if !$user;
331 $user->homenode($node->call) if !$user->homenode;
332 $user->node($node->call);
333 $user->lastin($main::systime) unless DXChannel->get($call);
337 # queue up any messages (look for privates only)
338 DXMsg::queue_msg(1) if $self->state eq 'normal';
342 if ($pcno == 17) { # remove a user
343 my $node = DXCluster->get_exact($field[2]);
344 last SWITCH unless $node->isa('DXNode');
345 if ($node->dxchan != $self) {
346 dbg('chan', "LOOP: come in on wrong channel");
349 my $ref = DXCluster->get_exact($field[1]);
354 if ($pcno == 18) { # link request
355 $self->send_local_config();
357 $self->state('init');
358 return; # we don't pass these on
361 if ($pcno == 19) { # incoming cluster list
363 for ($i = 1; $i < $#field-1; $i += 4) {
364 my $here = $field[$i];
365 my $call = uc $field[$i+1];
366 my $confmode = $field[$i+2] eq '*';
367 my $ver = $field[$i+3];
369 # now check the call over
370 my $node = DXCluster->get_exact($call); # we already have this
371 if ($node && $node->dxchan != $self) {
372 dbg('chan', "LOOP: come in on wrong channel");
377 # check for sane parameters
378 next if $ver < 5000; # only works with version 5 software
379 next if length $call < 3; # min 3 letter callsigns
380 DXNode->new($self, $call, $confmode, $here, $ver);
382 # unbusy and stop and outgoing mail (ie if somehow we receive another PC19 without a disconnect)
383 my $mref = DXMsg::get_busy($call);
384 $mref->stop_msg($self) if $mref;
386 # add this station to the user database, if required (don't remove SSID from nodes)
387 my $user = DXUser->get_current($call);
389 $user = DXUser->new($call);
391 $user->priv(1); # I have relented and defaulted nodes
392 $self->{priv} = 1; # to user RCMDs allowed
393 $user->homenode($call);
396 $user->lastin($main::systime) unless DXChannel->get($call);
400 # queue up any messages
401 DXMsg::queue_msg(0) if $self->state eq 'normal';
405 if ($pcno == 20) { # send local configuration
406 $self->send_local_config();
408 $self->state('normal');
416 if ($pcno == 21) { # delete a cluster from the list
417 my $call = uc $field[1];
418 if ($call ne $main::mycall) { # don't allow malicious buggers to disconnect me!
419 my $node = DXCluster->get_exact($call);
421 if ($node->dxchan != $self) {
422 dbg('chan', "LOOP: come in on wrong channel");
427 dbg('chan', "$call not in table, dropped");
435 $self->state('normal');
442 if ($pcno == 23 || $pcno == 27) { # WWV info
444 my $d = cltounix($field[1], sprintf("%02d18Z", $field[2]));
445 my $sfi = unpad($field[3]);
446 my $k = unpad($field[4]);
447 my $i = unpad($field[5]);
448 my $dupkey = "$d.$sfi$k$i";
449 if ($wwvdup{$dupkey}) {
450 dbg('chan', "Dup WWV Spot ignored\n");
453 if ($d > $main::systime + 900 || $field[2] < 0 || $field[2] > 23) {
454 dbg('chan', "WWV Date ($field[1] $field[2]) out of range");
457 $wwvdup{$dupkey} = $d;
458 $field[6] =~ s/-\d+$//o; # remove spotter's ssid
460 my $wwv = Geomag::update($d, $field[2], $sfi, $k, $i, @field[6..$#field]);
464 $r = Local::wwv($self, $field[1], $field[2], $sfi, $k, $i, @field[6..$#field]);
466 # dbg('local', "Local::wwv2 error $@") if $@;
469 # DON'T be silly and send on PC27s!
470 return if $pcno == 27;
472 # broadcast to the eager users
473 broadcast_users("WWV de $field[7] <$field[2]>: SFI=$sfi, A=$k, K=$i, $field[6]", 'wwv', $wwv );
477 if ($pcno == 24) { # set here status
478 my $call = uc $field[1];
479 my $ref = DXCluster->get_exact($call);
480 $ref->here($field[2]) if $ref;
484 if ($pcno == 25) { # merge request
485 if ($field[1] ne $main::mycall) {
486 route($field[1], $line);
490 Log('DXProt', "Merge request for $field[3] spots and $field[4] WWV from $field[1]");
494 my @in = reverse Spot::search(1, undef, undef, 0, $field[3]-1);
497 $self->send(pc26(@{$in}[0..4], $in->[7]));
503 my @in = reverse Geomag::search(0, $field[4], time, 1);
506 $self->send(pc27(@{$in}));
512 if (($pcno >= 28 && $pcno <= 33) || $pcno == 40 || $pcno == 42 || $pcno == 49) { # mail/file handling
513 DXMsg::process($self, $line);
517 if ($pcno == 34 || $pcno == 36) { # remote commands (incoming)
518 if ($field[1] eq $main::mycall) {
519 my $ref = DXUser->get_current($field[2]);
520 my $cref = DXCluster->get($field[2]);
521 Log('rcmd', 'in', $ref->{priv}, $field[2], $field[3]);
522 unless ($field[3] =~ /rcmd/i || !$cref || !$ref || $cref->mynode->call ne $ref->homenode) { # not allowed to relay RCMDS!
523 if ($ref->{priv}) { # you have to have SOME privilege, the commands have further filtering
524 $self->{remotecmd} = 1; # for the benefit of any command that needs to know
525 my $oldpriv = $self->{priv};
526 $self->{priv} = $ref->{priv}; # assume the user's privilege level
527 my @in = (DXCommandmode::run_cmd($self, $field[3]));
528 $self->{priv} = $oldpriv;
531 $self->send(pc35($main::mycall, $field[2], "$main::mycall:$_"));
532 Log('rcmd', 'out', $field[2], $_);
534 delete $self->{remotecmd};
536 $self->send(pc35($main::mycall, $field[2], "$main::mycall:sorry...!"));
539 $self->send(pc35($main::mycall, $field[2], "$main::mycall:your attempt is logged, Tut tut tut...!"));
542 route($field[1], $line);
547 if ($pcno == 35) { # remote command replies
548 if ($field[1] eq $main::mycall) {
549 my $s = $rcmds{$field[2]};
551 my $dxchan = DXChannel->get($s->{call});
552 $dxchan->send($field[3]) if $dxchan;
553 delete $rcmds{$field[2]} if !$dxchan;
556 route($field[1], $line);
565 if ($pcno == 38) { # node connected list from neighbour
569 if ($pcno == 39) { # incoming disconnect
574 if ($pcno == 41) { # user info
575 # add this station to the user database, if required
576 my $user = DXUser->get_current($field[1]);
578 # then try without an SSID
579 $field[1] =~ s/-\d+$//o;
580 $user = DXUser->get_current($field[1]);
582 $user = DXUser->new($field[1]) if !$user;
584 if ($field[2] == 1) {
585 $user->name($field[3]);
586 } elsif ($field[2] == 2) {
587 $user->qth($field[3]);
588 } elsif ($field[2] == 3) {
589 my ($lat, $long) = DXBearing::stoll($field[3]);
592 } elsif ($field[2] == 4) {
593 $user->homenode($field[3]);
617 if ($pcno == 50) { # keep alive/user list
618 my $ref = DXCluster->get_exact($field[1]);
619 $ref->update_users($field[2]) if $ref;
623 if ($pcno == 51) { # incoming ping requests/answers
626 if ($field[1] eq $main::mycall) {
627 my $flag = $field[3];
629 $self->send(pc51($field[2], $field[1], '0'));
631 # it's a reply, look in the ping list for this one
632 my $ref = $pings{$field[2]};
635 my $dxchan = DXChannel->get($r->{call});
636 $dxchan->send($dxchan->msg('pingi', $field[2], atime($main::systime), $main::systime - $r->{t})) if $dxchan;
641 # route down an appropriate thingy
642 route($field[1], $line);
648 # if get here then rebroadcast the thing with its Hop count decremented (if
649 # there is one). If it has a hop count and it decrements to zero then don't
652 # NOTE - don't arrive here UNLESS YOU WANT this lump of protocol to be
656 if (!$self->{isolate}) {
657 broadcast_ak1a($line, $self); # send it to everyone but me
662 # This is called from inside the main cluster processing loop and is used
663 # for despatching commands that are doing some long processing job
668 my @dxchan = DXChannel->get_all();
671 foreach $dxchan (@dxchan) {
672 next unless $dxchan->is_ak1a();
673 next if $dxchan == $me;
675 # send a pc50 out on this channel
676 if ($t >= $dxchan->pc50_t + $DXProt::pc50_interval) {
677 $dxchan->send(pc50());
685 if ($main::systime - 3600 > $last_hour) {
686 $cutoff = $main::systime - $pc11_dup_age;
687 while (($key, $val) = each %spotdup) {
688 delete $spotdup{$key} if $val < $cutoff;
690 $cutoff = $main::systime - $pc23_dup_age;
691 while (($key, $val) = each %wwvdup) {
692 delete $wwvdup{$key} if $val < $cutoff;
694 $cutoff = $main::systime - $pc12_dup_age;
695 while (($key, $val) = each %anndup) {
696 delete $anndup{$key} if $val < $cutoff;
698 $last_hour = $main::systime;
703 # finish up a pc context
708 my $call = $self->call;
709 my $ref = DXCluster->get_exact($call);
711 # unbusy and stop and outgoing mail
712 my $mref = DXMsg::get_busy($call);
713 $mref->stop_msg($self) if $mref;
715 # broadcast to all other nodes that all the nodes connected to via me are gone
716 my @gonenodes = map { $_->dxchan == $self ? $_ : () } DXNode::get_all();
719 foreach $node (@gonenodes) {
720 next if $node->call eq $call;
721 broadcast_ak1a(pc21($node->call, 'Gone') , $self) unless $self->{isolate};
725 # remove outstanding pings
726 delete $pings{$call};
728 # now broadcast to all other ak1a nodes that I have gone
729 broadcast_ak1a(pc21($call, 'Gone.'), $self);
731 Log('DXProt', $call . " Disconnected");
736 # some active measures
742 my @dxchan = DXChannel->get_all();
745 # send it if it isn't the except list and isn't isolated and still has a hop count
746 # taking into account filtering and so on
747 foreach $dxchan (@dxchan) {
749 my ($filter, $hops) = Filter::it($dxchan->{spotfilter}, @_, $self->{call} ) if $dxchan->{spotfilter};
750 if ($dxchan->is_ak1a) {
751 next if $dxchan == $self;
754 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
756 $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name
757 next unless $routeit;
760 $dxchan->send($routeit) if $routeit;
762 $dxchan->send($routeit) unless $dxchan->{isolate} || $self->{isolate};
765 } elsif ($dxchan->is_user && $dxchan->{dx}) {
766 my $buf = Spot::formatb($_[0], $_[1], $_[2], $_[3], $_[4]);
767 $buf .= "\a\a" if $dxchan->{beep};
768 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'convers') {
769 $dxchan->send($buf) if !$hops || ($hops && $filter);
771 $dxchan->delay($buf) if !$hops || ($hops && $filter);
777 sub send_local_config
786 if ($self->{isolate}) {
787 @localnodes = (DXCluster->get_exact($main::mycall));
789 # create a list of all the nodes that are not connected to this connection
790 # and are not themselves isolated, this to make sure that isolated nodes
791 # don't appear outside of this node
792 @nodes = DXNode::get_all();
793 @nodes = grep { $_->{call} ne $main::mycall } @nodes;
794 @nodes = grep { $_->dxchan != $self } @nodes if @nodes;
795 @nodes = grep { !$_->dxchan->{isolate} } @nodes if @nodes;
796 @localnodes = grep { $_->dxchan->{call} eq $_->{call} } @nodes if @nodes;
797 unshift @localnodes, DXCluster->get_exact($main::mycall);
798 @remotenodes = grep { $_->dxchan->{call} ne $_->{call} } @nodes if @nodes;
801 my @s = $me->pc19(@localnodes, @remotenodes);
803 my $routeit = adjust_hops($self, $_);
804 $self->send($routeit) if $routeit;
807 # get all the users connected on the above nodes and send them out
808 foreach $n (@localnodes, @remotenodes) {
809 my @users = values %{$n->list};
810 my @s = pc16($n, @users);
812 my $routeit = adjust_hops($self, $_);
813 $self->send($routeit) if $routeit;
819 # route a message down an appropriate interface for a callsign
821 # is called route(to, pcline);
825 my ($call, $line) = @_;
826 my $cl = DXCluster->get_exact($call);
829 my $dxchan = $cl->{dxchan};
831 my $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name
833 $dxchan->send($routeit) if $dxchan;
839 # broadcast a message to all clusters taking into account isolation
840 # [except those mentioned after buffer]
843 my $s = shift; # the line to be rebroadcast
844 my @except = @_; # to all channels EXCEPT these (dxchannel refs)
845 my @dxchan = get_all_ak1a();
848 # send it if it isn't the except list and isn't isolated and still has a hop count
849 foreach $dxchan (@dxchan) {
850 next if grep $dxchan == $_, @except;
851 my $routeit = adjust_hops($dxchan, $s); # adjust its hop count by node name
852 $dxchan->send($routeit) unless $dxchan->{isolate} || !$routeit;
856 # broadcast a message to all clusters ignoring isolation
857 # [except those mentioned after buffer]
858 sub broadcast_all_ak1a
860 my $s = shift; # the line to be rebroadcast
861 my @except = @_; # to all channels EXCEPT these (dxchannel refs)
862 my @dxchan = get_all_ak1a();
865 # send it if it isn't the except list and isn't isolated and still has a hop count
866 foreach $dxchan (@dxchan) {
867 next if grep $dxchan == $_, @except;
868 my $routeit = adjust_hops($dxchan, $s); # adjust its hop count by node name
869 $dxchan->send($routeit);
873 # broadcast to all users
874 # storing the spot or whatever until it is in a state to receive it
877 my $s = shift; # the line to be rebroadcast
878 my $sort = shift; # the type of transmission
879 my $fref = shift; # a reference to an object to filter on
880 my @except = @_; # to all channels EXCEPT these (dxchannel refs)
881 my @dxchan = get_all_users();
885 foreach $dxchan (@dxchan) {
886 next if grep $dxchan == $_, @except;
889 broadcast_list($s, $sort, $fref, @out);
892 # broadcast to a list of users
900 foreach $dxchan (@_) {
904 next unless $dxchan->{dx};
905 ($filter) = Filter::it($dxchan->{spotfilter}, @{$fref}) if ref $fref;
908 next if $sort eq 'ann' && !$dxchan->{ann};
909 next if $sort eq 'wwv' && !$dxchan->{wwv};
910 next if $sort eq 'wx' && !$dxchan->{wx};
912 $s =~ s/\a//og unless $dxchan->{beep};
914 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'convers') {
923 # gimme all the ak1a nodes
927 my @list = DXChannel->get_all();
930 foreach $ref (@list) {
931 push @out, $ref if $ref->is_ak1a;
936 # return a list of all users
939 my @list = DXChannel->get_all();
942 foreach $ref (@list) {
943 push @out, $ref if $ref->is_user;
948 # return a list of all user callsigns
949 sub get_all_user_calls
951 my @list = DXChannel->get_all();
954 foreach $ref (@list) {
955 push @out, $ref->call if $ref->is_user;
961 # obtain the hops from the list for this callsign and pc no
967 my $hops = $DXProt::hopcount{$pcno};
968 $hops = $DXProt::def_hopcount if !$hops;
973 # adjust the hop count on a per node basis using the user loadable
974 # hop table if available or else decrement an existing one
981 my $call = $self->{call};
984 if (($hops) = $s =~ /\^H(\d+)\^~?$/o) {
985 my ($pcno) = $s =~ /^PC(\d\d)/o;
986 confess "$call called adjust_hops with '$s'" unless $pcno;
987 my $ref = $nodehops{$call} if %nodehops;
989 my $newhops = $ref->{$pcno};
990 return "" if defined $newhops && $newhops == 0;
991 $newhops = $ref->{default} unless $newhops;
992 return "" if defined $newhops && $newhops == 0;
993 $newhops = $hops if !$newhops;
994 $s =~ s/\^H(\d+)(\^~?)$/\^H$newhops$2/ if $newhops;
996 # simply decrement it
999 $s =~ s/\^H(\d+)(\^~?)$/\^H$hops$2/ if $hops;
1011 return $self->msg('lh1') unless -e "$main::data/hop_table.pl";
1012 do "$main::data/hop_table.pl";
1017 # remove leading and trailing spaces from an input string
1021 $s =~ s/^\s+|\s+$//;
1025 # add a ping request to the ping queues
1028 my ($from, $to) = @_;
1029 my $ref = $pings{$to};
1030 $ref = $pings{$to} = [] if !$ref;
1033 $r->{t} = $main::systime;
1034 route($to, pc51($to, $main::mycall, 1));
1038 # add a rcmd request to the rcmd queues
1041 my ($from, $to, $cmd) = @_;
1044 $r->{t} = $main::systime;
1046 route($to, pc34($main::mycall, $to, $cmd));