Skip to content

Commit 83894b5

Browse files
authored
Merge pull request secdev#2110 from polybassa/uds_response_pending
Add configuration for UDS Negative Response
2 parents c141b3a + bec7192 commit 83894b5

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

  • scapy/contrib/automotive

scapy/contrib/automotive/uds.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,24 @@
1414
XShortField, X3BytesField, XIntField, ByteField, \
1515
ShortField, ObservableDict, XShortEnumField, XByteEnumField
1616
from scapy.packet import Packet, bind_layers
17+
from scapy.config import conf
18+
from scapy.error import log_loading
1719

1820
"""
1921
UDS
2022
"""
2123

24+
try:
25+
if conf.contribs['UDS']['treat-response-pending-as-answer']:
26+
pass
27+
except KeyError:
28+
log_loading.info("Specify \"conf.contribs['UDS'] = "
29+
"{'treat-response-pending-as-answer': True}\" to treat "
30+
"a negative response 'requestCorrectlyReceived-"
31+
"ResponsePending' as answer of a request. \n"
32+
"The default value is False.")
33+
conf.contribs['UDS'] = {'treat-response-pending-as-answer': False}
34+
2235

2336
class UDS(Packet):
2437
services = ObservableDict(
@@ -83,7 +96,9 @@ def answers(self, other):
8396
if other.__class__ == self.__class__:
8497
return (other.service + 0x40) == self.service or \
8598
(self.service == 0x7f and
86-
self.requestServiceId == other.service)
99+
self.requestServiceId == other.service and
100+
(self.negativeResponseCode != 0x78 or
101+
conf.contribs['UDS']['treat-response-pending-as-answer']))
87102
return 0
88103

89104
def hashret(self):

0 commit comments

Comments
 (0)