File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
scapy/contrib/automotive/bmw
test/contrib/automotive/bmw Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -59,15 +59,19 @@ class HSFZ(Packet):
59
59
IntField ('length' , None ),
60
60
ShortEnumField ('control' , 1 , control_words ),
61
61
ConditionalField (
62
- XByteField ('source' , 0 ), lambda p : p .control == 1 ),
62
+ XByteField ('source' , 0 ), lambda p : p ._hasaddrs () ),
63
63
ConditionalField (
64
- XByteField ('target' , 0 ), lambda p : p .control == 1 ),
64
+ XByteField ('target' , 0 ), lambda p : p ._hasaddrs () ),
65
65
ConditionalField (
66
66
StrFixedLenField ("identification_string" ,
67
67
None , None , lambda p : p .length ),
68
68
lambda p : p .control == 0x11 )
69
69
]
70
70
71
+ def _hasaddrs (self ):
72
+ # type: () -> bool
73
+ return self .control == 0x01 or self .control == 0x02
74
+
71
75
def hashret (self ):
72
76
# type: () -> bytes
73
77
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
76
76
assert pkt.securitySeed == b"0" * 0xfff00
77
77
78
78
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
+
79
97
= Dissect identification
80
98
81
99
pkt = HSFZ(bytes.fromhex("000000320011444941474144523130424d574d4143374346436343463837393343424d5756494e5742413558373333333246483735373334"))
You can’t perform that action at this time.
0 commit comments