add RouteDB
[spider.git] / cmd / show / route.pl
1 #
2 # show the routing to a node or station
3 #
4 # Copyright (c) 2001 Dirk Koopman G1TLH
5 #
6 # $Id$
7 #
8
9 my ($self, $line) = @_;
10 my @list = map { uc } split /\s+/, $line;           # list of callsigns of nodes
11 my @out;
12
13 return (1, $self->msg('e6')) unless @list;
14
15 use RouteDB;
16
17 my $l;
18 foreach $l (@list) {
19         my $ref = Route::get($l);
20         if ($ref) {
21                 my $parents = $ref->isa('Route::Node') ? $l : join(',', $ref->parents);
22                 push @out, $self->msg('route', $l, $parents,  join(',', map {$_->call} $ref->alldxchan));
23         } else {
24                 push @out, $self->msg('e7', $l);
25         }
26         my @in = RouteDB::_sorted($l);
27         if (@in) {
28                 push @out, "Learned Routes:";
29                 for (@in) {
30                         push @out, "$l via $_->{call} count: $_->{count} last heard: " . atime($_->{t});
31                 }
32         }
33 }
34
35 return (1, @out);