+
+ my $ref = Route::Node::get($to);
+ my $dxchan = $ref->dxchan;
+ if ($dxchan && $dxchan->is_clx) {
+ route(undef, $to, pc84($main::mycall, $to, $self->{call}, $cmd));
+ } else {
+ route(undef, $to, pc34($main::mycall, $to, $cmd));
+ }
+}
+
+sub disconnect
+{
+ my $self = shift;
+ my $pc39flag = shift;
+ my $call = $self->call;
+
+ unless ($pc39flag && $pc39flag == 1) {
+ $self->send_now("D", DXProt::pc39($main::mycall, $self->msg('disc1', "System Op")));
+ }
+
+ # do routing stuff
+ my $node = Route::Node::get($call);
+ my @rout;
+ if ($node) {
+ @rout = $node->del($main::routeroot);
+ }
+
+ # unbusy and stop and outgoing mail
+ my $mref = DXMsg::get_busy($call);
+ $mref->stop_msg($call) if $mref;
+
+ # broadcast to all other nodes that all the nodes connected to via me are gone
+ unless ($pc39flag && $pc39flag == 2) {
+ $self->route_pc21(@rout) if @rout;
+ }
+
+ # remove outstanding pings
+ delete $pings{$call};
+
+ # I was the last node visited
+ $self->user->node($main::mycall);
+
+ # send info to all logged in thingies
+ $self->tell_login('logoutn');
+
+ Log('DXProt', $call . " Disconnected");
+
+ $self->SUPER::disconnect;
+}
+
+
+#
+# send a talk message to this thingy
+#
+sub talk
+{
+ my ($self, $from, $to, $via, $line) = @_;
+
+ $line =~ s/\^/\\5E/g; # remove any ^ characters
+ $self->send(DXProt::pc10($from, $to, $via, $line));
+ Log('talk', $self->call, $from, $via?$via:$main::mycall, $line);
+}
+
+# send it if it isn't the except list and isn't isolated and still has a hop count
+# taking into account filtering and so on
+sub send_route
+{
+ my $self = shift;
+ my $generate = shift;
+ my $no = shift; # the no of things to filter on
+ my $routeit;
+ my ($filter, $hops);
+ my @rin;
+
+ for (; @_ && $no; $no--) {
+ my $r = shift;
+
+ if ($self->{routefilter}) {
+ $filter = undef;
+ if ($r) {
+ ($filter, $hops) = $self->{routefilter}->it($self->{call}, $self->{dxcc}, $self->{itu}, $self->{cq}, $r->call, $r->dxcc, $r->itu, $r->cq);
+ if ($filter) {
+ push @rin, $r;
+ } else {
+ dbg("DXPROT: $self->{call}/" . $r->call . " rejected by output filter") if isdbg('chanerr');
+ }
+ } else {
+ dbg("was sent a null value") if isdbg('chanerr');
+ }
+ } else {
+ push @rin, $r;
+ }
+ }
+ if (@rin) {
+ foreach my $line (&$generate(@rin, @_)) {
+ if ($hops) {
+ $routeit = $line;
+ $routeit =~ s/\^H\d+\^\~$/\^H$hops\^\~/;
+ } else {
+ $routeit = adjust_hops($self, $line); # adjust its hop count by node name
+ next unless $routeit;
+ }
+ $self->send($routeit);
+ }
+ }
+}
+
+sub broadcast_route
+{
+ my $self = shift;
+ my $generate = shift;
+ my @dxchan = DXChannel::get_all_nodes();
+ my $dxchan;
+ my $line;
+
+ foreach $dxchan (@dxchan) {
+ next if $dxchan == $self;
+ next if $dxchan == $me;
+ if ($dxchan->{routefilter}) {
+ $dxchan->send_route($generate, @_);
+ } else {
+ $dxchan->send_route($generate, @_) unless $self->{isolate} || $dxchan->{isolate};
+ }
+ }
+}
+
+sub route_pc16
+{
+ my $self = shift;
+ broadcast_route($self, \&pc16, 1, @_);
+}
+
+sub route_pc17
+{
+ my $self = shift;
+ broadcast_route($self, \&pc17, 1, @_);