]> dxcluster.net Git - spider.git/blob - perl/Thingy/Bye.pm
start ping work
[spider.git] / perl / Thingy / Bye.pm
1 #
2 # Bye Thingy handling
3 #
4 # Note that this is a generator of pc21n and pc17n/pc17u
5 # and a consumer of fpc21n and fpc21n
6 #
7 # $Id$
8 #
9 # Copyright (c) 2005 Dirk Koopman G1TLH
10 #
11
12 use strict;
13
14 package Thingy::Bye;
15
16 use vars qw($VERSION $BRANCH);
17
18 main::mkver($VERSION = q$Revision$);
19
20 use DXChannel;
21 use DXDebug;
22 use Verify;
23 use Thingy;
24 use Thingy::RouteFilter;
25
26 use vars qw(@ISA);
27 @ISA = qw(Thingy Thingy::RouteFilter);
28
29 sub gen_Aranea
30 {
31         my $thing = shift;
32         unless ($thing->{Aranea}) {
33                 $thing->{Aranea} = Aranea::genmsg($thing, [qw(s auth)]);
34         }
35         return $thing->{Aranea};
36 }
37
38 sub handle
39 {
40         my $thing = shift;
41         my $dxchan = shift;
42
43         # fix the interface routing
44         my $intcall = $thing->{user} || $thing->{origin};
45         if ($dxchan->{call} eq $thing->{origin} && !$thing->{user}) {
46                 RouteDB::delete_interface($intcall);
47         } else {
48                 RouteDB::delete($intcall, $dxchan->{call});
49         }
50
51         # pc prot generation
52         my @pc21;
53         if (my $user = $thing->{user}) {
54                 my $parent = Route::Node::get($thing->{origin});
55                 my $uref = Route::get($user);
56                 if ($parent && $uref) {
57                         if ($uref->isa('Route::Node')) {
58                                 @pc21 = $uref->del($parent);
59                         } else {
60                                 $parent->del_user($uref);
61                                 $thing->{pc17n} = $parent;
62                                 $thing->{pc17u} = [$uref];
63                         }
64                 }
65         } else {
66                 my $parent = Route::get($thing->{origin});
67                 @pc21 = $parent->del_nodes if $parent;
68         }
69
70         $thing->{pc21n} = \@pc21 if @pc21;
71                 
72         $thing->broadcast($dxchan);
73 }
74
75 1;