2 # Thingy Route Filter handling
4 # This to provide multiple inheritance to Routing entities
5 # that wish to do standard filtering
9 # Copyright (c) 2005 Dirk Koopman G1TLH
14 package Thingy::RouteFilter;
16 use vars qw($VERSION $BRANCH);
18 main::mkver($VERSION = q$Revision$);
34 my ($filter, $hops) = $dxchan->{routefilter}->it($dxchan->{call}, $dxchan->{dxcc}, $dxchan->{itu}, $dxchan->{cq}, $r->{call}, $r->{dxcc}, $r->{itu}, $r->{cq}, $dxchan->{state}, $r->{state});
35 push @out, $r if $filter;
44 push @out, DXProt::pc21(@{$thing->{fpc21n}}) if $thing->{fpc21n};
45 push @out, DXProt::pc17($thing->{fpc17n}, @{$thing->{pc17u}}) if $thing->{pc17u} && $thing->{fpc17n};
46 push @out, DXProt::pc19(@{$thing->{fpc19n}}) if $thing->{fpc19n};
47 push @out, DXProt::pc16($thing->{fpc16n}, @{$thing->{pc16u}}) if $thing->{pc16u} && $thing->{fpc16n};
56 # global route filtering on INPUT
57 if ($dxchan->{inroutefilter}) {
58 my $r = Route::Node::get($thing->{origin}) || Route->new($thing->{origin});
59 my ($filter, $hops) = $dxchan->{inroutefilter}->it($dxchan->{call}, $dxchan->{dxcc}, $dxchan->{itu}, $dxchan->{cq}, $r->{call}, $r->{dxcc}, $r->{itu}, $r->{cq}, $dxchan->{state}, $r->{state});
61 dbg("PCPROT: Rejected by input route filter") if isdbg('chanerr');
64 } elsif ($dxchan->{isolate} && $thing->{origin} ne $main::mycall) {
75 # global route filtering on OUTPUT
76 if ($dxchan->{routefilter}) {
77 my $r = Route::Node::get($thing->{origin});
78 my ($filter, $hops) = $dxchan->{routefilter}->it($dxchan->{call}, $dxchan->{dxcc}, $dxchan->{itu}, $dxchan->{cq}, $r->{call}, $r->{dxcc}, $r->{itu}, $r->{cq}, $dxchan->{state}, $r->{state});
80 dbg("PCPROT: Rejected by output route filter") if isdbg('chanerr');
84 if ($dxchan->isa('DXProt')) {
85 $thing->{hops} = $hops if $hops;
86 delete $thing->{fpc16n};
87 delete $thing->{fpc17n};
88 delete $thing->{fpc19n};
89 delete $thing->{fpc21n};
91 my @n16 = _filter($dxchan, $thing->{pc16n}) if $thing->{pc16u} && $thing->{pc16n};
92 $thing->{fpc16n} = $n16[0] if @n16;
93 my @n17 = _filter($dxchan, $thing->{pc17n}) if $thing->{pc17u} && $thing->{pc17n};
94 $thing->{fpc17n} = $n17[0] if @n17;
95 my @pc19 = _filter($dxchan, @{$thing->{pc19n}}) if $thing->{pc19n};
96 $thing->{fpc19n} = \@pc19 if @pc19;
97 my @pc21 = _filter($dxchan, @{$thing->{pc21n}}) if $thing->{pc21n};
98 $thing->{fpc21n} = \@pc21 if @pc21;
102 } elsif ($dxchan->{isolate}) {
103 return if $thing->{origin} ne $main::mycall;
105 if ($dxchan->isa('DXProt')) {
106 $thing->{fpc16n} ||= $thing->{pc16n};
107 $thing->{fpc17n} ||= $thing->{pc17n};
108 $thing->{fpc19n} ||= $thing->{pc18n};
109 $thing->{fpc21n} ||= $thing->{pc21n};