16
16
BitEnumField , BitField , XByteField , FieldListField , \
17
17
XShortField , X3BytesField , XIntField , ByteField , \
18
18
ShortField , ObservableDict , XShortEnumField , XByteEnumField , StrLenField , \
19
- FieldLenField , XStrFixedLenField , XStrLenField , FlagsField , PacketListField
19
+ FieldLenField , XStrFixedLenField , XStrLenField
20
20
from scapy .packet import Packet , bind_layers , NoPayload
21
21
from scapy .config import conf
22
22
from scapy .error import log_loading
@@ -152,7 +152,7 @@ class UDS_DSCPR(Packet):
152
152
153
153
def answers (self , other ):
154
154
return isinstance (other , UDS_DSC ) and \
155
- other .diagnosticSessionType == self .diagnosticSessionType
155
+ other .diagnosticSessionType == self .diagnosticSessionType
156
156
157
157
158
158
bind_layers (UDS , UDS_DSCPR , service = 0x50 )
@@ -218,7 +218,7 @@ class UDS_SAPR(Packet):
218
218
219
219
def answers (self , other ):
220
220
return isinstance (other , UDS_SA ) \
221
- and other .securityAccessType == self .securityAccessType
221
+ and other .securityAccessType == self .securityAccessType
222
222
223
223
224
224
bind_layers (UDS , UDS_SAPR , service = 0x67 )
@@ -273,7 +273,7 @@ class UDS_CCPR(Packet):
273
273
274
274
def answers (self , other ):
275
275
return isinstance (other , UDS_CC ) \
276
- and other .controlType == self .controlType
276
+ and other .controlType == self .controlType
277
277
278
278
279
279
bind_layers (UDS , UDS_CCPR , service = 0x68 )
@@ -429,7 +429,7 @@ class UDS_AUTHPR(Packet):
429
429
430
430
def answers (self , other ):
431
431
return isinstance (other , UDS_AUTH ) \
432
- and other .subFunction == self .subFunction
432
+ and other .subFunction == self .subFunction
433
433
434
434
435
435
bind_layers (UDS , UDS_AUTHPR , service = 0x69 )
@@ -491,8 +491,8 @@ class UDS_ATPPR(Packet):
491
491
492
492
def answers (self , other ):
493
493
return isinstance (other , UDS_ATP ) \
494
- and other .timingParameterAccessType == \
495
- self .timingParameterAccessType
494
+ and other .timingParameterAccessType == \
495
+ self .timingParameterAccessType
496
496
497
497
498
498
bind_layers (UDS , UDS_ATPPR , service = 0xC3 )
@@ -605,7 +605,7 @@ class UDS_ROEPR(Packet):
605
605
606
606
def answers (self , other ):
607
607
return isinstance (other , UDS_ROE ) \
608
- and other .eventType == self .eventType
608
+ and other .eventType == self .eventType
609
609
610
610
611
611
bind_layers (UDS , UDS_ROEPR , service = 0xC6 )
@@ -644,7 +644,7 @@ class UDS_LCPR(Packet):
644
644
645
645
def answers (self , other ):
646
646
return isinstance (other , UDS_LC ) \
647
- and other .linkControlType == self .linkControlType
647
+ and other .linkControlType == self .linkControlType
648
648
649
649
650
650
bind_layers (UDS , UDS_LCPR , service = 0xC7 )
@@ -673,7 +673,7 @@ class UDS_RDBIPR(Packet):
673
673
674
674
def answers (self , other ):
675
675
return isinstance (other , UDS_RDBI ) \
676
- and self .dataIdentifier in other .identifiers
676
+ and self .dataIdentifier in other .identifiers
677
677
678
678
679
679
bind_layers (UDS , UDS_RDBIPR , service = 0x62 )
@@ -743,7 +743,7 @@ class UDS_RSDBIPR(Packet):
743
743
744
744
def answers (self , other ):
745
745
return isinstance (other , UDS_RSDBI ) \
746
- and other .dataIdentifier == self .dataIdentifier
746
+ and other .dataIdentifier == self .dataIdentifier
747
747
748
748
749
749
bind_layers (UDS , UDS_RSDBIPR , service = 0x64 )
@@ -780,7 +780,7 @@ class UDS_RDBPIPR(Packet):
780
780
781
781
def answers (self , other ):
782
782
return isinstance (other , UDS_RDBPI ) \
783
- and other .periodicDataIdentifier == self .periodicDataIdentifier
783
+ and other .periodicDataIdentifier == self .periodicDataIdentifier
784
784
785
785
786
786
bind_layers (UDS , UDS_RDBPIPR , service = 0x6A )
@@ -812,7 +812,7 @@ class UDS_DDDIPR(Packet):
812
812
813
813
def answers (self , other ):
814
814
return isinstance (other , UDS_DDDI ) \
815
- and other .subFunction == self .subFunction
815
+ and other .subFunction == self .subFunction
816
816
817
817
818
818
bind_layers (UDS , UDS_DDDIPR , service = 0x6C )
@@ -839,7 +839,7 @@ class UDS_WDBIPR(Packet):
839
839
840
840
def answers (self , other ):
841
841
return isinstance (other , UDS_WDBI ) \
842
- and other .dataIdentifier == self .dataIdentifier
842
+ and other .dataIdentifier == self .dataIdentifier
843
843
844
844
845
845
bind_layers (UDS , UDS_WDBIPR , service = 0x6E )
@@ -900,8 +900,8 @@ class UDS_WMBAPR(Packet):
900
900
901
901
def answers (self , other ):
902
902
return isinstance (other , UDS_WMBA ) \
903
- and other .memorySizeLen == self .memorySizeLen \
904
- and other .memoryAddressLen == self .memoryAddressLen
903
+ and other .memorySizeLen == self .memorySizeLen \
904
+ and other .memoryAddressLen == self .memoryAddressLen
905
905
906
906
907
907
bind_layers (UDS , UDS_WMBAPR , service = 0x7D )
@@ -956,39 +956,12 @@ class UDS_RDTCI(Packet):
956
956
20 : 'reportDTCFaultDetectionCounter' ,
957
957
21 : 'reportDTCWithPermanentStatus'
958
958
}
959
- dtcStatus = {
960
- 1 : 'TestFailed' ,
961
- 2 : 'TestFailedThisOperationCycle' ,
962
- 4 : 'PendingDTC' ,
963
- 8 : 'ConfirmedDTC' ,
964
- 16 : 'TestNotCompletedSinceLastClear' ,
965
- 32 : 'TestFailedSinceLastClear' ,
966
- 64 : 'TestNotCompletedThisOperationCycle' ,
967
- 128 : 'WarningIndicatorRequested'
968
- }
969
- dtcStatusMask = {
970
- 1 : 'ActiveDTCs' ,
971
- 4 : 'PendingDTCs' ,
972
- 8 : 'ConfirmedOrStoredDTCs' ,
973
- 255 : 'AllRecordDTCs'
974
- }
975
- dtcSeverityMask = {
976
- # 0: 'NoSeverityInformation',
977
- 1 : 'NoClassInformation' ,
978
- 2 : 'WWH-OBDClassA' ,
979
- 4 : 'WWH-OBDClassB1' ,
980
- 8 : 'WWH-OBDClassB2' ,
981
- 16 : 'WWH-OBDClassC' ,
982
- 32 : 'MaintenanceRequired' ,
983
- 64 : 'CheckAtNextHalt' ,
984
- 128 : 'CheckImmediately'
985
- }
986
959
name = 'ReadDTCInformation'
987
960
fields_desc = [
988
961
ByteEnumField ('reportType' , 0 , reportTypes ),
989
- ConditionalField (FlagsField ('DTCSeverityMask' , 0 , 8 , dtcSeverityMask ),
962
+ ConditionalField (ByteField ('DTCSeverityMask' , 0 ),
990
963
lambda pkt : pkt .reportType in [0x07 , 0x08 ]),
991
- ConditionalField (FlagsField ('DTCStatusMask' , 0 , 8 , dtcStatusMask ),
964
+ ConditionalField (XByteField ('DTCStatusMask' , 0 ),
992
965
lambda pkt : pkt .reportType in [
993
966
0x01 , 0x02 , 0x07 , 0x08 , 0x0f , 0x11 , 0x12 , 0x13 ]),
994
967
ConditionalField (ByteField ('DTCHighByte' , 0 ),
@@ -1010,25 +983,11 @@ class UDS_RDTCI(Packet):
1010
983
bind_layers (UDS , UDS_RDTCI , service = 0x19 )
1011
984
1012
985
1013
- class DTC (Packet ):
1014
- name = 'DTC and status record'
1015
- fields_desc = [
1016
- BitEnumField ("system" , 0 , 2 , {0 : "Powertrain" , 1 : "Chassis" , 2 : "Body" , 3 : "Network" }),
1017
- BitEnumField ("type" , 0 , 2 , {0 : "Generic" , 1 : "ManufacturerSpecific" , 2 : "Generic" , 3 : "Generic" }),
1018
- BitField ("numeric_value_code" , 0 , 12 ),
1019
- ByteField ("additional_information_code" , 0 ),
1020
- FlagsField ("status" , 0 , 8 , UDS_RDTCI .dtcStatus )
1021
- ]
1022
-
1023
- def extract_padding (self , s ):
1024
- return '' , s
1025
-
1026
-
1027
986
class UDS_RDTCIPR (Packet ):
1028
987
name = 'ReadDTCInformationPositiveResponse'
1029
988
fields_desc = [
1030
989
ByteEnumField ('reportType' , 0 , UDS_RDTCI .reportTypes ),
1031
- ConditionalField (FlagsField ('DTCStatusAvailabilityMask' , 0 , 8 , UDS_RDTCI . dtcStatus ),
990
+ ConditionalField (XByteField ('DTCStatusAvailabilityMask' , 0 ),
1032
991
lambda pkt : pkt .reportType in [0x01 , 0x07 , 0x11 ,
1033
992
0x12 , 0x02 , 0x0A ,
1034
993
0x0B , 0x0C , 0x0D ,
@@ -1044,7 +1003,7 @@ class UDS_RDTCIPR(Packet):
1044
1003
ConditionalField (ShortField ('DTCCount' , 0 ),
1045
1004
lambda pkt : pkt .reportType in [0x01 , 0x07 ,
1046
1005
0x11 , 0x12 ]),
1047
- ConditionalField (PacketListField ('DTCAndStatusRecord' , None , pkt_cls = DTC ),
1006
+ ConditionalField (StrField ('DTCAndStatusRecord' , b"" ),
1048
1007
lambda pkt : pkt .reportType in [0x02 , 0x0A , 0x0B ,
1049
1008
0x0C , 0x0D , 0x0E ,
1050
1009
0x0F , 0x13 , 0x15 ]),
@@ -1056,7 +1015,7 @@ class UDS_RDTCIPR(Packet):
1056
1015
1057
1016
def answers (self , other ):
1058
1017
return isinstance (other , UDS_RDTCI ) \
1059
- and other .reportType == self .reportType
1018
+ and other .reportType == self .reportType
1060
1019
1061
1020
1062
1021
bind_layers (UDS , UDS_RDTCIPR , service = 0x59 )
@@ -1091,8 +1050,8 @@ class UDS_RCPR(Packet):
1091
1050
1092
1051
def answers (self , other ):
1093
1052
return isinstance (other , UDS_RC ) \
1094
- and other .routineControlType == self .routineControlType \
1095
- and other .routineIdentifier == self .routineIdentifier
1053
+ and other .routineControlType == self .routineControlType \
1054
+ and other .routineIdentifier == self .routineIdentifier
1096
1055
1097
1056
1098
1057
bind_layers (UDS , UDS_RCPR , service = 0x71 )
@@ -1211,7 +1170,7 @@ class UDS_TDPR(Packet):
1211
1170
1212
1171
def answers (self , other ):
1213
1172
return isinstance (other , UDS_TD ) \
1214
- and other .blockSequenceCounter == self .blockSequenceCounter
1173
+ and other .blockSequenceCounter == self .blockSequenceCounter
1215
1174
1216
1175
1217
1176
bind_layers (UDS , UDS_TDPR , service = 0x76 )
@@ -1300,24 +1259,24 @@ def _contains_data_format_identifier(packet):
1300
1259
fmt = 'B' ),
1301
1260
lambda p : p .modeOfOperation != 2 ),
1302
1261
ConditionalField (StrLenField ('maxNumberOfBlockLength' , b"" ,
1303
- length_from = lambda p : p .lengthFormatIdentifier ),
1262
+ length_from = lambda p : p .lengthFormatIdentifier ),
1304
1263
lambda p : p .modeOfOperation != 2 ),
1305
1264
ConditionalField (BitField ('compressionMethod' , 0 , 4 ),
1306
1265
lambda p : p .modeOfOperation != 0x02 ),
1307
1266
ConditionalField (BitField ('encryptingMethod' , 0 , 4 ),
1308
1267
lambda p : p .modeOfOperation != 0x02 ),
1309
1268
ConditionalField (FieldLenField ('fileSizeOrDirInfoParameterLength' ,
1310
- None ,
1311
- length_of = 'fileSizeUncompressedOrDirInfoLength' ),
1269
+ None ,
1270
+ length_of = 'fileSizeUncompressedOrDirInfoLength' ),
1312
1271
lambda p : p .modeOfOperation not in [1 , 2 , 3 ]),
1313
1272
ConditionalField (StrLenField ('fileSizeUncompressedOrDirInfoLength' ,
1314
1273
b"" ,
1315
1274
length_from = lambda p :
1316
1275
p .fileSizeOrDirInfoParameterLength ),
1317
1276
lambda p : p .modeOfOperation not in [1 , 2 , 3 ]),
1318
1277
ConditionalField (StrLenField ('fileSizeCompressed' , b"" ,
1319
- length_from = lambda p :
1320
- p .fileSizeOrDirInfoParameterLength ),
1278
+ length_from = lambda p :
1279
+ p .fileSizeOrDirInfoParameterLength ),
1321
1280
lambda p : p .modeOfOperation not in [1 , 2 , 3 , 5 ]),
1322
1281
]
1323
1282
@@ -1351,7 +1310,7 @@ class UDS_IOCBIPR(Packet):
1351
1310
1352
1311
def answers (self , other ):
1353
1312
return isinstance (other , UDS_IOCBI ) \
1354
- and other .dataIdentifier == self .dataIdentifier
1313
+ and other .dataIdentifier == self .dataIdentifier
1355
1314
1356
1315
1357
1316
bind_layers (UDS , UDS_IOCBIPR , service = 0x6F )
@@ -1416,8 +1375,8 @@ class UDS_NR(Packet):
1416
1375
1417
1376
def answers (self , other ):
1418
1377
return self .requestServiceId == other .service and \
1419
- (self .negativeResponseCode != 0x78 or
1420
- conf .contribs ['UDS' ]['treat-response-pending-as-answer' ])
1378
+ (self .negativeResponseCode != 0x78 or
1379
+ conf .contribs ['UDS' ]['treat-response-pending-as-answer' ])
1421
1380
1422
1381
1423
1382
bind_layers (UDS , UDS_NR , service = 0x7f )
0 commit comments