X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FAGWMsg.pm;h=cb64177e20931cf5bb5c067bc36a26f13c4e235c;hb=9e5520826fe61fd3ac6941f2b8bf736a432eaa15;hp=08660d626d987ea7de5b036c9ca771bf06ccaaaa;hpb=96d6698d3f043a960ec5ef387747e5b470ac93b3;p=spider.git diff --git a/perl/AGWMsg.pm b/perl/AGWMsg.pm index 08660d62..cb64177e 100644 --- a/perl/AGWMsg.pm +++ b/perl/AGWMsg.pm @@ -30,7 +30,7 @@ use AGWConnect; use DXDebug; use vars qw(@ISA $sock @outqueue $send_offset $inmsg $rproc $noports $lastytime - $lasthtime $ypolltime $hpolltime %circuit); + $lasthtime $ypolltime $hpolltime %circuit $total_in $total_out); @ISA = qw(Msg ExtMsg); $sock = undef; @@ -43,6 +43,7 @@ $lastytime = $lasthtime = time; $ypolltime = 10 unless defined $ypolltime; $hpolltime = 300 unless defined $hpolltime; %circuit = (); +$total_in = $total_out = 0; use vars qw($VERSION $BRANCH); $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ ); @@ -103,6 +104,11 @@ sub finish } } +sub login +{ + goto &main::login; # save some writing, this was the default +} + sub active { return $sock; @@ -171,6 +177,7 @@ sub _send if (isdbg('raw')) { dbgdump('raw', "AGW send $bytes_written: ", $msg); } + $total_out += $bytes_written; $offset += $bytes_written; $bytes_to_write -= $bytes_written; } @@ -196,6 +203,7 @@ sub _rcv { # Complement to _send $bytes_read = sysread ($sock, $msg, 1024, 0); if (defined ($bytes_read)) { if ($bytes_read > 0) { + $total_in += $bytes_read; $inmsg .= $msg; if (isdbg('raw')) { dbgdump('raw', "AGW read $bytes_read: ", $msg); @@ -266,8 +274,8 @@ sub _decode $data = '' unless defined $data; if ($sort eq 'D') { my $d = unpack "Z*", $data; - $d =~ s/\cJ//g; # remove all new line characters - $d =~ s/\cM$//; + $d =~ s/\cM\cJ?$//; + $d =~ s/^\cJ//; dbg("AGW Data In port: $port pid: $pid '$from'->'$to' length: $len \"$d\"") if isdbg('agw'); my $conn = _find($from eq $main::mycall ? $to : $from); if ($conn) { @@ -282,13 +290,10 @@ sub _decode $conn->to_connected($conn->{call}, 'O', $conn->{csort}); } } else { - my @lines = split /\cM/, $data; - if (@lines) { - for (@lines) { - &{$conn->{rproc}}($conn, "I$conn->{call}|$_"); - } - } else { - &{$conn->{rproc}}($conn, "I$conn->{call}|"); + my @lines = split /\cM\cJ?/, $d; + push @lines, $d unless @lines; + for (@lines) { + &{$conn->{rproc}}($conn, "I$conn->{call}|$_"); } } } else { @@ -296,9 +301,9 @@ sub _decode } } elsif ($sort eq 'I' || $sort eq 'S' || $sort eq 'U' || $sort eq 'M' || $sort eq 'T') { my $d = unpack "Z*", $data; - $d =~ s/\cJ//g; # remove all new line characters - $d =~ s/\cM$//; - my @lines = split /\cM/, $d; + $d =~ s/^\cJ//; + $d =~ s/\cM\cJ?$//; + my @lines = split /\cM\cJ?/, $d; for (@lines) { # s/([\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg; @@ -306,7 +311,7 @@ sub _decode } } elsif ($sort eq 'C') { my $d = unpack "Z*", $data; - $d =~ s/\cM$//; + $d =~ s/\cM\cJ?$//; dbg("AGW Connect port: $port pid: $pid '$from'->'$to' \"$d\"") if isdbg('agw'); my $call = $from eq $main::mycall ? $to : $from; my $conn = _find($call); @@ -327,21 +332,15 @@ sub _decode $conn->{incoming} = 1; $conn->{agwcall} = $call; $circuit{$call} = $conn; - 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; - } + if (my ($c, $s) = $call =~ /^(\w+)-(\d\d?)$/) { + $s = 15 - $s if $s > 8; + $call = $s > 0 ? "${c}-${s}" : $c; } $conn->to_connected($call, 'A', $conn->{csort} = 'ax25'); } } elsif ($sort eq 'd') { my $d = unpack "Z*", $data; - $d =~ s/\cM$//; + $d =~ s/\cM\cJ?$//; dbg("AGW '$from'->'$to' port: $port Disconnected ($d)") if isdbg('agw'); my $conn = _find($from eq $main::mycall ? $to : $from); if ($conn) { @@ -361,7 +360,7 @@ sub _decode } elsif ($sort eq 'H') { unless ($from =~ /^\s+$/) { my $d = unpack "Z*", $data; - $d =~ s/\cM$//; + $d =~ s/\cM\cJ?$//; dbg("AGW Heard port: $port \"$d\"") if isdbg('agw'); } } elsif ($sort eq 'X') {