<s> """<STR_LIT>""" <EOL> import logging , struct <EOL> from scapy . config import conf <EOL> from scapy . packet import * <EOL> from scapy . fields import * <EOL> from scapy . layers . l2 import Ether <EOL> from scapy . layers . dot11 import Dot11 <EOL> _ppi_types = { } <EOL> def addPPIType ( id , value ) : <EOL> _ppi_types [ id ] = value <EOL> def getPPIType ( id , default = "<STR_LIT:default>" ) : <EOL> return _ppi_types . get ( id , _ppi_types . get ( default , None ) ) <EOL> class PPIGenericFldHdr ( Packet ) : <EOL> name = "<STR_LIT>" <EOL> fields_desc = [ LEShortField ( '<STR_LIT>' , <NUM_LIT:0> ) , <EOL> FieldLenField ( '<STR_LIT>' , None , length_of = "<STR_LIT:value>" , fmt = '<STR_LIT>' , adjust = lambda p , x : x + <NUM_LIT:4> ) , <EOL> StrLenField ( "<STR_LIT:value>" , "<STR_LIT>" , length_from = lambda p : p . pfh_length ) ] <EOL> def extract_padding ( self , p ) : <EOL> return "<STR_LIT>" , p <EOL> def _PPIGuessPayloadClass ( p , ** kargs ) : <EOL> """<STR_LIT>""" <EOL> if len ( p ) >= <NUM_LIT:4> : <EOL> t , pfh_len = struct . unpack ( "<STR_LIT>" , p [ : <NUM_LIT:4> ] ) <EOL> cls = getPPIType ( t , "<STR_LIT:default>" ) <EOL> pfh_len += <NUM_LIT:4> <EOL> out = cls ( p [ : pfh_len ] , ** kargs ) <EOL> if ( out . payload ) : <EOL> out . payload = conf . raw_layer ( out . payload . load ) <EOL> if ( len ( p ) > pfh_len ) : <EOL> out . payload . payload = conf . padding_layer ( p [ pfh_len : ] ) <EOL> elif ( len ( p ) > pfh_len ) : <EOL> out . payload = conf . padding_layer ( p [ pfh_len : ] ) <EOL> else : <EOL> out = conf . raw_layer ( p , ** kargs ) <EOL> return out <EOL> class PPI ( Packet ) : <EOL> name = "<STR_LIT>" <EOL> fields_desc = [ ByteField ( '<STR_LIT>' , <NUM_LIT:0> ) , <EOL> ByteField ( '<STR_LIT>' , <NUM_LIT:0> ) , <EOL> FieldLenField ( '<STR_LIT>' , None , length_of = "<STR_LIT>" , fmt = "<STR_LIT>" , adjust = lambda p , x : x + <NUM_LIT:8> ) , <EOL> LEIntField ( '<STR_LIT>' , None ) , <EOL> PacketListField ( "<STR_LIT>" , [ ] , _PPIGuessPayloadClass , length_from = lambda p : p . pph_len - <NUM_LIT:8> , ) ] <EOL> def guess_payload_class ( self , payload ) : <EOL> return conf . l2types . get ( self . dlt , Packet . guess_payload_class ( self , payload ) ) <EOL> addPPIType ( "<STR_LIT:default>" , PPIGenericFldHdr ) <EOL> conf . l2types . register ( <NUM_LIT> , PPI ) <EOL> conf . l2types . register_num2layer ( <NUM_LIT> , PPI ) <EOL> bind_layers ( PPI , Dot11 , dlt = conf . l2types . get ( Dot11 ) ) <EOL> bind_layers ( Dot11 , PPI ) <EOL> bind_layers ( PPI , Ether , dlt = conf . l2types . get ( Ether ) ) <EOL> bind_layers ( Dot11 , Ether ) </s>
