outgoing calls on AGW engine?
authorminima <minima>
Wed, 28 Mar 2001 21:53:53 +0000 (21:53 +0000)
committerminima <minima>
Wed, 28 Mar 2001 21:53:53 +0000 (21:53 +0000)
Changes
perl/AGWConnect.pm
perl/AGWMsg.pm
perl/ExtMsg.pm

diff --git a/Changes b/Changes
index 7ebe03efbb53bda9d93c5cebd97a241268d6ae4a..8d90f47d4b0a385ebff81e69033684b3a0261ffd 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+28Mar01=======================================================================
+1. AGW engine stuff now accepts incoming calls and at least attempts to do
+outgoing ones. YMMV.
 27Mar01=======================================================================
 1. add first cut at an AGW Engine. Copy /spider/perl/AGWConnect.pm to 
 /spider/local and edit it appropriately. You shouldn't need a login and passwd
index c19055ef4e731adbd2dde14b28eb594eeeb22938..f9fc2761aceaafbbfdfaf6252b83d941ea435c04 100644 (file)
@@ -10,7 +10,7 @@
 package AGWMsg;
 
 use strict;
-use vars qw($enable $login $passwd $addr $port $monitor);
+use vars qw($enable $login $passwd $addr $port $monitor $ypolltime $hpolltime);
 
 # set this to 1 to enable AGW Engine handling
 $enable = 0;
@@ -32,5 +32,11 @@ $port = 8000;
 
 # default monitor status
 $monitor = 0;
+
+# time between polls of channel queues
+$ypolltime = 10;
+
+# time between polls of Mheard
+$hpolltime = 120;
  
 1;
index 8f78319b0c0430685aae4d32b3eff4bbc6566392..5e583d25bdbd4c7ff312a70cf001695d15e5c465 100644 (file)
@@ -29,7 +29,8 @@ use Msg;
 use AGWConnect;
 use DXDebug;
 
-use vars qw(@ISA $sock @outqueue $send_offset $inmsg $rproc $noports $lasttime);
+use vars qw(@ISA $sock @outqueue $send_offset $inmsg $rproc $noports $lastytime 
+                       $lasthtime $ypolltime $hpolltime);
 
 @ISA = qw(Msg ExtMsg);
 $sock = undef;
@@ -38,7 +39,9 @@ $send_offset = 0;
 $inmsg = '';
 $rproc = undef;
 $noports = 0;
-$lasttime = time;
+$lastytime = $lasthtime = time;
+$ypolltime = 10 unless defined $ypolltime;
+$hpolltime = 120 unless defined $hpolltime;
 
 sub init
 {
@@ -100,7 +103,17 @@ sub _sendf
        my $len  = 0;
        
        $len = length $data; 
-       dbg('agw', "AGW sendf: $sort '${from}'->'${to}' port: $port pid: $pid \"$data\"");
+       if ($sort eq 'y' || $sort eq 'H') {
+               dbg('agwpoll', "AGW sendf: $sort '${from}'->'${to}' port: $port pid: $pid \"$data\"");
+       } elsif ($sort eq 'D') {
+               if (isdbg('agw')) {
+                       my $d = $data;
+                       $d =~ s/\cM$//;
+                       dbg('agw', "AGW sendf: $sort '${from}'->'${to}' port: $port pid: $pid \"$d\"");
+               }
+       } else {
+               dbg('agw', "AGW sendf: $sort '${from}'->'${to}' port: $port pid: $pid \"$data\"");
+       }
        push @outqueue, pack('C x3 a1 x1 C x1 a10 a10 V x4 a*', $port, $sort, $pid, $from, $to, $len, $data);
        Msg::set_event_handler($sock, write=>\&_send);
 }
@@ -230,7 +243,7 @@ sub _decode
                my $d = unpack "Z*", $data;
                $d =~ s/\cM$//;
                dbg('agw', "AGW Data In port: $port pid: $pid '$from'->'$to' length: $len \"$d\"");
