3 # This module impliments the protocal mode for a dx cluster
5 # Copyright (c) 1998 Dirk Koopman G1TLH
30 use Time::HiRes qw(gettimeofday tv_interval);
37 use vars qw($me $pc11_max_age $pc23_max_age
38 $last_hour $last10 %eph %pings %rcmds
39 %nodehops $baddx $badspotter $badnode $censorpc
40 $allowzero $decode_dk0wcy $send_opernam @checklist);
42 $me = undef; # the channel id for this cluster
43 $pc11_max_age = 1*3600; # the maximum age for an incoming 'real-time' pc11
44 $pc23_max_age = 1*3600; # the maximum age for an incoming 'real-time' pc23
46 $last_hour = time; # last time I did an hourly periodic update
47 %pings = (); # outstanding ping requests outbound
48 %rcmds = (); # outstanding rcmd requests outbound
49 %nodehops = (); # node specific hop control
50 $censorpc = 1; # Do a BadWords::check on text fields and reject things
51 # loads of 'bad things'
52 $baddx = new DXHash "baddx";
53 $badspotter = new DXHash "badspotter";
54 $badnode = new DXHash "badnode";
59 [ qw(c c m bp bc c) ], # pc10
60 [ qw(f m d t m c c h) ], # pc11
61 [ qw(c bc m bp bm p h) ], # pc12
65 undef , # pc16 has to be validated manually
68 undef , # pc19 has to be validated manually
69 undef , # pc20 no validation
71 undef , # pc22 no validation
72 [ qw(d n n n n m c c h) ], # pc23
74 [ qw(c c n n) ], # pc25
75 [ qw(f m d t m c c bc) ], # pc26
76 [ qw(d n n n n m c c bc) ], # pc27
77 [ qw(c c m c d t p m bp n p bp bc) ], # pc28
78 [ qw(c c n m) ], # pc29
86 [ qw(c c n m) ], # pc37
87 undef, # pc38 not interested
89 [ qw(c c m p n) ], # pc40
90 [ qw(c n m h) ], # pc41
92 undef, # pc43 don't handle it
93 [ qw(c c n m m c) ], # pc44
94 [ qw(c c n m) ], # pc45
100 [ qw(c c n) ], # pc51
122 [ qw(d n n n n n n m m m c c h) ], # pc73
133 [ qw(c c c m) ], # pc84
134 [ qw(c c c m) ], # pc85
137 # use the entry in the check list to check the field list presented
138 # return OK if line NOT in check list (for now)
143 return 0 if $n < 0 || $n > @checklist;
144 my $ref = $checklist[$n];
145 return 0 unless ref $ref;
148 shift; # not interested in the first field
149 for ($i = 0; $i < @$ref; $i++) {
150 my ($blank, $act) = $$ref[$i] =~ /^(b?)(\w)$/;
151 return 0 unless $act;
152 next if $blank && $_[$i] =~ /^[ \*]$/;
154 return $i+1 unless is_callsign($_[$i]);
155 } elsif ($act eq 'm') {
156 return $i+1 unless is_pctext($_[$i]);
157 } elsif ($act eq 'p') {
158 return $i+1 unless is_pcflag($_[$i]);
159 } elsif ($act eq 'f') {
160 return $i+1 unless is_freq($_[$i]);
161 } elsif ($act eq 'n') {
162 return $i+1 unless $_[$i] =~ /^[\d ]+$/;
163 } elsif ($act eq 'h') {
164 return $i+1 unless $_[$i] =~ /^H\d\d?$/;
165 } elsif ($act eq 'd') {
166 return $i+1 unless $_[$i] =~ /^\s*\d+-\w\w\w-[12][90]\d\d$/;
167 } elsif ($act eq 't') {
168 return $i+1 unless $_[$i] =~ /^[012]\d[012345]\dZ$/;
176 my $user = DXUser->get($main::mycall);
177 $DXProt::myprot_version += $main::version*100;
178 $me = DXProt->new($main::mycall, 0, $user);
180 $me->{state} = "indifferent";
181 do "$main::data/hop_table.pl" if -e "$main::data/hop_table.pl";
183 $me->{sort} = 'S'; # S for spider
185 # $Route::Node::me->adddxchan($me);
189 # obtain a new connection this is derived from dxchannel
194 my $self = DXChannel::alloc(@_);
196 # add this node to the table, the values get filled in later
199 $main::routeroot->add($call, '0000', Route::here(1)) if $call ne $main::mycall;
204 # this is how a pc connection starts (for an incoming connection)
205 # issue a PC38 followed by a PC18, then wait for a PC20 (remembering
206 # all the crap that comes between).
209 my ($self, $line, $sort) = @_;
210 my $call = $self->{call};
211 my $user = $self->{user};
213 # remember type of connection
214 $self->{consort} = $line;
215 $self->{outbound} = $sort eq 'O';
216 $self->{priv} = $user->priv || 1; # other clusters can always be 'normal' users
217 $self->{lang} = $user->lang || 'en';
218 $self->{isolate} = $user->{isolate};
219 $self->{consort} = $line; # save the connection type
222 # get the output filters
223 $self->{spotsfilter} = Filter::read_in('spots', $call, 0) || Filter::read_in('spots', 'node_default', 0);
224 $self->{wwvfilter} = Filter::read_in('wwv', $call, 0) || Filter::read_in('wwv', 'node_default', 0);
225 $self->{wcyfilter} = Filter::read_in('wcy', $call, 0) || Filter::read_in('wcy', 'node_default', 0);
226 $self->{annfilter} = Filter::read_in('ann', $call, 0) || Filter::read_in('ann', 'node_default', 0) ;
227 $self->{routefilter} = Filter::read_in('route', $call, 0) || Filter::read_in('route', 'node_default', 0) ;
230 # get the INPUT filters (these only pertain to Clusters)
231 $self->{inspotsfilter} = Filter::read_in('spots', $call, 1) || Filter::read_in('spots', 'node_default', 1);
232 $self->{inwwvfilter} = Filter::read_in('wwv', $call, 1) || Filter::read_in('wwv', 'node_default', 1);
233 $self->{inwcyfilter} = Filter::read_in('wcy', $call, 1) || Filter::read_in('wcy', 'node_default', 1);
234 $self->{inannfilter} = Filter::read_in('ann', $call, 1) || Filter::read_in('ann', 'node_default', 1);
235 $self->{inroutefilter} = Filter::read_in('route', $call, 1) || Filter::read_in('route', 'node_default', 1);
237 # set unbuffered and no echo
238 $self->send_now('B',"0");
239 $self->send_now('E',"0");
241 # ping neighbour node stuff
242 my $ping = $user->pingint;
243 $ping = 5*60 unless defined $ping;
244 $self->{pingint} = $ping;
245 $self->{nopings} = $user->nopings || 2;
246 $self->{pingtime} = [ ];
247 $self->{pingave} = 0;
249 # send initialisation string
250 unless ($self->{outbound}) {
252 $self->{lastping} = $main::systime;
254 $self->{lastping} = $main::systime + ($self->pingint / 2);
256 $self->state('init');
257 $self->{pc50_t} = $main::systime;
259 # send info to all logged in thingies
260 $self->tell_login('loginn');
262 Log('DXProt', "$call connected");
266 # This is the normal pcxx despatcher
270 my ($self, $line) = @_;
271 my @field = split /\^/, $line;
272 return unless @field;
274 pop @field if $field[-1] eq '~';
276 # print join(',', @field), "\n";
278 # ignore any lines that don't start with PC
279 return if !$field[0] =~ /^PC/;
282 my ($pcno) = $field[0] =~ /^PC(\d\d)/; # just get the number
284 return if $pcno < 10 || $pcno > 99;
286 # check for and dump bad protocol messages
287 my $n = check($pcno, @field);
289 dbg("PCPROT: bad field $n, dumped (" . parray($checklist[$pcno-10]) . ")") if isdbg('chan');
296 $pcr = Local::pcprot($self, $pcno, @field);
298 # dbg("Local::pcprot error $@") if isdbg('local') if $@;
302 if ($pcno == 10) { # incoming talk
304 # will we allow it at all?
307 if (@bad = BadWords::check($field[3])) {
308 dbg("PCPROT: Bad words: @bad, dropped") if isdbg('chan');
313 # is it for me or one of mine?
314 my ($to, $via, $call, $dxchan);
315 if ($field[5] gt ' ') {
316 $call = $via = $field[2];
319 $call = $to = $field[2];
321 $dxchan = DXChannel->get($call);
322 if ($dxchan && $dxchan->is_user) {
323 $field[3] =~ s/\%5E/^/g;
324 $dxchan->talk($field[1], $to, $via, $field[3]);
326 $self->route($field[2], $line); # relay it on its way
331 if ($pcno == 11 || $pcno == 26) { # dx spot
333 # route 'foreign' pc26s
335 if ($field[7] ne $main::mycall) {
336 $self->route($field[7], $line);
341 # if this is a 'nodx' node then ignore it
342 if ($badnode->in($field[7])) {
343 dbg("PCPROT: Bad Node, dropped") if isdbg('chan');
347 # if this is a 'bad spotter' user then ignore it
348 if ($badspotter->in($field[6])) {
349 dbg("PCPROT: Bad Spotter, dropped") if isdbg('chan');
353 # convert the date to a unix date
354 my $d = cltounix($field[3], $field[4]);
355 # bang out (and don't pass on) if date is invalid or the spot is too old (or too young)
356 if (!$d || ($pcno == 11 && ($d < $main::systime - $pc11_max_age || $d > $main::systime + 900))) {
357 dbg("PCPROT: Spot ignored, invalid date or out of range ($field[3] $field[4])\n") if isdbg('chan');
362 if ($baddx->in($field[2])) {
363 dbg("PCPROT: Bad DX spot, ignored") if isdbg('chan');
368 $field[5] =~ s/^\s+//; # take any leading blanks off
369 $field[2] = unpad($field[2]); # take off leading and trailing blanks from spotted callsign
370 if ($field[2] =~ /BUST\w*$/) {
371 dbg("PCPROT: useless 'BUSTED' spot") if isdbg('chan');
374 if (Spot::dup($field[1], $field[2], $d, $field[5])) {
375 dbg("PCPROT: Duplicate Spot ignored\n") if isdbg('chan');
380 if (@bad = BadWords::check($field[5])) {
381 dbg("PCPROT: Bad words: @bad, dropped") if isdbg('chan');
386 my @spot = Spot::prepare($field[1], $field[2], $d, $field[5], $field[6], $field[7]);
387 # global spot filtering on INPUT
388 if ($self->{inspotsfilter}) {
389 my ($filter, $hops) = $self->{inspotsfilter}->it(@spot);
391 dbg("PCPROT: Rejected by filter") if isdbg('chan');
400 # @spot at this point contains:-
401 # freq, spotted call, time, text, spotter, spotted cc, spotters cc, orig node
402 # then spotted itu, spotted cq, spotters itu, spotters cq
403 # you should be able to route on any of these
406 # fix up qra locators of known users
407 my $user = DXUser->get_current($spot[4]);
409 my $qra = $user->qra;
410 unless ($qra && DXBearing::is_qra($qra)) {
411 my $lat = $user->lat;
412 my $long = $user->long;
413 if (defined $lat && defined $long) {
414 $user->qra(DXBearing::lltoqra($lat, $long));
419 # send a remote command to a distant cluster if it is visible and there is no
420 # qra locator and we havn't done it for a month.
422 unless ($user->qra) {
424 my $to = $user->homenode;
425 my $last = $user->lastoper || 0;
426 if ($send_opernam && $main::systime > $last + $DXUser::lastoperinterval && $to && ($node = Route::Node::get($to)) ) {
427 my $cmd = "forward/opernam $spot[4]";
428 # send the rcmd but we aren't interested in the replies...
429 my $dxchan = $node->dxchan;
430 if ($dxchan && $dxchan->is_clx) {
431 route(undef, $to, pc84($main::mycall, $to, $main::mycall, $cmd));
433 route(undef, $to, pc34($main::mycall, $to, $cmd));
435 if ($to ne $field[7]) {
437 $node = Route::Node::get($to);
439 $dxchan = $node->dxchan;
440 if ($dxchan && $dxchan->is_clx) {
441 route(undef, $to, pc84($main::mycall, $to, $main::mycall, $cmd));
443 route(undef, $to, pc34($main::mycall, $to, $cmd));
447 $user->lastoper($main::systime);
456 $r = Local::spot($self, @spot);
458 # dbg("Local::spot1 error $@") if isdbg('local') if $@;
461 # DON'T be silly and send on PC26s!
462 return if $pcno == 26;
464 # send out the filtered spots
465 send_dx_spot($self, $line, @spot) if @spot;
469 if ($pcno == 12) { # announces
470 # announce duplicate checking
471 $field[3] =~ s/^\s+//; # remove leading blanks
472 if (AnnTalk::dup($field[1], $field[2], $field[3])) {
473 dbg("PCPROT: Duplicate Announce ignored") if isdbg('chan');
479 if (@bad = BadWords::check($field[3])) {
480 dbg("PCPROT: Bad words: @bad, dropped") if isdbg('chan');
485 if ($field[2] eq '*' || $field[2] eq $main::mycall) {
487 # global ann filtering on INPUT
488 if ($self->{inannfilter}) {
489 my ($ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
490 my @dxcc = Prefix::extract($field[1]);
492 $ann_dxcc = $dxcc[1]->dxcc;
493 $ann_itu = $dxcc[1]->itu;
494 $ann_cq = $dxcc[1]->cq();
496 @dxcc = Prefix::extract($field[5]);
498 $org_dxcc = $dxcc[1]->dxcc;
499 $org_itu = $dxcc[1]->itu;
500 $org_cq = $dxcc[1]->cq();
502 my ($filter, $hops) = $self->{inannfilter}->it(@field[1..6], $self->{call},
503 $ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq);
505 dbg("PCPROT: Rejected by filter") if isdbg('chan');
511 $self->send_announce($line, @field[1..6]);
513 $self->route($field[2], $line);
529 if ($pcno == 16) { # add a user
533 my $ncall = $field[1];
534 my $newline = "PC16^";
536 if ($ncall eq $main::mycall) {
537 dbg("PCPROT: trying to alter config on this node from outside!") if isdbg('chan');
540 $dxchan = DXChannel->get($ncall);
541 if ($dxchan && $dxchan ne $self) {
542 dbg("PCPROT: PC16 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chan');
545 my $parent = Route::Node::get($ncall);
547 dbg("PCPROT: Node $ncall not in config") if isdbg('chan');
552 for ($i = 2; $i < $#field; $i++) {
553 my ($call, $conf, $here) = $field[$i] =~ /^(\S+) (\S) (\d)/o;
554 next unless $call && $conf && defined $here && is_callsign($call);
555 $conf = $conf eq '*';
557 my $r = Route::User::get($call);
558 my $flags = Route::here($here)|Route::conf($conf);
560 if ($r && $r->flags != $flags) {
564 push @rout, $parent->add_user($call, $flags);
567 # add this station to the user database, if required
568 $call =~ s/-\d+$//o; # remove ssid for users
569 my $user = DXUser->get_current($call);
570 $user = DXUser->new($call) if !$user;
571 $user->homenode($parent->call) if !$user->homenode;
572 $user->node($parent->call);
573 $user->lastin($main::systime) unless DXChannel->get($call);
578 # queue up any messages (look for privates only)
579 DXMsg::queue_msg(1) if $self->state eq 'normal';
581 $self->route_pc16($parent, @rout) if @rout;
585 if ($pcno == 17) { # remove a user
587 my $ncall = $field[2];
588 my $ucall = $field[1];
589 if ($ncall eq $main::mycall) {
590 dbg("PCPROT: trying to alter config on this node from outside!") if isdbg('chan');
593 $dxchan = DXChannel->get($ncall);
594 if ($dxchan && $dxchan ne $self) {
595 dbg("PCPROT: PC17 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chan');
598 my $parent = Route::Node::get($ncall);
600 dbg("PCPROT: Route::Node $ncall not in config") if isdbg('chan');
603 my @rout = $parent->del_user($ucall);
604 $self->route_pc17($parent, @rout) if @rout;
608 if ($pcno == 18) { # link request
609 $self->state('init');
611 # first clear out any nodes on this dxchannel
612 my $parent = Route::Node::get($self->{call});
613 my @rout = $parent->del_nodes;
614 $self->route_pc21(@rout, $parent);
615 $self->send_local_config();
617 return; # we don't pass these on
620 if ($pcno == 19) { # incoming cluster list
622 my $newline = "PC19^";
626 my $parent = Route::Node::get($self->{call});
629 for ($i = 1; $i < $#field-1; $i += 4) {
630 my $here = $field[$i];
631 my $call = uc $field[$i+1];
632 my $conf = $field[$i+2];
633 my $ver = $field[$i+3];
634 next unless defined $here && defined $conf && is_callsign($call);
635 # check for sane parameters
636 $ver = 5000 if $ver eq '0000';
637 next if $ver < 5000; # only works with version 5 software
638 next if length $call < 3; # min 3 letter callsigns
640 # update it if required
642 my $flags = Route::here($here)|Route::conf($conf);
643 if ($parent->call eq $call && ($parent->version ne $ver || $parent->flags != $flags)) {
644 $parent->version($ver);
645 $parent->flags($flags);
647 } elsif ($parent->call ne $call) {
648 next if $call eq $main::mycall || $call eq $self->{call};
650 my $r = $parent->add($call, $ver, Route::here($here)|Route::conf($conf));
651 push @rout, $r if $r;
653 $r = Route::Node::get($call);
654 if ($r && ($r->version ne $ver || $r->flags != $flags)) {
656 $r->flags(Route::here($here)|Route::conf($conf));
661 # unbusy and stop and outgoing mail (ie if somehow we receive another PC19 without a disconnect)
662 my $mref = DXMsg::get_busy($call);
663 $mref->stop_msg($call) if $mref;
665 # add this station to the user database, if required (don't remove SSID from nodes)
666 my $user = DXUser->get_current($call);
668 $user = DXUser->new($call);
670 $user->priv(1); # I have relented and defaulted nodes
671 $self->{priv} = 1; # to user RCMDs allowed
672 $user->homenode($call);
675 $user->lastin($main::systime) unless DXChannel->get($call);
679 $self->route_pc19(@rout) if @rout;
683 if ($pcno == 20) { # send local configuration
684 $self->send_local_config();
686 $self->state('normal');
690 if ($pcno == 21) { # delete a cluster from the list
691 my $call = uc $field[1];
693 my $parent = Route::Node::get($self->{call});
695 dbg("PCPROT: Route::Node $call not in config") if isdbg('chan');
698 my $node = Route::Node::get($call);
700 if ($call ne $main::mycall) { # don't allow malicious buggers to disconnect me!
701 if ($call eq $self->{call}) {
702 dbg("PCPROT: Trying to disconnect myself with PC21") if isdbg('chan');
707 push @rout, $node->del($parent) if $node;
709 dbg("PCPROT: I WILL _NOT_ be disconnected!") if isdbg('chan');
712 $self->route_pc21(@rout) if @rout;
717 $self->state('normal');
721 if ($pcno == 23 || $pcno == 27) { # WWV info
723 # route 'foreign' pc27s
725 if ($field[8] ne $main::mycall) {
726 $self->route($field[8], $line);
732 my $d = cltounix($field[1], sprintf("%02d18Z", $field[2]));
733 my $sfi = unpad($field[3]);
734 my $k = unpad($field[4]);
735 my $i = unpad($field[5]);
736 my ($r) = $field[6] =~ /R=(\d+)/;
738 if (($pcno == 23 && $d < $main::systime - $pc23_max_age) || $d > $main::systime + 1500 || $field[2] < 0 || $field[2] > 23) {
739 dbg("PCPROT: WWV Date ($field[1] $field[2]) out of range") if isdbg('chan');
742 if (Geomag::dup($d,$sfi,$k,$i,$field[6])) {
743 dbg("PCPROT: Dup WWV Spot ignored\n") if isdbg('chan');
746 $field[7] =~ s/-\d+$//o; # remove spotter's ssid
748 my $wwv = Geomag::update($d, $field[2], $sfi, $k, $i, @field[6..8], $r);
752 $rep = Local::wwv($self, $field[1], $field[2], $sfi, $k, $i, @field[6..8], $r);
754 # dbg("Local::wwv2 error $@") if isdbg('local') if $@;
757 # DON'T be silly and send on PC27s!
758 return if $pcno == 27;
760 # broadcast to the eager world
761 send_wwv_spot($self, $line, $d, $field[2], $sfi, $k, $i, @field[6..8]);
765 if ($pcno == 24) { # set here status
766 my $call = uc $field[1];
767 my $ref = Route::Node::get($call);
768 $ref->here($field[2]) if $ref;
769 $ref = Route::User::get($call);
770 $ref->here($field[2]) if $ref;
772 $self->route_pc24($ref, $field[3]) if $ref && !eph_dup($line);
776 if ($pcno == 25) { # merge request
777 if ($field[1] ne $main::mycall) {
778 $self->route($field[1], $line);
781 if ($field[2] eq $main::mycall) {
782 dbg("PCPROT: Trying to merge to myself, ignored") if isdbg('chan');
786 Log('DXProt', "Merge request for $field[3] spots and $field[4] WWV from $field[1]");
790 my @in = reverse Spot::search(1, undef, undef, 0, $field[3]);
793 $self->send(pc26(@{$in}[0..4], $field[2]));
799 my @in = reverse Geomag::search(0, $field[4], time, 1);
802 $self->send(pc27(@{$in}[0..5], $field[2]));
808 if (($pcno >= 28 && $pcno <= 33) || $pcno == 40 || $pcno == 42 || $pcno == 49) { # mail/file handling
809 if ($pcno == 49 || $field[1] eq $main::mycall) {
810 DXMsg::process($self, $line);
812 $self->route($field[1], $line) unless $self->is_clx;
817 if ($pcno == 34 || $pcno == 36) { # remote commands (incoming)
818 if ($field[1] eq $main::mycall) {
819 my $ref = DXUser->get_current($field[2]);
820 my $cref = Route::Node::get($field[2]);
821 Log('rcmd', 'in', $ref->{priv}, $field[2], $field[3]);
822 unless (!$cref || !$ref || $cref->call ne $ref->homenode) { # not allowed to relay RCMDS!
823 if ($ref->{priv}) { # you have to have SOME privilege, the commands have further filtering
824 $self->{remotecmd} = 1; # for the benefit of any command that needs to know
825 my $oldpriv = $self->{priv};
826 $self->{priv} = $ref->{priv}; # assume the user's privilege level
827 my @in = (DXCommandmode::run_cmd($self, $field[3]));
828 $self->{priv} = $oldpriv;
831 $self->send(pc35($main::mycall, $field[2], "$main::mycall:$_"));
832 Log('rcmd', 'out', $field[2], $_);
834 delete $self->{remotecmd};
836 $self->send(pc35($main::mycall, $field[2], "$main::mycall:sorry...!"));
839 $self->send(pc35($main::mycall, $field[2], "$main::mycall:your attempt is logged, Tut tut tut...!"));
842 my $ref = DXUser->get_current($field[1]);
843 if ($ref && $ref->is_clx) {
844 $self->route($field[1], pc84($field[2], $field[1], $field[2], $field[3]));
846 $self->route($field[1], $line);
852 if ($pcno == 35) { # remote command replies
853 if ($field[1] eq $main::mycall) {
854 my $s = $rcmds{$field[2]};
856 my $dxchan = DXChannel->get($s->{call});
857 $dxchan->send($field[3]) if $dxchan;
858 delete $rcmds{$field[2]} if !$dxchan;
860 # send unsolicited ones to the sysop
861 my $dxchan = DXChannel->get($main::myalias);
862 $dxchan->send($field[3]) if $dxchan;
865 my $ref = DXUser->get_current($field[1]);
866 if ($ref && $ref->is_clx) {
867 $self->route($field[1], pc85($field[2], $field[1], $field[2], $field[3]));
869 $self->route($field[1], $line);
875 # for pc 37 see 44 onwards
877 if ($pcno == 38) { # node connected list from neighbour
881 if ($pcno == 39) { # incoming disconnect
882 if ($field[1] eq $self->{call}) {
883 $self->disconnect(1);
885 dbg("PCPROT: came in on wrong channel") if isdbg('chan');
890 if ($pcno == 41) { # user info
891 # add this station to the user database, if required
892 my $call = $field[1];
893 my $user = DXUser->get_current($call);
894 $user = DXUser->new($call) if !$user;
896 if ($field[2] == 1) {
897 $user->name($field[3]);
898 } elsif ($field[2] == 2) {
899 $user->qth($field[3]);
900 } elsif ($field[2] == 3) {
901 my ($lat, $long) = DXBearing::stoll($field[3]);
904 $user->qra(DXBearing::lltoqra($lat, $long)) unless $user->qra && DXBearing::is_qra($user->qra);
905 } elsif ($field[2] == 4) {
906 $user->homenode($field[3]);
908 $user->lastoper($main::systime); # to cut down on excessive for/opers being generated
910 my $ref = Route::get($call);
911 $self->route_pc41($ref, $call, $field[2], $field[3], $field[4]) if $ref && !eph_dup($line);
919 if ($pcno == 37 || $pcno == 44 || $pcno == 45 || $pcno == 46 || $pcno == 47 || $pcno == 48) {
920 DXDb::process($self, $line);
924 if ($pcno == 50) { # keep alive/user list
925 my $call = $field[1];
926 my $node = Route::Node::get($call);
928 return unless $node->call eq $self->{call};
929 $node->usercount($field[2]);
930 $self->route_pc50($node, $field[2], $field[3]) unless eph_dup($line);
935 if ($pcno == 51) { # incoming ping requests/answers
937 my $from = $field[2];
938 my $flag = $field[3];
941 if ($to eq $main::mycall) {
943 $self->send(pc51($from, $to, '0'));
945 # it's a reply, look in the ping list for this one
946 my $ref = $pings{$from};
948 my $tochan = DXChannel->get($from);
951 my $dxchan = DXChannel->get($r->{call});
953 my $t = tv_interval($r->{t}, [ gettimeofday ]);
954 if ($dxchan->is_user) {
955 my $s = sprintf "%.2f", $t;
956 my $ave = sprintf "%.2f", $tochan ? ($tochan->{pingave} || $t) : $t;
957 $dxchan->send($dxchan->msg('pingi', $from, $s, $ave))
958 } elsif ($dxchan->is_node) {
960 $tochan->{nopings} = $tochan->user->nopings || 2; # pump up the timer
961 push @{$tochan->{pingtime}}, $t;
962 shift @{$tochan->{pingtime}} if @{$tochan->{pingtime}} > 6;
964 for (@{$tochan->{pingtime}}) {
967 $tochan->{pingave} = $st / @{$tochan->{pingtime}};
974 # route down an appropriate thingy
975 $self->route($to, $line);
980 if ($pcno == 75) { # dunno but route it
981 my $call = $field[1];
982 if ($call ne $main::mycall) {
983 $self->route($call, $line);
988 if ($pcno == 73) { # WCY broadcasts
989 my $call = $field[1];
992 my $d = cltounix($call, sprintf("%02d18Z", $field[2]));
993 if (($pcno == 23 && $d < $main::systime - $pc23_max_age) || $d > $main::systime + 1500 || $field[2] < 0 || $field[2] > 23) {
994 dbg("PCPROT: WCY Date ($call $field[2]) out of range") if isdbg('chan');
997 @field = map { unpad($_) } @field;
998 if (WCY::dup($d,@field[3..7])) {
999 dbg("PCPROT: Dup WCY Spot ignored\n") if isdbg('chan');
1003 my $wcy = WCY::update($d, @field[2..12]);
1007 $rep = Local::wwv($self, @field[1..12]);
1009 # dbg("Local::wcy error $@") if isdbg('local') if $@;
1012 # broadcast to the eager world
1013 send_wcy_spot($self, $line, $d, @field[2..12]);
1017 if ($pcno == 84) { # remote commands (incoming)
1018 my $call = $field[1];
1019 if ($call eq $main::mycall) {
1020 my $ref = DXUser->get_current($field[2]);
1021 my $cref = Route::Node::get($field[2]);
1022 Log('rcmd', 'in', $ref->{priv}, $field[2], $field[4]);
1023 unless ($field[4] =~ /rcmd/i || !$cref || !$ref || $cref->call ne $ref->homenode) { # not allowed to relay RCMDS!
1024 if ($ref->{priv}) { # you have to have SOME privilege, the commands have further filtering
1025 $self->{remotecmd} = 1; # for the benefit of any command that needs to know
1026 my $oldpriv = $self->{priv};
1027 $self->{priv} = $ref->{priv}; # assume the user's privilege level
1028 my @in = (DXCommandmode::run_cmd($self, $field[4]));
1029 $self->{priv} = $oldpriv;
1032 $self->send(pc85($main::mycall, $field[2], $field[3], "$main::mycall:$_"));
1033 Log('rcmd', 'out', $field[2], $_);
1035 delete $self->{remotecmd};
1037 $self->send(pc85($main::mycall, $field[2], $field[3], "$main::mycall:sorry...!"));
1040 $self->send(pc85($main::mycall, $field[2], $field[3],"$main::mycall:your attempt is logged, Tut tut tut...!"));
1043 my $ref = DXUser->get_current($call);
1044 if ($ref && $ref->is_clx) {
1045 $self->route($call, $line);
1047 $self->route($call, pc34($field[2], $call, $field[4]));
1053 if ($pcno == 85) { # remote command replies
1054 my $call = $field[1];
1055 if ($call eq $main::mycall) {
1056 my $dxchan = DXChannel->get($field[3]);
1058 $dxchan->send($field[4]);
1060 my $s = $rcmds{$field[2]};
1062 $dxchan = DXChannel->get($s->{call});
1063 $dxchan->send($field[4]) if $dxchan;
1064 delete $rcmds{$field[2]} if !$dxchan;
1066 # send unsolicited ones to the sysop
1067 my $dxchan = DXChannel->get($main::myalias);
1068 $dxchan->send($field[4]) if $dxchan;
1072 my $ref = DXUser->get_current($call);
1073 if ($ref && $ref->is_clx) {
1074 $self->route($call, $line);
1076 $self->route($call, pc35($field[2], $call, $field[4]));
1083 # if get here then rebroadcast the thing with its Hop count decremented (if
1084 # there is one). If it has a hop count and it decrements to zero then don't
1087 # NOTE - don't arrive here UNLESS YOU WANT this lump of protocol to be
1091 if (eph_dup($line)) {
1092 dbg("PCPROT: Ephemeral dup, dropped") if isdbg('chan');
1094 unless ($self->{isolate}) {
1095 broadcast_ak1a($line, $self); # send it to everyone but me
1101 # This is called from inside the main cluster processing loop and is used
1102 # for despatching commands that are doing some long processing job
1107 my @dxchan = DXChannel->get_all();
1110 foreach $dxchan (@dxchan) {
1111 next unless $dxchan->is_node();
1112 next if $dxchan == $me;
1114 # send a pc50 out on this channel
1115 $dxchan->{pc50_t} = $main::systime unless exists $dxchan->{pc50_t};
1116 if ($t >= $dxchan->{pc50_t} + $DXProt::pc50_interval) {
1117 my $s = pc50($me, scalar DXChannel::get_all_users);
1120 $dxchan->{pc50_t} = $t;
1123 # send a ping out on this channel
1124 if ($dxchan->{pingint} && $t >= $dxchan->{pingint} + $dxchan->{lastping}) {
1125 if ($dxchan->{nopings} <= 0) {
1126 $dxchan->disconnect;
1128 addping($main::mycall, $dxchan->call);
1129 $dxchan->{nopings} -= 1;
1130 $dxchan->{lastping} = $t;
1136 if ($t - $last10 >= 10) {
1137 # clean out ephemera
1144 if ($main::systime - 3600 > $last_hour) {
1145 $last_hour = $main::systime;
1150 # finish up a pc context
1154 # some active measures
1161 my @dxchan = DXChannel->get_all();
1164 # send it if it isn't the except list and isn't isolated and still has a hop count
1165 # taking into account filtering and so on
1166 foreach $dxchan (@dxchan) {
1167 next if $dxchan == $me;
1169 my ($filter, $hops);
1171 if ($dxchan->{spotsfilter}) {
1172 ($filter, $hops) = $dxchan->{spotsfilter}->it(@_, $self->{call} );
1173 next unless $filter;
1176 if ($dxchan->is_node) {
1177 next if $dxchan == $self;
1180 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
1182 $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name
1183 next unless $routeit;
1186 $dxchan->send($routeit) if $routeit;
1188 $dxchan->send($routeit) unless $dxchan->{isolate} || $self->{isolate};
1190 } elsif ($dxchan->is_user && $dxchan->{dx}) {
1191 my $buf = Spot::formatb($dxchan->{user}->wantgrid, $_[0], $_[1], $_[2], $_[3], $_[4]);
1192 $buf .= "\a\a" if $dxchan->{beep};
1194 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'talk') {
1195 $dxchan->send($buf);
1197 $dxchan->delay($buf);
1207 my @dxchan = DXChannel->get_all();
1209 my ($wwv_dxcc, $wwv_itu, $wwv_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
1210 my @dxcc = Prefix::extract($_[7]);
1212 $wwv_dxcc = $dxcc[1]->dxcc;
1213 $wwv_itu = $dxcc[1]->itu;
1214 $wwv_cq = $dxcc[1]->cq;
1216 @dxcc = Prefix::extract($_[8]);
1218 $org_dxcc = $dxcc[1]->dxcc;
1219 $org_itu = $dxcc[1]->itu;
1220 $org_cq = $dxcc[1]->cq;
1223 # send it if it isn't the except list and isn't isolated and still has a hop count
1224 # taking into account filtering and so on
1225 foreach $dxchan (@dxchan) {
1226 next if $dxchan == $self;
1227 next if $dxchan == $me;
1229 my ($filter, $hops);
1231 if ($dxchan->{wwvfilter}) {
1232 ($filter, $hops) = $dxchan->{wwvfilter}->it(@_, $self->{call}, $wwv_dxcc, $wwv_itu, $wwv_cq, $org_dxcc, $org_itu, $org_cq);
1233 next unless $filter;
1235 if ($dxchan->is_node) {
1238 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
1240 $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name
1241 next unless $routeit;
1244 $dxchan->send($routeit) if $routeit;
1246 $dxchan->send($routeit) unless $dxchan->{isolate} || $self->{isolate};
1249 } elsif ($dxchan->is_user && $dxchan->{wwv}) {
1250 my $buf = "WWV de $_[6] <$_[1]>: SFI=$_[2], A=$_[3], K=$_[4], $_[5]";
1251 $buf .= "\a\a" if $dxchan->{beep};
1252 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'talk') {
1253 $dxchan->send($buf);
1255 $dxchan->delay($buf);
1265 my @dxchan = DXChannel->get_all();
1267 my ($wcy_dxcc, $wcy_itu, $wcy_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
1268 my @dxcc = Prefix::extract($_[11]);
1270 $wcy_dxcc = $dxcc[1]->dxcc;
1271 $wcy_itu = $dxcc[1]->itu;
1272 $wcy_cq = $dxcc[1]->cq;
1274 @dxcc = Prefix::extract($_[12]);
1276 $org_dxcc = $dxcc[1]->dxcc;
1277 $org_itu = $dxcc[1]->itu;
1278 $org_cq = $dxcc[1]->cq;
1281 # send it if it isn't the except list and isn't isolated and still has a hop count
1282 # taking into account filtering and so on
1283 foreach $dxchan (@dxchan) {
1284 next if $dxchan == $me;
1286 my ($filter, $hops);
1288 if ($dxchan->{wcyfilter}) {
1289 ($filter, $hops) = $dxchan->{wcyfilter}->it(@_, $self->{call}, $wcy_dxcc, $wcy_itu, $wcy_cq, $org_dxcc, $org_itu, $org_cq);
1290 next unless $filter;
1292 if ($dxchan->is_clx || $dxchan->is_spider || $dxchan->is_dxnet) {
1295 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
1297 $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name
1298 next unless $routeit;
1301 $dxchan->send($routeit) if $routeit;
1303 $dxchan->send($routeit) unless $dxchan->{isolate} || $self->{isolate};
1305 } elsif ($dxchan->is_user && $dxchan->{wcy}) {
1306 my $buf = "WCY de $_[10] <$_[1]> : K=$_[4] expK=$_[5] A=$_[3] R=$_[6] SFI=$_[2] SA=$_[7] GMF=$_[8] Au=$_[9]";
1307 $buf .= "\a\a" if $dxchan->{beep};
1308 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'talk') {
1309 $dxchan->send($buf);
1311 $dxchan->delay($buf);
1322 my @dxchan = DXChannel->get_all();
1324 my $text = unpad($_[2]);
1328 if ($_[3] eq '*') { # sysops
1330 } elsif ($_[3] gt ' ') { # speciality list handling
1331 my ($name) = split /\./, $_[3];
1332 $target = "$name"; # put the rest in later (if bothered)
1339 $target = "ALL" if !$target;
1341 Log('ann', $target, $_[0], $text);
1343 # obtain country codes etc
1344 my ($ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
1345 my @dxcc = Prefix::extract($_[0]);
1347 $ann_dxcc = $dxcc[1]->dxcc;
1348 $ann_itu = $dxcc[1]->itu;
1349 $ann_cq = $dxcc[1]->cq;
1351 @dxcc = Prefix::extract($_[4]);
1353 $org_dxcc = $dxcc[1]->dxcc;
1354 $org_itu = $dxcc[1]->itu;
1355 $org_cq = $dxcc[1]->cq;
1358 # send it if it isn't the except list and isn't isolated and still has a hop count
1359 # taking into account filtering and so on
1360 foreach $dxchan (@dxchan) {
1361 next if $dxchan == $self;
1362 next if $dxchan == $me;
1364 my ($filter, $hops);
1366 if ($dxchan->{annfilter}) {
1367 ($filter, $hops) = $dxchan->{annfilter}->it(@_, $self->{call}, $ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq);
1368 next unless $filter;
1370 if ($dxchan->is_node && $_[1] ne $main::mycall) { # i.e not specifically routed to me
1373 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
1375 $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name
1376 next unless $routeit;
1379 $dxchan->send($routeit) if $routeit;
1381 $dxchan->send($routeit) unless $dxchan->{isolate} || $self->{isolate};
1384 } elsif ($dxchan->is_user) {
1385 unless ($dxchan->{ann}) {
1386 next if $_[0] ne $main::myalias && $_[0] ne $main::mycall;
1388 next if $target eq 'SYSOP' && $dxchan->{priv} < 5;
1389 my $buf = "$to$target de $_[0]: $text";
1391 $buf .= "\a\a" if $dxchan->{beep};
1392 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'talk') {
1393 $dxchan->send($buf);
1395 $dxchan->delay($buf);
1401 sub send_local_config
1409 dbg('DXProt::send_local_config') if isdbg('trace');
1412 if ($self->{isolate}) {
1413 @localnodes = ( $main::routeroot );
1415 # create a list of all the nodes that are not connected to this connection
1416 # and are not themselves isolated, this to make sure that isolated nodes
1417 # don't appear outside of this node
1418 my @dxchan = grep { $_->call ne $main::mycall && $_->call ne $self->{call} } DXChannel::get_all_nodes();
1419 @localnodes = map { Route::Node::get($_->{call}) or die "connot find node $_->{call}" } @dxchan if @dxchan;
1420 my @intcalls = map { $_->nodes } @localnodes if @localnodes;
1421 my $ref = Route::Node::get($self->{call});
1422 my @rnodes = $ref->nodes;
1423 for my $n (@intcalls) {
1424 push @remotenodes, Route::Node::get($n) unless grep $n eq $_, @rnodes;
1426 unshift @localnodes, $main::routeroot;
1429 send_route($self, \&pc19, scalar(@localnodes)+scalar(@remotenodes), @localnodes, @remotenodes);
1431 # get all the users connected on the above nodes and send them out
1432 foreach $n (@localnodes, @remotenodes) {
1434 send_route($self, \&pc16, 1, $n, map {my $r = Route::User::get($_); $r ? ($r) : ()} $n->users);
1436 dbg("sent a null value") if isdbg('chan');
1442 # route a message down an appropriate interface for a callsign
1444 # is called route(to, pcline);
1448 my ($self, $call, $line) = @_;
1450 if (ref $self && $call eq $self->{call}) {
1451 dbg("PCPROT: Trying to route back to source, dropped") if isdbg('chan');
1455 # always send it down the local interface if available
1456 my $dxchan = DXChannel->get($call);
1458 my $cl = Route::Node::get($call);
1459 $dxchan = $cl->dxchan if $cl;
1461 if (ref $self && $dxchan eq $self) {
1462 dbg("PCPROT: Trying to route back to source, dropped") if isdbg('chan');
1468 my $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name
1470 $dxchan->send($routeit);
1473 dbg("PCPROT: No route available, dropped") if isdbg('chan');
1477 # broadcast a message to all clusters taking into account isolation
1478 # [except those mentioned after buffer]
1481 my $s = shift; # the line to be rebroadcast
1482 my @except = @_; # to all channels EXCEPT these (dxchannel refs)
1483 my @dxchan = DXChannel::get_all_nodes();
1486 # send it if it isn't the except list and isn't isolated and still has a hop count
1487 foreach $dxchan (@dxchan) {
1488 next if grep $dxchan == $_, @except;
1489 next if $dxchan == $me;
1491 my $routeit = adjust_hops($dxchan, $s); # adjust its hop count by node name
1492 $dxchan->send($routeit) unless $dxchan->{isolate} || !$routeit;
1496 # broadcast a message to all clusters ignoring isolation
1497 # [except those mentioned after buffer]
1498 sub broadcast_all_ak1a
1500 my $s = shift; # the line to be rebroadcast
1501 my @except = @_; # to all channels EXCEPT these (dxchannel refs)
1502 my @dxchan = DXChannel::get_all_nodes();
1505 # send it if it isn't the except list and isn't isolated and still has a hop count
1506 foreach $dxchan (@dxchan) {
1507 next if grep $dxchan == $_, @except;
1508 next if $dxchan == $me;
1510 my $routeit = adjust_hops($dxchan, $s); # adjust its hop count by node name
1511 $dxchan->send($routeit);
1515 # broadcast to all users
1516 # storing the spot or whatever until it is in a state to receive it
1519 my $s = shift; # the line to be rebroadcast
1520 my $sort = shift; # the type of transmission
1521 my $fref = shift; # a reference to an object to filter on
1522 my @except = @_; # to all channels EXCEPT these (dxchannel refs)
1523 my @dxchan = DXChannel::get_all_users();
1527 foreach $dxchan (@dxchan) {
1528 next if grep $dxchan == $_, @except;
1531 broadcast_list($s, $sort, $fref, @out);
1534 # broadcast to a list of users
1542 foreach $dxchan (@_) {
1544 next if $dxchan == $me;
1546 if ($sort eq 'dx') {
1547 next unless $dxchan->{dx};
1548 ($filter) = $dxchan->{spotsfilter}->it(@{$fref}) if ref $fref;
1549 next unless $filter;
1551 next if $sort eq 'ann' && !$dxchan->{ann} && $s !~ /^To\s+LOCAL\s+de\s+(?:$main::myalias|$main::mycall)/i;
1552 next if $sort eq 'wwv' && !$dxchan->{wwv};
1553 next if $sort eq 'wcy' && !$dxchan->{wcy};
1554 next if $sort eq 'wx' && !$dxchan->{wx};
1556 $s =~ s/\a//og unless $dxchan->{beep};
1558 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'talk') {
1568 # obtain the hops from the list for this callsign and pc no
1574 my $hops = $DXProt::hopcount{$pcno};
1575 $hops = $DXProt::def_hopcount if !$hops;
1580 # adjust the hop count on a per node basis using the user loadable
1581 # hop table if available or else decrement an existing one
1588 my $call = $self->{call};
1591 if (($hops) = $s =~ /\^H(\d+)\^~?$/o) {
1592 my ($pcno) = $s =~ /^PC(\d\d)/o;
1593 confess "$call called adjust_hops with '$s'" unless $pcno;
1594 my $ref = $nodehops{$call} if %nodehops;
1596 my $newhops = $ref->{$pcno};
1597 return "" if defined $newhops && $newhops == 0;
1598 $newhops = $ref->{default} unless $newhops;
1599 return "" if defined $newhops && $newhops == 0;
1600 $newhops = $hops if !$newhops;
1601 $s =~ s/\^H(\d+)(\^~?)$/\^H$newhops$2/ if $newhops;
1603 # simply decrement it
1605 return "" if !$hops;
1606 $s =~ s/\^H(\d+)(\^~?)$/\^H$hops$2/ if $hops;
1618 return $self->msg('lh1') unless -e "$main::data/hop_table.pl";
1619 do "$main::data/hop_table.pl";
1625 # add a ping request to the ping queues
1628 my ($from, $to) = @_;
1629 my $ref = $pings{$to} || [];
1632 $r->{t} = [ gettimeofday ];
1633 route(undef, $to, pc51($to, $main::mycall, 1));
1638 # add a rcmd request to the rcmd queues
1641 my ($self, $to, $cmd) = @_;
1644 $r->{call} = $self->{call};
1645 $r->{t} = $main::systime;
1649 my $ref = Route::Node::get($to);
1650 my $dxchan = $ref->dxchan;
1651 if ($dxchan && $dxchan->is_clx) {
1652 route(undef, $to, pc84($main::mycall, $to, $self->{call}, $cmd));
1654 route(undef, $to, pc34($main::mycall, $to, $cmd));
1661 my $pc39flag = shift;
1662 my $call = $self->call;
1664 unless ($pc39flag && $pc39flag == 1) {
1665 $self->send_now("D", DXProt::pc39($main::mycall, $self->msg('disc1', "System Op")));
1669 my $node = Route::Node::get($call);
1672 @rout = $node->del_nodes; # at the next level
1673 @rout = $node->del($main::routeroot);
1676 # unbusy and stop and outgoing mail
1677 my $mref = DXMsg::get_busy($call);
1678 $mref->stop_msg($call) if $mref;
1680 # broadcast to all other nodes that all the nodes connected to via me are gone
1681 unless ($pc39flag && $pc39flag == 2) {
1682 $self->route_pc21(@rout) if @rout;
1685 # remove outstanding pings
1686 delete $pings{$call};
1688 # I was the last node visited
1689 $self->user->node($main::mycall);
1691 # send info to all logged in thingies
1692 $self->tell_login('logoutn');
1694 Log('DXProt', $call . " Disconnected");
1696 $self->SUPER::disconnect;
1701 # send a talk message to this thingy
1705 my ($self, $from, $to, $via, $line) = @_;
1707 $line =~ s/\^/\\5E/g; # remove any ^ characters
1708 $self->send(DXProt::pc10($from, $to, $via, $line));
1709 Log('talk', $self->call, $from, $via?$via:$main::mycall, $line);
1712 # send it if it isn't the except list and isn't isolated and still has a hop count
1713 # taking into account filtering and so on
1717 my $generate = shift;
1718 my $no = shift; # the no of things to filter on
1720 my ($filter, $hops);
1723 if ($self->{routefilter}) {
1724 for (; @_ && $no; $no--) {
1727 ($filter, $hops) = $self->{routefilter}->it($self->{call}, $self->{dxcc}, $self->{itu}, $self->{cq}, $r->call, $r->dxcc, $r->itu, $r->cq);
1728 push @rin, $r if $filter;
1730 dbg("was sent a null value") if isdbg('chan');
1735 foreach my $line (&$generate(@rin, @_)) {
1738 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
1740 $routeit = adjust_hops($self, $line); # adjust its hop count by node name
1741 next unless $routeit;
1743 $self->send($routeit);
1751 my $generate = shift;
1752 my @dxchan = DXChannel::get_all_nodes();
1756 foreach $dxchan (@dxchan) {
1757 next if $dxchan == $self;
1758 next if $dxchan == $me;
1759 $dxchan->send_route($generate, @_);
1766 broadcast_route($self, \&pc16, 1, @_);
1772 broadcast_route($self, \&pc17, 1, @_);
1778 broadcast_route($self, \&pc19, scalar @_, @_);
1784 broadcast_route($self, \&pc21, scalar @_, @_);
1790 broadcast_route($self, \&pc24, 1, @_);
1796 broadcast_route($self, \&pc41, 1, @_);
1802 broadcast_route($self, \&pc50, 1, @_);
1812 $s =~ s/\^H\d\d?\^?~?$//;
1813 return 1 if exists $eph{$s};
1814 $eph{$s} = $main::systime;
1822 while (($key, $val) = each %eph) {
1823 if ($main::systime - $val > 90) {