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);
38 use vars qw($VERSION $BRANCH);
39 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
40 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ ) || 0;
41 $main::build += $VERSION;
42 $main::branch += $BRANCH;
44 use vars qw($me $pc11_max_age $pc23_max_age $last_pc50
45 $last_hour $last10 %eph %pings %rcmds
46 %nodehops $baddx $badspotter $badnode $censorpc
47 $allowzero $decode_dk0wcy $send_opernam @checklist);
49 $me = undef; # the channel id for this cluster
50 $pc11_max_age = 1*3600; # the maximum age for an incoming 'real-time' pc11
51 $pc23_max_age = 1*3600; # the maximum age for an incoming 'real-time' pc23
53 $last_hour = time; # last time I did an hourly periodic update
54 %pings = (); # outstanding ping requests outbound
55 %rcmds = (); # outstanding rcmd requests outbound
56 %nodehops = (); # node specific hop control
57 $censorpc = 1; # Do a BadWords::check on text fields and reject things
58 # loads of 'bad things'
59 $baddx = new DXHash "baddx";
60 $badspotter = new DXHash "badspotter";
61 $badnode = new DXHash "badnode";
62 $last10 = $last_pc50 = time;
66 [ qw(c c m bp bc c) ], # pc10
67 [ qw(f m d t m c c h) ], # pc11
68 [ qw(c bc m bp bm p h) ], # pc12
72 undef , # pc16 has to be validated manually
75 undef , # pc19 has to be validated manually
76 undef , # pc20 no validation
78 undef , # pc22 no validation
79 [ qw(d n n n n m c c h) ], # pc23
81 [ qw(c c n n) ], # pc25
82 [ qw(f m d t m c c bc) ], # pc26
83 [ qw(d n n n n m c c bc) ], # pc27
84 [ qw(c c m c d t p m bp n p bp bc) ], # pc28
85 [ qw(c c n m) ], # pc29
93 [ qw(c c n m) ], # pc37
94 undef, # pc38 not interested
96 [ qw(c c m p n) ], # pc40
97 [ qw(c n m h) ], # pc41
99 undef, # pc43 don't handle it
100 [ qw(c c n m m c) ], # pc44
101 [ qw(c c n m) ], # pc45
102 [ qw(c c n) ], # pc46
105 [ qw(c m h) ], # pc49
106 [ qw(c n h) ], # pc50
107 [ qw(c c n) ], # pc51
129 [ qw(d n n n n n n m m m c c h) ], # pc73
140 [ qw(c c c m) ], # pc84
141 [ qw(c c c m) ], # pc85
144 # use the entry in the check list to check the field list presented
145 # return OK if line NOT in check list (for now)
150 return 0 if $n < 0 || $n > @checklist;
151 my $ref = $checklist[$n];
152 return 0 unless ref $ref;
155 shift; # not interested in the first field
156 for ($i = 0; $i < @$ref; $i++) {
157 my ($blank, $act) = $$ref[$i] =~ /^(b?)(\w)$/;
158 return 0 unless $act;
159 next if $blank && $_[$i] =~ /^[ \*]$/;
161 return $i+1 unless is_callsign($_[$i]);
162 } elsif ($act eq 'm') {
163 return $i+1 unless is_pctext($_[$i]);
164 } elsif ($act eq 'p') {
165 return $i+1 unless is_pcflag($_[$i]);
166 } elsif ($act eq 'f') {
167 return $i+1 unless is_freq($_[$i]);
168 } elsif ($act eq 'n') {
169 return $i+1 unless $_[$i] =~ /^[\d ]+$/;
170 } elsif ($act eq 'h') {
171 return $i+1 unless $_[$i] =~ /^H\d\d?$/;
172 } elsif ($act eq 'd') {
173 return $i+1 unless $_[$i] =~ /^\s*\d+-\w\w\w-[12][90]\d\d$/;
174 } elsif ($act eq 't') {
175 return $i+1 unless $_[$i] =~ /^[012]\d[012345]\dZ$/;
183 my $user = DXUser->get($main::mycall);
184 $DXProt::myprot_version += $main::version*100;
185 $me = DXProt->new($main::mycall, 0, $user);
187 $me->{state} = "indifferent";
188 do "$main::data/hop_table.pl" if -e "$main::data/hop_table.pl";
190 $me->{sort} = 'S'; # S for spider
192 # $Route::Node::me->adddxchan($me);
196 # obtain a new connection this is derived from dxchannel
201 my $self = DXChannel::alloc(@_);
203 # add this node to the table, the values get filled in later
206 $main::routeroot->add($call, '0000', Route::here(1)) if $call ne $main::mycall;
211 # this is how a pc connection starts (for an incoming connection)
212 # issue a PC38 followed by a PC18, then wait for a PC20 (remembering
213 # all the crap that comes between).
216 my ($self, $line, $sort) = @_;
217 my $call = $self->{call};
218 my $user = $self->{user};
220 # remember type of connection
221 $self->{consort} = $line;
222 $self->{outbound} = $sort eq 'O';
223 my $priv = $user->priv;
224 $priv = $user->priv(1) unless $priv;
225 $self->{priv} = $priv; # other clusters can always be 'normal' users
226 $self->{lang} = $user->lang || 'en';
227 $self->{isolate} = $user->{isolate};
228 $self->{consort} = $line; # save the connection type
232 # get the output filters
233 $self->{spotsfilter} = Filter::read_in('spots', $call, 0) || Filter::read_in('spots', 'node_default', 0);
234 $self->{wwvfilter} = Filter::read_in('wwv', $call, 0) || Filter::read_in('wwv', 'node_default', 0);
235 $self->{wcyfilter} = Filter::read_in('wcy', $call, 0) || Filter::read_in('wcy', 'node_default', 0);
236 $self->{annfilter} = Filter::read_in('ann', $call, 0) || Filter::read_in('ann', 'node_default', 0) ;
237 $self->{routefilter} = Filter::read_in('route', $call, 0) || Filter::read_in('route', 'node_default', 0) unless $self->{isolate} ;
240 # get the INPUT filters (these only pertain to Clusters)
241 $self->{inspotsfilter} = Filter::read_in('spots', $call, 1) || Filter::read_in('spots', 'node_default', 1);
242 $self->{inwwvfilter} = Filter::read_in('wwv', $call, 1) || Filter::read_in('wwv', 'node_default', 1);
243 $self->{inwcyfilter} = Filter::read_in('wcy', $call, 1) || Filter::read_in('wcy', 'node_default', 1);
244 $self->{inannfilter} = Filter::read_in('ann', $call, 1) || Filter::read_in('ann', 'node_default', 1);
245 $self->{inroutefilter} = Filter::read_in('route', $call, 1) || Filter::read_in('route', 'node_default', 1) unless $self->{isolate};
247 # set unbuffered and no echo
248 $self->send_now('B',"0");
249 $self->send_now('E',"0");
251 # ping neighbour node stuff
252 my $ping = $user->pingint;
253 $ping = 5*60 unless defined $ping;
254 $self->{pingint} = $ping;
255 $self->{nopings} = $user->nopings || 2;
256 $self->{pingtime} = [ ];
257 $self->{pingave} = 999;
258 $self->{lastping} = $main::systime;
260 # send initialisation string
261 unless ($self->{outbound}) {
265 $self->state('init');
266 $self->{pc50_t} = $main::systime;
268 # send info to all logged in thingies
269 $self->tell_login('loginn');
271 Log('DXProt', "$call connected");
275 # This is the normal pcxx despatcher
279 my ($self, $line) = @_;
280 my @field = split /\^/, $line;
281 return unless @field;
283 pop @field if $field[-1] eq '~';
285 # print join(',', @field), "\n";
288 # process PC frames, this will fail unless the frame starts PCnn
289 my ($pcno) = $field[0] =~ /^PC(\d\d)/; # just get the number
291 return if $pcno < 10 || $pcno > 99;
293 # check for and dump bad protocol messages
294 my $n = check($pcno, @field);
296 dbg("PCPROT: bad field $n, dumped (" . parray($checklist[$pcno-10]) . ")") if isdbg('chanerr');
303 $pcr = Local::pcprot($self, $pcno, @field);
305 # dbg("Local::pcprot error $@") if isdbg('local') if $@;
309 if ($pcno == 10) { # incoming talk
311 # will we allow it at all?
314 if (@bad = BadWords::check($field[3])) {
315 dbg("PCPROT: Bad words: @bad, dropped") if isdbg('chanerr');
320 # is it for me or one of mine?
321 my ($to, $via, $call, $dxchan);
322 if ($field[5] gt ' ') {
323 $call = $via = $field[2];
326 $call = $to = $field[2];
328 $dxchan = DXChannel->get($main::myalias) if $call eq $main::mycall;
329 $dxchan = DXChannel->get($call) unless $dxchan;
330 if ($dxchan && $dxchan->is_user) {
331 $field[3] =~ s/\%5E/^/g;
332 $dxchan->talk($field[1], $to, $via, $field[3]);
334 $self->route($field[2], $line); # relay it on its way
339 if ($pcno == 11 || $pcno == 26) { # dx spot
341 # route 'foreign' pc26s
343 if ($field[7] ne $main::mycall) {
344 $self->route($field[7], $line);
349 # if this is a 'nodx' node then ignore it
350 if ($badnode->in($field[7])) {
351 dbg("PCPROT: Bad Node, dropped") if isdbg('chanerr');
355 # if this is a 'bad spotter' user then ignore it
356 if ($badspotter->in($field[6])) {
357 dbg("PCPROT: Bad Spotter, dropped") if isdbg('chanerr');
361 # convert the date to a unix date
362 my $d = cltounix($field[3], $field[4]);
363 # bang out (and don't pass on) if date is invalid or the spot is too old (or too young)
364 if (!$d || ($pcno == 11 && ($d < $main::systime - $pc11_max_age || $d > $main::systime + 900))) {
365 dbg("PCPROT: Spot ignored, invalid date or out of range ($field[3] $field[4])\n") if isdbg('chanerr');
370 if ($baddx->in($field[2])) {
371 dbg("PCPROT: Bad DX spot, ignored") if isdbg('chanerr');
376 $field[5] =~ s/^\s+//; # take any leading blanks off
377 $field[2] = unpad($field[2]); # take off leading and trailing blanks from spotted callsign
378 if ($field[2] =~ /BUST\w*$/) {
379 dbg("PCPROT: useless 'BUSTED' spot") if isdbg('chanerr');
382 if (Spot::dup($field[1], $field[2], $d, $field[5])) {
383 dbg("PCPROT: Duplicate Spot ignored\n") if isdbg('chanerr');
388 if (@bad = BadWords::check($field[5])) {
389 dbg("PCPROT: Bad words: @bad, dropped") if isdbg('chanerr');
394 my @spot = Spot::prepare($field[1], $field[2], $d, $field[5], $field[6], $field[7]);
395 # global spot filtering on INPUT
396 if ($self->{inspotsfilter}) {
397 my ($filter, $hops) = $self->{inspotsfilter}->it(@spot);
399 dbg("PCPROT: Rejected by input spot filter") if isdbg('chanerr');
408 # @spot at this point contains:-
409 # freq, spotted call, time, text, spotter, spotted cc, spotters cc, orig node
410 # then spotted itu, spotted cq, spotters itu, spotters cq
411 # you should be able to route on any of these
414 # fix up qra locators of known users
415 my $user = DXUser->get_current($spot[4]);
417 my $qra = $user->qra;
418 unless ($qra && is_qra($qra)) {
419 my $lat = $user->lat;
420 my $long = $user->long;
421 if (defined $lat && defined $long) {
422 $user->qra(DXBearing::lltoqra($lat, $long));
427 # send a remote command to a distant cluster if it is visible and there is no
428 # qra locator and we havn't done it for a month.
430 unless ($user->qra) {
432 my $to = $user->homenode;
433 my $last = $user->lastoper || 0;
434 if ($send_opernam && $to && $to ne $main::mycall && $main::systime > $last + $DXUser::lastoperinterval && ($node = Route::Node::get($to)) ) {
435 my $cmd = "forward/opernam $spot[4]";
436 # send the rcmd but we aren't interested in the replies...
437 my $dxchan = $node->dxchan;
438 if ($dxchan && $dxchan->is_clx) {
439 route(undef, $to, pc84($main::mycall, $to, $main::mycall, $cmd));
441 route(undef, $to, pc34($main::mycall, $to, $cmd));
443 if ($to ne $field[7]) {
445 $node = Route::Node::get($to);
447 $dxchan = $node->dxchan;
448 if ($dxchan && $dxchan->is_clx) {
449 route(undef, $to, pc84($main::mycall, $to, $main::mycall, $cmd));
451 route(undef, $to, pc34($main::mycall, $to, $cmd));
455 $user->lastoper($main::systime);
464 $r = Local::spot($self, @spot);
466 # dbg("Local::spot1 error $@") if isdbg('local') if $@;
469 # DON'T be silly and send on PC26s!
470 return if $pcno == 26;
472 # send out the filtered spots
473 send_dx_spot($self, $line, @spot) if @spot;
477 if ($pcno == 12) { # announces
478 # announce duplicate checking
479 $field[3] =~ s/^\s+//; # remove leading blanks
480 if (AnnTalk::dup($field[1], $field[2], $field[3])) {
481 dbg("PCPROT: Duplicate Announce ignored") if isdbg('chanerr');
487 if (@bad = BadWords::check($field[3])) {
488 dbg("PCPROT: Bad words: @bad, dropped") if isdbg('chanerr');
493 if ($field[2] eq '*' || $field[2] eq $main::mycall) {
495 # global ann filtering on INPUT
496 if ($self->{inannfilter}) {
497 my ($ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
498 my @dxcc = Prefix::extract($field[1]);
500 $ann_dxcc = $dxcc[1]->dxcc;
501 $ann_itu = $dxcc[1]->itu;
502 $ann_cq = $dxcc[1]->cq();
504 @dxcc = Prefix::extract($field[5]);
506 $org_dxcc = $dxcc[1]->dxcc;
507 $org_itu = $dxcc[1]->itu;
508 $org_cq = $dxcc[1]->cq();
510 my ($filter, $hops) = $self->{inannfilter}->it(@field[1..6], $self->{call},
511 $ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq);
513 dbg("PCPROT: Rejected by input announce filter") if isdbg('chanerr');
519 $self->send_announce($line, @field[1..6]);
521 $self->route($field[2], $line);
537 if ($pcno == 16) { # add a user
541 my $ncall = $field[1];
542 my $newline = "PC16^";
544 if ($ncall eq $main::mycall) {
545 dbg("PCPROT: trying to alter config on this node from outside!") if isdbg('chanerr');
548 $dxchan = DXChannel->get($ncall);
549 if ($dxchan && $dxchan ne $self) {
550 dbg("PCPROT: PC16 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr');
553 my $parent = Route::Node::get($ncall);
555 dbg("PCPROT: Node $ncall not in config") if isdbg('chanerr');
559 # input filter if required
560 return unless $self->in_filter_route($parent);
564 for ($i = 2; $i < $#field; $i++) {
565 my ($call, $conf, $here) = $field[$i] =~ /^(\S+) (\S) (\d)/o;
566 next unless $call && $conf && defined $here && is_callsign($call);
567 next if $call eq $main::mycall;
569 eph_del_regex("^PC17\^$call\^$ncall");
571 $conf = $conf eq '*';
573 my $r = Route::User::get($call);
574 my $flags = Route::here($here)|Route::conf($conf);
577 if ($r->flags != $flags) {
581 $r->addparent($parent);
583 push @rout, $parent->add_user($call, $flags);
586 # add this station to the user database, if required
587 $call =~ s/-\d+$//o; # remove ssid for users
588 my $user = DXUser->get_current($call);
589 $user = DXUser->new($call) if !$user;
590 $user->homenode($parent->call) if !$user->homenode;
591 $user->node($parent->call);
592 $user->lastin($main::systime) unless DXChannel->get($call);
596 if (eph_dup($line)) {
597 dbg("PCPROT: dup PC16 detected") if isdbg('chanerr');
601 # queue up any messages (look for privates only)
602 DXMsg::queue_msg(1) if $self->state eq 'normal';
604 $self->route_pc16($parent, @rout) if @rout;
608 if ($pcno == 17) { # remove a user
610 my $ncall = $field[2];
611 my $ucall = $field[1];
613 eph_del_regex("^PC16.*$ncall.*$ucall");
615 if ($ncall eq $main::mycall) {
616 dbg("PCPROT: trying to alter config on this node from outside!") if isdbg('chanerr');
619 $dxchan = DXChannel->get($ncall);
620 if ($dxchan && $dxchan ne $self) {
621 dbg("PCPROT: PC17 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr');
624 my $parent = Route::Node::get($ncall);
626 dbg("PCPROT: Route::Node $ncall not in config") if isdbg('chanerr');
629 my $uref = Route::User::get($ucall);
631 dbg("PCPROT: Route::User $ucall not in config") if isdbg('chanerr');
636 # input filter if required
637 return unless $self->in_filter_route($parent);
639 my @rout = $parent->del_user($uref);
641 if (eph_dup($line)) {
642 dbg("PCPROT: dup PC17 detected") if isdbg('chanerr');
646 $self->route_pc17($parent, @rout) if @rout;
650 if ($pcno == 18) { # link request
651 $self->state('init');
653 # first clear out any nodes on this dxchannel
654 my $parent = Route::Node::get($self->{call});
655 my @rout = $parent->del_nodes;
656 $self->route_pc21(@rout, $parent) if @rout;
657 $self->send_local_config();
659 return; # we don't pass these on
662 if ($pcno == 19) { # incoming cluster list
664 my $newline = "PC19^";
668 my $parent = Route::Node::get($self->{call});
670 dbg("DXPROT: my parent $self->{call} has disappeared");
676 for ($i = 1; $i < $#field-1; $i += 4) {
677 my $here = $field[$i];
678 my $call = uc $field[$i+1];
679 my $conf = $field[$i+2];
680 my $ver = $field[$i+3];
681 next unless defined $here && defined $conf && is_callsign($call);
683 eph_del_regex("^PC(?:21\^$call|17\^[^\^]+\^$call)");
685 # check for sane parameters
686 $ver = 5000 if $ver eq '0000';
687 next if $ver < 5000; # only works with version 5 software
688 next if length $call < 3; # min 3 letter callsigns
689 next if $call eq $main::mycall;
691 # update it if required
692 my $r = Route::Node::get($call);
693 my $flags = Route::here($here)|Route::conf($conf);
696 if ($call ne $parent->call) {
697 if ($self->in_filter_route($r)) {
698 $ar = $parent->add($call, $ver, $flags);
699 push @rout, $ar if $ar;
704 if ($r->version ne $ver || $r->flags != $flags) {
707 push @rout, $r unless $ar;
710 if ($call eq $self->{call}) {
711 dbg("DXPROT: my channel route for $call has disappeared");
715 my $new = Route->new($call); # throw away
716 if ($self->in_filter_route($new)) {
717 my $r = $parent->add($call, $ver, $flags);
724 # unbusy and stop and outgoing mail (ie if somehow we receive another PC19 without a disconnect)
725 my $mref = DXMsg::get_busy($call);
726 $mref->stop_msg($call) if $mref;
728 # add this station to the user database, if required (don't remove SSID from nodes)
729 my $user = DXUser->get_current($call);
731 $user = DXUser->new($call);
733 $user->priv(1); # I have relented and defaulted nodes
735 $user->homenode($call);
738 $user->lastin($main::systime) unless DXChannel->get($call);
742 if (eph_dup($line)) {
743 dbg("PCPROT: dup PC19 detected") if isdbg('chanerr');
747 $self->route_pc19(@rout) if @rout;
751 if ($pcno == 20) { # send local configuration
752 $self->send_local_config();
754 $self->state('normal');
755 $self->{lastping} = 0;
759 if ($pcno == 21) { # delete a cluster from the list
760 my $call = uc $field[1];
762 eph_del_regex("^PC1[79].*$call");
765 my $parent = Route::Node::get($self->{call});
767 dbg("DXPROT: my parent $self->{call} has disappeared");
771 my $node = Route::Node::get($call);
772 if ($call ne $main::mycall) { # don't allow malicious buggers to disconnect me!
773 if ($call eq $self->{call}) {
774 dbg("PCPROT: Trying to disconnect myself with PC21") if isdbg('chanerr');
780 return unless $self->in_filter_route($node);
783 push @rout, $node->del($parent);
786 dbg("PCPROT: I WILL _NOT_ be disconnected!") if isdbg('chanerr');
790 if (eph_dup($line)) {
791 dbg("PCPROT: dup PC21 detected") if isdbg('chanerr');
795 $self->route_pc21(@rout) if @rout;
800 $self->state('normal');
801 $self->{lastping} = 0;
805 if ($pcno == 23 || $pcno == 27) { # WWV info
807 # route 'foreign' pc27s
809 if ($field[8] ne $main::mycall) {
810 $self->route($field[8], $line);
816 my $d = cltounix($field[1], sprintf("%02d18Z", $field[2]));
817 my $sfi = unpad($field[3]);
818 my $k = unpad($field[4]);
819 my $i = unpad($field[5]);
820 my ($r) = $field[6] =~ /R=(\d+)/;
822 if (($pcno == 23 && $d < $main::systime - $pc23_max_age) || $d > $main::systime + 1500 || $field[2] < 0 || $field[2] > 23) {
823 dbg("PCPROT: WWV Date ($field[1] $field[2]) out of range") if isdbg('chanerr');
826 if (Geomag::dup($d,$sfi,$k,$i,$field[6])) {
827 dbg("PCPROT: Dup WWV Spot ignored\n") if isdbg('chanerr');
830 $field[7] =~ s/-\d+$//o; # remove spotter's ssid
832 my $wwv = Geomag::update($d, $field[2], $sfi, $k, $i, @field[6..8], $r);
836 $rep = Local::wwv($self, $field[1], $field[2], $sfi, $k, $i, @field[6..8], $r);
838 # dbg("Local::wwv2 error $@") if isdbg('local') if $@;
841 # DON'T be silly and send on PC27s!
842 return if $pcno == 27;
844 # broadcast to the eager world
845 send_wwv_spot($self, $line, $d, $field[2], $sfi, $k, $i, @field[6..8]);
849 if ($pcno == 24) { # set here status
850 my $call = uc $field[1];
852 $nref = Route::Node::get($call);
853 $uref = Route::User::get($call);
854 return unless $nref || $uref; # if we don't know where they are, it's pointless sending it on
856 unless (eph_dup($line)) {
857 $nref->here($field[2]) if $nref;
858 $uref->here($field[2]) if $uref;
859 my $ref = $nref || $uref;
860 return unless $self->in_filter_route($ref);
861 $self->route_pc24($ref, $field[3]);
866 if ($pcno == 25) { # merge request
867 if ($field[1] ne $main::mycall) {
868 $self->route($field[1], $line);
871 if ($field[2] eq $main::mycall) {
872 dbg("PCPROT: Trying to merge to myself, ignored") if isdbg('chanerr');
876 Log('DXProt', "Merge request for $field[3] spots and $field[4] WWV from $field[2]");
880 my @in = reverse Spot::search(1, undef, undef, 0, $field[3]);
883 $self->send(pc26(@{$in}[0..4], $field[2]));
889 my @in = reverse Geomag::search(0, $field[4], time, 1);
892 $self->send(pc27(@{$in}[0..5], $field[2]));
898 if (($pcno >= 28 && $pcno <= 33) || $pcno == 40 || $pcno == 42 || $pcno == 49) { # mail/file handling
899 if ($pcno == 49 || $field[1] eq $main::mycall) {
900 DXMsg::process($self, $line);
902 $self->route($field[1], $line) unless $self->is_clx;
907 if ($pcno == 34 || $pcno == 36) { # remote commands (incoming)
908 $self->process_rcmd($field[1], $field[2], $field[2], $field[3]);
912 if ($pcno == 35) { # remote command replies
913 $self->process_rcmd_reply($field[1], $field[2], $field[1], $field[3]);
917 # for pc 37 see 44 onwards
919 if ($pcno == 38) { # node connected list from neighbour
923 if ($pcno == 39) { # incoming disconnect
924 if ($field[1] eq $self->{call}) {
925 $self->disconnect(1);
926 eph_del_regex("^PC(?:1[679]|21).*$field[1]");
928 dbg("PCPROT: came in on wrong channel") if isdbg('chanerr');
933 if ($pcno == 41) { # user info
934 my $call = $field[1];
936 # input filter if required
937 # my $ref = Route::get($call) || Route->new($call);
938 # return unless $self->in_filter_route($ref);
940 if ($field[3] eq $field[2]) {
941 dbg('PCPROT: invalid value') if isdbg('chanerr');
945 # add this station to the user database, if required
946 my $user = DXUser->get_current($call);
947 $user = DXUser->new($call) if !$user;
949 if ($field[2] == 1) {
950 $user->name($field[3]);
951 } elsif ($field[2] == 2) {
952 $user->qth($field[3]);
953 } elsif ($field[2] == 3) {
954 if (is_latlong($field[3])) {
955 my ($lat, $long) = DXBearing::stoll($field[3]);
958 $user->qra(DXBearing::lltoqra($lat, $long));
960 dbg('PCPROT: not a valid lat/long') if isdbg('chanerr');
963 } elsif ($field[2] == 4) {
964 $user->homenode($field[3]);
965 } elsif ($field[2] == 5) {
966 if (is_qra($field[3])) {
967 my ($lat, $long) = DXBearing::qratoll($field[3]);
970 $user->qra($field[3]);
972 dbg('PCPROT: not a valid QRA locator') if isdbg('chanerr');
976 $user->lastoper($main::systime); # to cut down on excessive for/opers being generated
979 # perhaps this IS what we want after all
980 # $self->route_pc41($ref, $call, $field[2], $field[3], $field[4]);
988 if ($pcno == 37 || $pcno == 44 || $pcno == 45 || $pcno == 46 || $pcno == 47 || $pcno == 48) {
989 DXDb::process($self, $line);
993 if ($pcno == 50) { # keep alive/user list
994 my $call = $field[1];
995 my $node = Route::Node::get($call);
997 return unless $node->call eq $self->{call};
998 $node->usercount($field[2]);
1000 # input filter if required
1001 return unless $self->in_filter_route($node);
1003 $self->route_pc50($node, $field[2], $field[3]) unless eph_dup($line);
1008 if ($pcno == 51) { # incoming ping requests/answers
1010 my $from = $field[2];
1011 my $flag = $field[3];
1015 if ($to eq $main::mycall) {
1017 $self->send(pc51($from, $to, '0'));
1019 # it's a reply, look in the ping list for this one
1020 my $ref = $pings{$from};
1022 my $tochan = DXChannel->get($from);
1024 my $r = shift @$ref;
1025 my $dxchan = DXChannel->get($r->{call});
1026 next unless $dxchan;
1027 my $t = tv_interval($r->{t}, [ gettimeofday ]);
1028 if ($dxchan->is_user) {
1029 my $s = sprintf "%.2f", $t;
1030 my $ave = sprintf "%.2f", $tochan ? ($tochan->{pingave} || $t) : $t;
1031 $dxchan->send($dxchan->msg('pingi', $from, $s, $ave))
1032 } elsif ($dxchan->is_node) {
1034 $tochan->{nopings} = $tochan->user->nopings || 2; # pump up the timer
1035 push @{$tochan->{pingtime}}, $t;
1036 shift @{$tochan->{pingtime}} if @{$tochan->{pingtime}} > 6;
1038 for (@{$tochan->{pingtime}}) {
1041 $tochan->{pingave} = $st / @{$tochan->{pingtime}};
1048 if (eph_dup($line)) {
1049 dbg("PCPROT: dup PC51 detected") if isdbg('chanerr');
1052 # route down an appropriate thingy
1053 $self->route($to, $line);
1058 if ($pcno == 75) { # dunno but route it
1059 my $call = $field[1];
1060 if ($call ne $main::mycall) {
1061 $self->route($call, $line);
1066 if ($pcno == 73) { # WCY broadcasts
1067 my $call = $field[1];
1070 my $d = cltounix($call, sprintf("%02d18Z", $field[2]));
1071 if (($pcno == 23 && $d < $main::systime - $pc23_max_age) || $d > $main::systime + 1500 || $field[2] < 0 || $field[2] > 23) {
1072 dbg("PCPROT: WCY Date ($call $field[2]) out of range") if isdbg('chanerr');
1075 @field = map { unpad($_) } @field;
1076 if (WCY::dup($d,@field[3..7])) {
1077 dbg("PCPROT: Dup WCY Spot ignored\n") if isdbg('chanerr');
1081 my $wcy = WCY::update($d, @field[2..12]);
1085 $rep = Local::wwv($self, @field[1..12]);
1087 # dbg("Local::wcy error $@") if isdbg('local') if $@;
1090 # broadcast to the eager world
1091 send_wcy_spot($self, $line, $d, @field[2..12]);
1095 if ($pcno == 84) { # remote commands (incoming)
1096 $self->process_rcmd($field[1], $field[2], $field[3], $field[4]);
1100 if ($pcno == 85) { # remote command replies
1101 $self->process_rcmd_reply($field[1], $field[2], $field[3], $field[4]);
1107 # if get here then rebroadcast the thing with its Hop count decremented (if
1108 # there is one). If it has a hop count and it decrements to zero then don't
1111 # NOTE - don't arrive here UNLESS YOU WANT this lump of protocol to be
1115 if (eph_dup($line)) {
1116 dbg("PCPROT: Ephemeral dup, dropped") if isdbg('chanerr');
1118 unless ($self->{isolate}) {
1119 broadcast_ak1a($line, $self); # send it to everyone but me
1125 # This is called from inside the main cluster processing loop and is used
1126 # for despatching commands that are doing some long processing job
1131 my @dxchan = DXChannel->get_all();
1135 # send out a pc50 on EVERY channel all at once
1136 if ($t >= $last_pc50 + $DXProt::pc50_interval) {
1137 $pc50s = pc50($me, scalar DXChannel::get_all_users);
1142 foreach $dxchan (@dxchan) {
1143 next unless $dxchan->is_node();
1144 next if $dxchan == $me;
1147 $dxchan->send($pc50s) if $pc50s;
1149 # send a ping out on this channel
1150 if ($dxchan->{pingint} && $t >= $dxchan->{pingint} + $dxchan->{lastping}) {
1151 if ($dxchan->{nopings} <= 0) {
1152 $dxchan->disconnect;
1154 addping($main::mycall, $dxchan->call);
1155 $dxchan->{nopings} -= 1;
1156 $dxchan->{lastping} = $t;
1162 if ($t - $last10 >= 10) {
1163 # clean out ephemera
1170 if ($main::systime - 3600 > $last_hour) {
1171 $last_hour = $main::systime;
1176 # finish up a pc context
1180 # some active measures
1187 my @dxchan = DXChannel->get_all();
1190 # send it if it isn't the except list and isn't isolated and still has a hop count
1191 # taking into account filtering and so on
1192 foreach $dxchan (@dxchan) {
1193 next if $dxchan == $me;
1194 next if $dxchan == $self && $self->is_node;
1195 $dxchan->dx_spot($line, $self->{isolate}, @_, $self->{call});
1203 my $isolate = shift;
1204 my ($filter, $hops);
1206 if ($self->{spotsfilter}) {
1207 ($filter, $hops) = $self->{spotsfilter}->it(@_);
1208 return unless $filter;
1210 send_prot_line($self, $filter, $hops, $isolate, $line);
1215 my ($self, $filter, $hops, $isolate, $line) = @_;
1220 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
1222 $routeit = adjust_hops($self, $line); # adjust its hop count by node name
1223 return unless $routeit;
1226 $self->send($routeit);
1228 $self->send($routeit) unless $self->{isolate} || $isolate;
1237 my @dxchan = DXChannel->get_all();
1239 my ($wwv_dxcc, $wwv_itu, $wwv_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
1240 my @dxcc = Prefix::extract($_[7]);
1242 $wwv_dxcc = $dxcc[1]->dxcc;
1243 $wwv_itu = $dxcc[1]->itu;
1244 $wwv_cq = $dxcc[1]->cq;
1246 @dxcc = Prefix::extract($_[8]);
1248 $org_dxcc = $dxcc[1]->dxcc;
1249 $org_itu = $dxcc[1]->itu;
1250 $org_cq = $dxcc[1]->cq;
1253 # send it if it isn't the except list and isn't isolated and still has a hop count
1254 # taking into account filtering and so on
1255 foreach $dxchan (@dxchan) {
1256 next if $dxchan == $me;
1257 next if $dxchan == $self && $self->is_node;
1259 my ($filter, $hops);
1261 $dxchan->wwv($line, $self->{isolate}, @_, $self->{call}, $wwv_dxcc, $wwv_itu, $wwv_cq, $org_dxcc, $org_itu, $org_cq);
1270 my $isolate = shift;
1271 my ($filter, $hops);
1273 if ($self->{wwvfilter}) {
1274 ($filter, $hops) = $self->{wwvfilter}->it(@_);
1275 return unless $filter;
1277 send_prot_line($self, $filter, $hops, $isolate, $line)
1284 my @dxchan = DXChannel->get_all();
1286 my ($wcy_dxcc, $wcy_itu, $wcy_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
1287 my @dxcc = Prefix::extract($_[11]);
1289 $wcy_dxcc = $dxcc[1]->dxcc;
1290 $wcy_itu = $dxcc[1]->itu;
1291 $wcy_cq = $dxcc[1]->cq;
1293 @dxcc = Prefix::extract($_[12]);
1295 $org_dxcc = $dxcc[1]->dxcc;
1296 $org_itu = $dxcc[1]->itu;
1297 $org_cq = $dxcc[1]->cq;
1300 # send it if it isn't the except list and isn't isolated and still has a hop count
1301 # taking into account filtering and so on
1302 foreach $dxchan (@dxchan) {
1303 next if $dxchan == $me;
1304 next if $dxchan == $self;
1306 $dxchan->wcy($line, $self->{isolate}, @_, $self->{call}, $wcy_dxcc, $wcy_itu, $wcy_cq, $org_dxcc, $org_itu, $org_cq);
1314 my $isolate = shift;
1315 my ($filter, $hops);
1317 if ($self->{wcyfilter}) {
1318 ($filter, $hops) = $self->{wcyfilter}->it(@_);
1319 return unless $filter;
1321 send_prot_line($self, $filter, $hops, $isolate, $line) if $self->is_clx || $self->is_spider || $self->is_dxnet;
1329 my @dxchan = DXChannel->get_all();
1333 my $text = unpad($_[2]);
1335 if ($_[3] eq '*') { # sysops
1337 } elsif ($_[3] gt ' ') { # speciality list handling
1338 my ($name) = split /\./, $_[3];
1339 $target = "$name"; # put the rest in later (if bothered)
1346 $target = "ALL" if !$target;
1348 Log('ann', $target, $_[0], $text);
1350 # obtain country codes etc
1351 my ($ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
1352 my @dxcc = Prefix::extract($_[0]);
1354 $ann_dxcc = $dxcc[1]->dxcc;
1355 $ann_itu = $dxcc[1]->itu;
1356 $ann_cq = $dxcc[1]->cq;
1358 @dxcc = Prefix::extract($_[4]);
1360 $org_dxcc = $dxcc[1]->dxcc;
1361 $org_itu = $dxcc[1]->itu;
1362 $org_cq = $dxcc[1]->cq;
1365 # send it if it isn't the except list and isn't isolated and still has a hop count
1366 # taking into account filtering and so on
1367 foreach $dxchan (@dxchan) {
1368 next if $dxchan == $me;
1369 next if $dxchan == $self && $self->is_node;
1370 $dxchan->announce($line, $self->{isolate}, $to, $target, $text, @_, $self->{call}, $ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq);
1378 my $isolate = shift;
1382 my ($filter, $hops);
1384 if ($self->{annfilter}) {
1385 ($filter, $hops) = $self->{annfilter}->it(@_);
1386 return unless $filter;
1388 send_prot_line($self, $filter, $hops, $isolate, $line) unless $_[1] eq $main::mycall;
1392 sub send_local_config
1400 dbg('DXProt::send_local_config') if isdbg('trace');
1403 if ($self->{isolate}) {
1404 @localnodes = ( $main::routeroot );
1406 # create a list of all the nodes that are not connected to this connection
1407 # and are not themselves isolated, this to make sure that isolated nodes
1408 # don't appear outside of this node
1409 my @dxchan = grep { $_->call ne $main::mycall && $_ != $self && !$_->{isolate} } DXChannel::get_all_nodes();
1410 @localnodes = map { my $r = Route::Node::get($_->{call}); $r ? $r : () } @dxchan if @dxchan;
1411 my @intcalls = map { $_->nodes } @localnodes if @localnodes;
1412 my $ref = Route::Node::get($self->{call});
1413 my @rnodes = $ref->nodes;
1414 for my $n (@intcalls) {
1415 push @remotenodes, Route::Node::get($n) unless grep $n eq $_, @rnodes;
1417 unshift @localnodes, $main::routeroot;
1420 send_route($self, \&pc19, scalar(@localnodes)+scalar(@remotenodes), @localnodes, @remotenodes);
1422 # get all the users connected on the above nodes and send them out
1423 foreach $n (@localnodes, @remotenodes) {
1425 send_route($self, \&pc16, 1, $n, map {my $r = Route::User::get($_); $r ? ($r) : ()} $n->users);
1427 dbg("sent a null value") if isdbg('chanerr');
1433 # route a message down an appropriate interface for a callsign
1435 # is called route(to, pcline);
1439 my ($self, $call, $line) = @_;
1441 if (ref $self && $call eq $self->{call}) {
1442 dbg("PCPROT: Trying to route back to source, dropped") if isdbg('chanerr');
1446 # always send it down the local interface if available
1447 my $dxchan = DXChannel->get($call);
1449 my $cl = Route::get($call);
1450 $dxchan = $cl->dxchan if $cl;
1452 if (ref $self && $dxchan eq $self) {
1453 dbg("PCPROT: Trying to route back to source, dropped") if isdbg('chanerr');
1459 my $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name
1461 $dxchan->send($routeit) unless $dxchan == $me;
1464 dbg("PCPROT: No route available, dropped") if isdbg('chanerr');
1468 # broadcast a message to all clusters taking into account isolation
1469 # [except those mentioned after buffer]
1472 my $s = shift; # the line to be rebroadcast
1473 my @except = @_; # to all channels EXCEPT these (dxchannel refs)
1474 my @dxchan = DXChannel::get_all_nodes();
1477 # send it if it isn't the except list and isn't isolated and still has a hop count
1478 foreach $dxchan (@dxchan) {
1479 next if grep $dxchan == $_, @except;
1480 next if $dxchan == $me;
1482 my $routeit = adjust_hops($dxchan, $s); # adjust its hop count by node name
1483 $dxchan->send($routeit) unless $dxchan->{isolate} || !$routeit;
1487 # broadcast a message to all clusters ignoring isolation
1488 # [except those mentioned after buffer]
1489 sub broadcast_all_ak1a
1491 my $s = shift; # the line to be rebroadcast
1492 my @except = @_; # to all channels EXCEPT these (dxchannel refs)
1493 my @dxchan = DXChannel::get_all_nodes();
1496 # send it if it isn't the except list and isn't isolated and still has a hop count
1497 foreach $dxchan (@dxchan) {
1498 next if grep $dxchan == $_, @except;
1499 next if $dxchan == $me;
1501 my $routeit = adjust_hops($dxchan, $s); # adjust its hop count by node name
1502 $dxchan->send($routeit);
1506 # broadcast to all users
1507 # storing the spot or whatever until it is in a state to receive it
1510 my $s = shift; # the line to be rebroadcast
1511 my $sort = shift; # the type of transmission
1512 my $fref = shift; # a reference to an object to filter on
1513 my @except = @_; # to all channels EXCEPT these (dxchannel refs)
1514 my @dxchan = DXChannel::get_all_users();
1518 foreach $dxchan (@dxchan) {
1519 next if grep $dxchan == $_, @except;
1522 broadcast_list($s, $sort, $fref, @out);
1525 # broadcast to a list of users
1533 foreach $dxchan (@_) {
1535 next if $dxchan == $me;
1537 if ($sort eq 'dx') {
1538 next unless $dxchan->{dx};
1539 ($filter) = $dxchan->{spotsfilter}->it(@{$fref}) if ref $fref;
1540 next unless $filter;
1542 next if $sort eq 'ann' && !$dxchan->{ann} && $s !~ /^To\s+LOCAL\s+de\s+(?:$main::myalias|$main::mycall)/i;
1543 next if $sort eq 'wwv' && !$dxchan->{wwv};
1544 next if $sort eq 'wcy' && !$dxchan->{wcy};
1545 next if $sort eq 'wx' && !$dxchan->{wx};
1547 $s =~ s/\a//og unless $dxchan->{beep};
1549 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'talk') {
1559 # obtain the hops from the list for this callsign and pc no
1565 my $hops = $DXProt::hopcount{$pcno};
1566 $hops = $DXProt::def_hopcount if !$hops;
1571 # adjust the hop count on a per node basis using the user loadable
1572 # hop table if available or else decrement an existing one
1579 my $call = $self->{call};
1582 if (($hops) = $s =~ /\^H(\d+)\^~?$/o) {
1583 my ($pcno) = $s =~ /^PC(\d\d)/o;
1584 confess "$call called adjust_hops with '$s'" unless $pcno;
1585 my $ref = $nodehops{$call} if %nodehops;
1587 my $newhops = $ref->{$pcno};
1588 return "" if defined $newhops && $newhops == 0;
1589 $newhops = $ref->{default} unless $newhops;
1590 return "" if defined $newhops && $newhops == 0;
1591 $newhops = $hops if !$newhops;
1592 $s =~ s/\^H(\d+)(\^~?)$/\^H$newhops$2/ if $newhops;
1594 # simply decrement it
1596 return "" if !$hops;
1597 $s =~ s/\^H(\d+)(\^~?)$/\^H$hops$2/ if $hops;
1609 return $self->msg('lh1') unless -e "$main::data/hop_table.pl";
1610 do "$main::data/hop_table.pl";
1616 # add a ping request to the ping queues
1619 my ($from, $to) = @_;
1620 my $ref = $pings{$to} || [];
1623 $r->{t} = [ gettimeofday ];
1624 route(undef, $to, pc51($to, $main::mycall, 1));
1631 my ($self, $tonode, $fromnode, $user, $cmd) = @_;
1632 if ($tonode eq $main::mycall) {
1633 my $ref = DXUser->get_current($fromnode);
1634 my $cref = Route::Node::get($fromnode);
1635 Log('rcmd', 'in', $ref->{priv}, $fromnode, $cmd);
1636 if ($cmd !~ /^\s*rcmd/i && $cref && $ref && $cref->call eq $ref->homenode) { # not allowed to relay RCMDS!
1637 if ($ref->{priv}) { # you have to have SOME privilege, the commands have further filtering
1638 $self->{remotecmd} = 1; # for the benefit of any command that needs to know
1639 my $oldpriv = $self->{priv};
1640 $self->{priv} = $ref->{priv}; # assume the user's privilege level
1641 my @in = (DXCommandmode::run_cmd($self, $cmd));
1642 $self->{priv} = $oldpriv;
1643 $self->send_rcmd_reply($main::mycall, $fromnode, $user, @in);
1644 delete $self->{remotecmd};
1646 $self->send_rcmd_reply($main::mycall, $fromnode, $user, "sorry...!");
1649 $self->send_rcmd_reply($main::mycall, $fromnode, $user, "your attempt is logged, Tut tut tut...!");
1652 my $ref = DXUser->get_current($tonode);
1653 if ($ref && $ref->is_clx) {
1654 $self->route($tonode, pc84($fromnode, $tonode, $user, $cmd));
1656 $self->route($tonode, pc34($fromnode, $tonode, $cmd));
1661 sub process_rcmd_reply
1663 my ($self, $tonode, $fromnode, $user, $line) = @_;
1664 if ($tonode eq $main::mycall) {
1665 my $s = $rcmds{$fromnode};
1667 my $dxchan = DXChannel->get($s->{call});
1668 my $ref = $user eq $tonode ? $dxchan : (DXChannel->get($user) || $dxchan);
1669 $ref->send($line) if $ref;
1670 delete $rcmds{$fromnode} if !$dxchan;
1672 # send unsolicited ones to the sysop
1673 my $dxchan = DXChannel->get($main::myalias);
1674 $dxchan->send($line) if $dxchan;
1677 my $ref = DXUser->get_current($tonode);
1678 if ($ref && $ref->is_clx) {
1679 $self->route($tonode, pc85($fromnode, $tonode, $user, $line));
1681 $self->route($tonode, pc35($fromnode, $tonode, $line));
1690 my $fromnode = shift;
1695 Log('rcmd', 'out', $fromnode, $line);
1696 if ($self->is_clx) {
1697 $self->send(pc85($main::mycall, $fromnode, $user, "$main::mycall:$line"));
1699 $self->send(pc35($main::mycall, $fromnode, "$main::mycall:$line"));
1704 # add a rcmd request to the rcmd queues
1707 my ($self, $to, $cmd) = @_;
1710 $r->{call} = $self->{call};
1711 $r->{t} = $main::systime;
1715 my $ref = Route::Node::get($to);
1716 my $dxchan = $ref->dxchan;
1717 if ($dxchan && $dxchan->is_clx) {
1718 route(undef, $to, pc84($main::mycall, $to, $self->{call}, $cmd));
1720 route(undef, $to, pc34($main::mycall, $to, $cmd));
1727 my $pc39flag = shift;
1728 my $call = $self->call;
1730 return if $self->{disconnecting}++;
1732 unless ($pc39flag && $pc39flag == 1) {
1733 $self->send_now("D", DXProt::pc39($main::mycall, $self->msg('disc1', "System Op")));
1737 my $node = Route::Node::get($call);
1740 @rout = $node->del($main::routeroot);
1743 # unbusy and stop and outgoing mail
1744 my $mref = DXMsg::get_busy($call);
1745 $mref->stop_msg($call) if $mref;
1747 # broadcast to all other nodes that all the nodes connected to via me are gone
1748 unless ($pc39flag && $pc39flag == 2) {
1749 $self->route_pc21(@rout) if @rout;
1752 # remove outstanding pings
1753 delete $pings{$call};
1755 # I was the last node visited
1756 $self->user->node($main::mycall);
1758 # send info to all logged in thingies
1759 $self->tell_login('logoutn');
1761 Log('DXProt', $call . " Disconnected");
1763 $self->SUPER::disconnect;
1768 # send a talk message to this thingy
1772 my ($self, $from, $to, $via, $line) = @_;
1774 $line =~ s/\^/\\5E/g; # remove any ^ characters
1775 $self->send(DXProt::pc10($from, $to, $via, $line));
1776 Log('talk', $self->call, $from, $via?$via:$main::mycall, $line);
1779 # send it if it isn't the except list and isn't isolated and still has a hop count
1780 # taking into account filtering and so on
1784 my $generate = shift;
1785 my $no = shift; # the no of things to filter on
1787 my ($filter, $hops);
1790 for (; @_ && $no; $no--) {
1793 if (!$self->{isolate} && $self->{routefilter}) {
1796 ($filter, $hops) = $self->{routefilter}->it($self->{call}, $self->{dxcc}, $self->{itu}, $self->{cq}, $r->call, $r->dxcc, $r->itu, $r->cq);
1800 dbg("DXPROT: $self->{call}/" . $r->call . " rejected by output filter") if isdbg('chanerr');
1803 dbg("was sent a null value") if isdbg('chanerr');
1806 push @rin, $r unless $self->{isolate} && $r->call ne $main::mycall;
1810 foreach my $line (&$generate(@rin, @_)) {
1813 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
1815 $routeit = adjust_hops($self, $line); # adjust its hop count by node name
1816 next unless $routeit;
1818 $self->send($routeit);
1826 my $generate = shift;
1827 my @dxchan = DXChannel::get_all_nodes();
1831 unless ($self->{isolate}) {
1832 foreach $dxchan (@dxchan) {
1833 next if $dxchan == $self;
1834 next if $dxchan == $me;
1835 $dxchan->send_route($generate, @_);
1843 broadcast_route($self, \&pc16, 1, @_);
1849 broadcast_route($self, \&pc17, 1, @_);
1855 broadcast_route($self, \&pc19, scalar @_, @_);
1861 broadcast_route($self, \&pc21, scalar @_, @_);
1867 broadcast_route($self, \&pc24, 1, @_);
1873 broadcast_route($self, \&pc41, 1, @_);
1879 broadcast_route($self, \&pc50, 1, @_);
1886 my ($filter, $hops) = (1, 1);
1888 if ($self->{inroutefilter}) {
1889 ($filter, $hops) = $self->{inroutefilter}->it($self->{call}, $self->{dxcc}, $self->{itu}, $self->{cq}, $r->call, $r->dxcc, $r->itu, $r->cq);
1890 dbg("PCPROT: $self->{call}/" . $r->call . ' rejected by in_filter_route') if !$filter && isdbg('chanerr');
1900 $s =~ s/\^H\d\d?\^?\~?$//;
1901 return 1 if exists $eph{$s};
1902 $eph{$s} = $main::systime;
1910 while (($key, $val) = each %eph) {
1911 if ($key =~ m{$regex}) {
1921 while (($key, $val) = each %eph) {
1922 if ($main::systime - $val > 90) {