stop the routing of messages back down the same interface
[spider.git] / perl / DXProt.pm
index 7f2aaba82c415a1053fe572f34704dd46539de63..04f2aff75d7efcc0b3bab3990e7ccc3374e0c2e4 100644 (file)
@@ -1225,6 +1225,19 @@ sub send_wwv_spot
        my $line = shift;
        my @dxchan = DXChannel->get_all();
        my $dxchan;
+       my ($wwv_dxcc, $wwv_itu, $wwv_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
+       my @dxcc = Prefix::extract($_[7]);
+       if (@dxcc > 0) {
+               $wwv_dxcc = $dxcc[1]->dxcc;
+               $wwv_itu = $dxcc[1]->itu;
+               $wwv_cq = $dxcc[1]->cq;                                         
+       }
+       @dxcc = Prefix::extract($_[8]);
+       if (@dxcc > 0) {
+               $org_dxcc = $dxcc[1]->dxcc;
+               $org_itu = $dxcc[1]->itu;
+               $org_cq = $dxcc[1]->cq;                                         
+       }
        
        # send it if it isn't the except list and isn't isolated and still has a hop count
        # taking into account filtering and so on
@@ -1233,7 +1246,7 @@ sub send_wwv_spot
                my ($filter, $hops);
 
                if ($dxchan->{wwvfilter}) {
-                        ($filter, $hops) = $dxchan->{wwvfilter}->it(@_, $self->{call} );
+                       ($filter, $hops) = $dxchan->{wwvfilter}->it(@_, $self->{call}, $wwv_dxcc, $wwv_itu, $wwv_cq, $org_dxcc, $org_itu, $org_cq);
                         next unless $filter;
                }
                if ($dxchan->is_node) {
@@ -1269,6 +1282,19 @@ sub send_wcy_spot
        my $line = shift;
        my @dxchan = DXChannel->get_all();
        my $dxchan;
+       my ($wcy_dxcc, $wcy_itu, $wcy_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
+       my @dxcc = Prefix::extract($_[11]);
+       if (@dxcc > 0) {
+               $wcy_dxcc = $dxcc[1]->dxcc;
+               $wcy_itu = $dxcc[1]->itu;
+               $wcy_cq = $dxcc[1]->cq;                                         
+       }
+       @dxcc = Prefix::extract($_[12]);
+       if (@dxcc > 0) {
+               $org_dxcc = $dxcc[1]->dxcc;
+               $org_itu = $dxcc[1]->itu;
+               $org_cq = $dxcc[1]->cq;                                         
+       }
        
        # send it if it isn't the except list and isn't isolated and still has a hop count
        # taking into account filtering and so on
@@ -1277,7 +1303,7 @@ sub send_wcy_spot
                my ($filter, $hops);
 
                if ($dxchan->{wcyfilter}) {
-                        ($filter, $hops) = $dxchan->{wcyfilter}->it(@_, $self->{call} );
+                       ($filter, $hops) = $dxchan->{wcyfilter}->it(@_, $self->{call}, $wcy_dxcc, $wcy_itu, $wcy_cq, $org_dxcc, $org_itu, $org_cq);
                         next unless $filter;
                }
                if ($dxchan->is_clx || $dxchan->is_spider || $dxchan->is_dxnet) {
@@ -1328,10 +1354,25 @@ sub send_announce
                $target = "WX"; 
                $to = '';
        }
-       $target = "All" if !$target;
+       $target = "ALL" if !$target;
        
        Log('ann', $target, $_[0], $text);
 
+       # obtain country codes etc 
+       my ($ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
+       my @dxcc = Prefix::extract($_[0]);
+       if (@dxcc > 0) {
+               $ann_dxcc = $dxcc[1]->dxcc;
+               $ann_itu = $dxcc[1]->itu;
+               $ann_cq = $dxcc[1]->cq;                                         
+       }
+       @dxcc = Prefix::extract($_[4]);
+       if (@dxcc > 0) {
+               $org_dxcc = $dxcc[1]->dxcc;
+               $org_itu = $dxcc[1]->itu;
+               $org_cq = $dxcc[1]->cq;                                         
+       }
+
        # send it if it isn't the except list and isn't isolated and still has a hop count
        # taking into account filtering and so on
        foreach $dxchan (@dxchan) {
@@ -1339,19 +1380,6 @@ sub send_announce
                my ($filter, $hops);
 
                if ($dxchan->{annfilter}) {
-                       my ($ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
-                       my @dxcc = Prefix::extract($_[0]);
-                       if (@dxcc > 0) {
-                               $ann_dxcc = $dxcc[1]->dxcc;
-                               $ann_itu = $dxcc[1]->itu;
-                               $ann_cq = $dxcc[1]->cq;                                         
-                       }
-                       @dxcc = Prefix::extract($_[4]);
-                       if (@dxcc > 0) {
-                               $org_dxcc = $dxcc[1]->dxcc;
-                               $org_itu = $dxcc[1]->itu;
-                               $org_cq = $dxcc[1]->cq;                                         
-                       }
                        ($filter, $hops) = $dxchan->{annfilter}->it(@_, $self->{call}, $ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq);
                        next unless $filter;
                } 
@@ -1447,12 +1475,18 @@ sub route
        unless ($dxchan) {
                my $cl = DXCluster->get_exact($call);
                $dxchan = $cl->dxchan if $cl;
+               if ($dxchan eq $self) {
+                       dbg('chan', "PCPROT: Trying to route back to source, dropped");
+                       return;
+               }
        }
        if ($dxchan) {
                my $routeit = adjust_hops($dxchan, $line);   # adjust its hop count by node name
                if ($routeit) {
                        $dxchan->send($routeit);
                }
+       } else {
+               dbg('chan', "PCPROT: No route available, dropped");
        }
 }