From a931b090e0be3329bcbf7deddb7c17c30fa0e74a Mon Sep 17 00:00:00 2001 From: minima Date: Wed, 21 Jul 2004 13:21:35 +0000 Subject: [PATCH] move stuff around and try to get pc59 handling/generation more correct --- perl/DXProtHandler.pm | 10 +++++----- perl/DXProtout.pm | 19 ++++++++++++++----- perl/Route.pm | 21 ++++----------------- perl/Route/Node.pm | 18 ++++++++++++++++++ perl/Route/User.pm | 11 +++++++++++ 5 files changed, 52 insertions(+), 27 deletions(-) diff --git a/perl/DXProtHandler.pm b/perl/DXProtHandler.pm index 726c3447..9685243e 100644 --- a/perl/DXProtHandler.pm +++ b/perl/DXProtHandler.pm @@ -431,7 +431,7 @@ sub handle_16 $user->lastin($main::systime) unless DXChannel->get($call); $user->put; } - $self->process_pc59($pcno, 'A', hexstamp(), $main::routeroot, + $self->process_pc59($pcno, 'A', hexstamp(), Route::Node::get($self->{call}), $node, undef, @rout); } @@ -488,7 +488,7 @@ sub handle_17 return; } - $self->process_pc59($pcno, 'D', hexstamp(), $main::routeroot, $node, undef, $uref); + $self->process_pc59($pcno, 'D', hexstamp(), Route::Node::get($self->{call}), $node, undef, $uref); } # link request @@ -516,7 +516,7 @@ sub handle_18 $self->version($_[2] / 100) if $_[2] && $_[2] =~ /^\d+$/; $self->user->version($self->version); } - $self->newroute( $_[1] =~ /!NRt/ ); + $self->newroute( $_[1] =~ /\!NRt/ ); # first clear out any nodes on this dxchannel my $node = Route::Node::get($self->{call}) ; @@ -618,7 +618,7 @@ sub handle_19 # unshift in the route::node for this interface if isn't present if (@rout) { unshift @rout, $parent unless $rout[0]->call ne $self->{call}; - $self->process_pc59($pcno, 'A', hexstamp(), $main::routeroot, $parent, undef, @rout); + $self->process_pc59($pcno, 'A', hexstamp(), Route::Node::get($self->{call}), $parent, undef, @rout); } } @@ -684,7 +684,7 @@ sub handle_21 push @rout, $node; } - $self->process_pc59($pcno, 'D', hexstamp(), $main::routeroot, $parent, undef, @rout); + $self->process_pc59($pcno, 'D', hexstamp(), Route::Node::get($self->{call}), $parent, undef, @rout); } diff --git a/perl/DXProtout.pm b/perl/DXProtout.pm index 4194d6c4..840c4ede 100644 --- a/perl/DXProtout.pm +++ b/perl/DXProtout.pm @@ -361,20 +361,29 @@ sub pc51 } my $hexlasttime = 0; -my $hexlastlet = '!'; +my $hexlastlet = 'A'; +my $hexoverflow = ''; sub hexstamp { my $t = shift || $main::systime; - if ($hexlastlet gt '>' || $t ne $hexlasttime) { + if ($t ne $hexlasttime) { $hexlasttime = $t; - $hexlastlet = '!'; + $hexoverflow = ''; + $hexlastlet = 'A'; } else { do { $hexlastlet = chr(ord($hexlastlet) + 1); + if ($hexlastlet ge '~') { + $hexlastlet = 'A'; + $hexoverflow ||= '@'; + do { + $hexoverflow = chr(ord($hexoverflow) + 1); + } while ($hexoverflow eq '^'); + } } while ($hexlastlet eq '^'); } - return sprintf "%s%08X", $hexlastlet, $hexlasttime; + return sprintf "%08X%s%s", $hexlasttime, $hexoverflow, $hexlastlet; } sub pc58 @@ -402,7 +411,7 @@ sub pc59 my $ref = $_; my $call = $ref->call; my $here = $ref->here; - $s .= $ref->enc_pc59; + $s .= '^' . $ref->enc_pc59; } push @out, sprintf "$s^%s^", get_hops(59); return @out; diff --git a/perl/Route.pm b/perl/Route.pm index 695eed8d..6c22e22f 100644 --- a/perl/Route.pm +++ b/perl/Route.pm @@ -170,20 +170,6 @@ sub conf return $r ? 1 : 0; } -# -# pc59 entity encoding and decoding -# -sub enc_pc59 -{ - my $self = shift; - my $sort = shift || 'N'; - my $out = "$sort$self->{flag}$self->{call}"; - if ($self->{build}) { - $out .= "b$self->{build}"; - } elsif ($self->{version}) { - $out .= "v$self->{version}"; - } -} sub dec_pc59 { @@ -191,16 +177,17 @@ sub dec_pc59 my $s = ref($node) ? shift : $node; $node = undef; - my ($sort, $here, $call) = unpack "A A A*", $s; + my ($sort, $here, $callstring) = unpack "A A A*", $s; + my ($call) = $callstring =~ /^([A-Z0-9\-]+)/; return unless is_callsign($call); return unless $here =~ /^[0123]$/; return unless $sort =~ /^[NUE]$/; if ($sort eq 'E' || $sort eq 'N') { $node = Route::Node::get($call) || Route::Node->new($call); - if ($s =~ /b([\d\.])/) { + if ($callstring =~ /b([\d\.])/) { $node->{build} = $1; } - if ($s =~ /v([\d\.])/) { + if ($callstring =~ /v([\d\.])/) { $node->{version} = $1; } } elsif ($sort eq 'U') { diff --git a/perl/Route/Node.pm b/perl/Route/Node.pm index f3072db1..4e1692f1 100644 --- a/perl/Route/Node.pm +++ b/perl/Route/Node.pm @@ -270,6 +270,24 @@ sub get_all return values %list; } +# +# pc59 entity encoding and decoding +# +sub enc_pc59 +{ + my $self = shift; + my $sort = shift || 'N'; + my $out = "$sort$self->{flags}$self->{call}"; + if ($sort eq 'N') { + if ($self->{build}) { + $out .= "b$self->{build}"; + } elsif ($self->{version}) { + $out .= "v$self->{version}"; + } + } + return $out; +} + sub DESTROY { my $self = shift; diff --git a/perl/Route/User.pm b/perl/Route/User.pm index d3cfb7d3..7bf19d44 100644 --- a/perl/Route/User.pm +++ b/perl/Route/User.pm @@ -110,6 +110,17 @@ sub nodes return @{$self->{nodes}}; } +# +# pc59 entity encoding and decoding +# +sub enc_pc59 +{ + my $self = shift; + my $sort = shift || 'U'; + my $out = "$sort$self->{flags}$self->{call}"; + return $out; +} + # # generic AUTOLOAD for accessors # -- 2.43.0