From 611e9ea5204765638eceecbd8e1dd04a4f10a1be Mon Sep 17 00:00:00 2001 From: minima Date: Mon, 23 Aug 2004 21:43:04 +0000 Subject: [PATCH] add RouteDB --- Changes | 2 ++ cmd/ping.pl | 1 + cmd/show/route.pl | 9 +++++++++ perl/DXProt.pm | 10 +++++----- perl/RouteDB.pm | 13 +++++++------ 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Changes b/Changes index 5caf541d..d2d9d61c 100644 --- 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======================================================================= diff --git a/cmd/ping.pl b/cmd/ping.pl index 05ccd829..aab2a3e6 100644 --- a/cmd/ping.pl +++ b/cmd/ping.pl @@ -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; diff --git a/cmd/show/route.pl b/cmd/show/route.pl index 4ebebde3..d4120e0c 100644 --- a/cmd/show/route.pl +++ b/cmd/show/route.pl @@ -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); diff --git a/perl/DXProt.pm b/perl/DXProt.pm index 33c69f23..69085f35 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -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; } } diff --git a/perl/RouteDB.pm b/perl/RouteDB.pm index 9a63d368..c9c01ff4 100644 --- a/perl/RouteDB.pm +++ b/perl/RouteDB.pm @@ -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; } # -- 2.43.0