2 # Route Thingy handling
6 # Copyright (c) 2005 Dirk Koopman G1TLH
13 use vars qw($VERSION $BRANCH);
14 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
15 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /^\d+\.\d+(?:\.(\d+)\.(\d+))?$/ || (0,0));
16 $main::build += $VERSION;
17 $main::branch += $BRANCH;
31 unless ($thing->{Aranea}) {
33 $thing->{Aranea} = Aranea::genmsg($thing, 'RT', @items);
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}) {
95 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");
118 dbg("Thingy::Rt::ea no node");
131 if (my $d = $thing->{d}) {
132 for (split /:/, $d) {
133 my ($type, $here, $call) = unpack "A1 A1 A*", $_;
137 dbg("Thingy::Rt::ed need a node before $call");
140 $nref->del_user($call);
141 RouteDB::delete($call, $dxchan->{call});
142 } elsif ($type eq 'N') {
143 $nref = Route::Node::get($call);
145 dbg("Thingy::Rt::ed need a definition for $call");
148 RouteDB::update($nref->{call}, $dxchan->{call}, $dxchan->{call} eq $nref->{call} ? 2 : ($thing->{hops} || 99));
150 dbg("Thingy::Rt::ed invalid type $type");
154 dbg("Thingy::Rt::ed no node");
167 # global route filtering on INPUT
168 if ($dxchan->{inroutefilter}) {
169 my $r = Route::Node::get($thing->{origin});
170 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});
172 dbg("PCPROT: Rejected by input route filter") if isdbg('chanerr');
184 # global route filtering on OUTPUT
185 if ($dxchan->{routefilter}) {
186 my $r = Route::Node::get($thing->{origin});
187 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});
189 dbg("PCPROT: Rejected by output route filter") if isdbg('chanerr');
192 $thing->{hops} = $hops if $hops;
193 } elsif ($dxchan->{isolate}) {
205 $node->add_user($user, $flag);
206 my $ur = upd_user_rec($user, $node);
213 my $parentcall = shift;
215 # add this station to the user database, if required
216 $call =~ s/-\d+$//o; # remove ssid for users
217 my $user = DXUser->get_current($call);
218 $user = DXUser->new($call) if !$user;
219 $user->homenode($parentcall) if !$user->homenode;
220 $user->node($parentcall);
221 $user->lastin($main::systime) unless DXChannel->get($call);