From patchwork Wed Oct 10 13:39:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Ospite X-Patchwork-Id: 14969 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1TLwb1-0007ju-I3 for patchwork@linuxtv.org; Wed, 10 Oct 2012 15:45:11 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-4) with esmtp for id 1TLwb0-0007Zf-CY; Wed, 10 Oct 2012 15:45:11 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756325Ab2JJNpH (ORCPT ); Wed, 10 Oct 2012 09:45:07 -0400 Received: from smtp209.alice.it ([82.57.200.105]:37349 "EHLO smtp209.alice.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754675Ab2JJNpG (ORCPT ); Wed, 10 Oct 2012 09:45:06 -0400 X-Greylist: delayed 337 seconds by postgrey-1.27 at vger.kernel.org; Wed, 10 Oct 2012 09:45:06 EDT Received: from jcn (87.1.92.64) by smtp209.alice.it (8.6.023.02) id 506F18A000A9A3D1; Wed, 10 Oct 2012 15:39:27 +0200 Received: from ao2 by jcn with local (Exim 4.80) (envelope-from ) id 1TLwVR-00039r-1v; Wed, 10 Oct 2012 15:39:25 +0200 From: Antonio Ospite To: linux-media@vger.kernel.org Cc: Aapo Tahkola , CityK Subject: [PATCH 2/5] contrib: add a script to convert usbmon captures to usbsnoop Date: Wed, 10 Oct 2012 15:39:19 +0200 Message-Id: <1349876363-12098-3-git-send-email-ospite@studenti.unina.it> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1349876363-12098-1-git-send-email-ospite@studenti.unina.it> References: <1349876363-12098-1-git-send-email-ospite@studenti.unina.it> X-Face: z*RaLf`X<@C75u6Ig9}{oW$H; 1_\2t5)({*|jhM/Vb; ]yA5\I~93>J<_`<4)A{':UrE Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.10.10.133624 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __STOCK_PHRASE_7 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NS ' From: Aapo Tahkola This makes it possible to reuse tools written for usbsnoop with captures done using a virtual machine and usbmon. Signed-off-by: Aapo Tahkola --- contrib/usbmon2usbsnoop.pl | 53 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 contrib/usbmon2usbsnoop.pl diff --git a/contrib/usbmon2usbsnoop.pl b/contrib/usbmon2usbsnoop.pl new file mode 100755 index 0000000..c656687 --- /dev/null +++ b/contrib/usbmon2usbsnoop.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl +# +# This perl script converts output from usbmon to a format (usbsnoop's log format) that is compatible with usbreplay. +# Taken from http://www.linuxtv.org/wiki/index.php/Usbmon2usbsnoop + +sub print_bytes{ + my($str) = @_; + + @str_1 = split(/ /, $str); + + foreach(@str_1){ + if (length($_) == 8) { + print substr($_, 0, 2) . " " . substr($_, 2, 2) . " " . substr($_, 4, 2) . " " . substr($_, 6, 2); + }elsif(length($_) == 4) { + print substr($_, 2, 2) . " " . substr($_, 0, 2); + }elsif(length($_) == 2) { + print $_; + }elsif(length($_) == 1) { + next; + } + print " "; + } +} + + +$i = 0; +while($line = ) { + $i++; + + if($line =~ m/\S+ \S+ \S+ \S+ \S+ (.+) \S+ ; + $i++; + if($line =~ m/\S+ \S+ \S+ \S+ [a-fA-F0-9 ]+ = ([a-fA-F0-9 ]+)/) { + print_bytes($1); + #print "\n"; + #print " $1\n"; + } + print "\n"; + }elsif($line =~ m/\S+ \S+ \S+ \S+ ([a-fA-F0-9 ]+) [a-fA-F0-9]+ = ([a-fA-F0-9 ]+)/) { + printf "%06d: OUT: %06d ms %06d ms ", $i, 1, $i; + print_bytes($1); + print ">>> "; + print_bytes($2); + print "\n"; + }elsif($line =~ m/\S+ \S+ \S+ \S+ s (.+)/) { + printf "%06d: OUT: %06d ms %06d ms ", $i, 1, $i; + print_bytes($1); + print ">>>\n"; + } +}