fix here so that it is either on or off and remove all the Route::here
[spider.git] / perl / DXProt.pm
index 65b666a2fed8a5315e4b641ec1527314bb0e98ef..595cfae8246a64d4d7713bb2433a5bdb3940a54c 100644 (file)
@@ -225,6 +225,7 @@ sub init
        $main::me->{registered} = 1;
        $main::me->{version} = 5252 + $main::version;
        $main::me->{build} = $main::build;
+       $main::me->{lastcf} = $main::me->{lasthello} = time;
 }
 
 #
@@ -238,12 +239,7 @@ sub new
        # add this node to the table, the values get filled in later
        my $pkg = shift;
        my $call = shift;
-       $main::routeroot->add($call, '5000', Route::here(1)) if $call ne $main::mycall;
-       if ($self->{call} ne $main::mycall) {
-               my $thing = Thingy::Hello->new(user=>$call);
-               $thing->broadcast($self);
-       }
-       
+       $main::routeroot->add($call, '5000', 1) if $call ne $main::mycall;
        return $self;
 }
 
@@ -313,8 +309,10 @@ sub start
        $self->state('init');
        $self->{pc50_t} = $main::systime;
 
-       my $thing = Thingy::Hello->new(origin=>$main::mycall, user=>$call);
+       # ALWAYS output the hello
+       my $thing = Thingy::Hello->new(user => $call, h => $self->{here});
        $thing->broadcast($self);
+       $self->lasthello($main::systime);
        
        # send info to all logged in thingies
        $self->tell_login('loginn');
@@ -786,18 +784,24 @@ sub handle_16
                # input filter if required
                return unless $self->in_filter_route($parent);
        }
+
+       # is he under the control of the new protocol?
+       if ($parent && $parent->np) {
+               dbg("PCPROT: $ncall aranea node, ignored") if isdbg('chanerr');
+               return;
+       }
                
-               my $i;
+       my $i;
        my @rout;
-               for ($i = 2; $i < $#_; $i++) {
-                       my ($call, $conf, $here) = $_[$i] =~ /^(\S+) (\S) (\d)/o;
-                       next unless $call && $conf && defined $here && is_callsign($call);
-                       next if $call eq $main::mycall;
-                       
-                       eph_del_regex("^PC17\\^$call\\^$ncall");
-                               
+       for ($i = 2; $i < $#_; $i++) {
+               my ($call, $conf, $here) = $_[$i] =~ /^(\S+) (\S) (\d)/o;
+               next unless $call && $conf && defined $here && is_callsign($call);
+               next if $call eq $main::mycall;
+               
+               eph_del_regex("^PC17\\^$call\\^$ncall");
+               
                $conf = $conf eq '*';
-
+               
                # reject this if we think it is a node already
                my $r = Route::Node::get($call);
                my $u = DXUser->get_current($call) unless $r;
@@ -807,20 +811,20 @@ sub handle_16
                }
                
                $r = Route::User::get($call);
-               my $flags = Route::here($here)|Route::conf($conf);
-
+               my $flags = $here;
+               
                if ($r) {
                        my $au = $r->addparent($parent);                                        
                        if ($r->flags != $flags) {
                                $r->flags($flags);
                                $au = $r;
-               }
+                       }
                        push @rout, $r if $au;
-       } else {
+               } else {
                        push @rout, $parent->add_user($call, $flags);
                }
                
-                               
+               
                # add this station to the user database, if required
                $call =~ s/-\d+$//o;    # remove ssid for users
                my $user = DXUser->get_current($call);
@@ -883,6 +887,12 @@ sub handle_17
                return;
        }
 
+       # is he under the control of the new protocol?
+       if ($parent && $parent->np) {
+               dbg("PCPROT: $ncall aranea node, ignored") if isdbg('chanerr');
+               return;
+       }
+
        # input filter if required and then remove user if present
        if ($parent) {
 #              return unless $self->in_filter_route($parent);  
@@ -911,8 +921,8 @@ sub handle_18
 
        # record the type and version offered
        if ($_[1] =~ /DXSpider Version: (\d+\.\d+) Build: (\d+\.\d+)/) {
-               $self->version(52.51 + $1);
-               $self->user->version(52.51 + $1);
+               $self->version(0 + $1);
+               $self->user->version(0 + $1);
                $self->build(0 + $2);
                $self->user->build(0 + $2);
                unless ($self->is_spider) {
@@ -960,7 +970,7 @@ sub handle_19
        if ($origin ne $self->call) {
                my $op = Route::Node::get($origin);
                unless ($op) {
-                       $op = $parent->add($origin, 5000, Route::here(1));
+                       $op = $parent->add($origin, 5000, 1);
                        my $user = DXUser->get_current($origin);
                        if (!$user) {
                                $user = DXUser->new($origin);
@@ -1034,8 +1044,13 @@ sub handle_19
                }
 
                my $r = Route::Node::get($call);
-               my $flags = Route::here($here)|Route::conf($conf);
+               my $flags = $here;
 
+               # is he under the control of the new protocol?
+               if ($r && $r->np) {
+                       dbg("PCPROT: $call aranea node, ignored") if isdbg('chanerr');
+                       next;
+               }
                # modify the routing table if it is in it, otherwise store it in the pc19list for now
                if ($r) {
                        my $ar;
@@ -1094,9 +1109,12 @@ sub handle_20
        $self->send(pc22());
        $self->state('normal');
        $self->{lastping} = 0;
-       my $thing = Thingy::Rt->new_cf(user=>$self->{call});
+       my $thing = Thingy::Rt->new(user=>$self->{call});
        my $nref = Route::Node::get($self->{call});
-       $thing->broadcast if $thing->copy_pc16_data($nref);
+       $thing->copy_pc16_data($nref);
+       $thing->broadcast;
+       
+       $self->lastcf($main::systime);
 }
                
 # delete a cluster from the list
@@ -1155,6 +1173,12 @@ sub handle_21
                                                
                                # input filter it
                                return unless $self->in_filter_route($node);
+
+                               # is he under the control of the new protocol?
+                               if ($node->np) {
+                                       dbg("PCPROT: $call aranea node, ignored") if isdbg('chanerr');
+                                       return;
+                               }
                                                
                                # routing objects
                                push @rout, $node->del($parent);
@@ -1177,9 +1201,11 @@ sub handle_22
        my $origin = shift;
        $self->state('normal');
        $self->{lastping} = 0;
-       my $thing = Thingy::Rt->new_cf(user=>$self->{call});
+       my $thing = Thingy::Rt->new(user=>$self->{call});
        my $nref = Route::Node::get($self->{call});
-       $thing->broadcast if $thing->copy_pc16_data($nref);
+       $thing->copy_pc16_data($nref);
+       $thing->broadcast;
+       $self->lastcf($main::systime);
 }
                                
 # WWV info