my $i;
- my @rout;
+ my $rout;
for ($i = 2; $i < $#_; $i++) {
my ($call, $conf, $here) = $_[$i] =~ /^(\S+) (\S) (\d)/o;
next unless $call && $conf && defined $here && is_callsign($call);
eph_del_regex("^PC17\\^$call\\^$ncall");
- $conf = 1;
-
- my $r = Route::User::get($call);
- my $flags = Route::here($here)|Route::conf($conf);
-
- if ($r) {
- my $au = $r->addparent($parent);
- if ($r->flags != $flags) {
- $r->flags($flags);
- $au = $r;
- }
- push @rout, $r if $au;
- } else {
- push @rout, $parent->add_user($call, $flags);
- }
-
-
- # add this station to the user database, if required
- $call =~ s/-\d+$//o; # remove ssid for users
- my $user = DXUser->get_current($call);
- $user = DXUser->new($call) if !$user;
- $user->homenode($parent->call) if !$user->homenode;
- $user->node($parent->call);
- $user->lastin($main::systime) unless DXChannel->get($call);
- $user->put;
+ my $flags = $here ? 1 : 0;
+ $rout .= ":U$flags$call";
}
+
- if (@rout) {
- my $thing = Thingy::Rt->new(origin=>$main::mycall);
- $thing->from_DXProt(t=>'ea', n=>$ncall, u=>join(':',map {"$_->{flags}$_->{call}"} @rout), DXProt=>$line);
+ if ($rout) {
+ my $thing = Thingy::Rt->new(origin=>$main::mycall, user=>$self->{call});
+ $thing->from_DXProt(t=>'eau', d=>"N1$ncall$rout", DXProt=>$line);
$thing->queue($self);
} else {
dbg("PCPROT: No usable users") if isdbg('chanerr');
}
+ } else {
+ dbg("PCPROT: no PC19 seen for $ncall" ) if isdbg('chanerr');
}
}
}
$uref = Route->new($ucall) unless $uref; # throw away
- my $thing = Thingy::Rt->new(origin=>$main::mycall);
- $thing->from_DXProt(t=>'ed', n=>$ncall, u=>"1$ucall", DXProt=>$line);
+ my $thing = Thingy::Rt->new(origin=>$main::mycall, user=>$self->{call});
+ $thing->from_DXProt(t=>'edu', d=>"N1$ncall:U1$ucall", DXProt=>$line);
$thing->queue($self);
}
# These can be called in various ways:-
#
# Route::here or $ref->here returns 1 or 0 depending on value of the here flag
-# Route::here(1) returns 2 (the bit value of the here flag)
+# Route::here(1) returns 1 (the bit value of the here flag)
# $ref->here(1) or $ref->here(0) sets the here flag
#
+# these are now redundant really as we are not interested in conferences
+# and here is back to being '1'.
sub here
{
my $r = shift;
return $self ? 2 : 0 unless ref $self;
return ($self->{flags} & 2) ? 1 : 0 unless defined $r;
- $self->{flags} = (($self->{flags} & ~2) | ($r ? 2 : 0));
+ $self->{flags} = (($self->{flags} & ~1) | ($r ? 1 : 0));
return $r ? 1 : 0;
}
{
my $self = shift;
my $r = shift;
- return $self ? 1 : 0 unless ref $self;
+ return $self ? 2 : 0 unless ref $self;
return ($self->{flags} & 1) ? 1 : 0 unless defined $r;
- $self->{flags} = (($self->{flags} & ~1) | ($r ? 1 : 0));
- return $r ? 1 : 0;
+ $self->{flags} = (($self->{flags} & ~2) | ($r ? 2 : 0));
+ return $r ? 2 : 0;
}
sub parents
my $thing = shift;
unless ($thing->{Aranea}) {
my @items;
- $thing->{Aranea} = Aranea::genmsg($thing, 'Rt', @items);
+ $thing->{Aranea} = Aranea::genmsg($thing, 'RT', @items);
}
return $thing->{Aranea};
}
my $thing = shift;
my $dxchan = shift;
- $thing->broadcast($dxchan);
+ if ($thing->{t}) {
+ my $sub = "handle_$thing->{t}";
+ if ($thing->can($sub)) {
+ no strict 'refs';
+ $thing = $thing->$sub($dxchan);
+ }
+
+ $thing->broadcast($dxchan) if $thing;
+ }
+}
+
+sub handle_eau
+{
+ my $thing = shift;
+ my $dxchan = shift;
+
+ if (my $d = $thing->{d}) {
+ for (split /:/, $d) {
+ my ($type, $here, $call) = unpack "A1 A1 A*", $_;
+ my $nref;
+ if ($type eq 'U') {
+ unless ($nref) {
+ dbg("Thingy::Rt::ea need a node before $call");
+ return;
+ }
+ add_user($nref, $call, $here);
+ my $h = $dxchan->{call} eq $nref->{call} ? 3 : ($thing->{hops} || 99);
+ RouteDB::update($call, $dxchan->{call}, $h);
+ } elsif ($type eq 'N') {
+ $nref = Route::Node::get($call);
+ unless ($nref) {
+ dbg("Thingy::Rt::ea need a definition for $call");
+ return;
+ }
+ my $h = $dxchan->{call} eq $nref->{call} ? 2 : ($thing->{hops} || 99);
+ RouteDB::update($nref->{call}, $dxchan->{call}, $h);
+ } else {
+ dbg("Thingy::Rt::ea invalid type $type");
+ return;
+ }
+ unless ($nref) {
+ dbg("Thingy::Rt::ea no node");
+ return;
+ }
+ }
+ }
+ return $thing;
+}
+
+sub handle_edu
+{
+ my $thing = shift;
+ my $dxchan = shift;
+
+ if (my $d = $thing->{d}) {
+ for (split /:/, $d) {
+ my ($type, $here, $call) = unpack "A1 A1 A*", $_;
+ my $nref;
+ if ($type eq 'U') {
+ unless ($nref) {
+ dbg("Thingy::Rt::ed need a node before $call");
+ return;
+ }
+ $nref->del_user($call);
+ RouteDB::delete($call, $dxchan->{call});
+ } elsif ($type eq 'N') {
+ $nref = Route::Node::get($call);
+ unless ($nref) {
+ dbg("Thingy::Rt::ed need a definition for $call");
+ return;
+ }
+ RouteDB::update($nref->{call}, $dxchan->{call}, $dxchan->{call} eq $nref->{call} ? 2 : ($thing->{hops} || 99));
+ } else {
+ dbg("Thingy::Rt::ed invalid type $type");
+ return;
+ }
+ unless ($nref) {
+ dbg("Thingy::Rt::ed no node");
+ return;
+ }
+ }
+ }
+ return $thing;
}
sub in_filter
# global route filtering on INPUT
if ($dxchan->{inroutefilter}) {
- my $ref = Route::Node::get($thing->{origin});
- my ($filter, $hops) = $dxchan->{inroutefilter}->it($ref);
+ my $r = Route::Node::get($thing->{origin});
+ 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});
unless ($filter) {
dbg("PCPROT: Rejected by input route filter") if isdbg('chanerr');
return;
# global route filtering on OUTPUT
if ($dxchan->{routefilter}) {
- my $ref = Route::Node::get($thing->{origin});
- my ($filter, $hops) = $dxchan->{routefilter}->it($ref);
+ my $r = Route::Node::get($thing->{origin});
+ 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});
unless ($filter) {
dbg("PCPROT: Rejected by output route filter") if isdbg('chanerr');
return;
}
return 1;
}
+
+sub add_user
+{
+ my $node = shift;
+ my $user = shift;
+ my $flag = shift;
+
+ $node->add_user($user, $flag);
+ my $ur = upd_user_rec($user, $node);
+ $ur->put;
+}
+
+sub upd_user_rec
+{
+ my $call = shift;
+ my $parentcall = shift;
+
+ # add this station to the user database, if required
+ $call =~ s/-\d+$//o; # remove ssid for users
+ my $user = DXUser->get_current($call);
+ $user = DXUser->new($call) if !$user;
+ $user->homenode($parentcall) if !$user->homenode;
+ $user->node($parentcall);
+ $user->lastin($main::systime) unless DXChannel->get($call);
+}
1;