- my $self = shift;
- for (@{$self->{users}}) {
- my $ref = Route::User::get($_);
- $ref->del($self) if $ref;
+ my ($self, $neighbour, $dxchan) = @_;
+
+ # cut the dxchan link
+ # cut the node link
+ my @rout;
+ push @rout, $self->unlink_node($neighbour, $dxchan);
+ dbg("Orphanning $neighbour->{call}") if isdbg('routelow');
+
+ # then run down the tree removing this dxchan link from
+ # all the referenced nodes that use this interface
+ my %visited;
+ my @in = map { Route::Node::get($_) } $neighbour->nodes;
+ foreach my $r (@in) {
+ next unless $r;
+ next if $visited{$r->call};
+ next if $r->{call} eq $main::mycall;
+ next if $r->{call} eq $self->{call};
+ my ($o) = $r->del_dxchan($dxchan);
+ if ($o) {
+ dbg("Orphanning $o->{call}") if isdbg('routelow');
+ push @rout, $o;
+ }
+ push @in, map{ Route::Node::get($_) } $r->nodes;
+ $visited{$r->call} = $r;