3 # This module impliments the protocal mode for a dx cluster
5 # Copyright (c) 1998 Dirk Koopman G1TLH
31 use vars qw($me $pc11_max_age $pc11_dup_age $pc23_dup_age
32 %spotdup %wwvdup $last_hour %pings %rcmds
33 %nodehops @baddx $baddxfn $pc12_dup_age
36 $me = undef; # the channel id for this cluster
37 $pc11_max_age = 1*3600; # the maximum age for an incoming 'real-time' pc11
38 $pc11_dup_age = 24*3600; # the maximum time to keep the spot dup list for
39 $pc23_dup_age = 24*3600; # the maximum time to keep the wwv dup list for
40 $pc12_dup_age = 24*3600; # the maximum time to keep the ann dup list for
41 %spotdup = (); # the pc11 and 26 dup hash
42 %wwvdup = (); # the pc23 and 27 dup hash
43 %anndup = (); # the PC12 dup hash
44 $last_hour = time; # last time I did an hourly periodic update
45 %pings = (); # outstanding ping requests outbound
46 %rcmds = (); # outstanding rcmd requests outbound
47 %nodehops = (); # node specific hop control
48 @baddx = (); # list of illegal spotted callsigns
50 $baddxfn = "$main::data/baddx.pl";
54 my $user = DXUser->get($main::mycall);
55 $DXProt::myprot_version += $main::version*100;
56 $me = DXProt->new($main::mycall, 0, $user);
58 $me->{state} = "indifferent";
59 do "$main::data/hop_table.pl" if -e "$main::data/hop_table.pl";
61 # $me->{sort} = 'M'; # M for me
63 # now prime the spot duplicates file with today's and yesterday's data
64 my @today = Julian::unixtoj(time);
65 my @spots = Spot::readfile(@today);
66 @today = Julian::sub(@today, 1);
67 push @spots, Spot::readfile(@today);
69 my $dupkey = "$_->[0]$_->[1]$_->[2]$_->[3]$_->[4]";
70 $spotdup{$dupkey} = $_->[2];
73 # now prime the wwv duplicates file with just this month's data
74 my @wwv = Geomag::readfile(time);
76 my $dupkey = "$_->[1].$_->[2]$_->[3]$_->[4]";
77 $wwvdup{$dupkey} = $_->[1];
81 do "$baddxfn" if -e "$baddxfn";
86 # obtain a new connection this is derived from dxchannel
91 my $self = DXChannel::alloc(@_);
92 $self->{'sort'} = 'A'; # in absence of how to find out what sort of an object I am
96 # this is how a pc connection starts (for an incoming connection)
97 # issue a PC38 followed by a PC18, then wait for a PC20 (remembering
98 # all the crap that comes between).
101 my ($self, $line, $sort) = @_;
102 my $call = $self->{call};
103 my $user = $self->{user};
105 # remember type of connection
106 $self->{consort} = $line;
107 $self->{outbound} = $sort eq 'O';
108 $self->{priv} = $user->priv;
109 $self->{lang} = $user->lang;
110 $self->{isolate} = $user->{isolate};
111 $self->{consort} = $line; # save the connection type
115 $self->{spotfilter} = Filter::read_in('spots', $call);
116 $self->{wwvfilter} = Filter::read_in('wwv', $call);
117 $self->{annfilter} = Filter::read_in('ann', $call);
119 # set unbuffered and no echo
120 $self->send_now('B',"0");
121 $self->send_now('E',"0");
123 # send initialisation string
124 if (!$self->{outbound}) {
125 $self->send(pc38()) if DXNode->get_all();
128 $self->state('init');
131 Log('DXProt', "$call connected");
135 # This is the normal pcxx despatcher
139 my ($self, $line) = @_;
140 my @field = split /\^/, $line;
141 pop @field if $field[-1] eq '~';
143 # print join(',', @field), "\n";
145 # ignore any lines that don't start with PC
146 return if !$field[0] =~ /^PC/;
149 my ($pcno) = $field[0] =~ /^PC(\d\d)/; # just get the number
151 return if $pcno < 10 || $pcno > 51;
156 $pcr = Local::pcprot($self, $pcno, @field);
158 # dbg('local', "Local::pcprot error $@") if $@;
162 if ($pcno == 10) { # incoming talk
164 # is it for me or one of mine?
165 my $call = ($field[5] gt ' ') ? $field[5] : $field[2];
166 if ($call eq $main::mycall || grep $_ eq $call, get_all_user_calls()) {
169 my $text = unpad($field[3]);
170 Log('talk', $call, $field[1], $field[6], $text);
171 $call = $main::myalias if $call eq $main::mycall;
172 my $ref = DXChannel->get($call);
173 $ref->send("$call de $field[1]: $text") if $ref && $ref->{talk};
175 route($field[2], $line); # relay it on its way
180 if ($pcno == 11 || $pcno == 26) { # dx spot
182 # route 'foreign' pc26s
184 if ($field[7] ne $main::mycall) {
185 route($field[7], $line);
190 # if this is a 'nodx' node then ignore it
191 last SWITCH if grep $field[7] =~ /^$_/, @DXProt::nodx_node;
193 # convert the date to a unix date
194 my $d = cltounix($field[3], $field[4]);
195 # bang out (and don't pass on) if date is invalid or the spot is too old (or too young)
196 if (!$d || ($pcno == 11 && ($d < $main::systime - $pc11_max_age || $d > $main::systime + 900))) {
197 dbg('chan', "Spot ignored, invalid date or out of range ($field[3] $field[4])\n");
201 # strip off the leading & trailing spaces from the comment
202 my $text = unpad($field[5]);
205 my $spotter = $field[6];
206 $spotter =~ s/-\d+$//o; # strip off the ssid from the spotter
209 my $freq = $field[1] - 0;
210 my $dupkey = "$freq$field[2]$d$text$spotter";
211 if ($spotdup{$dupkey}) {
212 dbg('chan', "Duplicate Spot ignored\n");
216 $spotdup{$dupkey} = $d;
219 if (grep $field[2] eq $_, @baddx) {
220 dbg('chan', "Bad DX spot, ignored");
224 my @spot = Spot::add($freq, $field[2], $d, $text, $spotter, $field[7]);
227 # @spot at this point contains:-
228 # freq, spotted call, time, text, spotter, spotted cc, spotters cc, orig node
229 # then spotted itu, spotted cq, spotters itu, spotters cq
230 # you should be able to route on any of these
236 $r = Local::spot($self, @spot);
238 # dbg('local', "Local::spot1 error $@") if $@;
241 # DON'T be silly and send on PC26s!
242 return if $pcno == 26;
244 # send out the filtered spots
245 send_dx_spot($self, $line, @spot) if @spot;
249 if ($pcno == 12) { # announces
250 # announce duplicate checking
251 my $text = uc unpad($field[3]);
252 my $dupkey = $field[1].$field[2].$text.$field[4].$field[6];
253 if ($anndup{$dupkey}) {
254 dbg('chan', "Duplicate Announce ignored\n");
257 $anndup{$dupkey} = $main::systime;
259 # global ann filtering
260 my ($filter, $hops) = Filter::it($self->{annfilter}, @field[1..6], $self->{call} ) if $self->{annfilter};
261 if ($self->{annfilter} && !$filter) {
262 dbg('chan', "Rejected by filter");
266 if ($field[2] eq '*' || $field[2] eq $main::mycall) {
268 # strip leading and trailing stuff
269 my $text = unpad($field[3]);
274 if ($field[4] eq '*') { # sysops
276 @list = map { $_->priv >= 5 ? $_ : () } get_all_users();
277 } elsif ($field[4] gt ' ') { # speciality list handling
278 my ($name) = split /\./, $field[4];
279 $target = "$name"; # put the rest in later (if bothered)
282 if ($field[6] eq '1') {
286 $target = "All" if !$target;
289 broadcast_list("$to$target de $field[1]: $text", 'ann', undef, @list);
291 broadcast_users("$target de $field[1]: $text", 'ann', undef);
293 Log('ann', $target, $field[1], $text);
295 return if $field[2] eq $main::mycall; # it's routed to me
297 route($field[2], $line);
298 return; # only on a routed one
314 if ($pcno == 16) { # add a user
315 my $node = DXCluster->get_exact($field[1]);
316 return unless $node; # ignore if havn't seen a PC19 for this one yet
317 return unless $node->isa('DXNode');
318 if ($node->dxchan != $self) {
319 dbg('chan', "LOOP: $field[1] came in on wrong channel");
323 if (($dxchan = DXChannel->get($field[1])) && $dxchan != $self) {
324 dbg('chan', "LOOP: $field[1] connected locally");
330 for ($i = 2; $i < $#field; $i++) {
331 my ($call, $confmode, $here) = $field[$i] =~ /^(\S+) (\S) (\d)/o;
332 next if !$call || length $call < 3 || length $call > 8;
335 next if DXCluster->get_exact($call); # we already have this (loop?)
337 $confmode = $confmode eq '*';
338 DXNodeuser->new($self, $node, $call, $confmode, $here);
340 # add this station to the user database, if required
341 $call =~ s/-\d+$//o; # remove ssid for users
342 my $user = DXUser->get_current($call);
343 $user = DXUser->new($call) if !$user;
344 $user->homenode($node->call) if !$user->homenode;
345 $user->node($node->call);
346 $user->lastin($main::systime) unless DXChannel->get($call);
350 # queue up any messages (look for privates only)
351 DXMsg::queue_msg(1) if $self->state eq 'normal';
355 if ($pcno == 17) { # remove a user
356 my $node = DXCluster->get_exact($field[2]);
358 return unless $node->isa('DXNode');
359 if ($node->dxchan != $self) {
360 dbg('chan', "LOOP: $field[2] came in on wrong channel");
364 if (($dxchan = DXChannel->get($field[2])) && $dxchan != $self) {
365 dbg('chan', "LOOP: $field[2] connected locally");
368 my $ref = DXCluster->get_exact($field[1]);
373 if ($pcno == 18) { # link request
374 $self->state('init');
376 # first clear out any nodes on this dxchannel
377 my @gonenodes = map { $_->dxchan == $self ? $_ : () } DXNode::get_all();
378 foreach my $node (@gonenodes) {
379 next if $node->dxchan == $DXProt::me;
380 broadcast_ak1a(pc21($node->call, 'Gone, re-init') , $self) unless $self->{isolate};
383 $self->send_local_config();
385 return; # we don't pass these on
388 if ($pcno == 19) { # incoming cluster list
390 my $newline = "PC19^";
391 for ($i = 1; $i < $#field-1; $i += 4) {
392 my $here = $field[$i];
393 my $call = uc $field[$i+1];
394 my $confmode = $field[$i+2];
395 my $ver = $field[$i+3];
397 $ver = 5400 if !$ver && $allowzero;
399 # now check the call over
400 my $node = DXCluster->get_exact($call);
403 if (($dxchan = DXChannel->get($call)) && $dxchan != $self) {
404 dbg('chan', "LOOP: $call connected locally");
406 if ($node->dxchan != $self) {
407 dbg('chan', "LOOP: $call come in on wrong channel");
410 dbg('chan', "already have $call");
414 # check for sane parameters
415 next if $ver < 5000; # only works with version 5 software
416 next if length $call < 3; # min 3 letter callsigns
418 # add it to the nodes table and outgoing line
419 $newline .= "$here^$call^$confmode^$ver^";
420 DXNode->new($self, $call, $confmode, $here, $ver);
422 # unbusy and stop and outgoing mail (ie if somehow we receive another PC19 without a disconnect)
423 my $mref = DXMsg::get_busy($call);
424 $mref->stop_msg($call) if $mref;
426 # add this station to the user database, if required (don't remove SSID from nodes)
427 my $user = DXUser->get_current($call);
429 $user = DXUser->new($call);
431 $user->priv(1); # I have relented and defaulted nodes
432 $self->{priv} = 1; # to user RCMDs allowed
433 $user->homenode($call);
436 $user->lastin($main::systime) unless DXChannel->get($call);
440 return if $newline eq "PC19^";
443 $newline .= get_hops(19) . "^";
448 if ($pcno == 20) { # send local configuration
449 $self->send_local_config();
451 $self->state('normal');
455 if ($pcno == 21) { # delete a cluster from the list
456 my $call = uc $field[1];
457 if ($call ne $main::mycall) { # don't allow malicious buggers to disconnect me!
458 my $node = DXCluster->get_exact($call);
460 if ($node->dxchan != $self) {
461 dbg('chan', "LOOP: $call come in on wrong channel");
465 if (($dxchan = DXChannel->get($call)) && $dxchan != $self) {
466 dbg('chan', "LOOP: $call connected locally");
471 dbg('chan', "$call not in table, dropped");
479 $self->state('normal');
483 if ($pcno == 23 || $pcno == 27) { # WWV info
485 # route 'foreign' pc27s
487 if ($field[8] ne $main::mycall) {
488 route($field[8], $line);
494 my $d = cltounix($field[1], sprintf("%02d18Z", $field[2]));
495 my $sfi = unpad($field[3]);
496 my $k = unpad($field[4]);
497 my $i = unpad($field[5]);
498 my $dupkey = "$d.$sfi$k$i";
499 if ($wwvdup{$dupkey}) {
500 dbg('chan', "Dup WWV Spot ignored\n");
503 if ($d > $main::systime + 900 || $field[2] < 0 || $field[2] > 23) {
504 dbg('chan', "WWV Date ($field[1] $field[2]) out of range");
507 $wwvdup{$dupkey} = $d;
508 $field[6] =~ s/-\d+$//o; # remove spotter's ssid
510 my $wwv = Geomag::update($d, $field[2], $sfi, $k, $i, @field[6..8]);
514 $r = Local::wwv($self, $field[1], $field[2], $sfi, $k, $i, @field[6..8]);
516 # dbg('local', "Local::wwv2 error $@") if $@;
519 # DON'T be silly and send on PC27s!
520 return if $pcno == 27;
522 # broadcast to the eager world
523 send_wwv_spot($self, $line, $d, $field[2], $sfi, $k, $i, @field[6..8]);
527 if ($pcno == 24) { # set here status
528 my $call = uc $field[1];
529 my $ref = DXCluster->get_exact($call);
530 $ref->here($field[2]) if $ref;
534 if ($pcno == 25) { # merge request
535 if ($field[1] ne $main::mycall) {
536 route($field[1], $line);
539 if ($field[2] eq $main::mycall) {
540 dbg('chan', "Trying to merge to myself, ignored");
544 Log('DXProt', "Merge request for $field[3] spots and $field[4] WWV from $field[1]");
548 my @in = reverse Spot::search(1, undef, undef, 0, $field[3]-1);
551 $self->send(pc26(@{$in}[0..4], $field[2]));
557 my @in = reverse Geomag::search(0, $field[4], time, 1);
560 $self->send(pc27(@{$in}[0..5], $field[2]));
566 if (($pcno >= 28 && $pcno <= 33) || $pcno == 40 || $pcno == 42 || $pcno == 49) { # mail/file handling
567 if ($pcno == 49 || $field[1] eq $main::mycall) {
568 DXMsg::process($self, $line);
570 route($field[1], $line);
575 if ($pcno == 34 || $pcno == 36) { # remote commands (incoming)
576 if ($field[1] eq $main::mycall) {
577 my $ref = DXUser->get_current($field[2]);
578 my $cref = DXCluster->get($field[2]);
579 Log('rcmd', 'in', $ref->{priv}, $field[2], $field[3]);
580 unless ($field[3] =~ /rcmd/i || !$cref || !$ref || $cref->mynode->call ne $ref->homenode) { # not allowed to relay RCMDS!
581 if ($ref->{priv}) { # you have to have SOME privilege, the commands have further filtering
582 $self->{remotecmd} = 1; # for the benefit of any command that needs to know
583 my $oldpriv = $self->{priv};
584 $self->{priv} = $ref->{priv}; # assume the user's privilege level
585 my @in = (DXCommandmode::run_cmd($self, $field[3]));
586 $self->{priv} = $oldpriv;
589 $self->send(pc35($main::mycall, $field[2], "$main::mycall:$_"));
590 Log('rcmd', 'out', $field[2], $_);
592 delete $self->{remotecmd};
594 $self->send(pc35($main::mycall, $field[2], "$main::mycall:sorry...!"));
597 $self->send(pc35($main::mycall, $field[2], "$main::mycall:your attempt is logged, Tut tut tut...!"));
600 route($field[1], $line);
605 if ($pcno == 35) { # remote command replies
606 if ($field[1] eq $main::mycall) {
607 my $s = $rcmds{$field[2]};
609 my $dxchan = DXChannel->get($s->{call});
610 $dxchan->send($field[3]) if $dxchan;
611 delete $rcmds{$field[2]} if !$dxchan;
614 route($field[1], $line);
619 # for pc 37 see 44 onwards
621 if ($pcno == 38) { # node connected list from neighbour
625 if ($pcno == 39) { # incoming disconnect
630 if ($pcno == 41) { # user info
631 # add this station to the user database, if required
632 my $user = DXUser->get_current($field[1]);
634 # then try without an SSID
635 $field[1] =~ s/-\d+$//o;
636 $user = DXUser->get_current($field[1]);
638 $user = DXUser->new($field[1]) if !$user;
640 if ($field[2] == 1) {
641 $user->name($field[3]);
642 } elsif ($field[2] == 2) {
643 $user->qth($field[3]);
644 } elsif ($field[2] == 3) {
645 my ($lat, $long) = DXBearing::stoll($field[3]);
648 } elsif ($field[2] == 4) {
649 $user->homenode($field[3]);
657 if ($pcno == 37 || $pcno == 44 || $pcno == 45 || $pcno == 46 || $pcno == 47) {
658 if ($field[1] eq $main::mycall) {
661 route($field[1], $line);
666 if ($pcno == 50) { # keep alive/user list
667 my $node = DXCluster->get_exact($field[1]);
669 return unless $node->isa('DXNode');
670 return unless $node->dxchan == $self;
671 $node->update_users($field[2]);
676 if ($pcno == 51) { # incoming ping requests/answers
679 if ($field[1] eq $main::mycall) {
680 my $flag = $field[3];
682 $self->send(pc51($field[2], $field[1], '0'));
684 # it's a reply, look in the ping list for this one
685 my $ref = $pings{$field[2]};
688 my $dxchan = DXChannel->get($r->{call});
689 $dxchan->send($dxchan->msg('pingi', $field[2], atime($main::systime), $main::systime - $r->{t})) if $dxchan;
694 # route down an appropriate thingy
695 route($field[1], $line);
701 # if get here then rebroadcast the thing with its Hop count decremented (if
702 # there is one). If it has a hop count and it decrements to zero then don't
705 # NOTE - don't arrive here UNLESS YOU WANT this lump of protocol to be
709 if (!$self->{isolate}) {
710 broadcast_ak1a($line, $self); # send it to everyone but me
715 # This is called from inside the main cluster processing loop and is used
716 # for despatching commands that are doing some long processing job
721 my @dxchan = DXChannel->get_all();
724 foreach $dxchan (@dxchan) {
725 next unless $dxchan->is_ak1a();
726 next if $dxchan == $me;
728 # send a pc50 out on this channel
729 if ($t >= $dxchan->pc50_t + $DXProt::pc50_interval) {
730 $dxchan->send(pc50());
738 if ($main::systime - 3600 > $last_hour) {
739 $cutoff = $main::systime - $pc11_dup_age;
740 while (($key, $val) = each %spotdup) {
741 delete $spotdup{$key} if $val < $cutoff;
743 $cutoff = $main::systime - $pc23_dup_age;
744 while (($key, $val) = each %wwvdup) {
745 delete $wwvdup{$key} if $val < $cutoff;
747 $cutoff = $main::systime - $pc12_dup_age;
748 while (($key, $val) = each %anndup) {
749 delete $anndup{$key} if $val < $cutoff;
751 $last_hour = $main::systime;
756 # finish up a pc context
761 my $call = $self->call;
762 my $ref = DXCluster->get_exact($call);
764 # unbusy and stop and outgoing mail
765 my $mref = DXMsg::get_busy($call);
766 $mref->stop_msg($call) if $mref;
768 # broadcast to all other nodes that all the nodes connected to via me are gone
769 my @gonenodes = map { $_->dxchan == $self ? $_ : () } DXNode::get_all();
772 foreach $node (@gonenodes) {
773 next if $node->call eq $call;
774 broadcast_ak1a(pc21($node->call, 'Gone') , $self) unless $self->{isolate};
778 # remove outstanding pings
779 delete $pings{$call};
781 # now broadcast to all other ak1a nodes that I have gone
782 broadcast_ak1a(pc21($call, 'Gone.'), $self) unless $self->{isolate};
784 Log('DXProt', $call . " Disconnected");
789 # some active measures
795 my @dxchan = DXChannel->get_all();
798 # send it if it isn't the except list and isn't isolated and still has a hop count
799 # taking into account filtering and so on
800 foreach $dxchan (@dxchan) {
802 my ($filter, $hops) = Filter::it($dxchan->{spotfilter}, @_, $self->{call} ) if $dxchan->{spotfilter};
803 if ($dxchan->is_ak1a) {
804 next if $dxchan == $self;
807 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
809 $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name
810 next unless $routeit;
813 $dxchan->send($routeit) if $routeit;
815 $dxchan->send($routeit) unless $dxchan->{isolate} || $self->{isolate};
818 } elsif ($dxchan->is_user && $dxchan->{dx}) {
819 my $buf = Spot::formatb($_[0], $_[1], $_[2], $_[3], $_[4]);
820 $buf .= "\a\a" if $dxchan->{beep};
821 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'convers') {
822 $dxchan->send($buf) if !$hops || ($hops && $filter);
824 $dxchan->delay($buf) if !$hops || ($hops && $filter);
834 my @dxchan = DXChannel->get_all();
837 # send it if it isn't the except list and isn't isolated and still has a hop count
838 # taking into account filtering and so on
839 foreach $dxchan (@dxchan) {
841 my ($filter, $hops) = Filter::it($dxchan->{wwvfilter}, @_, $self->{call} ) if $dxchan->{wwvfilter};
842 if ($dxchan->is_ak1a) {
843 next if $dxchan == $self;
846 $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
848 $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name
849 next unless $routeit;
852 $dxchan->send($routeit) if $routeit;
854 $dxchan->send($routeit) unless $dxchan->{isolate} || $self->{isolate};
857 } elsif ($dxchan->is_user && $dxchan->{wwv}) {
858 my $buf = "WWV de $_[6] <$_[1]>: SFI=$_[2], A=$_[3], K=$_[4], $_[5]";
859 $buf .= "\a\a" if $dxchan->{beep};
860 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'convers') {
861 $dxchan->send($buf) if !$hops || ($hops && $filter);
863 $dxchan->delay($buf) if !$hops || ($hops && $filter);
869 sub send_local_config
878 if ($self->{isolate}) {
879 @localnodes = (DXCluster->get_exact($main::mycall));
881 # create a list of all the nodes that are not connected to this connection
882 # and are not themselves isolated, this to make sure that isolated nodes
883 # don't appear outside of this node
884 @nodes = DXNode::get_all();
885 @nodes = grep { $_->{call} ne $main::mycall } @nodes;
886 @nodes = grep { $_->dxchan != $self } @nodes if @nodes;
887 @nodes = grep { !$_->dxchan->{isolate} } @nodes if @nodes;
888 @localnodes = grep { $_->dxchan->{call} eq $_->{call} } @nodes if @nodes;
889 unshift @localnodes, DXCluster->get_exact($main::mycall);
890 @remotenodes = grep { $_->dxchan->{call} ne $_->{call} } @nodes if @nodes;
893 my @s = $me->pc19(@localnodes, @remotenodes);
895 my $routeit = adjust_hops($self, $_);
896 $self->send($routeit) if $routeit;
899 # get all the users connected on the above nodes and send them out
900 foreach $n (@localnodes, @remotenodes) {
901 my @users = values %{$n->list};
902 my @s = pc16($n, @users);
904 my $routeit = adjust_hops($self, $_);
905 $self->send($routeit) if $routeit;
911 # route a message down an appropriate interface for a callsign
913 # is called route(to, pcline);
917 my ($call, $line) = @_;
918 my $cl = DXCluster->get_exact($call);
921 my $dxchan = $cl->{dxchan};
923 my $routeit = adjust_hops($dxchan, $line); # adjust its hop count by node name
925 $dxchan->send($routeit) if $dxchan;
931 # broadcast a message to all clusters taking into account isolation
932 # [except those mentioned after buffer]
935 my $s = shift; # the line to be rebroadcast
936 my @except = @_; # to all channels EXCEPT these (dxchannel refs)
937 my @dxchan = get_all_ak1a();
940 # send it if it isn't the except list and isn't isolated and still has a hop count
941 foreach $dxchan (@dxchan) {
942 next if grep $dxchan == $_, @except;
943 my $routeit = adjust_hops($dxchan, $s); # adjust its hop count by node name
944 $dxchan->send($routeit) unless $dxchan->{isolate} || !$routeit;
948 # broadcast a message to all clusters ignoring isolation
949 # [except those mentioned after buffer]
950 sub broadcast_all_ak1a
952 my $s = shift; # the line to be rebroadcast
953 my @except = @_; # to all channels EXCEPT these (dxchannel refs)
954 my @dxchan = get_all_ak1a();
957 # send it if it isn't the except list and isn't isolated and still has a hop count
958 foreach $dxchan (@dxchan) {
959 next if grep $dxchan == $_, @except;
960 my $routeit = adjust_hops($dxchan, $s); # adjust its hop count by node name
961 $dxchan->send($routeit);
965 # broadcast to all users
966 # storing the spot or whatever until it is in a state to receive it
969 my $s = shift; # the line to be rebroadcast
970 my $sort = shift; # the type of transmission
971 my $fref = shift; # a reference to an object to filter on
972 my @except = @_; # to all channels EXCEPT these (dxchannel refs)
973 my @dxchan = get_all_users();
977 foreach $dxchan (@dxchan) {
978 next if grep $dxchan == $_, @except;
981 broadcast_list($s, $sort, $fref, @out);
984 # broadcast to a list of users
992 foreach $dxchan (@_) {
996 next unless $dxchan->{dx};
997 ($filter) = Filter::it($dxchan->{spotfilter}, @{$fref}) if ref $fref;
1000 next if $sort eq 'ann' && !$dxchan->{ann};
1001 next if $sort eq 'wwv' && !$dxchan->{wwv};
1002 next if $sort eq 'wx' && !$dxchan->{wx};
1004 $s =~ s/\a//og unless $dxchan->{beep};
1006 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'convers') {
1015 # gimme all the ak1a nodes
1019 my @list = DXChannel->get_all();
1022 foreach $ref (@list) {
1023 push @out, $ref if $ref->is_ak1a;
1028 # return a list of all users
1031 my @list = DXChannel->get_all();
1034 foreach $ref (@list) {
1035 push @out, $ref if $ref->is_user;
1040 # return a list of all user callsigns
1041 sub get_all_user_calls
1043 my @list = DXChannel->get_all();
1046 foreach $ref (@list) {
1047 push @out, $ref->call if $ref->is_user;
1053 # obtain the hops from the list for this callsign and pc no
1059 my $hops = $DXProt::hopcount{$pcno};
1060 $hops = $DXProt::def_hopcount if !$hops;
1065 # adjust the hop count on a per node basis using the user loadable
1066 # hop table if available or else decrement an existing one
1073 my $call = $self->{call};
1076 if (($hops) = $s =~ /\^H(\d+)\^~?$/o) {
1077 my ($pcno) = $s =~ /^PC(\d\d)/o;
1078 confess "$call called adjust_hops with '$s'" unless $pcno;
1079 my $ref = $nodehops{$call} if %nodehops;
1081 my $newhops = $ref->{$pcno};
1082 return "" if defined $newhops && $newhops == 0;
1083 $newhops = $ref->{default} unless $newhops;
1084 return "" if defined $newhops && $newhops == 0;
1085 $newhops = $hops if !$newhops;
1086 $s =~ s/\^H(\d+)(\^~?)$/\^H$newhops$2/ if $newhops;
1088 # simply decrement it
1090 return "" if !$hops;
1091 $s =~ s/\^H(\d+)(\^~?)$/\^H$hops$2/ if $hops;
1103 return $self->msg('lh1') unless -e "$main::data/hop_table.pl";
1104 do "$main::data/hop_table.pl";
1109 # remove leading and trailing spaces from an input string
1113 $s =~ s/^\s+|\s+$//;
1117 # add a ping request to the ping queues
1120 my ($from, $to) = @_;
1121 my $ref = $pings{$to};
1122 $ref = $pings{$to} = [] if !$ref;
1125 $r->{t} = $main::systime;
1126 route($to, pc51($to, $main::mycall, 1));
1130 # add a rcmd request to the rcmd queues
1133 my ($from, $to, $cmd) = @_;
1136 $r->{t} = $main::systime;
1138 route($to, pc34($main::mycall, $to, $cmd));