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$);
33 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});
34 return $filter ? $r : undef;
41 push @out, DXProt::pc21(@{$thing->{fpc21n}}) if $thing->{fpc21n};
42 push @out, DXProt::pc17($thing->{fpc17n}, @{$thing->{pc17u}}) if $thing->{fpc17n};
43 push @out, DXProt::pc19(@{$thing->{fpc19n}}) if $thing->{fpc19n};
44 push @out, DXProt::pc16($thing->{fpc16n}, @{$thing->{pc16u}}) if $thing->{fpc16n};
53 # global route filtering on INPUT
54 if ($dxchan->{inroutefilter}) {
55 my $r = Route::Node::get($thing->{origin}) || Route->new($thing->{origin});
56 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});
58 dbg("PCPROT: Rejected by input route filter") if isdbg('chanerr');
61 } elsif ($dxchan->{isolate} && $thing->{origin} ne $main::mycall) {
72 # global route filtering on OUTPUT
73 if ($dxchan->{routefilter}) {
74 my $r = Route::Node::get($thing->{origin});
75 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});
77 dbg("PCPROT: Rejected by output route filter") if isdbg('chanerr');
81 if ($dxchan->isa('DXProt')) {
82 $thing->{hops} = $hops if $hops;
83 delete $thing->{fpc16n};
84 delete $thing->{fpc17n};
85 delete $thing->{fpc19n};
86 delete $thing->{fpc21n};
88 $thing->{fpc16n} = _filter($dxchan, $thing->{pc16n}) if $thing->{pc16n};
89 $thing->{fpc17n} = _filter($dxchan, $thing->{pc17n}) if $thing->{pc17n};
90 $thing->{fpc19n} = [_filter($dxchan, @{$thing->{pc19n}})] if $thing->{pc19n};
91 $thing->{fpc21n} = [_filter($dxchan, @{$thing->{pc21n}})] if $thing->{pc21n};
95 } elsif ($dxchan->{isolate}) {
96 return if $thing->{origin} ne $main::mycall;
98 if ($dxchan->isa('DXProt')) {
99 $thing->{fpc16n} ||= $thing->{pc16n};
100 $thing->{fpc17n} ||= $thing->{pc17n};
101 $thing->{fpc19n} ||= $thing->{pc18n};
102 $thing->{fpc21n} ||= $thing->{pc21n};