-               my $conn = Msg->conns($from eq $main::mycall ? $to : $from);
+               my $conn = _find($from eq $main::mycall ? $to : $from);
                if ($conn) {
                        if ($conn->{state} eq 'WC') {
                                if (exists $conn->{cmd}) {
@@ -244,8 +257,12 @@ sub _decode
                                }
                        } else {
                                my @lines = split /\cM/, $data;
-                               for (@lines) {
-                                       &{$conn->{rproc}}($conn, "I$conn->{call}|$_");
+                               if (@lines) {
+                                       for (@lines) {
+                                               &{$conn->{rproc}}($conn, "I$conn->{call}|$_");
+                                       }
+                               } else {
+                                       &{$conn->{rproc}}($conn, "I$conn->{call}|");
                                }
                        }
                } else {
@@ -282,6 +299,16 @@ sub _decode
                        $conn->{lineend} = "\cM";
                        $conn->{incoming} = 1;
                        $conn->{agwcall} = $call;
+                       if ($call =~ /^(\w+)-(\d\d?)$/) {
+                               my $c = $1;
+                               my $s = $2;
+                               $s = 15 - $s;
+                               if ($s <= 8 && $s > 0) {
+                                       $call = "${c}-${s}";
+                               } else {
+                                       $call = $c;
+                               }
+                       }
                        $conn->to_connected($call, 'A', $conn->{csort} = 'ax25');
                }
        } elsif ($sort eq 'd') {
@@ -290,7 +317,7 @@ sub _decode
                $conn->in_disconnect if $conn;
        } elsif ($sort eq 'y') {
                my ($frames) = unpack "V", $data;
-               dbg('agw', "AGW Frames Outstanding on port $port = $frames");
+               dbg('agwpollans', "AGW Frames Outstanding on port $port = $frames");
                my $conn = Msg->conns($from);
                $conn->{oframes} = $frames if $conn;
        } elsif ($sort eq 'Y') {
@@ -298,6 +325,12 @@ sub _decode
                dbg('agw', "AGW Frames Outstanding on circuit '$from'->'$to' = $frames");
                my $conn = Msg->conns($from eq $main::mycall ? $to : $from);
                $conn->{oframes} = $frames if $conn;
+       } elsif ($sort eq 'H') {
+               unless ($from =~ /^\s+$/) {
+                       my $d = unpack "Z*", $data;
+                       $d =~ s/\cM$//;
+                       dbg('agw', "AGW Heard port: $port \"$d\"");
+               }
        } elsif ($sort eq 'X') {
                my ($r) = unpack "C", $data;
                $r = $r ? "Successful" : "Failed";
@@ -348,41 +381,53 @@ sub connect
        $conn->{agwcall} = uc $call;
        
        _sendf('C', $main::mycall, $conn->{agwcall}, $conn->{agwport}, $conn->{agwpid});
+       $conn->{state} = 'WC';
+       
        return 1;
 }
 
 sub in_disconnect
 {
        my $conn = shift;
+       _sendf('d', $conn->{agwcall}, $main::mycall, $conn->{agwport}, $conn->{agwpid});
        $conn->SUPER::disconnect;
 }
 
 sub disconnect
 {
        my $conn = shift;
-       _sendf('d', $main::mycall, $conn->{agwcall}, $conn->{agwport}, $conn->{agwpid});
+       if ($conn->{incoming}) {
+               _sendf('d', $conn->{agwcall}, $main::mycall, $conn->{agwport}, $conn->{agwpid});
+       } else {
+               _sendf('d', $main::mycall, $conn->{agwcall}, $conn->{agwport}, $conn->{agwpid});
+       }
        $conn->SUPER::disconnect;
 }
 
 sub enqueue
 {
        my ($conn, $msg) = @_;
-       if ($msg =~ /^[D]/) {
+       if ($msg =~ /^D/) {
                $msg =~ s/^[-\w]+\|//;
-               _sendf('Y', $main::mycall, $conn->{call}, $conn->{agwport}, $conn->{agwpid});
-               _sendf('D', $main::mycall, $conn->{call}, $conn->{agwport}, $conn->{agwpid}, $msg . $conn->{lineend});
+#              _sendf('Y', $main::mycall, $conn->{call}, $conn->{agwport}, $conn->{agwpid});
+               _sendf('D', $main::mycall, $conn->{agwcall}, $conn->{agwport}, $conn->{agwpid}, $msg . $conn->{lineend});
        }
 }
 
 sub process
 {
        return unless $sock;
-       if ($main::systime - $lasttime >= 60) {
+       if ($ypolltime && $main::systime - $lastytime >= $ypolltime) {
                for (my $i = 0; $i < $noports; $i++) {
                        _sendf('y', undef, undef, $i );
-#                      _sendf('H', undef, undef, $i );
                }
-               $lasttime = $main::systime;
+               $lastytime = $main::systime;
+       }
+       if ($hpolltime && $main::systime - $lasthtime >= $hpolltime) {
+               for (my $i = 0; $i < $noports; $i++) {
+                       _sendf('H', undef, undef, $i );
+               }
+               $lasthtime = $main::systime;
        }
 }
 1;
index de0c0bcaf4640b5e8b962702510e20fc8632fa45..c4522146defe2b09443003f1fe6bd64704915976 100644 (file)
@@ -312,7 +312,7 @@ sub _dochat
                        }
                        if ($line =~ /\Q$expect/i) {
                                dbg('connect', "got: \"$expect\" sending: \"$send\"");
-                               $conn->send_later($send);
+                               $conn->send_later("D$conn->{call}|$send");
                                delete $conn->{msg}; # get rid any input if a match
                                return;
                        }