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 push @items, 't', $thing->{t} if $thing->{t};
32 push @items, 'd', $thing->{d} if $thing->{d};
33 $thing->{Aranea} = Aranea::genmsg($thing, 'RT');
35 return $thing->{Aranea};
49 return $thing->{DXProt};
52 #sub gen_DXCommandmode
68 ($thing->{hops}) = $thing->{DXProt} =~ /\^H(\d+)\^?~?$/ if exists $thing->{DXProt};
78 my $sub = "handle_$thing->{t}";
79 if ($thing->can($sub)) {
81 $thing = $thing->$sub($dxchan);
84 $thing->broadcast($dxchan) if $thing;
93 if (my $d = $thing->{d}) {
96 my ($type, $here, $call) = unpack "A1 A1 A*", $_;
99 dbg("Thingy::Rt::ea need a node before $call");
102 add_user($nref, $call, $here);
103 my $h = $dxchan->{call} eq $nref->{call} ? 3 : ($thing->{hops} || 99);
104 RouteDB::update($call, $dxchan->{call}, $h);
105 } elsif ($type eq 'N') {
106 $nref = Route::Node::get($call);
108 dbg("Thingy::Rt::ea need a definition for $call");
111 my $h = $dxchan->{call} eq $nref->{call} ? 2 : ($thing->{hops} || 99);
112 RouteDB::update($nref->{call}, $dxchan->{call}, $h);
114 dbg("Thingy::Rt::ea invalid type $type");
127 if (my $d = $thing->{d}) {
129 for (split /:/, $d) {
130 my ($type, $here, $call) = unpack "A1 A1 A*", $_;
133 dbg("Thingy::Rt::edu need a node before $call");
136 my $uref = Route::User::get($call);
138 dbg("Thingy::Rt::edu $call not a user") if isdbg('chanerr');
141 $nref->del_user($uref);
142 RouteDB::delete($call, $dxchan->{call});
143 } elsif ($type eq 'N') {
144 $nref = Route::Node::get($call);
146 dbg("Thingy::Rt::ed need a definition for $call");
149 RouteDB::update($nref->{call}, $dxchan->{call}, $dxchan->{call} eq $nref->{call} ? 2 : ($thing->{hops} || 99));
151 dbg("Thingy::Rt::ed invalid type $type");
164 # global route filtering on INPUT
165 if ($dxchan->{inroutefilter}) {
166 my $r = Route::Node::get($thing->{origin});
167 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});
169 dbg("PCPROT: Rejected by input route filter") if isdbg('chanerr');
181 # global route filtering on OUTPUT
182 if ($dxchan->{routefilter}) {
183 my $r = Route::Node::get($thing->{origin});
184 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});
186 dbg("PCPROT: Rejected by output route filter") if isdbg('chanerr');
189 $thing->{hops} = $hops if $hops;
190 } elsif ($dxchan->{isolate}) {
202 $node->add_user($user, $flag);
203 my $ur = upd_user_rec($user, $node);
210 my $parentcall = shift;
212 # add this station to the user database, if required
213 $call =~ s/-\d+$//o; # remove ssid for users
214 my $user = DXUser->get_current($call);
215 $user = DXUser->new($call) if !$user;
216 $user->homenode($parentcall) if !$user->homenode;
217 $user->node($parentcall);
218 $user->lastin($main::systime) unless DXChannel->get($call);