From patchwork Thu Apr 5 08:52:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 150893 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) by ozlabs.org (Postfix) with ESMTP id 9C133B704F for ; Thu, 5 Apr 2012 18:52:45 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 123209D332; Thu, 5 Apr 2012 04:52:40 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2KhB7tuYbF6E; Thu, 5 Apr 2012 04:52:39 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id CF1299D311; Thu, 5 Apr 2012 04:52:35 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 20FEF9D311 for ; Thu, 5 Apr 2012 04:52:34 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b3J7+ecge8Xt for ; Thu, 5 Apr 2012 04:52:29 -0400 (EDT) Received: from sipsolutions.net (he.sipsolutions.net [78.46.109.217]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 2E1229D2E1 for ; Thu, 5 Apr 2012 04:52:29 -0400 (EDT) Received: by sipsolutions.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.77) (envelope-from ) id 1SFiQc-0005DO-G2; Thu, 05 Apr 2012 10:52:26 +0200 Message-ID: <1333615944.3479.5.camel@jlt3.sipsolutions.net> Subject: [PATCH] wpa_s: add script to convert debug output to pcap From: Johannes Berg To: hostap Date: Thu, 05 Apr 2012 10:52:24 +0200 X-Mailer: Evolution 3.2.2-1 Mime-Version: 1.0 Cc: Kalle Valo X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com From: Johannes Berg For debugging I needed to look at the frames in a wpa_supplicant debug log. Looking at the hexdump is a bit tedious, so I wrote a quick script to convert the nl80211 debugging output to a PCAP file that can be opened in wireshark. I've polished the initial raw script a bit to add error messages and to also record the timestamps to the pcap file. Hopefully it's useful to somebody else as well. Signed-off-by: Johannes Berg --- wpa_supplicant/utils/log2pcap.py | 54 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 54 insertions(+), 0 deletions(-) create mode 100755 wpa_supplicant/utils/log2pcap.py diff --git a/wpa_supplicant/utils/log2pcap.py b/wpa_supplicant/utils/log2pcap.py new file mode 100755 index 0000000..641a4e4 --- /dev/null +++ b/wpa_supplicant/utils/log2pcap.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# +# Copyright (c) 2012, Intel Corporation +# +# Author: Johannes Berg +# +# This software may be distributed under the terms of the BSD license. +# See README for more details. + +import sys, struct, re + +def write_pcap_header(pcap_file): + pcap_file.write( + struct.pack(' " % sys.argv[0] + sys.exit(2) + + input_file = open(input, 'r') + pcap_file = open(pcap, 'w') + frame_re = re.compile(r'(([0-9]+.[0-9]{6}):\s*)?nl80211: MLME event frame - hexdump\(len=[0-9]*\):((\s*[0-9a-fA-F]{2})*)') + + write_pcap_header(pcap_file) + + for line in input_file: + m = frame_re.match(line) + if m is None: + continue + if m.group(2): + ts = float(m.group(2)) + else: + ts = 0 + hexdata = m.group(3) + hexdata = hexdata.split() + data = ''.join([chr(int(x, 16)) for x in hexdata]) + pcap_addpacket(pcap_file, ts, data) + + input_file.close() + pcap_file.close()