Implemented detection of packet direction and improved handling of data frames
authorjaviplx <javiplx@gmail.com>
Mon, 11 Oct 2010 18:33:39 +0000 (18:33 +0000)
committerjaviplx <javiplx@gmail.com>
Mon, 11 Oct 2010 18:33:39 +0000 (18:33 +0000)
git-svn-id: file:///svnroot/wifihood/trunk@51 c51dfc6a-5949-4919-9c8e-f207a149c383

wifiscanner/wiviz.py

index 98001d4..530f7ee 100755 (executable)
@@ -123,6 +123,14 @@ data_subtypes = (
 ( "QOS_NULL"       , 0xc0 )  
 )
 
+# without IEEE80211_FC1_DIR_
+directions = (
+( "NODS"               , 0x00 ) , # STA->STA
+( "TODS"               , 0x01 ) , # STA->AP
+( "FROMDS"             , 0x02 ) , # AP ->STA
+( "DSTODS"             , 0x03 )   # AP ->AP
+)
+
 import time
 
 max_time = 1
@@ -187,7 +195,7 @@ def dealWithPacket ( hdr , data ) :
             type = name
             break
     else :
-        print "Unknown frame type %s" % frame_ctl & 0x0c
+        print "Unknown frame type %s" % ( frame_ctl & 0x0c , )
         return
 
     if type == "MGT" :
@@ -196,7 +204,7 @@ def dealWithPacket ( hdr , data ) :
                 subtype = name
                 break
         else :
-            print "Unknown MGT subtype %s" % frame_ctl & 0xf0
+            print "Unknown MGT subtype %s" % ( frame_ctl & 0xf0 , )
             return
 
     elif type == "CTL" :
@@ -205,11 +213,23 @@ def dealWithPacket ( hdr , data ) :
                 subtype = name
                 break
         else :
-            print "Unknown CTL subtype %s" % frame_ctl & 0xf0
+            print "Unknown CTL subtype %s" % ( frame_ctl & 0xf0 , )
             return
 
     elif type == "DATA" :
-        subtype = "UNDEFINED"
+        _subtype = []
+        for name,value in data_subtypes :
+            if frame_ctl & 0xf0 == value :
+                _subtype.append( name )
+        subtype = "-".join( _subtype )
+
+    for name,value in directions :
+        if frame_subtype & 0x03 == value :
+            direction = name
+            break
+    else :
+        print "Unknown direction %s" % ( frame_subtype & 0x03 , )
+        return
 
 
     mac_str = "BBBBBB" # is leading '<' required
@@ -249,7 +269,7 @@ def dealWithPacket ( hdr , data ) :
         fd.close()
         raise Exception( "Neighborhoud scan completed" )
 
-    print "%4s %13s %4d %4d from %4d" % (type,subtype,values[3],pcktlen,len(payload))," ; %4d %4d "%sequence,":"+" %s"*len(maclist) % tuple(maclist)
+    print "%4s %13s %6s %4d %4d from %4d" % (type,subtype,direction,values[3],pcktlen,len(payload))," ; %4d %4d "%sequence,":"+" %s"*len(maclist) % tuple(maclist)
 
 packet_limit = -1 # infinite
 pc.loop( packet_limit , dealWithPacket )