File tree Expand file tree Collapse file tree
scapy/contrib/automotive/bmw
test/contrib/automotive/bmw Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,15 +59,19 @@ class HSFZ(Packet):
5959 IntField ('length' , None ),
6060 ShortEnumField ('control' , 1 , control_words ),
6161 ConditionalField (
62- XByteField ('source' , 0 ), lambda p : p .control == 1 ),
62+ XByteField ('source' , 0 ), lambda p : p ._hasaddrs () ),
6363 ConditionalField (
64- XByteField ('target' , 0 ), lambda p : p .control == 1 ),
64+ XByteField ('target' , 0 ), lambda p : p ._hasaddrs () ),
6565 ConditionalField (
6666 StrFixedLenField ("identification_string" ,
6767 None , None , lambda p : p .length ),
6868 lambda p : p .control == 0x11 )
6969 ]
7070
71+ def _hasaddrs (self ):
72+ # type: () -> bool
73+ return self .control == 0x01 or self .control == 0x02
74+
7175 def hashret (self ):
7276 # type: () -> bytes
7377 hdr_hash = struct .pack ("B" , self .source ^ self .target )
Original file line number Diff line number Diff line change @@ -76,6 +76,24 @@ assert pkt.control == 1
7676assert pkt.securitySeed == b"0" * 0xfff00
7777
7878
79+ = Dissect diagnostic request
80+
81+ pkt = HSFZ(hex_bytes("000000050001f41022f150"))
82+ assert pkt.length == 5
83+ assert pkt.control == 0x01
84+ assert pkt.source == 0xf4
85+ assert pkt.target == 0x10
86+
87+
88+ = Dissect acknowledgment transfer
89+
90+ pkt = HSFZ(hex_bytes("000000050002f41022f150"))
91+ assert pkt.length == 5
92+ assert pkt.control == 0x02
93+ assert pkt.source == 0xf4
94+ assert pkt.target == 0x10
95+
96+
7997= Dissect identification
8098
8199pkt = HSFZ(bytes.fromhex("000000320011444941474144523130424d574d4143374346436343463837393343424d5756494e5742413558373333333246483735373334"))
You can’t perform that action at this time.
0 commit comments