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";
279 # process PC frames, this will fail unless the frame starts PCnn
280 my ($pcno) = $field[0] =~ /^PC(\d\d)/; # just get the number
282 return if $pcno < 10 || $pcno > 99;
284 # check for and dump bad protocol messages
285 my $n = check($pcno, @field);
287 dbg("PCPROT: bad field $n, dumped (" . parray($checklist[$pcno-10]) . ")") if isdbg('chanerr');
294 $pcr = Local::pcprot($self, $pcno, @field);
296 # dbg("Local::pcprot error $@") if isdbg('local') if $@;
300 if ($pcno == 10) { # incoming talk
302 # will we allow it at all?
305 if (@bad = BadWords::check($field[3])) {
306 dbg("PCPROT: Bad words: @bad, dropped") if isdbg('chanerr');
311 # is it for me or one of mine?
312 my ($to, $via, $call, $dxchan);
313 if ($field[5] gt ' ') {
314 $call = $via = $field[2];
317 $call = $to = $field[2];
319 $dxchan = DXChannel->get($call);
320 if ($dxchan && $dxchan->is_user) {
321 $field[3] =~ s/\%5E/^/g;
322 $dxchan->talk($field[1], $to, $via, $field[3]);
324 $self->route($field[2], $line); # relay it on its way
329 if ($pcno == 11 || $pcno == 26) { # dx spot
331 # route 'foreign' pc26s
333 if ($field[7] ne $main::mycall) {
334 $self->route($field[7], $line);
339 # if this is a 'nodx' node then ignore it
340 if ($badnode->in($field[7])) {
341 dbg("PCPROT: Bad Node, dropped") if isdbg('chanerr');
345 # if this is a 'bad spotter' user then ignore it
346 if ($badspotter->in($field[6])) {
347 dbg("PCPROT: Bad Spotter, dropped") if isdbg('chanerr');
351 # convert the date to a unix date
352 my $d = cltounix($field[3], $field[4]);
353 # bang out (and don't pass on) if date is invalid or the spot is too old (or too young)
354 if (!$d || ($pcno == 11 && ($d < $main::systime - $pc11_max_age || $d > $main::systime + 900))) {
355 dbg("PCPROT: Spot ignored, invalid date or out of range ($field[3] $field[4])\n") if isdbg('chanerr');
360 if ($baddx->in($field[2])) {
361 dbg("PCPROT: Bad DX spot, ignored") if isdbg('chanerr');
366 $field[5] =~ s/^\s+//; # take any leading blanks off
367 $field[2] = unpad($field[2]); # take off leading and trailing blanks from spotted callsign
368 if ($field[2] =~ /BUST\w*$/) {
369 dbg("PCPROT: useless 'BUSTED' spot") if isdbg('chanerr');
372 if (Spot::dup($field[1], $field[2], $d, $field[5])) {
373 dbg("PCPROT: Duplicate Spot ignored\n") if isdbg('chanerr');
378 if (@bad = BadWords::check($field[5])) {
379 dbg("PCPROT: Bad words: @bad, dropped") if isdbg('chanerr');
384 my @spot = Spot::prepare($field[1], $field[2], $d, $field[5], $field[6], $field[7]);
385 # global spot filtering on INPUT
386 if ($self->{inspotsfilter}) {
387 my ($filter, $hops) = $self->{inspotsfilter}->it(@spot);
389 dbg("PCPROT: Rejected by input spot filter") if isdbg('chanerr');
398 # @spot at this point contains:-
399 # freq, spotted call, time, text, spotter, spotted cc, spotters cc, orig node
400 # then spotted itu, spotted cq, spotters itu, spotters cq
401 # you should be able to route on any of these
404 # fix up qra locators of known users
405 my $user = DXUser->get_current($spot[4]);
407 my $qra = $user->qra;
408 unless ($qra && DXBearing::is_qra($qra)) {
409 my $lat = $user->lat;
410 my $long = $user->long;
411 if (defined $lat && defined $long) {
412 $user->qra(DXBearing::lltoqra($lat, $long));
417 # send a remote command to a distant cluster if it is visible and there is no
418 # qra locator and we havn't done it for a month.
420 unless ($user->qra) {
422 my $to = $user->homenode;
423 my $last = $user->lastoper || 0;
424 if ($send_opernam && $main::systime > $last + $DXUser::lastoperinterval && $to && ($node = Route::Node::get($to)) ) {
425 my $cmd = "forward/opernam $spot[4]";
426 # send the rcmd but we aren't interested in the replies...
427 my $dxchan = $node->dxchan;
428 if ($dxchan && $dxchan->is_clx) {
429 route(undef, $to, pc84($main::mycall, $to, $main::mycall, $cmd));
431 route(undef, $to, pc34($main::mycall, $to, $cmd));
433 if ($to ne $field[7]) {
435 $node = Route::Node::get($to);
437 $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));
445 $user->lastoper($main::systime);
454 $r = Local::spot($self, @spot);
456 # dbg("Local::spot1 error $@") if isdbg('local') if $@;
459 # DON'T be silly and send on PC26s!
460 return if $pcno == 26;
462 # send out the filtered spots
463 send_dx_spot($self, $line, @spot) if @spot;
467 if ($pcno == 12) { # announces
468 # announce duplicate checking
469 $field[3] =~ s/^\s+//; # remove leading blanks
470 if (AnnTalk::dup($field[1], $field[2], $field[3])) {
471 dbg("PCPROT: Duplicate Announce ignored") if isdbg('chanerr');
477 if (@bad = BadWords::check($field[3])) {
478 dbg("PCPROT: Bad words: @bad, dropped") if isdbg('chanerr');
483 if ($field[2] eq '*' || $field[2] eq $main::mycall) {
485 # global ann filtering on INPUT
486 if ($self->{inannfilter}) {
487 my ($ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
488 my @dxcc = Prefix::extract($field[1]);
490 $ann_dxcc = $dxcc[1]->dxcc;
491 $ann_itu = $dxcc[1]->itu;
492 $ann_cq = $dxcc[1]->cq();
494 @dxcc = Prefix::extract($field[5]);
496 $org_dxcc = $dxcc[1]->dxcc;
497 $org_itu = $dxcc[1]->itu;
498 $org_cq = $dxcc[1]->cq();
500 my ($filter, $hops) = $self->{inannfilter}->it(@field[1..6], $self->{call},
501 $ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq);
503 dbg("PCPROT: Rejected by input announce filter") if isdbg('chanerr');
509 $self->send_announce($line, @field[1..6]);
511 $self->route($field[2], $line);
527 if ($pcno == 16) { # add a user
531 my $ncall = $field[1];
532 my $newline = "PC16^";
534 if ($ncall eq $main::mycall) {
535 dbg("PCPROT: trying to alter config on this node from outside!") if isdbg('chanerr');
538 $dxchan = DXChannel->get($ncall);
539 if ($dxchan && $dxchan ne $self) {
540 dbg("PCPROT: PC16 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr');
543 my $parent = Route::Node::get($ncall);
545 dbg("PCPROT: Node $ncall not in config") if isdbg('chanerr');
549 # input filter if required
550 return unless $self->in_filter_route($parent);
554 for ($i = 2; $i < $#field; $i++) {
555 my ($call, $conf, $here) = $field[$i] =~ /^(\S+) (\S) (\d)/o;
556 next unless $call && $conf && defined $here && is_callsign($call);
557 $conf = $conf eq '*';
559 my $r = Route::User::get($call);
560 my $flags = Route::here($here)|Route::conf($conf);
563 if ($r->flags != $flags) {
567 $r->addparent($ncall);
569 push @rout, $parent->add_user($call, $flags);
572 # add this station to the user database, if required
573 $call =~ s/-\d+$//o; # remove ssid for users
574 my $user = DXUser->get_current($call);
575 $user = DXUser->new($call) if !$user;
576 $user->homenode($parent->call) if !$user->homenode;
577 $user->node($parent->call);
578 $user->lastin($main::systime) unless DXChannel->get($call);
583 # queue up any messages (look for privates only)
584 DXMsg::queue_msg(1) if $self->state eq 'normal';
586 $self->route_pc16($parent, @rout) if @rout;
590 if ($pcno == 17) { # remove a user
592 my $ncall = $field[2];
593 my $ucall = $field[1];
594 if ($ncall eq $main::mycall) {
595 dbg("PCPROT: trying to alter config on this node from outside!") if isdbg('chanerr');
598 $dxchan = DXChannel->get($ncall);
599 if ($dxchan && $dxchan ne $self) {
600 dbg("PCPROT: PC17 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr');
603 my $parent = Route::Node::get($ncall);
605 dbg("PCPROT: Route::Node $ncall not in config") if isdbg('chanerr');
609 # input filter if required
610 return unless $self->in_filter_route($parent);
612 my @rout = $parent->del_user($ucall);
613 $self->route_pc17($parent, @rout) if @rout;
617 if ($pcno == 18) { # link request
618 $self->state('init');
620 # first clear out any nodes on this dxchannel
621 my $parent = Route::Node::get($self->{call});
622 my @rout = $parent->del_nodes;
623 $self->route_pc21(@rout, $parent);
624 $self->send_local_config();
626 return; # we don't pass these on
629 if ($pcno == 19) { # incoming cluster list
631 my $newline = "PC19^";
635 my $parent = Route::Node::get($self->{call});
638 for ($i = 1; $i < $#field-1; $i += 4) {
639 my $here = $field[$i];
640 my $call = uc $field[$i+1];
641 my $conf = $field[$i+2];
642 my $ver = $field[$i+3];
643 next unless defined $here && defined $conf && is_callsign($call);
644 # check for sane parameters
645 $ver = 5000 if $ver eq '0000';
646 next if $ver < 5000; # only works with version 5 software
647 next if length $call < 3; # min 3 letter callsigns
649 # update it if required
650 my $r = Route::Node::get($call);
651 my $flags = Route::here($here)|Route::conf($conf);
654 if ($call ne $parent->call) {
655 if ($self->in_filter_route($r)) {
656 $ar = $parent->add($call, $ver, $flags);
657 push @rout, $ar if $ar;
662 if ($r->version ne $ver || $r->flags != $flags) {
665 push @rout, $r unless $ar;
668 next if $call eq $main::mycall || $call eq $self->{call};
670 my $new = Route->new($call); # throw away
671 if ($self->in_filter_route($new)) {
672 my $r = $parent->add($call, $ver, $flags);
679 # unbusy and stop and outgoing mail (ie if somehow we receive another PC19 without a disconnect)
680 my $mref = DXMsg::get_busy($call);
681 $mref->stop_msg($call) if $mref;
683 # add this station to the user database, if required (don't remove SSID from nodes)
684 my $user = DXUser->get_current($call);
686 $user = DXUser->new($call);
688 $user->priv(1); # I have relented and defaulted nodes
689 $self->{priv} = 1; # to user RCMDs allowed
690 $user->homenode($call);
693 $user->lastin($main::systime) unless DXChannel->get($call);
697 $self->route_pc19(@rout) if @rout;
701 if ($pcno == 20) { # send local configuration
702 $self->send_local_config();
704 $self->state('normal');
708 if ($pcno == 21) { # delete a cluster from the list
709 my $call = uc $field[1];
711 my $parent = Route::Node::get($self->{call});
713 dbg("PCPROT: Route::Node $call not in config") if isdbg('chanerr');
716 my $node = Route::Node::get($call);
717 if ($call ne $main::mycall) { # don't allow malicious buggers to disconnect me!
718 if ($call eq $self->{call}) {
719 dbg("PCPROT: Trying to disconnect myself with PC21") if isdbg('chanerr');
725 return unless $self->in_filter_route($node);
728 push @rout, $node->del($parent);
731 dbg("PCPROT: I WILL _NOT_ be disconnected!") if isdbg('chanerr');
734 $self->route_pc21(@rout) if @rout;
739 $self->state('normal');
743 if ($pcno == 23 || $pcno == 27) { # WWV info
745 # route 'foreign' pc27s
747 if ($field[8] ne $main::mycall) {
748 $self->route($field[8], $line);
754 my $d = cltounix($field[1], sprintf("%02d18Z", $field[2]));
755 my $sfi = unpad($field[3]);
756 my $k = unpad($field[4]);
757 my $i = unpad($field[5]);
758 my ($r) = $field[6] =~ /R=(\d+)/;
760 if (($pcno == 23 && $d < $main::systime - $pc23_max_age) || $d > $main::systime + 1500 || $field[2] < 0 || $field[2] > 23) {
761 dbg("PCPROT: WWV Date ($field[1] $field[2]) out of range") if isdbg('chanerr');
764 if (Geomag::dup($d,$sfi,$k,$i,$field[6])) {
765 dbg("PCPROT: Dup WWV Spot ignored\n") if isdbg('chanerr');
768 $field[7] =~ s/-\d+$//o; # remove spotter's ssid
770 my $wwv = Geomag::update($d, $field[2], $sfi, $k, $i, @field[6..8], $r);
774 $rep = Local::wwv($self, $field[1], $field[2], $sfi, $k, $i, @field[6..8], $r);
776 # dbg("Local::wwv2 error $@") if isdbg('local') if $@;
779 # DON'T be silly and send on PC27s!
780 return if $pcno == 27;
782 # broadcast to the eager world
783 send_wwv_spot($self, $line, $d, $field[2], $sfi, $k, $i, @field[6..8]);
787 if ($pcno == 24) { # set here status
788 my $call = uc $field[1];
790 $nref = Route::Node::get($call);
791 $uref = Route::User::get($call);
792 return unless $nref || $uref; # if we don't know where they are, it's pointless sending it on
794 unless (eph_dup($line)) {
795 $nref->here($field[2]) if $nref;
796 $uref->here($field[2]) if $uref;
797 my $ref = $nref || $uref;
798 return unless $self->in_filter_route($ref);
799 $self->route_pc24($ref, $field[3]);
804 if ($pcno == 25) { # merge request
805 if ($field[1] ne $main::mycall) {
806 $self->route($field[1], $line);
809 if ($field[2] eq $main::mycall) {
810 dbg("PCPROT: Trying to merge to myself, ignored") if isdbg('chanerr');
814 Log('DXProt', "Merge request for $field[3] spots and $field[4] WWV from $field[1]");
818 my @in = reverse Spot::search(1, undef, undef, 0, $field[3]);
821 $self->send(pc26(@{$in}[0..4], $field[2]));
827 my @in = reverse Geomag::search(0, $field[4], time, 1);
830 $self->send(pc27(@{$in}[0..5], $field[2]));
836 if (($pcno >= 28 && $pcno <= 33) || $pcno == 40 || $pcno == 42 || $pcno == 49) { # mail/file handling
837 if ($pcno == 49 || $field[1] eq $main::mycall) {
838 DXMsg::process($self, $line);
840 $self->route($field[1], $line) unless $self->is_clx;
845 if ($pcno == 34 || $pcno == 36) { # remote commands (incoming)
846 if ($field[1] eq $main::mycall) {
847 my $ref = DXUser->get_current($field[2]);
848 my $cref = Route::Node::get($field[2]);
849 Log('rcmd', 'in', $ref->{priv}, $field[2], $field[3]);
850 unless (!$cref || !$ref || $cref->call ne $ref->homenode) { # not allowed to relay RCMDS!
851 if ($ref->{priv}) { # you have to have SOME privilege, the commands have further filtering
852 $self->{remotecmd} = 1; # for the benefit of any command that needs to know
853 my $oldpriv = $self->{priv};
854 $self->{priv} = $ref->{priv}; # assume the user's privilege level
855 my @in = (DXCommandmode::run_cmd($self, $field[3]));
856 $self->{priv} = $oldpriv;
859 $self->send(pc35($main::mycall, $field[2], "$main::mycall:$_"));
860 Log('rcmd', 'out', $field[2], $_);
862 delete $self->{remotecmd};
864 $self->send(pc35($main::mycall, $field[2], "$main::mycall:sorry...!"));
867 $self->send(pc35($main::mycall, $field[2], "$main::mycall:your attempt is logged, Tut tut tut...!"));
870 my $ref = DXUser->get_current($field[1]);
871 if ($ref && $ref->is_clx) {
872 $self->route($field[1], pc84($field[2], $field[1], $field[2], $field[3]));
874 $self->route($field[1], $line);
880 if ($pcno == 35) { # remote command replies
881 if ($field[1] eq $main::mycall) {
882 my $s = $rcmds{$field[2]};
884 my $dxchan = DXChannel->get($s->{call});
885 $dxchan->send($field[3]) if $dxchan;
886 delete $rcmds{$field[2]} if !$dxchan;
888 # send unsolicited ones to the sysop
889 my $dxchan = DXChannel->get($main::myalias);
890 $dxchan->send($field[3]) if $dxchan;
893 my $ref = DXUser->get_current($field[1]);
894 if ($ref && $ref->is_clx) {
895 $self->route($field[1], pc85($field[2], $field[1], $field[2], $field[3]));
897 $self->route($field[1], $line);
903 # for pc 37 see 44 onwards
905 if ($pcno == 38) { # node connected list from neighbour
909 if ($pcno == 39) { # incoming disconnect
910 if ($field[1] eq $self->{call}) {
911 $self->disconnect(1);
913 dbg("PCPROT: came in on wrong channel") if isdbg('chanerr');
918 if ($pcno == 41) { # user info
919 # add this station to the user database, if required
920 my $call = $field[1];
921 my $user = DXUser->get_current($call);
922 $user = DXUser->new($call) if !$user;
924 if ($field[2] == 1) {
925 $user->name($field[3]);
926 } elsif ($field[2] == 2) {
927 $user->qth($field[3]);
928 } elsif ($field[2] == 3) {
929 my ($lat, $long) = DXBearing::stoll($field[3]);
932 $user->qra(DXBearing::lltoqra($lat, $long)) unless $user->qra && DXBearing::is_qra($user->qra);
933 } elsif ($field[2] == 4) {
934 $user->homenode($field[3]);
936 $user->lastoper($main::systime); # to cut down on excessive for/opers being generated
938 my $ref = Route::get($call) || Route->new($call);
940 # input filter if required
941 return unless $self->in_filter_route($ref);
943 $self->route_pc41($ref, $call, $field[2], $field[3], $field[4]) if $ref && !eph_dup($line);
951 if ($pcno == 37 || $pcno == 44 || $pcno == 45 || $pcno == 46 || $pcno == 47 || $pcno == 48) {
952 DXDb::process($self, $line);
956 if ($pcno == 50) { # keep alive/user list
957 my $call = $field[1];
958 my $node = Route::Node::get($call);
960 return unless $node->call eq $self->{call};
961 $node->usercount($field[2]);
963 # input filter if required
964 return unless $self->in_filter_route($node);
966 $self->route_pc50($node, $field[2], $field[3]) unless eph_dup($line);
971 if ($pcno == 51) { # incoming ping requests/answers
973 my $from = $field[2];
974 my $flag = $field[3];
977 if ($to eq $main::mycall) {
979 $self->send(pc51($from, $to, '0'));
981 # it's a reply, look in the ping list for this one
982 my $ref = $pings{$from};
984 my $tochan = DXChannel->get($from);
987 my $dxchan = DXChannel->get($r->{call});
989 my $t = tv_interval($r->{t}, [ gettimeofday ]);
990 if ($dxchan->is_user) {
991 my $s = sprintf "%.2f", $t;
992 my $ave = sprintf "%.2f", $tochan ? ($tochan->{pingave} || $t) : $t;
993 $dxchan->send($dxchan->msg('pingi', $from, $s, $ave))
994 } elsif ($dxchan->is_node) {
996 $tochan->{nopings} = $tochan->user->nopings || 2; # pump up the timer
997 push @{$tochan->{pingtime}}, $t;
998 shift @{$tochan->{pingtime}} if @{$tochan->{pingtime}} > 6;
1000 for (@{$tochan->{pingtime}}) {
1003 $tochan->{pingave} = $st / @{$tochan->{pingtime}};
1010 # route down an appropriate thingy
1011 $self->route($to, $line);
1016 if ($pcno == 75) { # dunno but route it
1017 my $call = $field[1];
1018 if ($call ne $main::mycall) {
1019 $self->route($call, $line);
1024 if ($pcno == 73) { # WCY broadcasts
1025 my $call = $field[1];
1028 my $d = cltounix($call, sprintf("%02d18Z", $field[2]));
1029 if (($pcno == 23 && $d < $main::systime - $pc23_max_age) || $d > $main::systime + 1500 || $field[2] < 0 || $field[2] > 23) {
1030 dbg("PCPROT: WCY Date ($call $field[2]) out of range") if isdbg('chanerr');
1033 @field = map { unpad($_) } @field;
1034 if (WCY::dup($d,@field[3..7])) {
1035 dbg("PCPROT: Dup WCY Spot ignored\n") if isdbg('chanerr');
1039 my $wcy = WCY::update($d, @field[2..12]);
1043 $rep = Local::wwv($self, @field[1..12]);
1045 # dbg("Local::wcy error $@") if isdbg('local') if $@;
1048 # broadcast to the eager world
1049 send_wcy_spot($self, $line, $d, @field[2..12]);
1053 if ($pcno == 84) { # remote commands (incoming)
1054 my $call = $field[1];
1055 if ($call eq $main::mycall) {
1056 my $ref = DXUser->get_current($field[2]);
1057 my $cref = Route::Node::get($field[2]);
1058 Log('rcmd', 'in', $ref->{priv}, $field[2], $field[4]);
1059 unless ($field[4] =~ /rcmd/i || !$cref || !$ref || $cref->call ne $ref->homenode) { # not allowed to relay RCMDS!
1060 if ($ref->{priv}) { # you have to have SOME privilege, the commands have further filtering
1061 $self->{remotecmd} = 1; # for the benefit of any command that needs to know
1062 my $oldpriv = $self->{priv};
1063 $self->{priv} = $ref->{priv}; # assume the user's privilege level
1064 my @in = (DXCommandmode::run_cmd($self, $field[4]));
1065 $self->{priv} = $oldpriv;
1068 $self->send(pc85($main::mycall, $field[2], $field[3], "$main::mycall:$_"));
1069 Log('rcmd', 'out', $field[2], $_);
1071 delete $self->{remotecmd};
1073 $self->send(pc85($main::mycall, $field[2], $field[3], "$main::mycall:sorry...!"));
1076 $self->send(pc85($main::mycall, $field[2], $field[3],"$main::mycall:your attempt is logged, Tut tut tut...!"));
1079 my $ref = DXUser->get_current($call);
1080 if ($ref && $ref->is_clx) {
1081 $self->route($call, $line);
1083 $self->route($call, pc34($field[2], $call, $field[4]));
1089 if ($pcno == 85) { # remote command replies
1090 my $call = $field[1];
1091 if ($call eq $main::mycall) {
1092 my $dxchan = DXChannel->get($field[3]);
1094 $dxchan->send($field[4]);
1096 my $s = $rcmds{$field[2]};
1098 $dxchan = DXChannel->get($s->{call});
1099 $dxchan->send($field[4]) if $dxchan;
1100 delete $rcmds{$field[2]} if !$dxchan;
1102 # send unsolicited ones to the sysop
1103 my $dxchan = DXChannel->get($main::myalias);
1104 $dxchan->send($field[4]) if $dxchan;
1108 my $ref = DXUser->get_current($call);
1109 if ($ref && $ref->is_clx) {
1110 $self->route($call, $line);
1112 $self->route($call, pc35($field[2], $call, $field[4]));
1119 # if get here then rebroadcast the thing with its Hop count decremented (if
1120 # there is one). If it has a hop count and it decrements to zero then don't
1123 # NOTE - don't arrive here UNLESS YOU WANT this lump of protocol to be
1127 if (eph_dup($line)) {
1128 dbg("PCPROT: Ephemeral dup, dropped") if isdbg('chanerr');
1130 unless ($self->{isolate}) {
1131 broadcast_ak1a($line, $self); # send it to everyone but me
1137 # This is called from inside the main cluster processing loop and is used
1138 # for despatching commands that are doing some long processing job
1143 my @dxchan = DXChannel->get_all();
1146 foreach $dxchan (@dxchan) {
1147 next unless $dxchan->is_node();
1148 next if $dxchan == $me;
1150 # send a pc50 out on this channel
1151 $dxchan->{pc50_t} = $main::systime unless exists $dxchan->{pc50_t};
1152 if ($t >= $dxchan->{pc50_t} + $DXProt::pc50_interval) {
1153 my $s = pc50($me, scalar DXChannel::get_all_users);
1156 $dxchan->{pc50_t} = $t;
1159 # send a ping out on this channel
1160 if ($dxchan->{pingint} && $t >= $dxchan->{pingint} + $dxchan->{lastping}) {
1161 if ($dxchan->{nopings} <= 0) {
1162 $dxchan->disconnect;
1164 addping($main::mycall, $dxchan->call);
1165 $dxchan->{nopings} -= 1;
1166 $dxchan->{lastping} = $t;
1172 if ($t - $last10 >= 10) {
1173 # clean out ephemera
1180 if ($main::systime - 3600 > $last_hour) {
1181 $last_hour = $main::systime;
1186 # finish up a pc context
1190 # some active measures
1197 my @dxchan = DXChannel->get_all();
1200 # send it if it isn't the except list and isn't isolated and still has a hop count
1201 # taking into account filtering and so on
1202 foreach $dxchan (@dxchan) {
1203 next if $dxchan == $me;
1205 my ($filter, $hops);
1207 if ($dxchan->{spotsfilter}) {
1208 ($filter, $hops) = $dxchan->{spotsfilter}->it(@_, $self->{call} );
1209 next unless $filter;
1212 if ($dxchan->is_node) {
1213 next if $dxchan == $self;
1216 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
1218 $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name
1219 next unless $routeit;
1222 $dxchan->send($routeit) if $routeit;
1224 $dxchan->send($routeit) unless $dxchan->{isolate} || $self->{isolate};
1226 } elsif ($dxchan->is_user && $dxchan->{dx}) {
1227 my $buf = Spot::formatb($dxchan->{user}->wantgrid, $_[0], $_[1], $_[2], $_[3], $_[4]);
1228 $buf .= "\a\a" if $dxchan->{beep};
1230 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'talk') {
1231 $dxchan->send($buf);
1233 $dxchan->delay($buf);
1243 my @dxchan = DXChannel->get_all();
1245 my ($wwv_dxcc, $wwv_itu, $wwv_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
1246 my @dxcc = Prefix::extract($_[7]);
1248 $wwv_dxcc = $dxcc[1]->dxcc;
1249 $wwv_itu = $dxcc[1]->itu;
1250 $wwv_cq = $dxcc[1]->cq;
1252 @dxcc = Prefix::extract($_[8]);
1254 $org_dxcc = $dxcc[1]->dxcc;
1255 $org_itu = $dxcc[1]->itu;
1256 $org_cq = $dxcc[1]->cq;
1259 # send it if it isn't the except list and isn't isolated and still has a hop count
1260 # taking into account filtering and so on
1261 foreach $dxchan (@dxchan) {
1262 next if $dxchan == $self;
1263 next if $dxchan == $me;
1265 my ($filter, $hops);
1267 if ($dxchan->{wwvfilter}) {
1268 ($filter, $hops) = $dxchan->{wwvfilter}->it(@_, $self->{call}, $wwv_dxcc, $wwv_itu, $wwv_cq, $org_dxcc, $org_itu, $org_cq);
1269 next unless $filter;
1271 if ($dxchan->is_node) {
1274 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
1276 $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name
1277 next unless $routeit;
1280 $dxchan->send($routeit) if $routeit;
1282 $dxchan->send($routeit) unless $dxchan->{isolate} || $self->{isolate};
1285 } elsif ($dxchan->is_user && $dxchan->{wwv}) {
1286 my $buf = "WWV de $_[6] <$_[1]>: SFI=$_[2], A=$_[3], K=$_[4], $_[5]";
1287 $buf .= "\a\a" if $dxchan->{beep};
1288 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'talk') {
1289 $dxchan->send($buf);
1291 $dxchan->delay($buf);
1301 my @dxchan = DXChannel->get_all();
1303 my ($wcy_dxcc, $wcy_itu, $wcy_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
1304 my @dxcc = Prefix::extract($_[11]);
1306 $wcy_dxcc = $dxcc[1]->dxcc;
1307 $wcy_itu = $dxcc[1]->itu;
1308 $wcy_cq = $dxcc[1]->cq;
1310 @dxcc = Prefix::extract($_[12]);
1312 $org_dxcc = $dxcc[1]->dxcc;
1313 $org_itu = $dxcc[1]->itu;
1314 $org_cq = $dxcc[1]->cq;
1317 # send it if it isn't the except list and isn't isolated and still has a hop count
1318 # taking into account filtering and so on
1319 foreach $dxchan (@dxchan) {
1320 next if $dxchan == $me;
1322 my ($filter, $hops);
1324 if ($dxchan->{wcyfilter}) {
1325 ($filter, $hops) = $dxchan->{wcyfilter}->it(@_, $self->{call}, $wcy_dxcc, $wcy_itu, $wcy_cq, $org_dxcc, $org_itu, $org_cq);
1326 next unless $filter;
1328 if ($dxchan->is_clx || $dxchan->is_spider || $dxchan->is_dxnet) {
1331 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
1333 $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name
1334 next unless $routeit;
1337 $dxchan->send($routeit) if $routeit;
1339 $dxchan->send($routeit) unless $dxchan->{isolate} || $self->{isolate};
1341 } elsif ($dxchan->is_user && $dxchan->{wcy}) {
1342 my $buf = "WCY de $_[10] <$_[1]> : K=$_[4] expK=$_[5] A=$_[3] R=$_[6] SFI=$_[2] SA=$_[7] GMF=$_[8] Au=$_[9]";
1343 $buf .= "\a\a" if $dxchan->{beep};
1344 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'talk') {
1345 $dxchan->send($buf);
1347 $dxchan->delay($buf);
1358 my @dxchan = DXChannel->get_all();
1360 my $text = unpad($_[2]);
1364 if ($_[3] eq '*') { # sysops
1366 } elsif ($_[3] gt ' ') { # speciality list handling
1367 my ($name) = split /\./, $_[3];
1368 $target = "$name"; # put the rest in later (if bothered)
1375 $target = "ALL" if !$target;
1377 Log('ann', $target, $_[0], $text);
1379 # obtain country codes etc
1380 my ($ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
1381 my @dxcc = Prefix::extract($_[0]);
1383 $ann_dxcc = $dxcc[1]->dxcc;
1384 $ann_itu = $dxcc[1]->itu;
1385 $ann_cq = $dxcc[1]->cq;
1387 @dxcc = Prefix::extract($_[4]);
1389 $org_dxcc = $dxcc[1]->dxcc;
1390 $org_itu = $dxcc[1]->itu;
1391 $org_cq = $dxcc[1]->cq;
1394 # send it if it isn't the except list and isn't isolated and still has a hop count
1395 # taking into account filtering and so on
1396 foreach $dxchan (@dxchan) {
1397 next if $dxchan == $self;
1398 next if $dxchan == $me;
1400 my ($filter, $hops);
1402 if ($dxchan->{annfilter}) {
1403 ($filter, $hops) = $dxchan->{annfilter}->it(@_, $self->{call}, $ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq);
1404 next unless $filter;
1406 if ($dxchan->is_node && $_[1] ne $main::mycall) { # i.e not specifically routed to me
1409 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
1411 $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name
1412 next unless $routeit;
1415 $dxchan->send($routeit) if $routeit;
1417 $dxchan->send($routeit) unless $dxchan->{isolate} || $self->{isolate};
1420 } elsif ($dxchan->is_user) {
1421 unless ($dxchan->{ann}) {
1422 next if $_[0] ne $main::myalias && $_[0] ne $main::mycall;
1424 next if $target eq 'SYSOP' && $dxchan->{priv} < 5;
1425 my $buf = "$to$target de $_[0]: $text";
1427 $buf .= "\a\a" if $dxchan->{beep};
1428 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'talk') {
1429 $dxchan->send($buf);
1431 $dxchan->delay($buf);
1437 sub send_local_config
1445 dbg('DXProt::send_local_config') if isdbg('trace');
1448 if ($self->{isolate}) {
1449 @localnodes = ( $main::routeroot );
1451 # create a list of all the nodes that are not connected to this connection
1452 # and are not themselves isolated, this to make sure that isolated nodes
1453 # don't appear outside of this node
1454 my @dxchan = grep { $_->call ne $main::mycall && $_->call ne $self->{call} } DXChannel::get_all_nodes();
1455 @localnodes = map { my $r = Route::Node::get($_->{call}); $r ? $r : () } @dxchan if @dxchan;
1456 my @intcalls = map { $_->nodes } @localnodes if @localnodes;
1457 my $ref = Route::Node::get($self->{call});
1458 my @rnodes = $ref->nodes;
1459 for my $n (@intcalls) {
1460 push @remotenodes, Route::Node::get($n) unless grep $n eq $_, @rnodes;
1462 unshift @localnodes, $main::routeroot;
1465 send_route($self, \&pc19, scalar(@localnodes)+scalar(@remotenodes), @localnodes, @remotenodes);
1467 # get all the users connected on the above nodes and send them out
1468 foreach $n (@localnodes, @remotenodes) {
1470 send_route($self, \&pc16, 1, $n, map {my $r = Route::User::get($_); $r ? ($r) : ()} $n->users);
1472 dbg("sent a null value") if isdbg('chanerr');
1478 # route a message down an appropriate interface for a callsign
1480 # is called route(to, pcline);
1484 my ($self, $call, $line) = @_;
1486 if (ref $self && $call eq $self->{call}) {
1487 dbg("PCPROT: Trying to route back to source, dropped") if isdbg('chanerr');
1491 # always send it down the local interface if available
1492 my $dxchan = DXChannel->get($call);
1494 my $cl = Route::get($call);
1495 $dxchan = $cl->dxchan if $cl;
1497 if (ref $self && $dxchan eq $self) {
1498 dbg("PCPROT: Trying to route back to source, dropped") if isdbg('chanerr');
1504 my $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name
1506 $dxchan->send($routeit);
1509 dbg("PCPROT: No route available, dropped") if isdbg('chanerr');
1513 # broadcast a message to all clusters taking into account isolation
1514 # [except those mentioned after buffer]
1517 my $s = shift; # the line to be rebroadcast
1518 my @except = @_; # to all channels EXCEPT these (dxchannel refs)
1519 my @dxchan = DXChannel::get_all_nodes();
1522 # send it if it isn't the except list and isn't isolated and still has a hop count
1523 foreach $dxchan (@dxchan) {
1524 next if grep $dxchan == $_, @except;
1525 next if $dxchan == $me;
1527 my $routeit = adjust_hops($dxchan, $s); # adjust its hop count by node name
1528 $dxchan->send($routeit) unless $dxchan->{isolate} || !$routeit;
1532 # broadcast a message to all clusters ignoring isolation
1533 # [except those mentioned after buffer]
1534 sub broadcast_all_ak1a
1536 my $s = shift; # the line to be rebroadcast
1537 my @except = @_; # to all channels EXCEPT these (dxchannel refs)
1538 my @dxchan = DXChannel::get_all_nodes();
1541 # send it if it isn't the except list and isn't isolated and still has a hop count
1542 foreach $dxchan (@dxchan) {
1543 next if grep $dxchan == $_, @except;
1544 next if $dxchan == $me;
1546 my $routeit = adjust_hops($dxchan, $s); # adjust its hop count by node name
1547 $dxchan->send($routeit);
1551 # broadcast to all users
1552 # storing the spot or whatever until it is in a state to receive it
1555 my $s = shift; # the line to be rebroadcast
1556 my $sort = shift; # the type of transmission
1557 my $fref = shift; # a reference to an object to filter on
1558 my @except = @_; # to all channels EXCEPT these (dxchannel refs)
1559 my @dxchan = DXChannel::get_all_users();
1563 foreach $dxchan (@dxchan) {
1564 next if grep $dxchan == $_, @except;
1567 broadcast_list($s, $sort, $fref, @out);
1570 # broadcast to a list of users
1578 foreach $dxchan (@_) {
1580 next if $dxchan == $me;
1582 if ($sort eq 'dx') {
1583 next unless $dxchan->{dx};
1584 ($filter) = $dxchan->{spotsfilter}->it(@{$fref}) if ref $fref;
1585 next unless $filter;
1587 next if $sort eq 'ann' && !$dxchan->{ann} && $s !~ /^To\s+LOCAL\s+de\s+(?:$main::myalias|$main::mycall)/i;
1588 next if $sort eq 'wwv' && !$dxchan->{wwv};
1589 next if $sort eq 'wcy' && !$dxchan->{wcy};
1590 next if $sort eq 'wx' && !$dxchan->{wx};
1592 $s =~ s/\a//og unless $dxchan->{beep};
1594 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'talk') {
1604 # obtain the hops from the list for this callsign and pc no
1610 my $hops = $DXProt::hopcount{$pcno};
1611 $hops = $DXProt::def_hopcount if !$hops;
1616 # adjust the hop count on a per node basis using the user loadable
1617 # hop table if available or else decrement an existing one
1624 my $call = $self->{call};
1627 if (($hops) = $s =~ /\^H(\d+)\^~?$/o) {
1628 my ($pcno) = $s =~ /^PC(\d\d)/o;
1629 confess "$call called adjust_hops with '$s'" unless $pcno;
1630 my $ref = $nodehops{$call} if %nodehops;
1632 my $newhops = $ref->{$pcno};
1633 return "" if defined $newhops && $newhops == 0;
1634 $newhops = $ref->{default} unless $newhops;
1635 return "" if defined $newhops && $newhops == 0;
1636 $newhops = $hops if !$newhops;
1637 $s =~ s/\^H(\d+)(\^~?)$/\^H$newhops$2/ if $newhops;
1639 # simply decrement it
1641 return "" if !$hops;
1642 $s =~ s/\^H(\d+)(\^~?)$/\^H$hops$2/ if $hops;
1654 return $self->msg('lh1') unless -e "$main::data/hop_table.pl";
1655 do "$main::data/hop_table.pl";
1661 # add a ping request to the ping queues
1664 my ($from, $to) = @_;
1665 my $ref = $pings{$to} || [];
1668 $r->{t} = [ gettimeofday ];
1669 route(undef, $to, pc51($to, $main::mycall, 1));
1674 # add a rcmd request to the rcmd queues
1677 my ($self, $to, $cmd) = @_;
1680 $r->{call} = $self->{call};
1681 $r->{t} = $main::systime;
1685 my $ref = Route::Node::get($to);
1686 my $dxchan = $ref->dxchan;
1687 if ($dxchan && $dxchan->is_clx) {
1688 route(undef, $to, pc84($main::mycall, $to, $self->{call}, $cmd));
1690 route(undef, $to, pc34($main::mycall, $to, $cmd));
1697 my $pc39flag = shift;
1698 my $call = $self->call;
1700 unless ($pc39flag && $pc39flag == 1) {
1701 $self->send_now("D", DXProt::pc39($main::mycall, $self->msg('disc1', "System Op")));
1705 my $node = Route::Node::get($call);
1708 @rout = $node->del_nodes; # at the next level
1709 @rout = $node->del($main::routeroot);
1712 # unbusy and stop and outgoing mail
1713 my $mref = DXMsg::get_busy($call);
1714 $mref->stop_msg($call) if $mref;
1716 # broadcast to all other nodes that all the nodes connected to via me are gone
1717 unless ($pc39flag && $pc39flag == 2) {
1718 $self->route_pc21(@rout) if @rout;
1721 # remove outstanding pings
1722 delete $pings{$call};
1724 # I was the last node visited
1725 $self->user->node($main::mycall);
1727 # send info to all logged in thingies
1728 $self->tell_login('logoutn');
1730 Log('DXProt', $call . " Disconnected");
1732 $self->SUPER::disconnect;
1737 # send a talk message to this thingy
1741 my ($self, $from, $to, $via, $line) = @_;
1743 $line =~ s/\^/\\5E/g; # remove any ^ characters
1744 $self->send(DXProt::pc10($from, $to, $via, $line));
1745 Log('talk', $self->call, $from, $via?$via:$main::mycall, $line);
1748 # send it if it isn't the except list and isn't isolated and still has a hop count
1749 # taking into account filtering and so on
1753 my $generate = shift;
1754 my $no = shift; # the no of things to filter on
1756 my ($filter, $hops);
1759 for (; @_ && $no; $no--) {
1762 if ($self->{routefilter}) {
1765 ($filter, $hops) = $self->{routefilter}->it($self->{call}, $self->{dxcc}, $self->{itu}, $self->{cq}, $r->call, $r->dxcc, $r->itu, $r->cq);
1769 dbg("DXPROT: $self->{call}/" . $r->call . " rejected by output filter") if isdbg('chanerr');
1772 dbg("was sent a null value") if isdbg('chanerr');
1779 foreach my $line (&$generate(@rin, @_)) {
1782 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
1784 $routeit = adjust_hops($self, $line); # adjust its hop count by node name
1785 next unless $routeit;
1787 $self->send($routeit) if $self->{routefilter} || !$self->{isolate};
1795 my $generate = shift;
1796 my @dxchan = DXChannel::get_all_nodes();
1800 foreach $dxchan (@dxchan) {
1801 next if $dxchan == $self;
1802 next if $dxchan == $me;
1803 if ($dxchan->{routefilter} || !$self->{isolate}) {
1804 $dxchan->send_route($generate, @_)
1806 dbg('DXPROT: isolated') if isdbg('chanerr');
1814 broadcast_route($self, \&pc16, 1, @_);
1820 broadcast_route($self, \&pc17, 1, @_);
1826 broadcast_route($self, \&pc19, scalar @_, @_);
1832 broadcast_route($self, \&pc21, scalar @_, @_);
1838 broadcast_route($self, \&pc24, 1, @_);
1844 broadcast_route($self, \&pc41, 1, @_);
1850 broadcast_route($self, \&pc50, 1, @_);
1857 my ($filter, $hops) = (1, 1);
1859 if ($self->{inroutefilter}) {
1860 ($filter, $hops) = $self->{inroutefilter}->it($self->{call}, $self->{dxcc}, $self->{itu}, $self->{cq}, $r->call, $r->dxcc, $r->itu, $r->cq);
1861 dbg("PCPROT: $self->{call}/" . $r->call . ' rejected by in_filter_route') if !$filter && isdbg('chanerr');
1871 $s =~ s/\^H\d\d?\^?~?$//;
1872 return 1 if exists $eph{$s};
1873 $eph{$s} = $main::systime;
1881 while (($key, $val) = each %eph) {
1882 if ($main::systime - $val > 90) {