2 # Route Thingy handling
6 # Copyright (c) 2005 Dirk Koopman G1TLH
13 use vars qw($VERSION $BRANCH);
15 main::mkver($VERSION = q$Revision$);
29 unless ($thing->{Aranea}) {
31 $thing->{Aranea} = Aranea::genmsg($thing, 'RT', @items);
33 return $thing->{Aranea};
47 return $thing->{DXProt};
50 #sub gen_DXCommandmode
66 ($thing->{hops}) = $thing->{DXProt} =~ /\^H(\d+)\^?~?$/ if exists $thing->{DXProt};
76 my $sub = "handle_$thing->{t}";
77 if ($thing->can($sub)) {
79 $thing = $thing->$sub($dxchan);
82 $thing->broadcast($dxchan) if $thing;
91 if (my $d = $thing->{d}) {
94 my ($type, $here, $call) = unpack "A1 A1 A*", $_;
97 dbg("Thingy::Rt::ea need a node before $call");
100 add_user($nref, $call, $here);
101 my $h = $dxchan->{call} eq $nref->{call} ? 3 : ($thing->{hops} || 99);
102 RouteDB::update($call, $dxchan->{call}, $h);
103 } elsif ($type eq 'N') {
104 $nref = Route::Node::get($call);
106 dbg("Thingy::Rt::ea need a definition for $call");
109 my $h = $dxchan->{call} eq $nref->{call} ? 2 : ($thing->{hops} || 99);
110 RouteDB::update($nref->{call}, $dxchan->{call}, $h);
112 dbg("Thingy::Rt::ea invalid type $type");
125 if (my $d = $thing->{d}) {
127 for (split /:/, $d) {
128 my ($type, $here, $call) = unpack "A1 A1 A*", $_;
131 dbg("Thingy::Rt::ed need a node before $call");
134 $nref->del_user($call);
135 RouteDB::delete($call, $dxchan->{call});
136 } elsif ($type eq 'N') {
137 $nref = Route::Node::get($call);
139 dbg("Thingy::Rt::ed need a definition for $call");
142 RouteDB::update($nref->{call}, $dxchan->{call}, $dxchan->{call} eq $nref->{call} ? 2 : ($thing->{hops} || 99));
144 dbg("Thingy::Rt::ed invalid type $type");
157 # global route filtering on INPUT
158 if ($dxchan->{inroutefilter}) {
159 my $r = Route::Node::get($thing->{origin});
160 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});
162 dbg("PCPROT: Rejected by input route filter") if isdbg('chanerr');
174 # global route filtering on OUTPUT
175 if ($dxchan->{routefilter}) {
176 my $r = Route::Node::get($thing->{origin});
177 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});
179 dbg("PCPROT: Rejected by output route filter") if isdbg('chanerr');
182 $thing->{hops} = $hops if $hops;
183 } elsif ($dxchan->{isolate}) {
195 $node->add_user($user, $flag);
196 my $ur = upd_user_rec($user, $node);
203 my $parentcall = shift;
205 # add this station to the user database, if required
206 $call =~ s/-\d+$//o; # remove ssid for users
207 my $user = DXUser->get_current($call);
208 $user = DXUser->new($call) if !$user;
209 $user->homenode($parentcall) if !$user->homenode;
210 $user->node($parentcall);
211 $user->lastin($main::systime) unless DXChannel->get($call);