]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - contrib/logparse.pl
Dedicated routines for poly1305 arithmetic.
[PuTTY.git] / contrib / logparse.pl
index 1790f2e0ed23a559852e3b5bcc9c8998255617ae..4805c0f4bdf994300be67053f8fe036864585204 100755 (executable)
@@ -115,6 +115,16 @@ my %packets = (
         my ($direction, $seq, $data) = @_;
         print "\n";
     },
+#define SSH2_MSG_KEX_ECDH_INIT                    30    /* 0x1e */
+    'SSH2_MSG_KEX_ECDH_INIT' => sub {
+        my ($direction, $seq, $data) = @_;
+        print "\n";
+    },
+#define SSH2_MSG_KEX_ECDH_REPLY                   31    /* 0x1f */
+    'SSH2_MSG_KEX_ECDH_REPLY' => sub {
+        my ($direction, $seq, $data) = @_;
+        print "\n";
+    },
 #define SSH2_MSG_USERAUTH_REQUEST                 50   /* 0x32 */
     'SSH2_MSG_USERAUTH_REQUEST' => sub {
         my ($direction, $seq, $data) = @_;
@@ -217,11 +227,15 @@ my %packets = (
         # opposite to every other message in the protocol, which all
         # quote the _recipient's_ id of the channel.
         $sid = ($direction eq "i" ? "s" : "c") . $sid;
-        my $chan = {'id'=>$sid, 'state'=>'halfopen'};
+        my $chan = {'id'=>$sid, 'state'=>'halfopen',
+                   'i'=>{'win'=>0, 'seq'=>0},
+                   'o'=>{'win'=>0, 'seq'=>0}};
+       $chan->{$direction}{'win'} = $winsize;
         push @channels, $chan;
         my $index = $#channels;
         $chan_by_id{$sid} = $index;
-        printf "ch%d (%s) %s", $index, $chan->{'id'}, $type;
+        printf "ch%d (%s) %s (--%d)", $index, $chan->{'id'}, $type,
+           $chan->{$direction}{'win'};
         if ($type eq "x11") {
             my ($addr, $port) = &parse("su", $data);
             printf " from %s:%s", $addr, $port;
@@ -240,12 +254,18 @@ my %packets = (
         my ($rid, $sid, $winsize, $packet) = &parse("uuuu", $data);
         $rid = ($direction eq "i" ? "c" : "s") . $rid;
         my $index = $chan_by_id{$rid};
+        if (!defined $index) {
+            printf "UNKNOWN_CHANNEL (%s) (--%d)\n", $rid, $winsize;
+            return;
+        }
         $sid = ($direction eq "i" ? "s" : "c") . $sid;
         $chan_by_id{$sid} = $index;
         my $chan = $channels[$index];
         $chan->{'id'} = ($direction eq "i" ? "$rid/$sid" : "$sid/$rid");
         $chan->{'state'} = 'open';
-        printf "ch%d (%s)\n", $index, $chan->{'id'};
+       $chan->{$direction}{'win'} = $winsize;
+        printf "ch%d (%s) (--%d)\n", $index, $chan->{'id'},
+           $chan->{$direction}{'win'};
     },
 #define SSH2_MSG_CHANNEL_OPEN_FAILURE             92   /* 0x5c */
     'SSH2_MSG_CHANNEL_OPEN_FAILURE' => sub {
@@ -253,6 +273,10 @@ my %packets = (
         my ($rid, $reason, $desc, $lang) = &parse("uuss", $data);
         $rid = ($direction eq "i" ? "c" : "s") . $rid;
         my $index = $chan_by_id{$rid};
+        if (!defined $index) {
+            printf "UNKNOWN_CHANNEL (%s) %s\n", $rid, &str($reason);
+            return;
+        }
         my $chan = $channels[$index];
         $chan->{'state'} = 'rejected';
         printf "ch%d (%s) %s\n", $index, $chan->{'id'}, &str($reason);
@@ -263,8 +287,14 @@ my %packets = (
         my ($rid, $bytes) = &parse("uu", $data);
         $rid = ($direction eq "i" ? "c" : "s") . $rid;
         my $index = $chan_by_id{$rid};
+        if (!defined $index) {
+            printf "UNKNOWN_CHANNEL (%s) +%d\n", $rid, $bytes;
+            return;
+        }
         my $chan = $channels[$index];
-        printf "ch%d (%s) +%s\n", $index, $chan->{'id'}, $bytes;
+       $chan->{$direction}{'win'} += $bytes;
+        printf "ch%d (%s) +%d (--%d)\n", $index, $chan->{'id'}, $bytes,
+           $chan->{$direction}{'win'};
     },
 #define SSH2_MSG_CHANNEL_DATA                     94   /* 0x5e */
     'SSH2_MSG_CHANNEL_DATA' => sub {
@@ -272,8 +302,14 @@ my %packets = (
         my ($rid, $bytes) = &parse("uu", $data);
         $rid = ($direction eq "i" ? "c" : "s") . $rid;
         my $index = $chan_by_id{$rid};
+        if (!defined $index) {
+            printf "UNKNOWN_CHANNEL (%s), %s bytes\n", $rid, $bytes;
+            return;
+        }
         my $chan = $channels[$index];
-        printf "ch%d (%s), %s bytes\n", $index, $chan->{'id'}, $bytes;
+       $chan->{$direction}{'seq'} += $bytes;
+        printf "ch%d (%s), %s bytes (%d--%d)\n", $index, $chan->{'id'}, $bytes,
+           $chan->{$direction}{'seq'}-$bytes, $chan->{$direction}{'seq'};
         my @realdata = splice @$data, 0, $bytes;
         if ($dumpdata) {
             my $filekey = $direction . "file";
@@ -297,11 +333,22 @@ my %packets = (
 #define SSH2_MSG_CHANNEL_EXTENDED_DATA            95   /* 0x5f */
     'SSH2_MSG_CHANNEL_EXTENDED_DATA' => sub {
         my ($direction, $seq, $data) = @_;
-        my ($rid, $bytes) = &parse("uu", $data);
+        my ($rid, $type, $bytes) = &parse("uuu", $data);
+        if ($type == 1) {
+            $type = "SSH_EXTENDED_DATA_STDERR";
+        }
         $rid = ($direction eq "i" ? "c" : "s") . $rid;
         my $index = $chan_by_id{$rid};
+        if (!defined $index) {
+            printf "UNKNOWN_CHANNEL (%s), type %s, %s bytes\n", $rid,
+                $type, $bytes;
+            return;
+        }
         my $chan = $channels[$index];
-        printf "ch%d (%s), %s bytes\n", $index, $chan->{'id'}, $bytes;
+       $chan->{$direction}{'seq'} += $bytes;
+        printf "ch%d (%s), type %s, %s bytes (%d--%d)\n", $index,$chan->{'id'},
+            $type, $bytes, $chan->{$direction}{'seq'}-$bytes,
+            $chan->{$direction}{'seq'};
         my @realdata = splice @$data, 0, $bytes;
         if ($dumpdata) {
             # We treat EXTENDED_DATA as equivalent to DATA, for the
@@ -312,8 +359,8 @@ my %packets = (
             my $filekey = $direction . "file";
             if (!defined $chan->{$filekey}) {
                 my $filename = sprintf "ch%d.%s", $index, $direction;
-                $chan->{$filekey} = FileHandle->new;
-                if (!$chan->{$filekey}->open(">", $filename)) {
+                $chan->{$filekey} = FileHandle->new(">$filename");
+                if (!defined $chan->{$filekey}) {
                     die "$filename: $!\n";
                 }
             }
@@ -333,6 +380,10 @@ my %packets = (
         my ($rid) = &parse("uu", $data);
         $rid = ($direction eq "i" ? "c" : "s") . $rid;
         my $index = $chan_by_id{$rid};
+        if (!defined $index) {
+            printf "UNKNOWN_CHANNEL (%s)\n", $rid;
+            return;
+        }
         my $chan = $channels[$index];
         printf "ch%d (%s)\n", $index, $chan->{'id'};
     },
@@ -342,6 +393,10 @@ my %packets = (
         my ($rid) = &parse("uu", $data);
         $rid = ($direction eq "i" ? "c" : "s") . $rid;
         my $index = $chan_by_id{$rid};
+        if (!defined $index) {
+            printf "UNKNOWN_CHANNEL (%s)\n", $rid;
+            return;
+        }
         my $chan = $channels[$index];
         $chan->{'state'} = ($chan->{'state'} eq "open" ? "halfclosed" :
                             $chan->{'state'} eq "halfclosed" ? "closed" :
@@ -358,11 +413,17 @@ my %packets = (
         my ($rid, $type, $wantreply) = &parse("usb", $data);
         $rid = ($direction eq "i" ? "c" : "s") . $rid;
         my $index = $chan_by_id{$rid};
-        my $chan = $channels[$index];
-        printf "ch%d (%s) %s (%s)",
-            $index, $chan->{'id'}, $type, $wantreply eq "yes" ? "reply" : "noreply";
-        push @{$chan->{'requests_'.$direction}}, [$seq, $type]
-           if $wantreply eq "yes";
+        my $chan;
+        if (!defined $index) {
+            printf "UNKNOWN_CHANNEL (%s) %s (%s)", $rid,
+                $type, $wantreply eq "yes" ? "reply" : "noreply";
+        } else {
+            $chan = $channels[$index];
+            printf "ch%d (%s) %s (%s)", $index, $chan->{'id'},
+                $type, $wantreply eq "yes" ? "reply" : "noreply";
+            push @{$chan->{'requests_'.$direction}}, [$seq, $type]
+               if $wantreply eq "yes";
+        }
         if ($type eq "pty-req") {
             my ($term, $w, $h, $pw, $ph, $modes) = &parse("suuuus", $data);
             printf " %s %sx%s", &str($term), $w, $h;
@@ -404,6 +465,10 @@ my %packets = (
         my ($rid) = &parse("uu", $data);
         $rid = ($direction eq "i" ? "c" : "s") . $rid;
         my $index = $chan_by_id{$rid};
+        if (!defined $index) {
+            printf "UNKNOWN_CHANNEL (%s)\n", $rid;
+            return;
+        }
         my $chan = $channels[$index];
         printf "ch%d (%s)", $index, $chan->{'id'};
         my $otherdir = ($direction eq "i" ? "o" : "i");
@@ -421,6 +486,10 @@ my %packets = (
         my ($rid) = &parse("uu", $data);
         $rid = ($direction eq "i" ? "c" : "s") . $rid;
         my $index = $chan_by_id{$rid};
+        if (!defined $index) {
+            printf "UNKNOWN_CHANNEL (%s)\n", $rid;
+            return;
+        }
         my $chan = $channels[$index];
         printf "ch%d (%s)", $index, $chan->{'id'};
         my $otherdir = ($direction eq "i" ? "o" : "i");