sort working...
[spider.git] / perl / DXProt.pm
index e1d4fb28647bc854325538a418033766bb32cc37..1622728d4749760b59080caf41fc5d5698ed07fc 100644 (file)
@@ -812,7 +812,7 @@ sub handle_16
                                        my @nrout;
                                        for (@$nl) {
                                                $parent = Route::Node::get($_->[0]);
-                                               $dxchan = $parent->dxchan if $parent;
+                                               $dxchan = DXChannel->get($_->[0]) if $parent;
                                                if ($dxchan && $dxchan ne $self) {
                                                        dbg("PCPROT: PC19 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr');
                                                        $parent = undef;
@@ -844,7 +844,7 @@ sub handle_16
                }
        } else {
                                
-               $dxchan = $parent->dxchan;
+               $dxchan = DXChannel->get($parent->call);
                if ($dxchan && $dxchan ne $self) {
                        dbg("PCPROT: PC16 from $self->{call} trying to alter locally connected $ncall, ignored!") if isdbg('chanerr');
                        return;
@@ -1005,6 +1005,8 @@ sub handle_19
 
        # new routing list
        my @rout;
+
+       # first get the INTERFACE node
        my $parent = Route::Node::get($self->{call});
        unless ($parent) {
                dbg("DXPROT: my parent $self->{call} has disappeared");
@@ -1012,6 +1014,27 @@ sub handle_19
                return;
        }
 
+       # if the origin isn't the same as the INTERFACE, then reparent, creating nodes as necessary
+       if ($origin ne $self->call) {
+               my $op = Route::Node::get($origin);
+               unless ($op) {
+                       $op = $parent->add($origin, 5000, Route::here(1));
+                       my $user = DXUser->get_current($origin);
+                       if (!$user) {
+                               $user = DXUser->new($origin);
+                               $user->sort('S');
+                               $user->priv(1);         # I have relented and defaulted nodes
+                               $user->lockout(1);
+                               $user->homenode($origin);
+                               $user->node($origin);
+                               $user->wantroutepc19(1);
+                               $user->wantpc90(1);
+                       }
+                       $user->put;
+               }
+               $parent = $op;
+       }
+
        # parse the PC19
        for ($i = 1; $i < $#_-1; $i += 4) {
                my $here = $_[$i];
@@ -2058,13 +2081,13 @@ sub send_local_config
                                }
                        }
                } else {
-                       my @rawintcalls = map { $_->nodes } @localnodes if @localnodes;
+                       my @rawintcalls = map { $_->links } @localnodes if @localnodes;
                        my @intcalls;
                        for $node (@rawintcalls) {
                                push @intcalls, $node unless grep $node eq $_, @intcalls; 
                        }
                        my $ref = Route::Node::get($self->{call});
-                       my @rnodes = $ref->nodes;
+                       my @rnodes = $ref->links;
                        for $node (@intcalls) {
                                push @remotenodes, Route::Node::get($node) unless grep $node eq $_, @rnodes, @remotenodes;
                        }