sub pc17
{
my @out;
+ my $node = shift;
while (@_) {
- my $node = shift;
my $ref = shift;
my $hops = get_hops(17);
my $ncall = $node->call;
{
my $self = shift;
my $r = shift;
- return $self ? 2 : 0 unless ref $self;
- return ($self->{flags} & 2) ? 1 : 0 unless defined $r;
+ return $self ? 1 : 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;
}
my $self = shift;
my $r = shift;
return $self ? 2 : 0 unless ref $self;
- return ($self->{flags} & 1) ? 1 : 0 unless defined $r;
+ return ($self->{flags} & 2) ? 2 : 0 unless defined $r;
$self->{flags} = (($self->{flags} & ~2) | ($r ? 2 : 0));
return $r ? 2 : 0;
}
users => '0,Users,parray',
usercount => '0,User Count',
version => '0,Version',
+ build => '0,Build',
+ sw => '0,Software',
np => '0,Using New Prot,yesno',
- lid => '0,Last Msgid',
);
$filterdef = $Route::filterdef;
return @out;
}
+# return the differences in nodes between what we currently have and
+# the list proffered. Returns two refs one to a list of nodes to remove and
+# the other a list of nodes to add
+#
+# input is a list of callsigns (not refs)
+sub diff_nodes
+{
+ my $self = shift;
+ my $in = ref $_[0] ? shift : \@_;
+ my %del = map {($_, 1)} nodes($self);
+ my %in = map {($_, 1)} @$in;
+
+ # remove all the calls that are in both lists
+ for (@$in) {
+ delete $in{$_} if delete $del{$_};
+ }
+ return ([keys %del], [keys %in]);
+}
+
+# same as above but for users
+sub diff_users
+{
+ my $self = shift;
+ my $in = ref $_[0] ? shift : \@_;
+ my %del = map {($_, 1)} users($self);
+ my %in = map {($_, 1)} @$in;
+
+ # remove all the calls that are in both lists
+ for (@$in) {
+ delete $in{$_} if delete $del{$_};
+ }
+ return ([keys %del], [keys %in]);
+}
sub new
{
my $self = $pkg->SUPER::new($call);
$self->{parent} = ref $pkg ? [ $pkg->{call} ] : [ ];
- $self->{version} = shift;
- $self->{flags} = shift;
+ $self->{version} = 0 || shift;
+ $self->{flags} = 0 || shift;
$self->{users} = [];
$self->{nodes} = [];
$self->{lid} = 0;
my $self = $pkg->SUPER::new($call);
$self->{parent} = [ $ncall ];
- $self->{flags} = $flags;
+ $self->{flags} = 0 || $flags;
$list{$call} = $self;
return $self;
#
# Bye Thingy handling
#
+# Note that this is a generator of pc21n and pc17n/pc17u
+# and a consumer of fpc21n and fpc21n
+#
# $Id$
#
# Copyright (c) 2005 Dirk Koopman G1TLH
@pc21 = $parent->del($uref);
} else {
$parent->del_user($uref);
- $thing->{pc17n} = $thing->{origin};
- $thing->{pc17u} = $user;
+ $thing->{pc17n} = $parent;
+ $thing->{pc17u} = [$uref];
}
}
} else {
sub gen_Aranea
{
my $thing = shift;
+ my $dxchan = shift;
+
unless ($thing->{Aranea}) {
- $thing->add_auth;
-
- $thing->{sw} ||= 'DXSp';
- $thing->{v} ||= $main::version;
- $thing->{b} ||= $main::build;
+ if ($thing->{user}) {
+ $thing->{h} ||= $dxchan->here;
+ } else {
+ $thing->add_auth;
+ $thing->{sw} ||= 'DXSp';
+ $thing->{v} ||= $main::version;
+ $thing->{b} ||= $main::build;
+ $thing->{h} ||= $main::me->here;
+ }
- $thing->{Aranea} = Aranea::genmsg($thing, [qw(sw v b s auth)]);
+ $thing->{Aranea} = Aranea::genmsg($thing, [qw(sw h v b s auth)]);
}
return $thing->{Aranea};
}
if ($node eq $origin) {
# for directly connected calls
- if ($verify_on_login) {
+ if ($verify_on_login && !$thing->{user}) {
my $pp = $dxchan->user->passphrase;
unless ($pp) {
dbglog('err', "Thingy::Hello::handle: verify on and $origin has no passphrase");
}
}
if ($dxchan->{state} ne 'normal') {
- $nref = $main::routeroot->add($origin, $thing->{v}, 1);
+ $nref = $main::routeroot->add($origin, $thing->{v}, $thing->{h});
push @{$thing->{pc19n}}, $nref if $nref;
$dxchan->start($dxchan->{conn}->{csort}, $dxchan->{conn}->{outbound} ? 'O' : 'A');
if ($dxchan->{outbound}) {
}
}
$nref = Route::Node::get($origin);
+ $nref->np(1);
} else {
# for otherwise connected calls, that come in relayed from other nodes
my $v = $thing->{user} ? undef : $thing->{v};
$nref = Route::Node->new($origin, $v, 1);
push @{$thing->{pc19n}}, $nref;
+ $nref->np(1);
}
}
unless ($ur) {
my $uref = DXUser->get_current($user);
if ($uref->is_node || $uref->is_aranea) {
- my $u = $nref->add($user, $thing->{v}, 1);
- push @{$thing->{pc19n}}, $u if $u;
+ $ur = $nref->add($user, $thing->{v}, $thing->{h});
+ push @{$thing->{pc19n}}, $ur if $ur;
} else {
$thing->{pc16n} = $nref;
- $thing->{pc16u} = [$nref->add_user($user, 1)];
+ $thing->{pc16u} = [$ur = $nref->add_user($user, $thing->{h})];
}
}
+ $ur->np(1);
+ } else {
+ $nref->version($thing->{v}) unless $nref->version;
+ $nref->build($thing->{b}) unless $nref->build;
+ $nref->sw($thing->{sw}) unless $nref->sw;
+ $nref->here($thing->{h}) if exists $thing->{h};
}
+
RouteDB::update($origin, $node, $thing->{hopsaway});
RouteDB::update($thing->{user}, $node, $thing->{hopsaway}) if $thing->{user};
my $thing = shift;
my @out;
push @out, DXProt::pc21(@{$thing->{fpc21n}}) if $thing->{fpc21n};
- push @out, DXProt::pc17($thing->{fpc17n}, $thing->{pc17u}) if $thing->{fpc17n};
+ push @out, DXProt::pc17($thing->{fpc17n}, @{$thing->{pc17u}}) if $thing->{fpc17n};
push @out, DXProt::pc19(@{$thing->{fpc19n}}) if $thing->{fpc19n};
push @out, DXProt::pc16($thing->{fpc16n}, @{$thing->{pc16u}}) if $thing->{fpc16n};
return \@out;
#
# Route Thingy handling
#
+# Note that this is a generator of pc(16|17|19|21)n and pc(16|17)u
+# and a consumer of the fpc versions of the above
+#
# $Id$
#
# Copyright (c) 2005 Dirk Koopman G1TLH
unless ($thing->{Aranea}) {
my $ref;
if ($ref = $thing->{anodes}) {
- $thing->{n} = join(':', map {$_->{call}} @$ref);
+ $thing->{n} = join(':', map {"$_->{flags}$_->{call}"} @$ref);
}
if ($ref = $thing->{ausers}) {
- $thing->{u} = join(':', map {$_->{call}} @$ref);
+ $thing->{u} = join(':', map {"$_->{flags}$_->{call}"} @$ref);
}
$thing->{Aranea} = Aranea::genmsg($thing, [qw(s n u)]);
}
}
}
+# this handles the standard local configuration, it
+# will reset all the config, make / break links and
+# will generate pc sentences as required for nodes and users
+sub handle_lcf
+{
+ my $thing = shift;
+ my $dxchan = shift;
+ my $origin = $thing->{origin};
+ my $chan_call = $dxchan->{call};
+
+ my $parent = Route::Node::get($origin);
+ unless ($parent) {
+ dbg("Thingy::Rt::lcf: received from $origin on $chan_call unknown") if isdbg('chanerr');
+ return;
+ }
+
+ # do nodes
+ if ($thing->{n}) {
+ my %in = (map {my ($here, $call) = unpack "A1 A*", $_; ($call, $here)} split /:/, $thing->{n});
+ my ($del, $add) = $parent->diff_nodes(keys %in);
+
+ my $call;
+
+ my @pc21;
+ foreach $call (@$del) {
+ RouteDB::delete($call, $chan_call);
+ my $ref = Route::Node::get($call);
+ push @pc21, $ref->del($parent) if $ref;
+ }
+ $thing->{pc21n} = \@pc21 if @pc21;
+
+ my @pc19;
+ foreach $call (@$add) {
+ RouteDB::update($call, $chan_call);
+ my $ref = Route::Node::get($call);
+ push @pc19, $parent->add($call, 0, $in{$call}) unless $ref;
+ }
+ $thing->{pc19n} = \@pc19 if @pc19;
+ }
+
+ # now users
+ if ($thing->{u}) {
+ my %in = (map {my ($here, $call) = unpack "A1 A*", $_; ($call, $here)} split /:/, $thing->{u});
+ my ($del, $add) = $parent->diff_users(keys %in);
+
+ my $call;
+
+ my @pc17;
+ foreach $call (@$del) {
+ RouteDB::delete($call, $chan_call);
+ my $ref = Route::User::get($call);
+ if ($ref) {
+ $parent->del_user($ref);
+ push @pc17, $ref;
+ } else {
+ dbg("Thingy::Rt::lcf: del user $call not known, ignored") if isdbg('chanerr');
+ next;
+ }
+ }
+ if (@pc17) {
+ $thing->{pc17n} = $parent;
+ $thing->{pc17u} = \@pc17;
+ }
+
+ my @pc16;
+ foreach $call (@$add) {
+ RouteDB::update($call, $chan_call);
+ push @pc16, _add_user($parent, $call, $in{$call});
+ }
+ if (@pc16) {
+ $thing->{pc16n} = $parent;
+ $thing->{pc16u} = \@pc16;
+ }
+ }
+
+ return $thing;
+}
-sub add_user
+sub _add_user
{
my $node = shift;
my $user = shift;
my $flag = shift;
- $node->add_user($user, $flag);
- my $ur = upd_user_rec($user, $node);
+ my @out = $node->add_user($user, $flag);
+ my $ur = _upd_user_rec($user, $node);
$ur->put;
+ return @out;
}
-sub upd_user_rec
+sub _upd_user_rec
{
my $call = shift;
my $parentcall = shift;