add RouteDB
authorminima <minima>
Mon, 23 Aug 2004 21:43:04 +0000 (21:43 +0000)
committerminima <minima>
Mon, 23 Aug 2004 21:43:04 +0000 (21:43 +0000)
Changes
cmd/ping.pl
cmd/show/route.pl
perl/DXProt.pm
perl/RouteDB.pm

diff --git a/Changes b/Changes
index 5caf541dcaaa1bed7528dd9bd66714d0f513d454..d2d9d61c1e88bfc37c2a30dd3379c7ae0342ded7 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,5 @@
+23Aug04=======================================================================
+1. add the start of an alternative routing engine (RouteDB)
 20Aug04=======================================================================
 1. Added new protocol specification to techdoc
 17Aug04=======================================================================
index 05ccd829d8ab61f989a85eb09cd702786e01aaf5..aab2a3e6b2b94076f9b4ff0810465184ea49dd2f 100644 (file)
@@ -21,6 +21,7 @@ return (1, $self->msg('pinge1')) if $call eq $main::mycall;
 
 # can we see it? Is it a node?
 my $noderef = Route::Node::get($call);
+$noderef = RouteDB::get($call) unless $noderef;
 
 return (1, $self->msg('e7', $call)) unless $noderef;
 
index 4ebebde3242dd799c8568afc2b348af6ff355aa1..d4120e0c484a5244774388a81ca3aba357e68c4f 100644 (file)
@@ -12,6 +12,8 @@ my @out;
 
 return (1, $self->msg('e6')) unless @list;
 
+use RouteDB;
+
 my $l;
 foreach $l (@list) {
        my $ref = Route::get($l);
@@ -21,6 +23,13 @@ foreach $l (@list) {
        } else {
                push @out, $self->msg('e7', $l);
        }
+       my @in = RouteDB::_sorted($l);
+       if (@in) {
+               push @out, "Learned Routes:";
+               for (@in) {
+                       push @out, "$l via $_->{call} count: $_->{count} last heard: " . atime($_->{t});
+               }
+       }
 }
 
 return (1, @out);
index 33c69f234bd9c5b00fd516df0de2adacb79a9d3e..69085f358a146eee342562bf5cfc5b2ae8d9ba4f 100644 (file)
@@ -516,7 +516,7 @@ sub handle_11
        }
 
        # remember a route
-       RouteDB::update($_[7], $self->{call});
+#      RouteDB::update($_[7], $self->{call});
 #      RouteDB::update($_[6], $_[7]);
        
        my @spot = Spot::prepare($_[1], $_[2], $d, $_[5], $_[6], $_[7]);
@@ -652,7 +652,7 @@ sub handle_12
        } elsif ($_[2] eq '*' || $_[2] eq $main::mycall) {
 
                # remember a route
-               RouteDB::update($_[5], $self->{call});
+#              RouteDB::update($_[5], $self->{call});
 #              RouteDB::update($_[1], $_[5]);
 
                # ignore something that looks like a chat line coming in with sysop
@@ -2086,12 +2086,12 @@ sub route
        unless ($dxchan) {
                my $rcall = RouteDB::get($call);
                if ($rcall) {
-                       if ($rcall eq $self->{call}) {
+                       if ($self && $rcall eq $self->{call}) {
                                dbg("PCPROT: Trying to route back to source, dropped") if isdbg('chanerr');
                                return;
                        }
-                       $dxchan = DXChannel->get($call);
-                       dbg("route: $call -> $dxchan->{call} using RouteDB" ) if isdbg('route') && $dxchan;
+                       $dxchan = DXChannel->get($rcall);
+                       dbg("route: $call -> $rcall using RouteDB" ) if isdbg('route') && $dxchan;
                }
        }
 
index 9a63d368f121cc5b896136cf56f96d587caf87a2..c9c01ff4544565ea80651a35f78fb0dcd4526622 100644 (file)
@@ -36,7 +36,7 @@ use vars qw(%list %valid $default);
 $default = 99;                                 # the number of hops to use if we don't know
 %valid = (
                  call => "0,Callsign",
-                 items => "0,Interfaces,parray",
+                 item => "0,Interfaces,parray",
                  t => '0,Last Seen,atime',
                  hops => '0,Hops',
                  count => '0,Times Seen',
@@ -46,7 +46,7 @@ sub new
 {
        my $pkg = shift;
        my $call = shift;
-       return bless {call => $call, items => {}}, (ref $pkg || $pkg);
+       return bless {call => $call, list => {}}, (ref $pkg || $pkg);
 }
 
 # get the best one
@@ -76,7 +76,7 @@ sub _sorted
                } else {
                        $a->{hops} <=> $b->{hops};
                } 
-       } values %{$ref->{items}};
+       } values %{$ref->{item}};
 }
 
 
@@ -90,11 +90,12 @@ sub update
        my $interface = shift;
        my $hops = shift || $default;
        my $ref = $list{$call} || RouteDB->new($call);
-       my $iref = $ref->{list}->{$interface} ||= RouteDB::Item->new($call, $interface);
+       my $iref = $ref->{item}->{$interface} ||= RouteDB::Item->new($interface);
        $iref->{count}++;
        $iref->{hops} = $hops if $hops < $iref->{hops};
        $iref->{t} = shift || $main::systime;
-       $ref->{list}->{$interface} ||= $iref;
+       $ref->{item}->{$interface} ||= $iref;
+       $list{$call} ||= $ref;
 }
 
 sub delete
@@ -102,7 +103,7 @@ sub delete
        my $call = shift;
        my $interface = shift;
        my $ref = $list{$call};
-       delete $ref->{list}->{$interface} if $ref;
+       delete $ref->{item}->{$interface} if $ref;
 }
 
 #