From: javiplx Date: Mon, 11 Oct 2010 18:33:39 +0000 (+0000) Subject: Implemented detection of packet direction and improved handling of data frames X-Git-Tag: cleaned~33 X-Git-Url: http://vcs.maemo.org/git/?p=wifihood;a=commitdiff_plain;h=96b8375e2e41acd1d53b3711451081325591dbe0 Implemented detection of packet direction and improved handling of data frames git-svn-id: file:///svnroot/wifihood/trunk@51 c51dfc6a-5949-4919-9c8e-f207a149c383 --- diff --git a/wifiscanner/wiviz.py b/wifiscanner/wiviz.py index 98001d4..530f7ee 100755 --- a/wifiscanner/wiviz.py +++ b/wifiscanner/wiviz.py @@ -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 )