Coverage Report

Created: 2025-12-27 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-uds.c
Line
Count
Source
1
/* packet-uds.c
2
 * Routines for uds protocol packet disassembly
3
 *
4
 * Wireshark - Network traffic analyzer
5
 * By Gerald Combs <gerald@wireshark.org>
6
 * Copyright 1998 Gerald Combs
7
 *
8
 * SPDX-License-Identifier: GPL-2.0-or-later
9
 */
10
11
#include "config.h"
12
13
#include <epan/packet.h>
14
#include <epan/uat.h>
15
#include <epan/unit_strings.h>
16
17
#include <wsutil/array.h>
18
#include "packet-uds.h"
19
#include "packet-doip.h"
20
#include "packet-hsfz.h"
21
#include "packet-iso10681.h"
22
#include "packet-iso15765.h"
23
#include "packet-ber.h"
24
#include "packet-x509af.h"
25
#include <wsutil/utf8_entities.h>
26
27
void proto_register_uds(void);
28
void proto_reg_handoff_uds(void);
29
30
14
#define DATAFILE_UDS_ROUTINE_IDS "UDS_routine_identifiers"
31
14
#define DATAFILE_UDS_DATA_IDS    "UDS_data_identifiers"
32
14
#define DATAFILE_UDS_DTC_IDS     "UDS_dtc_identifiers"
33
14
#define DATAFILE_UDS_ADDRESSES   "UDS_diagnostic_addresses"
34
35
#define UDS_RESPONSE_CODES_GR       0x10
36
#define UDS_RESPONSE_CODES_SNS      0x11
37
#define UDS_RESPONSE_CODES_SFNS     0x12
38
#define UDS_RESPONSE_CODES_IMLOIF   0x13
39
#define UDS_RESPONSE_CODES_RTL      0x14
40
#define UDS_RESPONSE_CODES_BRR      0x21
41
#define UDS_RESPONSE_CODES_CNC      0x22
42
#define UDS_RESPONSE_CODES_RSE      0x24
43
#define UDS_RESPONSE_CODES_NRFSC    0x25
44
#define UDS_RESPONSE_CODES_FPEORA   0x26
45
#define UDS_RESPONSE_CODES_ROOR     0x31
46
#define UDS_RESPONSE_CODES_SAD      0x33
47
#define UDS_RESPONSE_CODES_AR       0x34
48
#define UDS_RESPONSE_CODES_IK       0x35
49
#define UDS_RESPONSE_CODES_ENOA     0x36
50
#define UDS_RESPONSE_CODES_RTDNE    0x37
51
#define UDS_RESPONSE_CODES_SDTR     0x38
52
#define UDS_RESPONSE_CODES_SDTNA    0x39
53
#define UDS_RESPONSE_CODES_SDTF     0x3A
54
#define UDS_RESPONSE_CODES_CVFITP   0x50
55
#define UDS_RESPONSE_CODES_CVFIS    0x51
56
#define UDS_RESPONSE_CODES_CVFICOT  0x52
57
#define UDS_RESPONSE_CODES_CVFIT    0x53
58
#define UDS_RESPONSE_CODES_CVFIF    0x54
59
#define UDS_RESPONSE_CODES_CVFIC    0x55
60
#define UDS_RESPONSE_CODES_CVFISD   0x56
61
#define UDS_RESPONSE_CODES_CVFICR   0x57
62
#define UDS_RESPONSE_CODES_OVF      0x58
63
#define UDS_RESPONSE_CODES_CCF      0x59
64
#define UDS_RESPONSE_CODES_SARF     0x5A
65
#define UDS_RESPONSE_CODES_SKCDF    0x5B
66
#define UDS_RESPONSE_CODES_CDUF     0x5C
67
#define UDS_RESPONSE_CODES_DAF      0x5D
68
#define UDS_RESPONSE_CODES_UDNA     0x70
69
#define UDS_RESPONSE_CODES_TDS      0x71
70
#define UDS_RESPONSE_CODES_GPF      0x72
71
#define UDS_RESPONSE_CODES_WBSC     0x73
72
#define UDS_RESPONSE_CODES_RCRRP    0x78
73
#define UDS_RESPONSE_CODES_SFNSIAS  0x7E
74
#define UDS_RESPONSE_CODES_SNSIAS   0x7F
75
#define UDS_RESPONSE_CODES_RPMTH    0x81
76
#define UDS_RESPONSE_CODES_RPMTL    0x82
77
#define UDS_RESPONSE_CODES_EIR      0x83
78
#define UDS_RESPONSE_CODES_EINR     0x84
79
#define UDS_RESPONSE_CODES_ERTTL    0x85
80
#define UDS_RESPONSE_CODES_TEMPTH   0x86
81
#define UDS_RESPONSE_CODES_TEMPTL   0x87
82
#define UDS_RESPONSE_CODES_VSTH     0x88
83
#define UDS_RESPONSE_CODES_VSTL     0x89
84
#define UDS_RESPONSE_CODES_TPTH     0x8a
85
#define UDS_RESPONSE_CODES_TPTL     0x8b
86
#define UDS_RESPONSE_CODES_TRNIN    0x8c
87
#define UDS_RESPONSE_CODES_TRNIG    0x8d
88
#define UDS_RESPONSE_CODES_BSNC     0x8f
89
#define UDS_RESPONSE_CODES_SLNIP    0x90
90
#define UDS_RESPONSE_CODES_TCCL     0x91
91
#define UDS_RESPONSE_CODES_VTH      0x92
92
#define UDS_RESPONSE_CODES_VTL      0x93
93
#define UDS_RESPONSE_CODES_RTNA     0x94
94
95
98
#define UDS_SUBFUNCTION_MASK                    0x7f
96
56
#define UDS_SUPPRESS_POS_RSP_MSG_IND_MASK       0x80
97
98
#define UDS_DSC_TYPES_DEFAULT_SESSION                   1
99
#define UDS_DSC_TYPES_PROGRAMMING_SESSION               2
100
#define UDS_DSC_TYPES_EXTENDED_DIAGNOSTIC_SESSION       3
101
#define UDS_DSC_TYPES_SAFETY_SYSTEM_DIAGNOSTIC_SESSION  4
102
103
#define UDS_ER_TYPES_HARD_RESET                   1
104
#define UDS_ER_TYPES_KEY_OFF_ON_RESET             2
105
#define UDS_ER_TYPES_SOFT_RESET                   3
106
0
#define UDS_ER_TYPES_ENABLE_RAPID_POWER_SHUTDOWN  4
107
#define UDS_ER_TYPES_DISABLE_RAPID_POWER_SHUTDOWN 5
108
109
0
#define UDS_ER_TYPE_ENABLE_RAPID_POWER_SHUTDOWN_INVALID 0xFF
110
111
0
#define UDS_RDTCI_TYPES_NUMBER_BY_STATUS_MASK     0x1
112
0
#define UDS_RDTCI_TYPES_BY_STATUS_MASK            0x2
113
0
#define UDS_RDTCI_TYPES_SNAPSHOT_IDENTIFICATION   0x3
114
0
#define UDS_RDTCI_TYPES_SNAPSHOT_RECORD_BY_DTC    0x4
115
0
#define UDS_RDTCI_TYPES_SNAPSHOT_RECORD_BY_RECORD 0x5
116
0
#define UDS_RDTCI_TYPES_EXTENDED_RECORD_BY_DTC    0x6
117
0
#define UDS_RDTCI_TYPES_NUM_DTC_BY_SEVERITY_MASK  0x7
118
0
#define UDS_RDTCI_TYPES_BY_SEVERITY_MASK          0x8
119
0
#define UDS_RDTCI_TYPES_SEVERITY_INFO_OF_DTC      0x9
120
0
#define UDS_RDTCI_TYPES_SUPPORTED_DTC             0xA
121
0
#define UDS_RDTCI_TYPES_FIRST_TEST_FAILED_DTC     0xB
122
0
#define UDS_RDTCI_TYPES_FIRST_CONFIRMED_DTC       0xC
123
0
#define UDS_RDTCI_TYPES_MOST_RECENT_TEST_FAILED   0xD
124
0
#define UDS_RDTCI_TYPES_MOST_RECENT_CONFIRMED_DTC 0xE
125
0
#define UDS_RDTCI_TYPES_OUTDATED_RMMDTCBSM        0xF
126
#define UDS_RDTCI_TYPES_OUTDATED_RMMDEDRBDN       0x10
127
0
#define UDS_RDTCI_TYPES_OUTDATED_RNOMMDTCBSM      0x11
128
0
#define UDS_RDTCI_TYPES_OUTDATED_RNOOEOBDDTCBSM   0x12
129
0
#define UDS_RDTCI_TYPES_OUTDATED_ROBDDTCBSM       0x13
130
0
#define UDS_RDTCI_TYPES_DTC_FAULT_DETECT_CTR      0x14
131
0
#define UDS_RDTCI_TYPES_DTC_WITH_PERM_STATUS      0x15
132
0
#define UDS_RDTCI_TYPES_DTC_EXT_DATA_REC_BY_NUM   0x16
133
0
#define UDS_RDTCI_TYPES_USER_MEM_DTC_BY_STATUS_M  0x17
134
0
#define UDS_RDTCI_TYPES_USER_MEM_DTC_REC_BY_DTC_N 0x18
135
0
#define UDS_RDTCI_TYPES_USER_MEM_DTC_EXT_REC_BY_N 0x19
136
0
#define UDS_RDTCI_TYPES_SUP_DTC_EXT_RECORD        0x1A
137
0
#define UDS_RDTCI_TYPES_WWH_OBD_DTC_BY_MASK_REC   0x42
138
0
#define UDS_RDTCI_TYPES_WWH_OBD_DTC_PERM_STATUS   0x55
139
0
#define UDS_RDTCI_TYPES_WWH_OBD_BY_GROUP_READY    0x56
140
141
42
#define UDS_RDTCI_DTC_STATUS_TEST_FAILED                      0x01
142
42
#define UDS_RDTCI_DTC_STATUS_TEST_FAILED_THIS_OPER_CYCLE      0x02
143
42
#define UDS_RDTCI_DTC_STATUS_PENDING_DTC                      0x04
144
42
#define UDS_RDTCI_DTC_STATUS_CONFIRMED_DTC                    0x08
145
42
#define UDS_RDTCI_DTC_STATUS_TEST_NOT_COMPL_SINCE_LAST_CLEAR  0x10
146
42
#define UDS_RDTCI_DTC_STATUS_TEST_FAILED_SINCE_LAST_CLEAR     0x20
147
42
#define UDS_RDTCI_DTC_STATUS_TEST_NOT_COMPL_THIS_OPER_CYCLE   0x40
148
42
#define UDS_RDTCI_DTC_STATUS_WARNING_INDICATOR_REQUESTED      0x80
149
150
#define UDS_RSDBI_DATA_TYPE_UNSIGNED_NUM                    0x00
151
#define UDS_RSDBI_DATA_TYPE_SIGNED_NUM                      0x01
152
0
#define UDS_RSDBI_DATA_TYPE_BITMAPPED_REPORTED_WO_MAP       0x02
153
#define UDS_RSDBI_DATA_TYPE_BITMAPPED_REPORTED_WITH_MAP     0x03
154
#define UDS_RSDBI_DATA_TYPE_BINARY_CODED_DECIMAL            0x04
155
#define UDS_RSDBI_DATA_TYPE_STATE_ENCODED_VARIABLE          0x05
156
#define UDS_RSDBI_DATA_TYPE_ASCII                           0x06
157
#define UDS_RSDBI_DATA_TYPE_SIGNED_FLOAT                    0x07
158
#define UDS_RSDBI_DATA_TYPE_PACKET                          0x08
159
0
#define UDS_RSDBI_DATA_TYPE_FORMULA                         0x09
160
0
#define UDS_RSDBI_DATA_TYPE_UNIT_FORMAT                     0x0a
161
#define UDS_RSDBI_DATA_TYPE_STATE_AND_CONNECTION_TYPE       0x0b
162
163
0
#define UDS_SA_TYPES_RESERVED                     0x00
164
0
#define UDS_SA_TYPES_REQUEST_SEED                 0x01
165
0
#define UDS_SA_TYPES_SEND_KEY                     0x02
166
0
#define UDS_SA_TYPES_REQUEST_SEED_ISO26021        0x03
167
0
#define UDS_SA_TYPES_SEND_KEY_ISO26021            0x04
168
0
#define UDS_SA_TYPES_SUPPLIER                     0xFE
169
0
#define UDS_SA_TYPES_UNCLEAR                      0xFF
170
171
#define UDS_CC_TYPES_ENABLE_RX_AND_TX                            0
172
#define UDS_CC_TYPES_ENABLE_RX_AND_DISABLE_TX                    1
173
#define UDS_CC_TYPES_DISABLE_RX_AND_ENABLE_TX                    2
174
#define UDS_CC_TYPES_DISABLE_RX_AND_TX                           3
175
0
#define UDS_CC_TYPES_ENABLE_RX_AND_DISABLE_TX_WITH_ENH_ADDR_INFO 4
176
0
#define UDS_CC_TYPES_ENABLE_RX_AND_TX_WITH_ENH_ADDR_INFO         5
177
178
14
#define UDS_CC_COMM_TYPE_COMM_TYPE_MASK             0x03
179
14
#define UDS_CC_COMM_TYPE_SUBNET_NUMBER_MASK         0xF0
180
181
0
#define UDS_ARS_TYPES_DEAUTHENTICATE                0x00
182
0
#define UDS_ARS_TYPES_VERIFY_CERT_UNIDIRECTIONAL    0x01
183
0
#define UDS_ARS_TYPES_VERIFY_CERT_BIDIRECTIONAL     0x02
184
0
#define UDS_ARS_TYPES_PROOF_OF_OWNERSHIP            0x03
185
0
#define UDS_ARS_TYPES_TRANSMIT_CERTIFICATE          0x04
186
0
#define UDS_ARS_TYPES_REQUEST_CHALLENGE_FOR_AUTH    0x05
187
0
#define UDS_ARS_TYPES_VERIFY_PROOF_OF_OWN_UNIDIR    0x06
188
0
#define UDS_ARS_TYPES_VERIFY_PROOF_OF_OWN_BIDIR     0x07
189
0
#define UDS_ARS_TYPES_AUTH_CONFIGURATION            0x08
190
191
#define UDS_ARS_AUTH_RET_REQUEST_ACCEPTED           0x00
192
#define UDS_ARS_AUTH_RET_GENERAL_REJECT             0x01
193
#define UDS_ARS_AUTH_RET_AUTH_CONFIG_APCE           0x02
194
#define UDS_ARS_AUTH_RET_AUTH_CONFIG_ACR_SYM        0x03
195
#define UDS_ARS_AUTH_RET_AUTH_CONFIG_ACR_ASYM       0x04
196
#define UDS_ARS_AUTH_RET_DEAUTH_SUCCESS             0x10
197
#define UDS_ARS_AUTH_RET_CERT_VER_OWN_VER_NEC       0x11
198
#define UDS_ARS_AUTH_RET_OWN_VER_AUTH_COMPL         0x12
199
#define UDS_ARS_AUTH_RET_CERT_VERIFIED              0x13
200
201
0
#define UDS_DDDI_TYPES_DEFINE_BY_IDENTIFIER         0x01
202
0
#define UDS_DDDI_TYPES_DEFINE_BY_MEM_ADDRESS        0x02
203
0
#define UDS_DDDI_TYPES_CLEAR_DYN_DEF_DATA_ID        0x03
204
205
#define UDS_IOCBI_PARAMETERS_RETURN_CONTROL_TO_ECU  0
206
#define UDS_IOCBI_PARAMETERS_RESET_TO_DEFAULT       1
207
#define UDS_IOCBI_PARAMETERS_FREEZE_CURRENT_STATE   2
208
#define UDS_IOCBI_PARAMETERS_SHORT_TERM_ADJUSTMENT  3
209
210
#define UDS_RC_TYPES_START   1
211
#define UDS_RC_TYPES_STOP    2
212
#define UDS_RC_TYPES_REQUEST 3
213
214
14
#define UDS_RD_COMPRESSION_METHOD_MASK          0xF0
215
14
#define UDS_RD_ENCRYPTING_METHOD_MASK           0x0F
216
14
#define UDS_RD_MEMORY_SIZE_LENGTH_MASK          0xF0
217
14
#define UDS_RD_MEMORY_ADDRESS_LENGTH_MASK       0x0F
218
14
#define UDS_RD_MAX_BLOCK_LEN_LEN_MASK           0xF0
219
220
0
#define UDS_RFT_MODE_ADD_FILE                   0x01
221
0
#define UDS_RFT_MODE_DELETE_FILE                0x02
222
0
#define UDS_RFT_MODE_REPLACE_FILE               0x03
223
0
#define UDS_RFT_MODE_READ_FILE                  0x04
224
0
#define UDS_RFT_MODE_READ_DIR                   0x05
225
0
#define UDS_RFT_MODE_RESUME_FILE                0x06
226
227
14
#define UDS_SDT_ADMIN_PARAM_REQ                 0x0001
228
14
#define UDS_SDT_ADMIN_PARAM_PRE_ESTABL_KEY      0x0008
229
14
#define UDS_SDT_ADMIN_PARAM_ENCRYPTED           0x0010
230
14
#define UDS_SDT_ADMIN_PARAM_SIGNED              0x0020
231
14
#define UDS_SDT_ADMIN_PARAM_SIGN_ON_RESP_REQ    0x0040
232
233
#define UDS_CDTCS_ACTIONS_ON  1
234
#define UDS_CDTCS_ACTIONS_OFF 2
235
236
0
#define UDS_LC_TYPES_VMTWFP 1
237
0
#define UDS_LC_TYPES_VMTWSP 2
238
0
#define UDS_LC_TYPES_TM     3
239
240
#define UDS_DID_BSIDID          0xF180
241
#define UDS_DID_ASIDID          0xF181
242
#define UDS_DID_ADIDID          0xF182
243
#define UDS_DID_BSFPDID         0xF183
244
#define UDS_DID_ASFPDID         0xF184
245
#define UDS_DID_ADFPDID         0xF185
246
0
#define UDS_DID_ADSDID          0xF186
247
#define UDS_DID_VMSPNDID        0xF187
248
#define UDS_DID_VMECUSNDID      0xF188
249
#define UDS_DID_VMECUSVNDID     0xF189
250
#define UDS_DID_SSIDDID         0xF18A
251
#define UDS_DID_ECUMDDID        0xF18B
252
#define UDS_DID_ECUSNDID        0xF18C
253
#define UDS_DID_SFUDID          0xF18D
254
#define UDS_DID_VMKAPNDID       0xF18E
255
#define UDS_DID_RXSWIN          0xF18F
256
0
#define UDS_DID_VINDID          0xF190
257
#define UDS_DID_VMECUHNDID      0xF191
258
#define UDS_DID_SSECUHWNDID     0xF192
259
#define UDS_DID_SSECUHWVNDID    0xF193
260
#define UDS_DID_SSECUSWNDID     0xF194
261
#define UDS_DID_SSECUSWVNDID    0xF195
262
#define UDS_DID_EROTANDID       0xF196
263
#define UDS_DID_SNOETDID        0xF197
264
#define UDS_DID_RSCOTSNDID      0xF198
265
#define UDS_DID_PDDID           0xF199
266
#define UDS_DID_CRSCOCESNDID    0xF19A
267
#define UDS_DID_CDDID           0xF19B
268
#define UDS_DID_CESWNDID        0xF19D
269
#define UDS_DID_EIDDID          0xF19D
270
#define UDS_DID_ODXFDID         0xF19E
271
#define UDS_DID_EDID            0xF19F
272
#define UDS_DID_ADDID_FA00      0xFA00
273
#define UDS_DID_ADDID_FA01      0xFA01
274
#define UDS_DID_ADDID_FA02      0xFA02
275
#define UDS_DID_ADDID_FA03      0xFA03
276
#define UDS_DID_ADDID_FA04      0xFA04
277
#define UDS_DID_ADDID_FA05      0xFA05
278
#define UDS_DID_ADDID_FA06      0xFA06
279
#define UDS_DID_ADDID_FA07      0xFA07
280
#define UDS_DID_ADDID_FA08      0xFA08
281
#define UDS_DID_ADDID_FA09      0xFA09
282
#define UDS_DID_ADDID_FA0A      0xFA0A
283
#define UDS_DID_ADDID_FA0B      0xFA0B
284
#define UDS_DID_ADDID_FA0C      0xFA0C
285
#define UDS_DID_ADDID_FA0D      0xFA0D
286
#define UDS_DID_ADDID_FA0E      0xFA0E
287
#define UDS_DID_ADDID_FA0F      0xFA0F
288
#define UDS_DID_NOEDRD          0xFA10
289
#define UDS_DID_EDRI            0xFA11
290
#define UDS_DID_EDRDAI          0xFA12
291
0
#define UDS_DID_UDSVDID         0xFF00
292
0
#define UDS_DID_RESRVDCPADLC    0xFF01
293
294
#define UDS_RID_EXSPLRI_        0xE200
295
#define UDS_RID_DLRI_           0xE201
296
#define UDS_RID_EM_             0xFF00
297
#define UDS_RID_CPD_            0xFF01
298
#define UDS_RID_FF02            0xFF02
299
300
16
#define UDS_ROE_SUBFUNC_MASK            0b00111111
301
14
#define UDS_ROE_STORE_MASK              0b01000000
302
#define UDS_ROE_SUBF_STPROE             0x00
303
0
#define UDS_ROE_SUBF_ONDTCS             0x01
304
0
#define UDS_ROE_SUBF_OCODID             0x03
305
0
#define UDS_ROE_SUBF_RAE                0x04
306
2
#define UDS_ROE_SUBF_OCOV               0x07
307
0
#define UDS_ROE_SUBF_RMRDOSC            0x08
308
0
#define UDS_ROE_SUBF_RDRIODSC           0x09
309
14
#define UDS_ROE_OCOV_LOCAL_SIGN_MASK    0b1000000000000000
310
14
#define UDS_ROE_OCOV_LOCAL_LEN_MASK     0b0111110000000000
311
14
#define UDS_ROE_OCOV_LOCAL_OFFSET_MASK  0b0000001111111111
312
14
#define UDS_ROE_DTC_STATUS_MASK_TF      0b00000001
313
14
#define UDS_ROE_DTC_STATUS_MASK_TFTOC   0b00000010
314
14
#define UDS_ROE_DTC_STATUS_MASK_PDTC    0b00000100
315
14
#define UDS_ROE_DTC_STATUS_MASK_CDTC    0b00001000
316
14
#define UDS_ROE_DTC_STATUS_MASK_TNCSLC  0b00010000
317
14
#define UDS_ROE_DTC_STATUS_MASK_TFSLC   0b00100000
318
14
#define UDS_ROE_DTC_STATUS_MASK_TNCTOC  0b01000000
319
14
#define UDS_ROE_DTC_STATUS_MASK_WIR     0b10000000
320
321
/*
322
 * Enums
323
 */
324
325
/* Services */
326
static const value_string _uds_services[]= {
327
    {OBD_SERVICES_0x01,  "OBD - Request Current Powertrain Diagnostic Data"},
328
    {OBD_SERVICES_0x02,  "OBD - Request Powertrain Freeze Frame Data"},
329
    {OBD_SERVICES_0x03,  "OBD - Request Emission-Related Diagnostic Trouble Codes"},
330
    {OBD_SERVICES_0x04,  "OBD - Clear/Reset Emission-Related Diagnostic Information"},
331
    {OBD_SERVICES_0x05,  "OBD - Request Oxygen Sensor Monitoring Test Results"},
332
    {OBD_SERVICES_0x06,  "OBD - Request On-Board Monitoring Test Results for Specific Monitored Systems"},
333
    {OBD_SERVICES_0x07,  "OBD - Request Emission-Related Diagnostic Trouble Codes Detected During Current or Last Completed Driving Cycle"},
334
    {OBD_SERVICES_0x08,  "OBD - Request Control of On-Board System, Test or Component"},
335
    {OBD_SERVICES_0x09,  "OBD - Request Vehicle Information"},
336
    {OBD_SERVICES_0x0A,  "OBD - Request Emission-Related Diagnostic Trouble Codes with Permanent Status"},
337
    {OBD_SERVICES_0x0B,  "OBD - Unknown Service"},
338
    {OBD_SERVICES_0x0C,  "OBD - Unknown Service"},
339
    {OBD_SERVICES_0x0D,  "OBD - Unknown Service"},
340
    {OBD_SERVICES_0x0E,  "OBD - Unknown Service"},
341
    {OBD_SERVICES_0x0F,  "OBD - Unknown Service"},
342
343
    {UDS_SERVICES_DSC,   "Diagnostic Session Control"},
344
    {UDS_SERVICES_ER,    "ECU Reset"},
345
    {UDS_SERVICES_CDTCI, "Clear Diagnostic Information"},
346
    {UDS_SERVICES_RDTCI, "Read DTC Information"},
347
    {UDS_SERVICES_RDBI,  "Read Data By Identifier"},
348
    {UDS_SERVICES_RMBA,  "Read Memory By Address"},
349
    {UDS_SERVICES_RSDBI, "Read Scaling Data By Identifier"},
350
    {UDS_SERVICES_SA,    "Security Access"},
351
    {UDS_SERVICES_CC,    "Communication Control"},
352
    {UDS_SERVICES_ARS,   "Authentication"},
353
    {UDS_SERVICES_RDBPI, "Read Data By Periodic Identifier"},
354
    {UDS_SERVICES_DDDI,  "Dynamically Define Data Identifier"},
355
    {UDS_SERVICES_WDBI,  "Write Data By Identifier"},
356
    {UDS_SERVICES_IOCBI, "Input Output Control By Identifier"},
357
    {UDS_SERVICES_RC,    "Routine Control"},
358
    {UDS_SERVICES_RD,    "Request Download"},
359
    {UDS_SERVICES_RU,    "Request Upload"},
360
    {UDS_SERVICES_TD,    "Transfer Data"},
361
    {UDS_SERVICES_RTE,   "Request Transfer Exit"},
362
    {UDS_SERVICES_RFT,   "Request File Transfer"},
363
    {UDS_SERVICES_WMBA,  "Write Memory By Address"},
364
    {UDS_SERVICES_TP,    "Tester Present"},
365
    {UDS_SERVICES_ERR,   "Error"},
366
    {UDS_SERVICES_SDT,   "Secured Data Transmission"},
367
    {UDS_SERVICES_CDTCS, "Control DTC Setting"},
368
    {UDS_SERVICES_ROE,   "Response On Event"},
369
    {UDS_SERVICES_LC,    "Link Control"},
370
    {0, NULL}
371
};
372
static value_string_ext uds_services_ext = VALUE_STRING_EXT_INIT(_uds_services);
373
374
/* Response code */
375
static const value_string _uds_response_codes[]= {
376
    {UDS_RESPONSE_CODES_GR,      "General reject"},
377
    {UDS_RESPONSE_CODES_SNS,     "Service not supported"},
378
    {UDS_RESPONSE_CODES_SFNS,    "SubFunction Not Supported"},
379
    {UDS_RESPONSE_CODES_IMLOIF,  "Incorrect Message Length or Invalid Format"},
380
    {UDS_RESPONSE_CODES_RTL,     "Response too long"},
381
    {UDS_RESPONSE_CODES_BRR,     "Busy repeat request"},
382
    {UDS_RESPONSE_CODES_CNC,     "Conditions Not Correct"},
383
    {UDS_RESPONSE_CODES_RSE,     "Request Sequence Error"},
384
    {UDS_RESPONSE_CODES_NRFSC,   "No response from sub-net component"},
385
    {UDS_RESPONSE_CODES_FPEORA,  "Failure prevents execution of requested action"},
386
    {UDS_RESPONSE_CODES_ROOR,    "Request Out of Range"},
387
    {UDS_RESPONSE_CODES_SAD,     "Security Access Denied"},
388
    {UDS_RESPONSE_CODES_AR,      "Authentication Required"},
389
    {UDS_RESPONSE_CODES_IK,      "Invalid Key"},
390
    {UDS_RESPONSE_CODES_ENOA,    "Exceeded Number Of Attempts"},
391
    {UDS_RESPONSE_CODES_RTDNE,   "Required Time Delay Not Expired"},
392
    {UDS_RESPONSE_CODES_SDTR,    "Secure Data Transmission Required"},
393
    {UDS_RESPONSE_CODES_SDTNA,   "Secure Data Transmission Not Allowed"},
394
    {UDS_RESPONSE_CODES_SDTF,    "Secure Data Verification Failed"},
395
    {UDS_RESPONSE_CODES_CVFITP,  "Certificate Verification Failed: Invalid Time Period"},
396
    {UDS_RESPONSE_CODES_CVFIS,   "Certificate Verification Failed: Invalid Signature"},
397
    {UDS_RESPONSE_CODES_CVFICOT, "Certificate Verification Failed: Invalid Chain of Trust"},
398
    {UDS_RESPONSE_CODES_CVFIT,   "Certificate Verification Failed: Invalid Type"},
399
    {UDS_RESPONSE_CODES_CVFIF,   "Certificate Verification Failed: Invalid Format"},
400
    {UDS_RESPONSE_CODES_CVFIC,   "Certificate Verification Failed: Invalid Content"},
401
    {UDS_RESPONSE_CODES_CVFISD,  "Certificate Verification Failed: Invalid Scope"},
402
    {UDS_RESPONSE_CODES_CVFICR,  "Certificate Verification Failed: Invalid Certificate (revoked)"},
403
    {UDS_RESPONSE_CODES_OVF,     "Ownership Verification Failed"},
404
    {UDS_RESPONSE_CODES_CCF,     "Challenge Calculation Failed"},
405
    {UDS_RESPONSE_CODES_SARF,    "Setting Access Rights Failed"},
406
    {UDS_RESPONSE_CODES_SKCDF,   "Session Key Creation/Derivation Failed"},
407
    {UDS_RESPONSE_CODES_CDUF,    "Configuration Data Usage Failed"},
408
    {UDS_RESPONSE_CODES_DAF,     "DeAuthentication Failed"},
409
    {UDS_RESPONSE_CODES_UDNA,    "Upload/Download not accepted"},
410
    {UDS_RESPONSE_CODES_TDS,     "Transfer data suspended"},
411
    {UDS_RESPONSE_CODES_GPF,     "General Programming Failure"},
412
    {UDS_RESPONSE_CODES_WBSC,    "Wrong Block Sequence Counter"},
413
    {UDS_RESPONSE_CODES_RCRRP,   "Request correctly received, but response is pending"},
414
    {UDS_RESPONSE_CODES_SFNSIAS, "Subfunction not supported in active session"},
415
    {UDS_RESPONSE_CODES_SNSIAS,  "Service not supported in active session"},
416
    {UDS_RESPONSE_CODES_RPMTH,   "RPM Too High"},
417
    {UDS_RESPONSE_CODES_RPMTL,   "RPM Too Low"},
418
    {UDS_RESPONSE_CODES_EIR,     "Engine Is Running"},
419
    {UDS_RESPONSE_CODES_EINR,    "Engine Is Not Running"},
420
    {UDS_RESPONSE_CODES_ERTTL,   "Run Time Too Low"},
421
    {UDS_RESPONSE_CODES_TEMPTH,  "Temperature Too High"},
422
    {UDS_RESPONSE_CODES_TEMPTL,  "Temperature Too Low"},
423
    {UDS_RESPONSE_CODES_VSTH,    "Vehicle Speed Too High"},
424
    {UDS_RESPONSE_CODES_VSTL,    "Vehicle Speed Too Low"},
425
    {UDS_RESPONSE_CODES_TPTH,    "Throttle/Pedal Too High"},
426
    {UDS_RESPONSE_CODES_TPTL,    "Throttle/Pedal Too Low"},
427
    {UDS_RESPONSE_CODES_TRNIN,   "Transmission Range Not In Neutral"},
428
    {UDS_RESPONSE_CODES_TRNIG,   "Transmission Range Not In Gear"},
429
    {UDS_RESPONSE_CODES_BSNC,    "Brake Switch(es) Not Closed"},
430
    {UDS_RESPONSE_CODES_SLNIP,   "Shifter/Lever Not in Park"},
431
    {UDS_RESPONSE_CODES_TCCL,    "Torque Converter Clutch Locked"},
432
    {UDS_RESPONSE_CODES_VTH,     "Voltage Too High"},
433
    {UDS_RESPONSE_CODES_VTL,     "Voltage Too Low"},
434
    {UDS_RESPONSE_CODES_RTNA,    "Resource Temporarily Not Available"},
435
    {0, NULL}
436
};
437
static value_string_ext uds_response_codes_ext = VALUE_STRING_EXT_INIT(_uds_response_codes);
438
439
/* DSC */
440
static const value_string uds_dsc_types[] = {
441
    {0,                                             "Reserved"},
442
    {UDS_DSC_TYPES_DEFAULT_SESSION,                 "Default Session"},
443
    {UDS_DSC_TYPES_PROGRAMMING_SESSION,             "Programming Session"},
444
    {UDS_DSC_TYPES_EXTENDED_DIAGNOSTIC_SESSION,     "Extended Diagnostic Session"},
445
    {UDS_DSC_TYPES_SAFETY_SYSTEM_DIAGNOSTIC_SESSION, "Safety System Diagnostic Session"},
446
    {0, NULL}
447
};
448
449
/* ER */
450
static const value_string uds_er_types[] = {
451
    {0,                                         "Reserved"},
452
    {UDS_ER_TYPES_HARD_RESET,                   "Hard Reset"},
453
    {UDS_ER_TYPES_KEY_OFF_ON_RESET,             "Key Off On Reset"},
454
    {UDS_ER_TYPES_SOFT_RESET,                   "Soft Reset"},
455
    {UDS_ER_TYPES_ENABLE_RAPID_POWER_SHUTDOWN,  "Enable Rapid Power Shutdown"},
456
    {UDS_ER_TYPES_DISABLE_RAPID_POWER_SHUTDOWN, "Disable Rapid Power Shutdown"},
457
    {0, NULL}
458
};
459
460
/* CDTCI */
461
static const value_string uds_cdtci_group_of_dtc[] = {
462
        {0xffff33, "Emissions-system group"},
463
        {0xffffd0, "Safety-system group"},
464
        {0xfffffe, "VOBD system"},
465
        {0xffffff, "All Groups (all DTCs)"},
466
        {0, NULL}
467
};
468
469
/* RDTCI */
470
static const value_string _uds_rdtci_types[] = {
471
    {UDS_RDTCI_TYPES_NUMBER_BY_STATUS_MASK,     "Report Number of DTC by Status Mask"},
472
    {UDS_RDTCI_TYPES_BY_STATUS_MASK,            "Report DTC by Status Mask"},
473
    {UDS_RDTCI_TYPES_SNAPSHOT_IDENTIFICATION,   "Report DTC Snapshot Identification"},
474
    {UDS_RDTCI_TYPES_SNAPSHOT_RECORD_BY_DTC,    "Report DTC Snapshot Record by DTC Number"},
475
    {UDS_RDTCI_TYPES_SNAPSHOT_RECORD_BY_RECORD, "Report DTC Snapshot Record by Record Number"},
476
    {UDS_RDTCI_TYPES_EXTENDED_RECORD_BY_DTC,    "Report DTC Extended Data Record by DTC Number"},
477
    {UDS_RDTCI_TYPES_NUM_DTC_BY_SEVERITY_MASK,  "Report Number of DTC By Severity Mask"},
478
    {UDS_RDTCI_TYPES_BY_SEVERITY_MASK,          "Report DTC by Severity Mask"},
479
    {UDS_RDTCI_TYPES_SEVERITY_INFO_OF_DTC,      "Report Severity Information of DTC"},
480
    {UDS_RDTCI_TYPES_SUPPORTED_DTC,             "Report Supported DTC"},
481
    {UDS_RDTCI_TYPES_FIRST_TEST_FAILED_DTC,     "Report First Test Failed DTC"},
482
    {UDS_RDTCI_TYPES_FIRST_CONFIRMED_DTC,       "Report First Confirmed DTC"},
483
    {UDS_RDTCI_TYPES_MOST_RECENT_TEST_FAILED,   "Report Most Recent Test Failed DTC"},
484
    {UDS_RDTCI_TYPES_MOST_RECENT_CONFIRMED_DTC, "Report Most Recent Confirmed DTC"},
485
    {UDS_RDTCI_TYPES_OUTDATED_RMMDTCBSM,        "Report Mirror Memory DTC By Status Mask (outdated 2013 revision)"},
486
    {UDS_RDTCI_TYPES_OUTDATED_RMMDEDRBDN,       "Report Mirror Memory DTC Ext Data Record by DTC Number (outdated 2013 revision)"},
487
    {UDS_RDTCI_TYPES_OUTDATED_RNOMMDTCBSM,      "Report Number of Mirror Memory DTC by Status Mask (outdated 2013 revision)"},
488
    {UDS_RDTCI_TYPES_OUTDATED_RNOOEOBDDTCBSM,   "Report Number of Emissions OBD DTC by Status Mask (outdated 2013 revision)"},
489
    {UDS_RDTCI_TYPES_OUTDATED_ROBDDTCBSM,       "Report Emissions OBD DTC By Status Mask (outdated 2013 revision)"},
490
    {UDS_RDTCI_TYPES_DTC_FAULT_DETECT_CTR,      "Report DTC Fault Detection Counter"},
491
    {UDS_RDTCI_TYPES_DTC_WITH_PERM_STATUS,      "Report DTC with Permanent Status"},
492
    {UDS_RDTCI_TYPES_DTC_EXT_DATA_REC_BY_NUM,   "Report DTC Extended Data Record by Record Number"},
493
    {UDS_RDTCI_TYPES_USER_MEM_DTC_BY_STATUS_M,  "Report User Defined Memory DTC By Status Mask"},
494
    {UDS_RDTCI_TYPES_USER_MEM_DTC_REC_BY_DTC_N, "Report User Defined Memory DTC Snapshot Record By DTC Number"},
495
    {UDS_RDTCI_TYPES_USER_MEM_DTC_EXT_REC_BY_N, "Report User Defined Memory DTC Extended Data Record by DTC Number"},
496
    {UDS_RDTCI_TYPES_SUP_DTC_EXT_RECORD,        "Report List of DTCs Supporting Specific Extended Data Record"},
497
    {UDS_RDTCI_TYPES_WWH_OBD_DTC_BY_MASK_REC,   "Report WWH-OBD DTC By Mask Record"},
498
    {UDS_RDTCI_TYPES_WWH_OBD_DTC_PERM_STATUS,   "Report WWH-OBD DTC With Permanent Status"},
499
    {UDS_RDTCI_TYPES_WWH_OBD_BY_GROUP_READY,    "Report WWH-OBD DTC By Readiness Group Identifier"},
500
    {0, NULL}
501
};
502
static value_string_ext uds_rdtci_types_ext = VALUE_STRING_EXT_INIT(_uds_rdtci_types);
503
504
static const value_string uds_rdtci_format_id_types[] = {
505
    {0x00, "SAE J2012-DA DTC Format 00"},
506
    {0x01, "ISO 14229-1 DTC Format"},
507
    {0x02, "SAE J1939-73 DTC Format"},
508
    {0x03, "ISO 11992-4 DTC Format"},
509
    {0x04, "SAE J2012-DA DTC Format 04"},
510
    {0, NULL}
511
};
512
513
/* RSDBI */
514
static const value_string uds_rsdbi_data_types[] = {
515
    {UDS_RSDBI_DATA_TYPE_UNSIGNED_NUM,                  "Unsigned Numeric"},
516
    {UDS_RSDBI_DATA_TYPE_SIGNED_NUM,                    "Signed Numeric"},
517
    {UDS_RSDBI_DATA_TYPE_BITMAPPED_REPORTED_WO_MAP,     "Bit Mapped Reported Without Mask"},
518
    {UDS_RSDBI_DATA_TYPE_BITMAPPED_REPORTED_WITH_MAP,   "Bit Mapped Reported With Mask"},
519
    {UDS_RSDBI_DATA_TYPE_BINARY_CODED_DECIMAL,          "Binary Coded Decimal"},
520
    {UDS_RSDBI_DATA_TYPE_STATE_ENCODED_VARIABLE,        "State Encoded Variable"},
521
    {UDS_RSDBI_DATA_TYPE_ASCII,                         "ASCII"},
522
    {UDS_RSDBI_DATA_TYPE_SIGNED_FLOAT,                  "Signed Floating Point"},
523
    {UDS_RSDBI_DATA_TYPE_PACKET,                        "Packet"},
524
    {UDS_RSDBI_DATA_TYPE_FORMULA,                       "Formula"},
525
    {UDS_RSDBI_DATA_TYPE_UNIT_FORMAT,                   "Unit/Format"},
526
    {UDS_RSDBI_DATA_TYPE_STATE_AND_CONNECTION_TYPE,     "State And Connection Type"},
527
    {0, NULL}
528
};
529
530
static const value_string uds_rsdbi_formulas[] = {
531
    {0, "y = C0 * x + C1"},
532
    {1, "y = C0 * (x + C1)"},
533
    {2, "y = C0 / (x + C1) + C2"},
534
    {3, "y = x / C0 + C1"},
535
    {4, "y = (x + C0) / C1"},
536
    {5, "y = (x + C0) / C1 + C2"},
537
    {6, "y = C0 * x"},
538
    {7, "y = x / C0"},
539
    {8, "y = x + C0"},
540
    {9, "y = x * C0 / C1"},
541
    {0, NULL}
542
};
543
544
static const value_string _uds_rsdbi_units[] = {
545
    {0x00, "No unit, no prefix"},
546
    {0x01, "Metre [m]"},
547
    {0x02, "Foot [ft]"},
548
    {0x03, "Inch [in]"},
549
    {0x04, "Yard [yd]"},
550
    {0x05, "Mile (English) [mi]"},
551
    {0x06, "Gram [g]"},
552
    {0x07, "Ton (metric) [t]"},
553
    {0x08, "Second [s]"},
554
    {0x09, "Minute [m]"},
555
    {0x0a, "Hour [h]"},
556
    {0x0b, "Day [d]"},
557
    {0x0c, "Year [y]"},
558
    {0x0d, "Ampere [A]"},
559
    {0x0e, "Volt [V]"},
560
    {0x0f, "Coulomb [C]"},
561
562
    {0x10, "Ohm [W]"}, /* sic! */
563
    {0x11, "Farad [F]"},
564
    {0x12, "Henry [H]"},
565
    {0x13, "Siemens [S]"},
566
    {0x14, "Weber [Wb]"},
567
    {0x15, "Telsa [T]"},
568
    {0x16, "Kelvin [K]"},
569
    {0x17, "Celsius [" UTF8_DEGREE_SIGN "C]"},
570
    {0x18, "Fahrenheit [" UTF8_DEGREE_SIGN "F]"},
571
    {0x19, "Candela [cd]"},
572
    {0x1a, "Radian [rad]"},
573
    {0x1b, "Degree [" UTF8_DEGREE_SIGN "]"},
574
    {0x1c, "Hertz [Hz]"},
575
    {0x1d, "Joule [J]"},
576
    {0x1e, "Newton [N]"},
577
    {0x1f, "Kilopond [kp]"},
578
579
    {0x20, "Pound force [lbf]"},
580
    {0x21, "Watt [W]"},
581
    {0x22, "Horse power (metric) [hk]"},
582
    {0x23, "Horse power (UK and US) [hp]"},
583
    {0x24, "Pascal [Pa]"},
584
    {0x25, "Bar [bar]"},
585
    {0x26, "Atmosphere [atm]"},
586
    {0x27, "Pound force per square inch [psi]"},
587
    {0x28, "Becquerel [Bq]"},
588
    {0x29, "Lumen [lm]"},
589
    {0x2a, "Lux [lx]"},
590
    {0x2b, "Litre [l]"},
591
    {0x2c, "Gallon (British)"},
592
    {0x2d, "Gallon (US liq)"},
593
    {0x2e, "Cubic inch [cu in]"},
594
    {0x2f, "Meter per second [m/s]"},
595
596
    {0x30, "Kilometer per hour [km/h]"},
597
    {0x31, "Mile per hour [mph]"},
598
    {0x32, "Revolutions per second [rps]"},
599
    {0x33, "Revolutions per minute [rpm]"},
600
    {0x34, "Counts"},
601
    {0x35, "Percent"},
602
    {0x36, "Milligram per stroke [mg/stroke]"},
603
    {0x37, "Meter per square second [m/s" UTF8_SUPERSCRIPT_TWO "]"},
604
    {0x38, "Newton meter [Nm]"},
605
    {0x39, "Litre per minute [l/min]"},
606
    {0x3a, "Watt per square meter [w/m" UTF8_SUPERSCRIPT_TWO "]"},
607
    {0x3b, "Bar per second [bar/s]"},
608
    {0x3c, "Radians per second [rad/s]"},
609
    {0x3d, "Radians per square second [rad/s" UTF8_SUPERSCRIPT_TWO "]"},
610
    {0x3e, "Kilogram per square meter [kg/m" UTF8_SUPERSCRIPT_TWO "]"},
611
    {0x3f, "*reserved*"},
612
613
    {0x40, "Exa (prefix) [E]"},
614
    {0x41, "Peta (prefix) [P]"},
615
    {0x42, "Tera (prefix) [T]"},
616
    {0x43, "Giga (prefix) [G]"},
617
    {0x44, "Mega (prefix) [M]"},
618
    {0x45, "Kilo (prefix) [k]"},
619
    {0x46, "Hecto (prefix) [h]"},
620
    {0x47, "Deca (prefix) [da]"},
621
    {0x48, "Deci (prefix)  [d]"},
622
    {0x49, "Centi (prefix) [c]"},
623
    {0x4a, "Milli (prefix) [m]"},
624
    {0x4b, "Micro (prefix) [m]"}, /* SIC! */
625
    {0x4c, "Nano (prefix) [n]"},
626
    {0x4d, "Pico (prefix) [p]"},
627
    {0x4e, "Femto (prefix) [f]"},
628
    {0x4f, "Atto (prefix) [a]"},
629
630
    {0x50, "Date1 (Year-Month-Day)"},
631
    {0x51, "Date2 (Day/Month/Year)"},
632
    {0x52, "Date3 (Month/Day/Year)"},
633
    {0x53, "Week (calender week)"},
634
    {0x54, "Time1 (UTC Hour/Minute/Second)"},
635
    {0x55, "Time2 (Hour/Minute/Second)"},
636
    {0x56, "DateAndTime1 (Second/Minute/Hour/Day/Month/Year)"},
637
    {0x57, "DateAndTime2 (Second/Minute/Hour/Day/Month/Year/Local minute offset/Local hour offset)"},
638
    {0x58, "DateAndTime3 (Second/Minute/Hour/Month/Day/Year)"},
639
    {0x59, "DateAndTime4 (Second/Minute/Hour/Month/Day/Year/Local minute offset/Local hour offset)"},
640
    {0, NULL}
641
};
642
static value_string_ext uds_rsdbi_units_ext = VALUE_STRING_EXT_INIT(_uds_rsdbi_units);
643
644
/* CC */
645
static const value_string uds_cc_types[] = {
646
    {UDS_CC_TYPES_ENABLE_RX_AND_TX,                             "Enable RX and TX"},
647
    {UDS_CC_TYPES_ENABLE_RX_AND_DISABLE_TX,                     "Enable RX and Disable TX"},
648
    {UDS_CC_TYPES_DISABLE_RX_AND_ENABLE_TX,                     "Disable RX and Enable TX"},
649
    {UDS_CC_TYPES_DISABLE_RX_AND_TX,                            "Disable RX and TX"},
650
    {UDS_CC_TYPES_ENABLE_RX_AND_DISABLE_TX_WITH_ENH_ADDR_INFO,  "Enable RX and Disable TX with Enhanced Address Information"},
651
    {UDS_CC_TYPES_ENABLE_RX_AND_TX_WITH_ENH_ADDR_INFO,          "Enable RX and TX with Enhanced Address Information"},
652
    {0, NULL}
653
};
654
655
static const value_string uds_cc_comm_types[] = {
656
    {0, "Reserved"},
657
    {1, "Normal Communication Messages"},
658
    {2, "Network Management Communication Messages"},
659
    {3, "Network Management and Normal Communication Messages"},
660
    {0, NULL}
661
};
662
663
static const value_string uds_cc_subnet_number_types[] = {
664
    {0x0, "Disable/Enable specified Communication Type "},
665
    /* 0x1 .. 0xe specific subnets numbers */
666
    {0xf, "Disable/Enable network which request is received on"},
667
    {0, NULL}
668
};
669
670
/* ARS */
671
static const value_string uds_ars_types[] = {
672
    {UDS_ARS_TYPES_DEAUTHENTICATE,              "DeAuthenticate"},
673
    {UDS_ARS_TYPES_VERIFY_CERT_UNIDIRECTIONAL,  "Verify Certificate Unidirectional"},
674
    {UDS_ARS_TYPES_VERIFY_CERT_BIDIRECTIONAL,   "Verify Certificate Bidirectional"},
675
    {UDS_ARS_TYPES_PROOF_OF_OWNERSHIP,          "Proof of Ownership"},
676
    {UDS_ARS_TYPES_TRANSMIT_CERTIFICATE,        "Transmit Certificate"},
677
    {UDS_ARS_TYPES_REQUEST_CHALLENGE_FOR_AUTH,  "Request Challenge for Authentication"},
678
    {UDS_ARS_TYPES_VERIFY_PROOF_OF_OWN_UNIDIR,  "Verify Proof of Ownership Unidirectional"},
679
    {UDS_ARS_TYPES_VERIFY_PROOF_OF_OWN_BIDIR,   "Verify Proof of Ownership Bidirectional"},
680
    {UDS_ARS_TYPES_AUTH_CONFIGURATION,          "Authentication Configuration"},
681
    {0, NULL}
682
};
683
684
static const value_string uds_ars_auth_ret_types[] = {
685
    {UDS_ARS_AUTH_RET_REQUEST_ACCEPTED,         "Request Accepted"},
686
    {UDS_ARS_AUTH_RET_GENERAL_REJECT,           "General Reject"},
687
    {UDS_ARS_AUTH_RET_AUTH_CONFIG_APCE,         "Authentication Configuration APCE"},
688
    {UDS_ARS_AUTH_RET_AUTH_CONFIG_ACR_SYM,      "Authentication Configuration ACR with asymmetric cryptography"},
689
    {UDS_ARS_AUTH_RET_AUTH_CONFIG_ACR_ASYM,     "Authentication Configuration ACR with symmetric cryptography"},
690
    {UDS_ARS_AUTH_RET_DEAUTH_SUCCESS,           "DeAuthentication successful "},
691
    {UDS_ARS_AUTH_RET_CERT_VER_OWN_VER_NEC,     "Certificate Verified, Ownership Verification Necessary"},
692
    {UDS_ARS_AUTH_RET_OWN_VER_AUTH_COMPL,       "Ownership Verified, Authentication Complete "},
693
    {UDS_ARS_AUTH_RET_CERT_VERIFIED,            "Certificate Verified"},
694
    {0, NULL}
695
};
696
697
/* RDBPI */
698
static const value_string uds_rdbpi_transmission_mode[] = {
699
    {0, "Reserved"},
700
    {1, "Send at Slow Rate"},
701
    {2, "Send at Medium Rate"},
702
    {3, "Send at Fast Rate"},
703
    {4, "Stop Sending"},
704
    {0, NULL}
705
};
706
707
/* DDDI */
708
static const value_string uds_dddi_types[] = {
709
    {UDS_DDDI_TYPES_DEFINE_BY_IDENTIFIER,   "Define by Identifier"},
710
    {UDS_DDDI_TYPES_DEFINE_BY_MEM_ADDRESS,  "Define by Memory Address"},
711
    {UDS_DDDI_TYPES_CLEAR_DYN_DEF_DATA_ID,  "Clear Dynamically Defined Data Identifier"},
712
    {0, NULL}
713
};
714
715
/* IOCBI */
716
static const value_string uds_iocbi_parameters[] = {
717
    {UDS_IOCBI_PARAMETERS_RETURN_CONTROL_TO_ECU, "Return Control To ECU"},
718
    {UDS_IOCBI_PARAMETERS_RESET_TO_DEFAULT,      "Reset To Default"},
719
    {UDS_IOCBI_PARAMETERS_FREEZE_CURRENT_STATE,  "Freeze Current State"},
720
    {UDS_IOCBI_PARAMETERS_SHORT_TERM_ADJUSTMENT, "Short Term Adjustment"},
721
    {0, NULL}
722
};
723
724
/* RC */
725
static const value_string uds_rc_types[] = {
726
    {0,                    "Reserved"},
727
    {UDS_RC_TYPES_START,   "Start routine"},
728
    {UDS_RC_TYPES_STOP,    "Stop routine"},
729
    {UDS_RC_TYPES_REQUEST, "Request routine result"},
730
    {0, NULL}
731
};
732
733
/* RFT */
734
static const value_string uds_rft_mode_types[] = {
735
    {0,                             "Reserved"},
736
    {UDS_RFT_MODE_ADD_FILE,         "Add File"},
737
    {UDS_RFT_MODE_DELETE_FILE,      "Delete File"},
738
    {UDS_RFT_MODE_REPLACE_FILE,     "Replace File"},
739
    {UDS_RFT_MODE_READ_FILE,        "Read File"},
740
    {UDS_RFT_MODE_READ_DIR,         "Read Dir"},
741
    {UDS_RFT_MODE_RESUME_FILE,      "Resume File"},
742
    {0, NULL}
743
};
744
745
/* CDTCS */
746
static const value_string uds_cdtcs_types[] = {
747
    {0,                     "Reserved"},
748
    {UDS_CDTCS_ACTIONS_ON,  "On"},
749
    {UDS_CDTCS_ACTIONS_OFF, "Off"},
750
    {0, NULL}
751
};
752
753
/* LC */
754
static const value_string uds_lc_types[] = {
755
    {0x00,                  "Reserved"},
756
    {UDS_LC_TYPES_VMTWFP,   "Verify Mode Transition with fixed Parameter"},
757
    {UDS_LC_TYPES_VMTWSP,   "Verify Mode Transition with specific Parameter"},
758
    {UDS_LC_TYPES_TM,       "Transition Mode"},
759
    {0, NULL}
760
};
761
762
static const value_string uds_lc_lcmi_types[] = {
763
    {0x00,  "Reserved"},
764
    {0x01,  "PC9600Baud"},
765
    {0x02,  "PC19200Baud"},
766
    {0x03,  "PC38400Baud"},
767
    {0x04,  "PC57600Baud"},
768
    {0x05,  "PC115200Baud"},
769
    {0x10,  "CAN125000Baud"},
770
    {0x11,  "CAN250000Baud"},
771
    {0x12,  "CAN500000Baud"},
772
    {0x13,  "CAN1000000Baud"},
773
    {0x20,  "ProgrammingSetup"},
774
    {0, NULL}
775
};
776
777
/* DIDS */
778
static const value_string _uds_standard_did_types[] = {
779
    {UDS_DID_BSIDID,        "BootSoftwareIdentificationDataIdentifier"},
780
    {UDS_DID_ASIDID,        "applicationSoftwareIdentificationDataIdentifier"},
781
    {UDS_DID_ADIDID,        "applicationDataIdentificationDataIdentifier"},
782
    {UDS_DID_BSFPDID,       "bootSoftwareFingerprintDataIdentifier"},
783
    {UDS_DID_ASFPDID,       "applicationSoftwareFingerprintDataIdentifier"},
784
    {UDS_DID_ADFPDID,       "applicationDataFingerprintDataIdentifier"},
785
    {UDS_DID_ADSDID,        "ActiveDiagnosticSessionDataIdentifier"},
786
    {UDS_DID_VMSPNDID,      "vehicleManufacturerSparePartNumberDataIdentifier"},
787
    {UDS_DID_VMECUSNDID,    "vehicleManufacturerECUSoftwareNumberDataIdentifier"},
788
    {UDS_DID_VMECUSVNDID,   "vehicleManufacturerECUSoftwareVersionNumberDataIdentifier"},
789
    {UDS_DID_SSIDDID,       "systemSupplierIdentifierDataIdentifier"},
790
    {UDS_DID_ECUMDDID,      "ECUManufacturingDateDataIdentifier (year/month/day)"},
791
    {UDS_DID_ECUSNDID,      "ECUSerialNumberDataIdentifier"},
792
    {UDS_DID_SFUDID,        "supportedFunctionalUnitsDataIdentifier"},
793
    {UDS_DID_VMKAPNDID,     "VehicleManufacturerKitAssemblyPartNumberDataIdentifier"},
794
    {UDS_DID_RXSWIN,        "RegulationXSoftwareIdentificationNumbers (RxSWIN)"},
795
    {UDS_DID_VINDID,        "VINDataIdentifier"},
796
    {UDS_DID_VMECUHNDID,    "vehicleManufacturerECUHardwareNumberDataIdentifier"},
797
    {UDS_DID_SSECUHWNDID,   "systemSupplierECUHardwareNumberDataIdentifier"},
798
    {UDS_DID_SSECUHWVNDID,  "systemSupplierECUHardwareVersionNumberDataIdentifier"},
799
    {UDS_DID_SSECUSWNDID,   "systemSupplierECUSoftwareNumberDataIdentifier"},
800
    {UDS_DID_SSECUSWVNDID,  "systemSupplierECUSoftwareVersionNumberDataIdentifier"},
801
    {UDS_DID_EROTANDID,     "exhaustRegulationOrTypeApprovalNumberDataIdentifier"},
802
    {UDS_DID_SNOETDID,      "systemNameOrEngineTypeDataIdentifier"},
803
    {UDS_DID_RSCOTSNDID,    "repairShopCodeOrTesterSerialNumberDataIdentifier"},
804
    {UDS_DID_PDDID,         "programmingDateDataIdentifier (year/month/day)"},
805
    {UDS_DID_CRSCOCESNDID,  "calibrationRepairShopCodeOrCalibrationEquipmentSerialNumberDataIdentifier"},
806
    {UDS_DID_CDDID,         "calibrationDateDataIdentifier (year/month/day)"},
807
    {UDS_DID_CESWNDID,      "calibrationEquipmentSoftwareNumberDataIdentifier"},
808
    {UDS_DID_EIDDID,        "ECUInstallationDateDataIdentifier (year/month/day)"},
809
    {UDS_DID_ODXFDID,       "ODXFileDataIdentifier"},
810
    {UDS_DID_EDID,          "EntityDataIdentifier"},
811
    {UDS_DID_ADDID_FA00,    "AirbagDeployment: Number of PCUs (ISO 26021-2)"},
812
    {UDS_DID_ADDID_FA01,    "AirbagDeployment: Deployment Method Version (ISO 26021-2)"},
813
    {UDS_DID_ADDID_FA02,    "AirbagDeployment: Address Information of PCU (ISO 26021-2)"},
814
    {UDS_DID_ADDID_FA03,    "AirbagDeployment (ISO 26021-2)"},
815
    {UDS_DID_ADDID_FA04,    "AirbagDeployment (ISO 26021-2)"},
816
    {UDS_DID_ADDID_FA05,    "AirbagDeployment (ISO 26021-2)"},
817
    {UDS_DID_ADDID_FA06,    "AirbagDeployment: Deployment Loop Table of PCU (ISO 26021-2)"},
818
    {UDS_DID_ADDID_FA07,    "AirbagDeployment: Dismantler Info (ISO 26021-2)"},
819
    {UDS_DID_ADDID_FA08,    "AirbagDeployment (ISO 26021-2)"},
820
    {UDS_DID_ADDID_FA09,    "AirbagDeployment (ISO 26021-2)"},
821
    {UDS_DID_ADDID_FA0A,    "AirbagDeployment (ISO 26021-2)"},
822
    {UDS_DID_ADDID_FA0B,    "AirbagDeployment (ISO 26021-2)"},
823
    {UDS_DID_ADDID_FA0C,    "AirbagDeployment (ISO 26021-2)"},
824
    {UDS_DID_ADDID_FA0D,    "AirbagDeployment (ISO 26021-2)"},
825
    {UDS_DID_ADDID_FA0E,    "AirbagDeployment (ISO 26021-2)"},
826
    {UDS_DID_ADDID_FA0F,    "AirbagDeployment (ISO 26021-2)"},
827
    {UDS_DID_NOEDRD,        "NumberOfEDRDevices"},
828
    {UDS_DID_EDRI,          "EDRIdentification"},
829
    {UDS_DID_EDRDAI,        "EDRDeviceAddressInformation"},
830
    {UDS_DID_UDSVDID,       "UDSVersionDataIdentifier"},
831
    {UDS_DID_RESRVDCPADLC,  "ReservedForISO15765-5 (CAN, CAN-FD, CAN+CAN-FD, ...)"},
832
    {0, NULL}
833
};
834
static value_string_ext uds_standard_did_types_ext = VALUE_STRING_EXT_INIT(_uds_standard_did_types);
835
836
/* ReservedForISO15765 */
837
static const value_string uds_did_resrvdcpadlc_types[] = {
838
    {0, "CAN Classic Only"},
839
    {1, "CAN FD only"},
840
    {2, "CAN Classic and CAN FD"},
841
    {0, NULL}
842
};
843
844
/* RIDS */
845
static const value_string uds_standard_rid_types[] = {
846
    {UDS_RID_EXSPLRI_,      "Execute SPL"},
847
    {UDS_RID_DLRI_,         "DeployLoopRoutineID"},
848
    {UDS_RID_EM_,           "eraseMemory"},
849
    {UDS_RID_CPD_,          "checkProgrammingDependencies"},
850
    {UDS_RID_FF02,          "eraseMirrorMemoryDTCs (deprecated)"},
851
    {0, NULL}
852
};
853
854
/* DTCS */
855
static const value_string uds_standard_dtc_types[] = {
856
    /* TODO: Add DTCs! */
857
    {0, NULL}
858
};
859
860
/* ROE */
861
static const value_string uds_roe_types[] = {
862
    {0, "stop"},
863
    {1, "onDTCStatusChange"},
864
    {3, "onChangeOfDataIdentifier"},
865
    {4, "reportActivatedEvents"},
866
    {5, "start"},
867
    {6, "clear"},
868
    {7, "onComparisonOfValues"},
869
    {8, "reportMostRecentDtcOnStatusChange"},
870
    {9, "reportDTCRecordInformationOnDtcStatusChange"},
871
    {0, NULL}
872
};
873
874
static const value_string uds_roe_windowtime_types[] = {
875
    {2, "infinite"},
876
    {3, "short"},
877
    {4, "medium"},
878
    {5, "long"},
879
    {6, "power"},
880
    {7, "ignition"},
881
    {8, "manufacturerTrigger"},
882
    {0, NULL}
883
};
884
885
static const value_string uds_roe_ocov_logic_types[] = {
886
    {1, "<"},
887
    {2, ">"},
888
    {3, "="},
889
    {4, "<>"},
890
    {0, NULL}
891
};
892
893
static const value_string uds_roe_localisation_sign_types[] = {
894
    {0, "without sign"},
895
    {1, "with sign"},
896
    {0, NULL}
897
};
898
899
/*
900
 * Fields
901
 */
902
903
static int hf_uds_diag_addr;
904
static int hf_uds_diag_addr_name;
905
static int hf_uds_diag_source_addr;
906
static int hf_uds_diag_source_addr_name;
907
static int hf_uds_diag_target_addr;
908
static int hf_uds_diag_target_addr_name;
909
910
static int hf_uds_service;
911
static int hf_uds_reply;
912
913
static int hf_uds_subfunction;
914
static int hf_uds_suppress_pos_rsp_msg_ind;
915
static int hf_uds_data_record;
916
917
static int hf_uds_compression_method;
918
static int hf_uds_encrypting_method;
919
static int hf_uds_memory_size_length;
920
static int hf_uds_memory_address_length;
921
static int hf_uds_memory_address;
922
static int hf_uds_memory_size;
923
static int hf_uds_max_block_len_len;
924
static int hf_uds_max_block_len;
925
926
static int hf_uds_dsc_subfunction;
927
static int hf_uds_dsc_suppress_pos_rsp_msg_ind;
928
static int hf_uds_dsc_parameter_record;
929
static int hf_uds_dsc_default_p2_server_timer;
930
static int hf_uds_dsc_enhanced_p2_server_timer;
931
932
static int hf_uds_er_subfunction;
933
static int hf_uds_er_power_down_time;
934
935
static int hf_uds_cdtci_group_of_dtc;
936
static int hf_uds_cdtci_memory_selection;
937
938
static int hf_uds_rdtci_subfunction;
939
static int hf_uds_rdtci_dtc_status_mask;
940
static int hf_uds_rdtci_dtc_status_mask_tf;
941
static int hf_uds_rdtci_dtc_status_mask_tftoc;
942
static int hf_uds_rdtci_dtc_status_mask_pdtc;
943
static int hf_uds_rdtci_dtc_status_mask_cdtc;
944
static int hf_uds_rdtci_dtc_status_mask_tncslc;
945
static int hf_uds_rdtci_dtc_status_mask_tfslc;
946
static int hf_uds_rdtci_dtc_status_mask_tnctoc;
947
static int hf_uds_rdtci_dtc_status_mask_wir;
948
static int hf_uds_rdtci_dtc_mask_record;
949
static int hf_uds_rdtci_dtc_snapshot_rec_no;
950
static int hf_uds_rdtci_dtc_stored_data_rec_no;
951
static int hf_uds_rdtci_dtc_ext_data_rec_no;
952
static int hf_uds_rdtci_memory_selection;
953
static int hf_uds_rdtci_user_def_dtc_snapshot_rec_no;
954
static int hf_uds_rdtci_dtc_severity_mask;
955
static int hf_uds_rdtci_functional_group_id;
956
static int hf_uds_rdtci_dtc_readiness_group_id;
957
static int hf_uds_rdtci_dtc_status_avail;
958
static int hf_uds_rdtci_dtc_status_avail_tf;
959
static int hf_uds_rdtci_dtc_status_avail_tftoc;
960
static int hf_uds_rdtci_dtc_status_avail_pdtc;
961
static int hf_uds_rdtci_dtc_status_avail_cdtc;
962
static int hf_uds_rdtci_dtc_status_avail_tncslc;
963
static int hf_uds_rdtci_dtc_status_avail_tfslc;
964
static int hf_uds_rdtci_dtc_status_avail_tnctoc;
965
static int hf_uds_rdtci_dtc_status_avail_wir;
966
static int hf_uds_rdtci_dtc_id;
967
static int hf_uds_rdtci_dtc_status;
968
static int hf_uds_rdtci_dtc_status_tf;
969
static int hf_uds_rdtci_dtc_status_tftoc;
970
static int hf_uds_rdtci_dtc_status_pdtc;
971
static int hf_uds_rdtci_dtc_status_cdtc;
972
static int hf_uds_rdtci_dtc_status_tncslc;
973
static int hf_uds_rdtci_dtc_status_tfslc;
974
static int hf_uds_rdtci_dtc_status_tnctoc;
975
static int hf_uds_rdtci_dtc_status_wir;
976
static int hf_uds_rdtci_dtc_format_id;
977
static int hf_uds_rdtci_dtc_count;
978
static int hf_uds_rdtci_dtc_snapshot_record_number_of_ids;
979
static int hf_uds_rdtci_dtc_stored_data_record_number_of_ids;
980
static int hf_uds_rdtci_dtc_severity;
981
static int hf_uds_rdtci_dtc_functional_unit;
982
static int hf_uds_rdtci_dtc_fault_detect_counter;
983
static int hf_uds_rdtci_dtc_severity_avail;
984
static int hf_uds_rdtci_record;
985
static int hf_uds_rdtci_record_unparsed;
986
987
static int hf_uds_rdbi_data_identifier;
988
989
static int hf_uds_rsdbi_data_identifier;
990
static int hf_uds_rsdbi_scaling_byte;
991
static int hf_uds_rsdbi_scaling_byte_data_type;
992
static int hf_uds_rsdbi_scaling_byte_num_of_bytes;
993
static int hf_uds_rsdbi_validity_mask;
994
static int hf_uds_rsdbi_formula_identifier;
995
static int hf_uds_rsdbi_formula_constant;
996
static int hf_uds_rsdbi_formula_constant_exp;
997
static int hf_uds_rsdbi_formula_constant_mantissa;
998
static int hf_uds_rsdbi_unit;
999
1000
static int hf_uds_sa_subfunction;
1001
static int hf_uds_sa_key;
1002
static int hf_uds_sa_seed;
1003
1004
static int hf_uds_cc_subfunction_no_suppress;
1005
static int hf_uds_cc_comm_type_and_subnet_number;
1006
static int hf_uds_cc_communication_type;
1007
static int hf_uds_cc_subnet_number;
1008
static int hf_uds_cc_node_identifier_number;
1009
1010
static int hf_uds_ars_subfunction_no_suppress;
1011
static int hf_uds_ars_comm_config;
1012
static int hf_uds_ars_length_of_cert_client;
1013
static int hf_uds_ars_cert_client;
1014
static int hf_uds_ars_length_of_cert_server;
1015
static int hf_uds_ars_cert_server;
1016
static int hf_uds_ars_length_of_challenge_client;
1017
static int hf_uds_ars_challenge_client;
1018
static int hf_uds_ars_length_of_challenge_server;
1019
static int hf_uds_ars_challenge_server;
1020
static int hf_uds_ars_length_of_proof_of_ownership_client;
1021
static int hf_uds_ars_proof_of_ownership_client;
1022
static int hf_uds_ars_length_of_proof_of_ownership_server;
1023
static int hf_uds_ars_proof_of_ownership_server;
1024
static int hf_uds_ars_length_of_ephemeral_public_key_client;
1025
static int hf_uds_ars_ephemeral_public_key_client;
1026
static int hf_uds_ars_length_of_ephemeral_public_key_server;
1027
static int hf_uds_ars_ephemeral_public_key_server;
1028
static int hf_uds_ars_cert_eval_id;
1029
static int hf_uds_ars_length_of_cert_data;
1030
static int hf_uds_ars_cert_data;
1031
static int hf_uds_ars_algo_indicator;
1032
static int hf_uds_ars_length_of_additional_parameter;
1033
static int hf_uds_ars_additional_parameter;
1034
static int hf_uds_ars_length_of_needed_additional_parameter;
1035
static int hf_uds_ars_needed_additional_parameter;
1036
static int hf_uds_ars_auth_ret_param;
1037
static int hf_uds_ars_length_of_session_key_info;
1038
static int hf_uds_ars_session_key_info;
1039
1040
static int hf_uds_signedCertificate;
1041
1042
static int hf_uds_rdbpi_transmission_mode;
1043
static int hf_uds_rdbpi_periodic_data_identifier;
1044
1045
static int hf_uds_dddi_subfunction_no_suppress;
1046
static int hf_uds_dddi_dyn_defined_data_identifier;
1047
static int hf_uds_dddi_source_data_identifier;
1048
static int hf_uds_dddi_position_in_source_data_record;
1049
static int hf_uds_dddi_memory_size;
1050
1051
static int hf_uds_wdbi_data_identifier;
1052
1053
static int hf_uds_iocbi_data_identifier;
1054
static int hf_uds_iocbi_parameter;
1055
static int hf_uds_iocbi_state;
1056
1057
static int hf_uds_rc_subfunction;
1058
static int hf_uds_rc_identifier;
1059
static int hf_uds_rc_option_record;
1060
static int hf_uds_rc_info;
1061
static int hf_uds_rc_status_record;
1062
1063
static int hf_uds_td_sequence_counter;
1064
static int hf_uds_td_record_data;
1065
1066
static int hf_uds_rte_record_data;
1067
1068
static int hf_uds_rft_mode_of_operation;
1069
static int hf_uds_rft_length_of_file_path_and_name;
1070
static int hf_uds_rft_file_path_and_name;
1071
static int hf_uds_rft_file_size_param_length;
1072
static int hf_uds_rft_file_size_uncompressed;
1073
static int hf_uds_rft_file_size_compressed;
1074
static int hf_uds_rft_length_format_identifier;
1075
static int hf_uds_rft_max_num_of_block_length;
1076
static int hf_uds_rft_file_size_or_dir_info_param_length;
1077
static int hf_uds_rft_file_size_uncompressed_or_dir_info_length;
1078
static int hf_uds_rft_file_position;
1079
1080
static int hf_uds_tp_subfunction_no_suppress;
1081
1082
static int hf_uds_err_sid;
1083
static int hf_uds_err_code;
1084
1085
static int hf_uds_sdt_administrative_param;
1086
static int hf_uds_sdt_administrative_param_req;
1087
static int hf_uds_sdt_administrative_param_pre_estab_key;
1088
static int hf_uds_sdt_administrative_param_encrypted;
1089
static int hf_uds_sdt_administrative_param_signed;
1090
static int hf_uds_sdt_administrative_param_resp_sign_req;
1091
static int hf_uds_sdt_signature_encryption_calculation;
1092
static int hf_uds_sdt_signature_length;
1093
static int hf_uds_sdt_anti_replay_counter;
1094
static int hf_uds_sdt_encapsulated_message;
1095
static int hf_uds_sdt_encapsulated_message_sid;
1096
static int hf_uds_sdt_encapsulated_message_sid_reply;
1097
static int hf_uds_sdt_signature_mac;
1098
1099
static int hf_uds_cdtcs_subfunction;
1100
static int hf_uds_cdtcs_subfunction_no_suppress;
1101
static int hf_uds_cdtcs_subfunction_pos_rsp_msg_ind;
1102
static int hf_uds_cdtcs_option_record;
1103
static int hf_uds_cdtcs_type;
1104
1105
static int hf_uds_lc_subfunction;
1106
static int hf_uds_lc_subfunction_no_suppress;
1107
static int hf_uds_lc_subfunction_pos_rsp_msg_ind;
1108
static int hf_uds_lc_control_mode_id;
1109
static int hf_uds_lc_link_record;
1110
1111
static int hf_uds_did_reply_f186_diag_session;
1112
static int hf_uds_did_reply_f190_vin;
1113
static int hf_uds_did_reply_ff00_version;
1114
static int hf_uds_did_reply_ff01_dlc_support;
1115
1116
static int hf_uds_roe_subfunction;
1117
static int hf_uds_roe_store_flag;
1118
static int hf_uds_roe_window_time;
1119
static int hf_uds_roe_NOIE;
1120
static int hf_uds_roe_EVOAE;
1121
static int hf_uds_roe_dtc_status_mask;
1122
static int hf_uds_roe_dtc_status_mask_TF;
1123
static int hf_uds_roe_dtc_status_mask_TFTOC;
1124
static int hf_uds_roe_dtc_status_mask_PDTC;
1125
static int hf_uds_roe_dtc_status_mask_CDTC;
1126
static int hf_uds_roe_dtc_status_mask_TNCSLC;
1127
static int hf_uds_roe_dtc_status_mask_TFSLC;
1128
static int hf_uds_roe_dtc_status_mask_TNCTOC;
1129
static int hf_uds_roe_dtc_status_mask_WIR;
1130
static int hf_uds_roe_identifier;
1131
static int hf_uds_roe_did;
1132
static int hf_uds_roe_comparison;
1133
static int hf_uds_roe_comparison_value;
1134
static int hf_uds_roe_hysteresis_value;
1135
static int hf_uds_roe_localization;
1136
static int hf_uds_roe_localization_sign;
1137
static int hf_uds_roe_localization_length;
1138
static int hf_uds_roe_localization_offset;
1139
1140
static int hf_uds_unparsed_bytes;
1141
1142
/*
1143
 * Trees
1144
 */
1145
static int ett_uds;
1146
static int ett_uds_subfunction;
1147
static int ett_uds_dtc_status_entry;
1148
static int ett_uds_dtc_status_bits;
1149
static int ett_uds_dtc_snapshot_entry;
1150
static int ett_uds_dtc_counter_entry;
1151
static int ett_uds_dsc_parameter_record;
1152
static int ett_uds_rsdbi_scaling_byte;
1153
static int ett_uds_rsdbi_formula_constant;
1154
static int ett_uds_cc_communication_type;
1155
static int ett_uds_ars_certificate;
1156
static int ett_uds_ars_algo_indicator;
1157
static int ett_uds_dddi_entry;
1158
static int ett_uds_sdt_admin_param;
1159
static int ett_uds_sdt_encap_message;
1160
static int ett_uds_roe_dtc_status_mask;
1161
static int ett_uds_roe_localization;
1162
1163
static int proto_uds;
1164
1165
static dissector_handle_t uds_handle;
1166
static dissector_handle_t uds_handle_doip;
1167
static dissector_handle_t uds_handle_hsfz;
1168
static dissector_handle_t uds_handle_iso10681;
1169
static dissector_handle_t uds_handle_iso15765;
1170
static dissector_handle_t obd_ii_handle;
1171
1172
/*** Subdissectors ***/
1173
static heur_dissector_list_t heur_subdissector_list;
1174
static heur_dtbl_entry_t *heur_dtbl_entry;
1175
1176
/*** Configuration ***/
1177
enum certificate_decoding_strategies {
1178
    cert_parsing_off = -1,
1179
    ber_cert_single_false = 0,
1180
    ber_cert_single_true  = 1,
1181
    ber_cert_multi_false  = 2,
1182
    ber_cert_multi_true   = 3,
1183
};
1184
1185
static const enum_val_t certificate_decoding_vals[] = {
1186
    {"0", "BER Certificate w/o implicit tag", ber_cert_single_false},
1187
    {"1", "BER Certificate w implicit tag", ber_cert_single_true},
1188
    {"2", "BER Certificates w/o implicit tag", ber_cert_multi_false},
1189
    {"3", "BER Certificates w implicit tag", ber_cert_multi_true},
1190
    {"off", "Do not parse", cert_parsing_off},
1191
    {NULL, NULL, -1}
1192
};
1193
1194
static int uds_certificate_decoding_config = (int)cert_parsing_off;
1195
1196
static bool uds_dissect_small_sids_with_obd_ii = true;
1197
static bool uds_clear_info_col = false;
1198
1199
typedef struct _address_string {
1200
    unsigned address;
1201
    char    *name;
1202
} address_string_t;
1203
1204
static void *
1205
0
copy_address_string_cb(void *n, const void *o, size_t size _U_) {
1206
0
    address_string_t *new_rec = (address_string_t *)n;
1207
0
    const address_string_t *old_rec = (const address_string_t *)o;
1208
1209
0
    new_rec->name = g_strdup(old_rec->name);
1210
0
    new_rec->address = old_rec->address;
1211
0
    return new_rec;
1212
0
}
1213
1214
static bool
1215
0
update_address_string_cb(void *r, char **err) {
1216
0
    address_string_t *rec = (address_string_t *)r;
1217
1218
0
    if (rec->name == NULL || rec->name[0] == 0) {
1219
0
        *err = g_strdup("Name cannot be empty");
1220
0
        return false;
1221
0
    }
1222
1223
0
    return true;
1224
0
}
1225
1226
static void
1227
0
free_address_string_cb(void *r) {
1228
0
    address_string_t *rec = (address_string_t *)r;
1229
1230
    /* freeing result of g_strdup */
1231
0
    g_free(rec->name);
1232
0
    rec->name = NULL;
1233
0
}
1234
1235
typedef struct _generic_addr_id_string {
1236
    uint32_t address;
1237
    uint32_t id;
1238
    char    *name;
1239
} generic_addr_id_string_t;
1240
1241
static void *
1242
0
copy_generic_one_id_string_cb(void *n, const void *o, size_t size _U_) {
1243
0
    generic_addr_id_string_t *new_rec = (generic_addr_id_string_t *)n;
1244
0
    const generic_addr_id_string_t *old_rec = (const generic_addr_id_string_t *)o;
1245
1246
0
    new_rec->name = g_strdup(old_rec->name);
1247
0
    new_rec->id = old_rec->id;
1248
0
    new_rec->address = old_rec->address;
1249
0
    return new_rec;
1250
0
}
1251
1252
static bool
1253
0
update_generic_addr_16bit_id_var(void *r, char **err, uint32_t limit) {
1254
0
    generic_addr_id_string_t *rec = (generic_addr_id_string_t *)r;
1255
1256
0
    if (rec->id > limit) {
1257
0
        *err = ws_strdup_printf("We currently only support identifiers <= %x (Addr: %x ID: %i  Name: %s)", limit, rec->address, rec->id, rec->name);
1258
0
        return false;
1259
0
    }
1260
1261
0
    if (rec->address > 0xffff && rec->address != UINT32_MAX) {
1262
0
        *err = ws_strdup_printf("We currently only support 16 bit addresses with 0xffffffff = \"don't care\" (Addr: %x  ID: %i  Name: %s)",
1263
0
                                rec->address, rec->id, rec->name);
1264
0
        return false;
1265
0
    }
1266
1267
0
    if (rec->name == NULL || rec->name[0] == 0) {
1268
0
        *err = g_strdup("Name cannot be empty");
1269
0
        return false;
1270
0
    }
1271
1272
0
    return true;
1273
0
}
1274
1275
static bool
1276
0
update_generic_addr_16bit_id_16bit(void *r, char **err) {
1277
0
    return update_generic_addr_16bit_id_var(r, err, 0xffff);
1278
0
}
1279
1280
static bool
1281
0
update_generic_addr_16bit_id_24bit(void *r, char **err) {
1282
0
    return update_generic_addr_16bit_id_var(r, err, 0xffffff);
1283
0
}
1284
1285
static void
1286
0
free_generic_one_id_string_cb(void *r) {
1287
0
    generic_addr_id_string_t *rec = (generic_addr_id_string_t *)r;
1288
1289
    /* freeing result of g_strdup */
1290
0
    g_free(rec->name);
1291
0
    rec->name = NULL;
1292
0
}
1293
1294
static uint64_t
1295
0
calc_key(uint32_t addr, uint32_t id) {
1296
0
    return ((uint64_t)id << 32) | (uint64_t)addr;
1297
0
}
1298
1299
static char *
1300
0
generic_lookup_addr_id(uint32_t addr, uint32_t id, GHashTable *ht) {
1301
0
    if (ht == NULL) {
1302
0
        return NULL;
1303
0
    }
1304
1305
0
    uint64_t key = calc_key(addr, id);
1306
0
    char *ret = g_hash_table_lookup(ht, &key);
1307
0
    if (ret == NULL) {
1308
0
        key = calc_key(UINT32_MAX, id);
1309
0
        ret = g_hash_table_lookup(ht, &key);
1310
0
    }
1311
1312
0
    return ret;
1313
0
}
1314
1315
1316
/* Routine IDs */
1317
static generic_addr_id_string_t *uds_uat_routine_ids;
1318
static unsigned uds_uat_routine_id_num;
1319
static GHashTable *uds_ht_routine_ids;
1320
1321
0
UAT_HEX_CB_DEF(uds_uat_routine_ids, address, generic_addr_id_string_t)
Unexecuted instantiation: packet-uds.c:uds_uat_routine_ids_address_set_cb
Unexecuted instantiation: packet-uds.c:uds_uat_routine_ids_address_tostr_cb
1322
0
UAT_HEX_CB_DEF(uds_uat_routine_ids, id, generic_addr_id_string_t)
Unexecuted instantiation: packet-uds.c:uds_uat_routine_ids_id_set_cb
Unexecuted instantiation: packet-uds.c:uds_uat_routine_ids_id_tostr_cb
1323
UAT_CSTRING_CB_DEF(uds_uat_routine_ids, name, generic_addr_id_string_t)
1324
1325
static void
1326
14
reset_update_uds_routine_cb(void) {
1327
    /* destroy hash table, if it exists */
1328
14
    if (uds_ht_routine_ids) {
1329
0
        g_hash_table_destroy(uds_ht_routine_ids);
1330
0
        uds_ht_routine_ids = NULL;
1331
0
    }
1332
14
}
1333
1334
static void
1335
14
post_update_uds_routine_cb(void) {
1336
14
    reset_update_uds_routine_cb();
1337
1338
    /* create new hash table */
1339
14
    uds_ht_routine_ids = g_hash_table_new_full(g_int64_hash, g_int64_equal, g_free, NULL);
1340
1341
14
    for (unsigned i = 0; i < uds_uat_routine_id_num; i++) {
1342
0
        uint64_t *key = g_new(uint64_t, 1);
1343
0
        *key = calc_key(uds_uat_routine_ids[i].address, uds_uat_routine_ids[i].id);
1344
0
        g_hash_table_insert(uds_ht_routine_ids, key, uds_uat_routine_ids[i].name);
1345
0
    }
1346
14
}
1347
1348
static const char *
1349
0
uds_lookup_routine_name(uint32_t addr, uint16_t id) {
1350
0
    const char *tmp = generic_lookup_addr_id(addr, id, uds_ht_routine_ids);
1351
1352
0
    if (tmp == NULL) {
1353
0
        tmp = try_val_to_str(id, uds_standard_rid_types);
1354
0
    }
1355
1356
0
    return tmp;
1357
0
}
1358
1359
static void
1360
0
protoitem_append_routine_name(proto_item *ti, uint32_t addr, uint16_t data_identifier) {
1361
0
    const char *routine_name = uds_lookup_routine_name(addr, data_identifier);
1362
0
    if (routine_name != NULL) {
1363
0
        proto_item_append_text(ti, " (%s)", routine_name);
1364
0
    }
1365
0
}
1366
1367
static void
1368
0
infocol_append_routine_name(packet_info *pinfo, uint32_t addr, uint16_t routine_identifier) {
1369
0
    const char *routine_name = uds_lookup_routine_name(addr, routine_identifier);
1370
0
    if (routine_name != NULL) {
1371
0
        col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)", routine_name);
1372
0
    }
1373
0
}
1374
1375
1376
/* Data IDs */
1377
static generic_addr_id_string_t *uds_uat_data_ids;
1378
static unsigned uds_uat_data_id_num;
1379
static GHashTable *uds_ht_data_ids;
1380
1381
0
UAT_HEX_CB_DEF(uds_uat_data_ids, address, generic_addr_id_string_t)
Unexecuted instantiation: packet-uds.c:uds_uat_data_ids_address_set_cb
Unexecuted instantiation: packet-uds.c:uds_uat_data_ids_address_tostr_cb
1382
0
UAT_HEX_CB_DEF(uds_uat_data_ids, id, generic_addr_id_string_t)
Unexecuted instantiation: packet-uds.c:uds_uat_data_ids_id_set_cb
Unexecuted instantiation: packet-uds.c:uds_uat_data_ids_id_tostr_cb
1383
UAT_CSTRING_CB_DEF(uds_uat_data_ids, name, generic_addr_id_string_t)
1384
1385
static void
1386
14
reset_update_uds_data_cb(void) {
1387
    /* destroy hash table, if it exists */
1388
14
    if (uds_ht_data_ids) {
1389
0
        g_hash_table_destroy(uds_ht_data_ids);
1390
0
        uds_ht_data_ids = NULL;
1391
0
    }
1392
14
}
1393
1394
static void
1395
14
post_update_uds_data_cb(void) {
1396
14
    reset_update_uds_data_cb();
1397
1398
    /* create new hash table */
1399
14
    uds_ht_data_ids = g_hash_table_new_full(g_int64_hash, g_int64_equal, g_free, NULL);
1400
1401
14
    for (unsigned i = 0; i < uds_uat_data_id_num; i++) {
1402
0
        uint64_t *key = g_new(uint64_t, 1);
1403
0
        *key = calc_key(uds_uat_data_ids[i].address, uds_uat_data_ids[i].id);
1404
0
        g_hash_table_insert(uds_ht_data_ids, key, uds_uat_data_ids[i].name);
1405
0
    }
1406
14
}
1407
1408
static const char *
1409
0
uds_lookup_data_name(uint32_t addr, uint16_t id) {
1410
0
    const char *tmp = generic_lookup_addr_id(addr, id, uds_ht_data_ids);
1411
1412
0
    if (tmp == NULL) {
1413
0
        tmp = try_val_to_str_ext(id, &uds_standard_did_types_ext);
1414
0
    }
1415
1416
0
    return tmp;
1417
0
}
1418
1419
static void
1420
0
protoitem_append_data_name(proto_item *ti, uint32_t addr, uint16_t data_identifier) {
1421
0
    const char *data_name = uds_lookup_data_name(addr, data_identifier);
1422
0
    if (data_name != NULL) {
1423
0
        proto_item_append_text(ti, " (%s)", data_name);
1424
0
    }
1425
0
}
1426
1427
static void
1428
0
infocol_append_data_name(packet_info *pinfo, uint32_t addr, uint16_t data_identifier) {
1429
0
    const char *data_name = uds_lookup_data_name(addr, data_identifier);
1430
0
    if (data_name != NULL) {
1431
0
        col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)", data_name);
1432
0
    }
1433
0
}
1434
1435
1436
/* DTC IDs */
1437
static generic_addr_id_string_t *uds_uat_dtc_ids;
1438
static unsigned uds_uat_dtc_id_num;
1439
static GHashTable *uds_ht_dtc_ids;
1440
1441
0
UAT_HEX_CB_DEF(uds_uat_dtc_ids, address, generic_addr_id_string_t)
Unexecuted instantiation: packet-uds.c:uds_uat_dtc_ids_address_set_cb
Unexecuted instantiation: packet-uds.c:uds_uat_dtc_ids_address_tostr_cb
1442
0
UAT_HEX_CB_DEF(uds_uat_dtc_ids, id, generic_addr_id_string_t)
Unexecuted instantiation: packet-uds.c:uds_uat_dtc_ids_id_set_cb
Unexecuted instantiation: packet-uds.c:uds_uat_dtc_ids_id_tostr_cb
1443
UAT_CSTRING_CB_DEF(uds_uat_dtc_ids, name, generic_addr_id_string_t)
1444
1445
static void
1446
14
reset_update_uds_dtc_cb(void) {
1447
    /* destroy hash table, if it exists */
1448
14
    if (uds_ht_dtc_ids) {
1449
0
        g_hash_table_destroy(uds_ht_dtc_ids);
1450
0
        uds_ht_dtc_ids = NULL;
1451
0
    }
1452
14
}
1453
1454
static void
1455
14
post_update_uds_dtc_cb(void) {
1456
14
    reset_update_uds_dtc_cb();
1457
1458
    /* create new hash table */
1459
14
    uds_ht_dtc_ids = g_hash_table_new_full(g_int64_hash, g_int64_equal, g_free, NULL);
1460
1461
14
    for (unsigned i = 0; i < uds_uat_dtc_id_num; i++) {
1462
0
        uint64_t *key = g_new(uint64_t, 1);
1463
0
        *key = calc_key(uds_uat_dtc_ids[i].address, uds_uat_dtc_ids[i].id);
1464
0
        g_hash_table_insert(uds_ht_dtc_ids, key, uds_uat_dtc_ids[i].name);
1465
0
    }
1466
14
}
1467
1468
static const char *
1469
0
uds_lookup_dtc_name(uint32_t addr, uint32_t id) {
1470
0
    const char *tmp = generic_lookup_addr_id(addr, id, uds_ht_dtc_ids);
1471
1472
0
    if (tmp == NULL) {
1473
0
        tmp = try_val_to_str(id, uds_standard_dtc_types);
1474
0
    }
1475
1476
0
    return tmp;
1477
0
}
1478
1479
static void
1480
0
protoitem_append_dtc_name(proto_item *ti, uint32_t addr, uint32_t dtc_id) {
1481
0
    const char *dtc_name = uds_lookup_dtc_name(addr, dtc_id);
1482
0
    if (dtc_name != NULL) {
1483
0
        proto_item_append_text(ti, " (%s)", dtc_name);
1484
0
    }
1485
0
}
1486
1487
1488
/* Addresses */
1489
static address_string_t *uds_uat_addresses;
1490
static unsigned uds_uat_addresses_num;
1491
static GHashTable *uds_ht_addresses;
1492
1493
0
UAT_HEX_CB_DEF(uds_uat_addresses, address, address_string_t)
Unexecuted instantiation: packet-uds.c:uds_uat_addresses_address_set_cb
Unexecuted instantiation: packet-uds.c:uds_uat_addresses_address_tostr_cb
1494
UAT_CSTRING_CB_DEF(uds_uat_addresses, name, address_string_t)
1495
1496
static void
1497
14
reset_uds_address_cb(void) {
1498
    /* destroy hash table, if it exists */
1499
14
    if (uds_ht_addresses) {
1500
0
        g_hash_table_destroy(uds_ht_addresses);
1501
0
        uds_ht_addresses = NULL;
1502
0
    }
1503
14
}
1504
1505
static void
1506
14
post_update_uds_address_cb(void) {
1507
14
    reset_uds_address_cb();
1508
1509
    /* create new hash table */
1510
14
    uds_ht_addresses = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL);
1511
1512
14
    for (unsigned i = 0; i < uds_uat_addresses_num; i++) {
1513
0
        g_hash_table_insert(uds_ht_addresses, GUINT_TO_POINTER(uds_uat_addresses[i].address), uds_uat_addresses[i].name);
1514
0
    }
1515
14
}
1516
1517
static void
1518
24
uds_proto_item_append_address_name(proto_item *ti, uint32_t addr) {
1519
24
    if (uds_ht_addresses != NULL) {
1520
24
        char *address_name = g_hash_table_lookup(uds_ht_addresses, GUINT_TO_POINTER(addr));
1521
24
        if (address_name != NULL) {
1522
0
            proto_item_append_text(ti, " (%s)", address_name);
1523
0
        }
1524
24
    }
1525
24
}
1526
1527
static proto_item *
1528
16
uds_proto_tree_add_address_item(proto_tree *tree, int hf, tvbuff_t *tvb, const int offset, const int size, unsigned addr, bool generated, bool hidden) {
1529
16
    proto_item *ti;
1530
1531
16
    ti = proto_tree_add_uint(tree, hf, tvb, offset, size, addr);
1532
16
    uds_proto_item_append_address_name(ti, addr);
1533
1534
16
    if (generated) {
1535
16
        proto_item_set_generated(ti);
1536
16
    }
1537
1538
16
    if (hidden) {
1539
8
        proto_item_set_hidden(ti);
1540
8
    }
1541
1542
16
    return ti;
1543
16
}
1544
1545
static proto_item *
1546
16
uds_proto_tree_add_address_name(proto_tree *tree, packet_info* pinfo, int hf, tvbuff_t *tvb, const int offset, const int size, unsigned addr) {
1547
16
    proto_item *ti;
1548
1549
16
    char *address_name = NULL;
1550
16
    if (uds_ht_addresses != NULL) {
1551
16
        address_name = g_hash_table_lookup(uds_ht_addresses, GUINT_TO_POINTER(addr));
1552
16
    }
1553
1554
16
    if (address_name != NULL) {
1555
0
        ti = proto_tree_add_string(tree, hf, tvb, offset, size, address_name);
1556
16
    } else {
1557
16
        address_name = wmem_strdup_printf(pinfo->pool, "%d", addr);
1558
16
        ti = proto_tree_add_string(tree, hf, tvb, offset, size, address_name);
1559
16
    }
1560
1561
16
    proto_item_set_generated(ti);
1562
16
    proto_item_set_hidden(ti);
1563
1564
16
    return ti;
1565
16
}
1566
1567
static void
1568
8
uds_proto_item_append_address_text(proto_item *ti, uint8_t address_length, const char *name, uint32_t value) {
1569
8
    if (ti == NULL) {
1570
0
        return;
1571
0
    }
1572
1573
8
    switch (address_length) {
1574
0
    case 1:
1575
0
        proto_item_append_text(ti, ", %s: 0x%02x", name, value);
1576
0
        break;
1577
8
    case 2:
1578
8
        proto_item_append_text(ti, ", %s: 0x%04x", name, value);
1579
8
        break;
1580
8
    }
1581
8
}
1582
1583
/*** Configuration End ***/
1584
1585
static bool
1586
call_heur_subdissector_uds(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *uds_tree, uint8_t service, bool reply, uint32_t id, uint32_t uds_address)
1587
0
{
1588
0
    uds_info_t uds_info;
1589
1590
0
    uds_info.id = id;
1591
0
    uds_info.uds_address = uds_address;
1592
0
    uds_info.reply = reply;
1593
0
    uds_info.service = service;
1594
1595
0
    bool ret = dissector_try_heuristic(heur_subdissector_list, tvb, pinfo, tree, &heur_dtbl_entry, &uds_info);
1596
1597
0
    if (!ret) {
1598
0
        if (service == UDS_SERVICES_RDBI && reply && id == UDS_DID_ADSDID) {
1599
0
            proto_tree_add_item(uds_tree, hf_uds_did_reply_f186_diag_session, tvb, 0, 1, ENC_NA);
1600
0
            return true;
1601
0
        }
1602
1603
0
        if (service == UDS_SERVICES_RDBI && reply && id == UDS_DID_VINDID) {
1604
0
            proto_tree_add_item(uds_tree, hf_uds_did_reply_f190_vin, tvb, 0, 17, ENC_ASCII);
1605
0
            return true;
1606
0
        }
1607
1608
0
        if (service == UDS_SERVICES_RDBI && reply && id == UDS_DID_UDSVDID) {
1609
0
            uint32_t tmp = tvb_get_uint32(tvb, 0, ENC_BIG_ENDIAN);
1610
0
            proto_tree_add_uint_format(uds_tree, hf_uds_did_reply_ff00_version, tvb, 0, 4, tmp, "UDS Version: %d.%d.%d.%d",
1611
0
                                       (tmp & 0xff000000) >> 24, (tmp & 0x00ff0000) >> 16, (tmp & 0x0000ff00) >> 8, tmp & 0x000000ff);
1612
0
            return true;
1613
0
        }
1614
1615
0
        if (service == UDS_SERVICES_RDBI && reply && id == UDS_DID_RESRVDCPADLC) {
1616
0
            proto_tree_add_item(uds_tree, hf_uds_did_reply_ff01_dlc_support, tvb, 0, 1, ENC_NA);
1617
0
            return true;
1618
0
        }
1619
0
    }
1620
1621
0
    return ret;
1622
0
}
1623
1624
static unsigned
1625
0
uds_sa_subfunction_to_type(uint8_t subf) {
1626
0
    subf = subf & 0x7f;
1627
1628
0
    if (subf == 0x00 || ((0x43 <= subf) && (subf <= 0x5e)) || (subf == 0x7f)) {
1629
0
        return UDS_SA_TYPES_RESERVED;
1630
0
    }
1631
1632
0
    if (subf == 0x5f) {
1633
0
        return UDS_SA_TYPES_REQUEST_SEED_ISO26021;
1634
0
    }
1635
1636
0
    if (subf == 0x60) {
1637
0
        return UDS_SA_TYPES_SEND_KEY_ISO26021;
1638
0
    }
1639
1640
0
    if ((0x61 <= subf) && (subf <= 0x7e)) {
1641
0
        return UDS_SA_TYPES_SUPPLIER;
1642
0
    }
1643
1644
0
    if ((subf & 0x01) == 0x01) {
1645
0
        return UDS_SA_TYPES_REQUEST_SEED;
1646
0
    }
1647
1648
0
    if ((subf & 0x01) == 0x00) {
1649
0
        return UDS_SA_TYPES_SEND_KEY;
1650
0
    }
1651
1652
0
    return UDS_SA_TYPES_UNCLEAR;
1653
0
}
1654
1655
static char *
1656
0
uds_sa_subfunction_to_string(uint8_t subf) {
1657
0
    switch (uds_sa_subfunction_to_type(subf)) {
1658
0
    case UDS_SA_TYPES_RESERVED:
1659
0
        return "Reserved";
1660
0
    case UDS_SA_TYPES_SUPPLIER:
1661
0
        return "System Supplier Specific";
1662
0
    case UDS_SA_TYPES_REQUEST_SEED:
1663
0
        return "Request Seed";
1664
0
    case UDS_SA_TYPES_SEND_KEY:
1665
0
        return "Send Key";
1666
0
    case UDS_SA_TYPES_REQUEST_SEED_ISO26021:
1667
0
        return "Request Seed ISO26021";
1668
0
    case UDS_SA_TYPES_SEND_KEY_ISO26021:
1669
0
        return "Send Key ISO26021";
1670
0
    }
1671
1672
0
    return "Unknown";
1673
0
}
1674
1675
static void
1676
0
uds_sa_subfunction_format(char *ret, uint32_t value) {
1677
0
    if (uds_sa_subfunction_to_type(value) == UDS_SA_TYPES_UNCLEAR) {
1678
0
        snprintf(ret, ITEM_LABEL_LENGTH, "0x%02x", value);
1679
0
        return;
1680
0
    }
1681
1682
0
    snprintf(ret, ITEM_LABEL_LENGTH, "%s (0x%02x)", uds_sa_subfunction_to_string(value), value);
1683
0
}
1684
1685
static int
1686
0
dissect_uds_dtc_and_status_record(tvbuff_t *tvb, packet_info *pinfo, proto_tree *uds_tree, uint32_t offset, uint32_t ecu_address, bool severity_present, bool func_unit_present) {
1687
0
    static int * const dtc_status_flags[] = {
1688
0
     &hf_uds_rdtci_dtc_status_wir,
1689
0
     &hf_uds_rdtci_dtc_status_tnctoc,
1690
0
     &hf_uds_rdtci_dtc_status_tfslc,
1691
0
     &hf_uds_rdtci_dtc_status_tncslc,
1692
0
     &hf_uds_rdtci_dtc_status_cdtc,
1693
0
     &hf_uds_rdtci_dtc_status_pdtc,
1694
0
     &hf_uds_rdtci_dtc_status_tftoc,
1695
0
     &hf_uds_rdtci_dtc_status_tf,
1696
0
     NULL
1697
0
    };
1698
1699
0
    proto_item *ti_status_record, *ti;
1700
0
    proto_tree *entry_tree;
1701
1702
0
    if (severity_present) {
1703
0
        entry_tree = proto_tree_add_subtree(uds_tree, tvb, offset, 4, ett_uds_dtc_status_entry, &ti_status_record, "DTC and Severity Record");
1704
1705
0
        unsigned severity;
1706
0
        proto_tree_add_item_ret_uint(entry_tree, hf_uds_rdtci_dtc_severity, tvb, offset, 1, ENC_NA, &severity);
1707
0
        offset += 1;
1708
1709
0
        if (func_unit_present) {
1710
0
            unsigned functional_unit;
1711
0
            proto_tree_add_item_ret_uint(entry_tree, hf_uds_rdtci_dtc_functional_unit, tvb, offset, 1, ENC_NA, &functional_unit);
1712
0
            offset += 1;
1713
1714
0
            proto_item_append_text(ti_status_record, ", Severity:0x%02x, Functional Unit:0x%02x", severity, functional_unit);
1715
0
        } else {
1716
0
            proto_item_append_text(ti_status_record, ", Severity:0x%02x", severity);
1717
0
        }
1718
0
    } else {
1719
0
        entry_tree = proto_tree_add_subtree(uds_tree, tvb, offset, 4, ett_uds_dtc_status_entry, &ti_status_record, "DTC and Status Record");
1720
0
    }
1721
1722
0
    unsigned dtc_id;
1723
0
    ti = proto_tree_add_item_ret_uint(entry_tree, hf_uds_rdtci_dtc_id, tvb, offset, 3, ENC_BIG_ENDIAN, &dtc_id);
1724
0
    protoitem_append_dtc_name(ti, ecu_address, dtc_id);
1725
0
    offset += 3;
1726
1727
0
    uint64_t dtc_status;
1728
0
    proto_tree_add_bitmask_with_flags_ret_uint64(entry_tree, tvb, offset, hf_uds_rdtci_dtc_status, ett_uds_dtc_status_bits, dtc_status_flags, ENC_NA, BMT_NO_APPEND, &dtc_status);
1729
0
    offset += 1;
1730
1731
0
    const char *dtc_name = uds_lookup_dtc_name(ecu_address, dtc_id);
1732
0
    if (dtc_name == NULL) {
1733
0
        proto_item_append_text(ti_status_record, ", DTC:0x%06x, Status:0x%02x", dtc_id, (uint32_t)dtc_status);
1734
0
    } else {
1735
0
        proto_item_append_text(ti_status_record, ", DTC:0x%06x (%s), Status:0x%02x", dtc_id, dtc_name, (uint32_t)dtc_status);
1736
0
    }
1737
1738
0
    col_append_fstr(pinfo->cinfo, COL_INFO, " 0x%06x:0x%02x", dtc_id, (uint32_t)dtc_status);
1739
1740
0
    return offset;
1741
0
}
1742
1743
static int
1744
0
dissect_uds_dtc_and_fault_detection_counter_record(tvbuff_t *tvb, packet_info *pinfo, proto_tree *uds_tree, uint32_t offset, uint32_t ecu_address) {
1745
0
    proto_item *ti_status_record, *ti;
1746
0
    proto_tree *entry_tree;
1747
1748
0
    entry_tree = proto_tree_add_subtree(uds_tree, tvb, offset, 4, ett_uds_dtc_counter_entry, &ti_status_record, "DTC and Fault Detection Counter Record");
1749
1750
0
    unsigned dtc_id;
1751
0
    ti = proto_tree_add_item_ret_uint(entry_tree, hf_uds_rdtci_dtc_id, tvb, offset, 3, ENC_BIG_ENDIAN, &dtc_id);
1752
0
    protoitem_append_dtc_name(ti, ecu_address, dtc_id);
1753
0
    offset += 3;
1754
1755
0
    unsigned counter;
1756
0
    proto_tree_add_item_ret_uint(entry_tree, hf_uds_rdtci_dtc_fault_detect_counter, tvb, offset, 1, ENC_NA, &counter);
1757
0
    offset += 1;
1758
1759
0
    const char *dtc_name = uds_lookup_dtc_name(ecu_address, dtc_id);
1760
0
    if (dtc_name == NULL) {
1761
0
        proto_item_append_text(ti_status_record, ", DTC:0x%06x, Counter:%04d", dtc_id, counter);
1762
0
    } else {
1763
0
        proto_item_append_text(ti_status_record, ", DTC:0x%06x (%s), Counter:%04d", dtc_id, dtc_name, counter);
1764
0
    }
1765
1766
0
    col_append_fstr(pinfo->cinfo, COL_INFO, " 0x%06x:%04d", dtc_id, counter);
1767
1768
0
    return offset;
1769
0
}
1770
1771
static uint32_t
1772
0
dissect_uds_subfunction(tvbuff_t *tvb, packet_info *pinfo, proto_tree *uds_tree, uint32_t offset, uint32_t *subfunc_value, int hf, const value_string *vs, bool suppress_bit) {
1773
0
    proto_item *ti = proto_tree_add_item(uds_tree, hf_uds_subfunction, tvb, offset, 1, ENC_NA);
1774
0
    proto_tree *subfunction_tree = proto_item_add_subtree(ti, ett_uds_subfunction);
1775
0
    proto_tree_add_item_ret_uint(subfunction_tree, hf, tvb, offset, 1, ENC_NA, subfunc_value);
1776
1777
0
    if (vs != NULL) {
1778
0
        char* str = val_to_str(pinfo->pool, *subfunc_value, vs, "Unknown (0x%02x)");
1779
0
        proto_item_append_text(ti, " (%s)", str);
1780
0
        col_append_fstr(pinfo->cinfo, COL_INFO, "   SubFunction: %s", str);
1781
0
    } else {
1782
0
        col_append_fstr(pinfo->cinfo, COL_INFO, "   SubFunction: 0x%02x", *subfunc_value);
1783
0
    }
1784
1785
0
    if (suppress_bit) {
1786
0
        bool suppress;
1787
1788
0
        proto_tree_add_item_ret_boolean(subfunction_tree, hf_uds_suppress_pos_rsp_msg_ind, tvb, offset, 1, ENC_NA, &suppress);
1789
1790
0
        if (suppress) {
1791
0
            col_append_str(pinfo->cinfo, COL_INFO, "   (Reply suppressed)");
1792
0
        }
1793
0
    }
1794
0
    offset += 1;
1795
1796
0
    return offset;
1797
0
}
1798
1799
static int
1800
0
dissect_uds_rdtci(tvbuff_t *tvb, packet_info *pinfo, proto_tree *uds_tree, uint32_t ecu_address, uint8_t sid, uint32_t offset, uint32_t data_length) {
1801
0
    uint32_t    enum_val;
1802
1803
0
    proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdtci_subfunction, tvb, offset, 1, ENC_NA, &enum_val);
1804
0
    col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", val_to_str_ext(pinfo->pool, enum_val, &uds_rdtci_types_ext, "Unknown (0x%02x)"));
1805
0
    offset += 1;
1806
1807
0
    if (sid & UDS_REPLY_MASK) {
1808
0
        static int * const dtc_status_avail_mask_flags[] = {
1809
0
             &hf_uds_rdtci_dtc_status_avail_wir,
1810
0
             &hf_uds_rdtci_dtc_status_avail_tnctoc,
1811
0
             &hf_uds_rdtci_dtc_status_avail_tfslc,
1812
0
             &hf_uds_rdtci_dtc_status_avail_tncslc,
1813
0
             &hf_uds_rdtci_dtc_status_avail_cdtc,
1814
0
             &hf_uds_rdtci_dtc_status_avail_pdtc,
1815
0
             &hf_uds_rdtci_dtc_status_avail_tftoc,
1816
0
             &hf_uds_rdtci_dtc_status_avail_tf,
1817
0
             NULL
1818
0
        };
1819
1820
0
        switch (enum_val) {
1821
0
        case UDS_RDTCI_TYPES_NUMBER_BY_STATUS_MASK:
1822
0
        case UDS_RDTCI_TYPES_NUM_DTC_BY_SEVERITY_MASK:
1823
0
        case UDS_RDTCI_TYPES_OUTDATED_RNOMMDTCBSM:
1824
0
        case UDS_RDTCI_TYPES_OUTDATED_RNOOEOBDDTCBSM: {
1825
0
            uint64_t dtc_status_avail_mask;
1826
0
            proto_tree_add_bitmask_with_flags_ret_uint64(uds_tree, tvb, offset, hf_uds_rdtci_dtc_status_avail, ett_uds_dtc_status_bits, dtc_status_avail_mask_flags, ENC_NA, BMT_NO_APPEND, &dtc_status_avail_mask);
1827
0
            col_append_fstr(pinfo->cinfo, COL_INFO, "    0x%02x", (uint32_t)dtc_status_avail_mask);
1828
0
            offset += 1;
1829
1830
0
            uint32_t dtc_format;
1831
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdtci_dtc_format_id, tvb, offset, 1, ENC_NA, &dtc_format);
1832
0
            col_append_fstr(pinfo->cinfo, COL_INFO, "  %s", val_to_str(pinfo->pool, dtc_format, uds_rdtci_format_id_types, "Unknown Format (0x%02x)"));
1833
0
            offset += 1;
1834
1835
0
            uint32_t dtc_count;
1836
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdtci_dtc_count, tvb, offset, 2, ENC_BIG_ENDIAN, &dtc_count);
1837
0
            col_append_fstr(pinfo->cinfo, COL_INFO, "  %d DTCs", dtc_count);
1838
0
            offset += 2;
1839
0
            break;
1840
0
        }
1841
1842
0
        case UDS_RDTCI_TYPES_BY_STATUS_MASK:
1843
0
        case UDS_RDTCI_TYPES_SUPPORTED_DTC:
1844
0
        case UDS_RDTCI_TYPES_FIRST_TEST_FAILED_DTC:
1845
0
        case UDS_RDTCI_TYPES_FIRST_CONFIRMED_DTC:
1846
0
        case UDS_RDTCI_TYPES_MOST_RECENT_TEST_FAILED:
1847
0
        case UDS_RDTCI_TYPES_MOST_RECENT_CONFIRMED_DTC:
1848
0
        case UDS_RDTCI_TYPES_OUTDATED_RMMDTCBSM:
1849
0
        case UDS_RDTCI_TYPES_OUTDATED_ROBDDTCBSM:
1850
0
        case UDS_RDTCI_TYPES_DTC_WITH_PERM_STATUS: {
1851
0
            uint64_t dtc_status_avail_mask;
1852
0
            proto_tree_add_bitmask_with_flags_ret_uint64(uds_tree, tvb, offset, hf_uds_rdtci_dtc_status_avail, ett_uds_dtc_status_bits, dtc_status_avail_mask_flags, ENC_NA, BMT_NO_APPEND, &dtc_status_avail_mask);
1853
0
            col_append_fstr(pinfo->cinfo, COL_INFO, "    0x%02x", (uint32_t)dtc_status_avail_mask);
1854
0
            offset += 1;
1855
1856
0
            while (offset + 4 <= data_length) {
1857
0
                offset = dissect_uds_dtc_and_status_record(tvb, pinfo, uds_tree, offset, ecu_address, false, false);
1858
0
            }
1859
0
        }
1860
0
            break;
1861
1862
0
        case UDS_RDTCI_TYPES_SNAPSHOT_IDENTIFICATION:
1863
0
            while (offset + 4 <= data_length) {
1864
0
                offset = dissect_uds_dtc_and_status_record(tvb, pinfo, uds_tree, offset, ecu_address, false, false);
1865
0
            }
1866
0
            break;
1867
1868
0
        case UDS_RDTCI_TYPES_SNAPSHOT_RECORD_BY_DTC: {
1869
            /* this cannot fully be parsed without configuration data (length of DID data) */
1870
1871
0
            offset = dissect_uds_dtc_and_status_record(tvb, pinfo, uds_tree, offset, ecu_address, false, false);
1872
1873
0
            if (offset < data_length) {
1874
0
                proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_snapshot_rec_no, tvb, offset, 1, ENC_NA);
1875
0
                offset += 1;
1876
0
            }
1877
1878
0
            if (offset < data_length) {
1879
0
                proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_snapshot_record_number_of_ids, tvb, offset, 1, ENC_NA);
1880
0
                offset += 1;
1881
0
            }
1882
1883
0
            if (offset < data_length) {
1884
0
                proto_tree_add_item(uds_tree, hf_uds_rdtci_record_unparsed, tvb, offset, data_length - offset, ENC_NA);
1885
0
                offset = data_length;
1886
0
            }
1887
0
        }
1888
0
            break;
1889
1890
0
        case UDS_RDTCI_TYPES_SNAPSHOT_RECORD_BY_RECORD: {
1891
            /* this cannot fully be parsed without configuration data (length of DID data) */
1892
1893
0
            uint32_t count;
1894
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdtci_dtc_stored_data_rec_no, tvb, offset, 1, ENC_NA, &count);
1895
0
            offset += 1;
1896
1897
0
            col_append_fstr(pinfo->cinfo, COL_INFO, "  %d Stored Data Records:  ", count);
1898
1899
0
            if (count > 0) {
1900
0
                offset = dissect_uds_dtc_and_status_record(tvb, pinfo, uds_tree, offset, ecu_address, false, false);
1901
1902
0
                proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_stored_data_record_number_of_ids, tvb, offset, 1, ENC_NA);
1903
0
                offset += 1;
1904
1905
0
                if (offset < data_length) {
1906
0
                    proto_tree_add_item(uds_tree, hf_uds_rdtci_record_unparsed, tvb, offset, data_length - offset, ENC_NA);
1907
0
                    offset = data_length;
1908
0
                }
1909
0
            }
1910
0
        }
1911
0
            break;
1912
1913
0
        case UDS_RDTCI_TYPES_EXTENDED_RECORD_BY_DTC:
1914
            /* this cannot fully be parsed without configuration data (length of DID data) */
1915
1916
0
            offset = dissect_uds_dtc_and_status_record(tvb, pinfo, uds_tree, offset, ecu_address, false, false);
1917
1918
0
            if (offset < data_length) {
1919
0
                proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_ext_data_rec_no, tvb, offset, 1, ENC_NA);
1920
0
                offset += 1;
1921
0
            }
1922
1923
0
            if (offset < data_length) {
1924
0
                proto_tree_add_item(uds_tree, hf_uds_rdtci_record_unparsed, tvb, offset, data_length - offset, ENC_NA);
1925
0
                offset = data_length;
1926
0
            }
1927
0
            break;
1928
1929
0
        case UDS_RDTCI_TYPES_BY_SEVERITY_MASK:
1930
0
            offset = dissect_uds_dtc_and_status_record(tvb, pinfo, uds_tree, offset, ecu_address, true, true);
1931
0
            break;
1932
1933
0
        case UDS_RDTCI_TYPES_SEVERITY_INFO_OF_DTC:
1934
0
            offset = dissect_uds_dtc_and_status_record(tvb, pinfo, uds_tree, offset, ecu_address, true, true);
1935
1936
0
            while (offset + 6 <= data_length) {
1937
0
                offset = dissect_uds_dtc_and_status_record(tvb, pinfo, uds_tree, offset, ecu_address, true, true);
1938
0
            }
1939
0
            break;
1940
1941
0
        case UDS_RDTCI_TYPES_DTC_FAULT_DETECT_CTR:
1942
0
            while (offset + 4 <= data_length) {
1943
0
                offset = dissect_uds_dtc_and_fault_detection_counter_record(tvb, pinfo, uds_tree, offset, ecu_address);
1944
0
            }
1945
0
            break;
1946
1947
0
        case UDS_RDTCI_TYPES_DTC_EXT_DATA_REC_BY_NUM:
1948
            /* this cannot fully be parsed without configuration data (length of data records) */
1949
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_ext_data_rec_no, tvb, offset, 1, ENC_NA);
1950
0
            offset += 1;
1951
1952
0
            if (offset < data_length) {
1953
0
                proto_tree_add_item(uds_tree, hf_uds_rdtci_record_unparsed, tvb, offset, data_length - offset, ENC_NA);
1954
0
                offset = data_length;
1955
0
            }
1956
0
            break;
1957
1958
0
        case UDS_RDTCI_TYPES_USER_MEM_DTC_BY_STATUS_M:
1959
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_memory_selection, tvb, offset, 1, ENC_NA);
1960
0
            offset += 1;
1961
1962
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_status_avail, tvb, offset, 1, ENC_NA);
1963
0
            offset += 1;
1964
1965
0
            while (offset + 4 <= data_length) {
1966
0
                offset = dissect_uds_dtc_and_status_record(tvb, pinfo, uds_tree, offset, ecu_address, false, false);
1967
0
            }
1968
0
            break;
1969
1970
0
        case UDS_RDTCI_TYPES_USER_MEM_DTC_REC_BY_DTC_N:
1971
            /* this cannot fully be parsed without configuration data (length of DID data) */
1972
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_memory_selection, tvb, offset, 1, ENC_NA);
1973
0
            offset += 1;
1974
1975
0
            offset = dissect_uds_dtc_and_status_record(tvb, pinfo, uds_tree, offset, ecu_address, false, false);
1976
1977
0
            if (offset < data_length) {
1978
0
                proto_tree_add_item(uds_tree, hf_uds_rdtci_record_unparsed, tvb, offset, data_length - offset, ENC_NA);
1979
0
                offset = data_length;
1980
0
            }
1981
0
            break;
1982
1983
0
        case UDS_RDTCI_TYPES_USER_MEM_DTC_EXT_REC_BY_N:
1984
            /* this cannot fully be parsed without configuration data (length of extended data) */
1985
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_memory_selection, tvb, offset, 1, ENC_NA);
1986
0
            offset += 1;
1987
1988
0
            offset = dissect_uds_dtc_and_status_record(tvb, pinfo, uds_tree, offset, ecu_address, false, false);
1989
1990
0
            if (offset < data_length) {
1991
0
                proto_tree_add_item(uds_tree, hf_uds_rdtci_record_unparsed, tvb, offset, data_length - offset, ENC_NA);
1992
0
                offset = data_length;
1993
0
            }
1994
0
            break;
1995
1996
0
        case UDS_RDTCI_TYPES_SUP_DTC_EXT_RECORD: {
1997
0
            unsigned status;
1998
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdtci_dtc_status_avail, tvb, offset, 1, ENC_NA, &status);
1999
0
            offset += 1;
2000
2001
0
            unsigned rec_no;
2002
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdtci_dtc_ext_data_rec_no, tvb, offset, 1, ENC_NA, &rec_no);
2003
0
            offset += 1;
2004
2005
0
            col_append_fstr(pinfo->cinfo, COL_INFO, " 0x%02x 0x%02x", status, rec_no);
2006
2007
0
            while (offset + 4 <= data_length) {
2008
0
                offset = dissect_uds_dtc_and_status_record(tvb, pinfo, uds_tree, offset, ecu_address, false, false);
2009
0
            }
2010
0
        }
2011
0
            break;
2012
2013
0
        case UDS_RDTCI_TYPES_WWH_OBD_DTC_BY_MASK_REC: {
2014
0
            unsigned func_group;
2015
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdtci_functional_group_id, tvb, offset, 1, ENC_NA, &func_group);
2016
0
            offset += 1;
2017
2018
0
            unsigned status;
2019
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdtci_dtc_status_avail, tvb, offset, 1, ENC_NA, &status);
2020
0
            offset += 1;
2021
2022
0
            unsigned severity;
2023
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdtci_dtc_severity_avail, tvb, offset, 1, ENC_NA, &severity);
2024
0
            offset += 1;
2025
2026
0
            unsigned format;
2027
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdtci_dtc_format_id, tvb, offset, 1, ENC_NA, &format);
2028
0
            offset += 1;
2029
2030
0
            col_append_fstr(pinfo->cinfo, COL_INFO, " 0x%02x 0x%02x 0x%02x 0x%02x", func_group, status, severity, format);
2031
2032
0
            while (offset + 5 <= data_length) {
2033
0
                offset = dissect_uds_dtc_and_status_record(tvb, pinfo, uds_tree, offset, ecu_address, true, false);
2034
0
            }
2035
0
        }
2036
0
            break;
2037
2038
0
        case UDS_RDTCI_TYPES_WWH_OBD_DTC_PERM_STATUS: {
2039
0
            unsigned func_group;
2040
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdtci_functional_group_id, tvb, offset, 1, ENC_NA, &func_group);
2041
0
            offset += 1;
2042
2043
0
            unsigned status;
2044
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdtci_dtc_status_avail, tvb, offset, 1, ENC_NA, &status);
2045
0
            offset += 1;
2046
2047
0
            unsigned format;
2048
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdtci_dtc_format_id, tvb, offset, 1, ENC_NA, &format);
2049
0
            offset += 1;
2050
2051
0
            col_append_fstr(pinfo->cinfo, COL_INFO, " 0x%02x 0x%02x 0x%02x", func_group, status, format);
2052
2053
0
            while (offset + 4 <= data_length) {
2054
0
                offset = dissect_uds_dtc_and_status_record(tvb, pinfo, uds_tree, offset, ecu_address, false, false);
2055
0
            }
2056
0
        }
2057
0
            break;
2058
2059
0
        case UDS_RDTCI_TYPES_WWH_OBD_BY_GROUP_READY: {
2060
0
            unsigned func_group;
2061
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdtci_functional_group_id, tvb, offset, 1, ENC_NA, &func_group);
2062
0
            offset += 1;
2063
2064
0
            unsigned status;
2065
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdtci_dtc_status_avail, tvb, offset, 1, ENC_NA, &status);
2066
0
            offset += 1;
2067
2068
0
            unsigned format;
2069
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdtci_dtc_format_id, tvb, offset, 1, ENC_NA, &format);
2070
0
            offset += 1;
2071
2072
0
            unsigned readiness;
2073
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdtci_dtc_readiness_group_id, tvb, offset, 1, ENC_NA, &readiness);
2074
0
            offset += 1;
2075
2076
0
            col_append_fstr(pinfo->cinfo, COL_INFO, " 0x%02x 0x%02x 0x%02x 0x%02x", func_group, status, format, readiness);
2077
2078
0
            while (offset + 4 <= data_length) {
2079
0
                offset = dissect_uds_dtc_and_status_record(tvb, pinfo, uds_tree, offset, ecu_address, false, false);
2080
0
            }
2081
0
        }
2082
0
            break;
2083
2084
0
        default:
2085
0
            if (offset < data_length) {
2086
0
                proto_tree_add_item(uds_tree, hf_uds_rdtci_record, tvb, offset, data_length - offset, ENC_NA);
2087
0
                col_append_fstr(pinfo->cinfo, COL_INFO, "    %s", tvb_bytes_to_str_punct(pinfo->pool, tvb, offset, data_length - offset, ' '));
2088
0
                offset = data_length;
2089
0
            }
2090
0
        }
2091
0
    } else {
2092
0
        static int * const dtc_status_mask_flags[] = {
2093
0
            &hf_uds_rdtci_dtc_status_mask_wir,
2094
0
            &hf_uds_rdtci_dtc_status_mask_tnctoc,
2095
0
            &hf_uds_rdtci_dtc_status_mask_tfslc,
2096
0
            &hf_uds_rdtci_dtc_status_mask_tncslc,
2097
0
            &hf_uds_rdtci_dtc_status_mask_cdtc,
2098
0
            &hf_uds_rdtci_dtc_status_mask_pdtc,
2099
0
            &hf_uds_rdtci_dtc_status_mask_tftoc,
2100
0
            &hf_uds_rdtci_dtc_status_mask_tf,
2101
0
            NULL
2102
0
        };
2103
2104
0
        switch (enum_val) {
2105
0
        case UDS_RDTCI_TYPES_NUMBER_BY_STATUS_MASK:
2106
0
        case UDS_RDTCI_TYPES_BY_STATUS_MASK:
2107
0
        case UDS_RDTCI_TYPES_OUTDATED_RMMDTCBSM:
2108
0
        case UDS_RDTCI_TYPES_OUTDATED_RNOMMDTCBSM:
2109
0
        case UDS_RDTCI_TYPES_OUTDATED_RNOOEOBDDTCBSM:
2110
0
        case UDS_RDTCI_TYPES_OUTDATED_ROBDDTCBSM: {
2111
0
            uint64_t status_mask;
2112
0
            proto_tree_add_bitmask_with_flags_ret_uint64(uds_tree, tvb, offset, hf_uds_rdtci_dtc_status_mask, ett_uds_dtc_status_bits, dtc_status_mask_flags, ENC_NA, BMT_NO_APPEND, &status_mask);
2113
0
            offset += 1;
2114
2115
0
            col_append_fstr(pinfo->cinfo, COL_INFO, "    0x%02x", (uint32_t)status_mask);
2116
0
        }
2117
0
            break;
2118
2119
0
        case UDS_RDTCI_TYPES_SNAPSHOT_IDENTIFICATION:
2120
            /* no additional params */
2121
0
            break;
2122
2123
0
        case UDS_RDTCI_TYPES_SNAPSHOT_RECORD_BY_DTC:
2124
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_mask_record, tvb, offset, 3, ENC_BIG_ENDIAN);
2125
0
            offset += 3;
2126
2127
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_snapshot_rec_no, tvb, offset, 1, ENC_NA);
2128
0
            offset += 1;
2129
0
            break;
2130
2131
0
        case UDS_RDTCI_TYPES_SNAPSHOT_RECORD_BY_RECORD:
2132
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_stored_data_rec_no, tvb, offset, 1, ENC_NA);
2133
0
            offset += 1;
2134
0
            break;
2135
2136
0
        case UDS_RDTCI_TYPES_EXTENDED_RECORD_BY_DTC:
2137
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_mask_record, tvb, offset, 3, ENC_BIG_ENDIAN);
2138
0
            offset += 3;
2139
2140
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_ext_data_rec_no, tvb, offset, 1, ENC_NA);
2141
0
            offset += 1;
2142
0
            break;
2143
2144
0
        case UDS_RDTCI_TYPES_NUM_DTC_BY_SEVERITY_MASK:
2145
0
        case UDS_RDTCI_TYPES_BY_SEVERITY_MASK:
2146
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_severity_mask, tvb, offset, 1, ENC_NA);
2147
0
            offset += 1;
2148
2149
0
            proto_tree_add_bitmask(uds_tree, tvb, offset, hf_uds_rdtci_dtc_status_mask, ett_uds_dtc_status_bits, dtc_status_mask_flags, ENC_NA);
2150
0
            offset += 1;
2151
0
            break;
2152
2153
0
        case UDS_RDTCI_TYPES_SEVERITY_INFO_OF_DTC:
2154
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_mask_record, tvb, offset, 3, ENC_BIG_ENDIAN);
2155
0
            offset += 3;
2156
0
            break;
2157
2158
0
        case UDS_RDTCI_TYPES_SUPPORTED_DTC:
2159
0
        case UDS_RDTCI_TYPES_FIRST_TEST_FAILED_DTC:
2160
0
        case UDS_RDTCI_TYPES_FIRST_CONFIRMED_DTC:
2161
0
        case UDS_RDTCI_TYPES_MOST_RECENT_TEST_FAILED:
2162
0
        case UDS_RDTCI_TYPES_MOST_RECENT_CONFIRMED_DTC:
2163
0
        case UDS_RDTCI_TYPES_DTC_FAULT_DETECT_CTR:
2164
0
        case UDS_RDTCI_TYPES_DTC_WITH_PERM_STATUS:
2165
            /* no additional params */
2166
0
            break;
2167
2168
0
        case UDS_RDTCI_TYPES_DTC_EXT_DATA_REC_BY_NUM:
2169
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_ext_data_rec_no, tvb, offset, 1, ENC_NA);
2170
0
            offset += 1;
2171
0
            break;
2172
2173
0
        case UDS_RDTCI_TYPES_USER_MEM_DTC_BY_STATUS_M:
2174
0
            proto_tree_add_bitmask(uds_tree, tvb, offset, hf_uds_rdtci_dtc_status_mask, ett_uds_dtc_status_bits, dtc_status_mask_flags, ENC_NA);
2175
0
            offset += 1;
2176
2177
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_memory_selection, tvb, offset, 1, ENC_NA);
2178
0
            offset += 1;
2179
0
            break;
2180
2181
0
        case UDS_RDTCI_TYPES_USER_MEM_DTC_REC_BY_DTC_N:
2182
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_mask_record, tvb, offset, 3, ENC_BIG_ENDIAN);
2183
0
            offset += 3;
2184
2185
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_user_def_dtc_snapshot_rec_no, tvb, offset, 1, ENC_NA);
2186
0
            offset += 1;
2187
2188
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_memory_selection, tvb, offset, 1, ENC_NA);
2189
0
            offset += 1;
2190
0
            break;
2191
2192
0
        case UDS_RDTCI_TYPES_USER_MEM_DTC_EXT_REC_BY_N:
2193
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_mask_record, tvb, offset, 3, ENC_BIG_ENDIAN);
2194
0
            offset += 3;
2195
2196
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_ext_data_rec_no, tvb, offset, 1, ENC_NA);
2197
0
            offset += 1;
2198
2199
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_memory_selection, tvb, offset, 1, ENC_NA);
2200
0
            offset += 1;
2201
0
            break;
2202
2203
0
        case UDS_RDTCI_TYPES_SUP_DTC_EXT_RECORD:
2204
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_ext_data_rec_no, tvb, offset, 1, ENC_NA);
2205
0
            offset += 1;
2206
0
            break;
2207
2208
0
        case UDS_RDTCI_TYPES_WWH_OBD_DTC_BY_MASK_REC:
2209
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_functional_group_id, tvb, offset, 1, ENC_NA);
2210
0
            offset += 1;
2211
2212
0
            proto_tree_add_bitmask(uds_tree, tvb, offset, hf_uds_rdtci_dtc_status_mask, ett_uds_dtc_status_bits, dtc_status_mask_flags, ENC_NA);
2213
0
            offset += 1;
2214
2215
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_severity_mask, tvb, offset, 1, ENC_NA);
2216
0
            offset += 1;
2217
0
            break;
2218
2219
0
        case UDS_RDTCI_TYPES_WWH_OBD_DTC_PERM_STATUS:
2220
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_functional_group_id, tvb, offset, 1, ENC_NA);
2221
0
            offset += 1;
2222
0
            break;
2223
2224
0
        case UDS_RDTCI_TYPES_WWH_OBD_BY_GROUP_READY:
2225
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_functional_group_id, tvb, offset, 1, ENC_NA);
2226
0
            offset += 1;
2227
2228
0
            proto_tree_add_item(uds_tree, hf_uds_rdtci_dtc_readiness_group_id, tvb, offset, 1, ENC_NA);
2229
0
            offset += 1;
2230
0
            break;
2231
2232
0
        default:
2233
0
            if (offset < data_length) {
2234
0
                proto_tree_add_item(uds_tree, hf_uds_rdtci_record, tvb, offset, data_length - offset, ENC_NA);
2235
0
                col_append_fstr(pinfo->cinfo, COL_INFO, "    %s", tvb_bytes_to_str_punct(pinfo->pool, tvb, offset, data_length - offset, ' '));
2236
0
                offset = data_length;
2237
0
            }
2238
0
        }
2239
0
    }
2240
2241
0
    return offset;
2242
0
}
2243
2244
static int
2245
0
dissect_uds_memory_addr_size(tvbuff_t *tvb, packet_info *pinfo, proto_tree *uds_tree, uint32_t offset, bool withDataFormatIdentifier) {
2246
0
    uint32_t compression, encrypting;
2247
2248
0
    if (withDataFormatIdentifier) {
2249
0
        proto_tree_add_item_ret_uint(uds_tree, hf_uds_compression_method, tvb, offset, 1, ENC_NA, &compression);
2250
0
        proto_tree_add_item_ret_uint(uds_tree, hf_uds_encrypting_method, tvb, offset, 1, ENC_NA, &encrypting);
2251
0
        offset += 1;
2252
0
    }
2253
2254
0
    uint32_t memory_size_length, memory_address_length;
2255
0
    proto_tree_add_item_ret_uint(uds_tree, hf_uds_memory_size_length, tvb, offset, 1, ENC_NA, &memory_size_length);
2256
0
    proto_tree_add_item_ret_uint(uds_tree, hf_uds_memory_address_length, tvb, offset, 1, ENC_NA, &memory_address_length);
2257
0
    offset += 1;
2258
2259
0
    uint64_t memory_address;
2260
0
    proto_tree_add_item_ret_uint64(uds_tree, hf_uds_memory_address, tvb, offset, memory_address_length, ENC_BIG_ENDIAN, &memory_address);
2261
0
    offset += memory_address_length;
2262
2263
0
    uint64_t memory_size;
2264
0
    proto_tree_add_item_ret_uint64(uds_tree, hf_uds_memory_size, tvb, offset, memory_size_length, ENC_BIG_ENDIAN, &memory_size);
2265
0
    offset += memory_size_length;
2266
2267
0
    col_append_fstr(pinfo->cinfo, COL_INFO, "   0x%" PRIx64 " bytes at 0x%" PRIx64, memory_size, memory_address);
2268
2269
0
    if (withDataFormatIdentifier) {
2270
0
        col_append_fstr(pinfo->cinfo, COL_INFO, "   (Compression:0x%x Encrypting:0x%x)", compression, encrypting);
2271
0
    }
2272
2273
0
    return offset;
2274
0
}
2275
2276
static int
2277
0
dissect_uds_certificates_into_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *ti, uint32_t offset, unsigned length) {
2278
0
    asn1_ctx_t  asn1_ctx;
2279
2280
0
    if (!tree || !tvb || !ti || length == 0 || uds_certificate_decoding_config == cert_parsing_off) {
2281
0
        return 0;
2282
0
    }
2283
2284
0
    tvbuff_t *sub_tvb = tvb_new_subset_length(tvb, offset, length);
2285
2286
0
    asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
2287
0
    proto_tree *cert_tree = proto_item_add_subtree(ti, ett_uds_ars_certificate);
2288
2289
0
    switch (uds_certificate_decoding_config) {
2290
0
    case ber_cert_single_false:
2291
0
        return dissect_x509af_Certificate(false, sub_tvb, 0, &asn1_ctx, cert_tree, hf_uds_signedCertificate);
2292
2293
0
    case ber_cert_single_true:
2294
0
        return dissect_x509af_Certificate(true, sub_tvb, 0, &asn1_ctx, cert_tree, hf_uds_signedCertificate);
2295
2296
0
    case ber_cert_multi_false:
2297
0
        return dissect_x509af_Certificates(false, sub_tvb, 0, &asn1_ctx, cert_tree, hf_uds_signedCertificate);
2298
2299
0
    case ber_cert_multi_true:
2300
0
        return dissect_x509af_Certificates(true, sub_tvb, 0, &asn1_ctx, cert_tree, hf_uds_signedCertificate);
2301
0
    }
2302
2303
0
    return 0;
2304
0
}
2305
2306
static int
2307
4
dissect_uds_internal(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint16_t source_address, uint16_t target_address, uint8_t number_of_addresses_valid, uint8_t address_size) {
2308
4
    proto_tree *uds_tree;
2309
4
    proto_tree *subfunction_tree;
2310
4
    proto_item *ti;
2311
4
    uint8_t     sid, service;
2312
4
    uint32_t    enum_val;
2313
4
    const char *service_name;
2314
4
    uint32_t    ecu_address;
2315
4
    uint32_t    data_length = tvb_reported_length(tvb);
2316
4
    tvbuff_t   *payload_tvb;
2317
2318
4
    uint32_t    offset = 0;
2319
2320
4
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "UDS");
2321
2322
4
    if (uds_clear_info_col) {
2323
0
        col_clear(pinfo->cinfo, COL_INFO);
2324
4
    } else {
2325
4
        col_append_str(pinfo->cinfo, COL_INFO, " ");
2326
4
    }
2327
2328
4
    sid = tvb_get_uint8(tvb, offset);
2329
4
    service = sid & UDS_SID_MASK;
2330
2331
4
    if (service < UDS_SERVICES_MIN && uds_dissect_small_sids_with_obd_ii && (obd_ii_handle != NULL)) {
2332
0
        return call_dissector(obd_ii_handle, tvb_new_subset_remaining(tvb, offset), pinfo, tree);
2333
0
    }
2334
2335
4
    service_name = val_to_str_ext(pinfo->pool, service, &uds_services_ext, "Unknown (0x%02x)");
2336
2337
4
    col_append_fstr(pinfo->cinfo, COL_INFO, "%-7s   %-36s", (sid & UDS_REPLY_MASK)? "Reply": "Request", service_name);
2338
2339
4
    ti = proto_tree_add_item(tree, proto_uds, tvb, offset, -1, ENC_NA);
2340
4
    uds_tree = proto_item_add_subtree(ti, ett_uds);
2341
2342
4
    if (sid & UDS_REPLY_MASK) {
2343
0
        ecu_address = source_address;
2344
4
    } else {
2345
4
        ecu_address = target_address;
2346
4
    }
2347
2348
4
    switch (number_of_addresses_valid) {
2349
0
    case 0:
2350
0
        ecu_address = UINT32_MAX;
2351
0
        break;
2352
0
    case 1:
2353
0
        uds_proto_item_append_address_text(ti, address_size, "Address", source_address);
2354
0
        uds_proto_item_append_address_name(ti, source_address);
2355
2356
0
        uds_proto_tree_add_address_item(uds_tree, hf_uds_diag_addr, tvb, 0, 0, source_address, true, false);
2357
0
        uds_proto_tree_add_address_name(uds_tree, pinfo, hf_uds_diag_addr_name, tvb, 0, 0, source_address);
2358
0
        break;
2359
4
    case 2:
2360
4
        uds_proto_item_append_address_text(ti, address_size, "Source", source_address);
2361
4
        uds_proto_item_append_address_name(ti, source_address);
2362
4
        uds_proto_item_append_address_text(ti, address_size, "Target", target_address);
2363
4
        uds_proto_item_append_address_name(ti, target_address);
2364
2365
4
        uds_proto_tree_add_address_item(uds_tree, hf_uds_diag_source_addr, tvb, 0, 0, source_address, true, false);
2366
4
        uds_proto_tree_add_address_name(uds_tree, pinfo, hf_uds_diag_source_addr_name, tvb, 0, 0, source_address);
2367
2368
4
        uds_proto_tree_add_address_item(uds_tree, hf_uds_diag_addr, tvb, 0, 0, source_address, true, true);
2369
4
        uds_proto_tree_add_address_name(uds_tree, pinfo, hf_uds_diag_addr_name, tvb, 0, 0, source_address);
2370
2371
4
        uds_proto_tree_add_address_item(uds_tree, hf_uds_diag_target_addr, tvb, 0, 0, target_address, true, false);
2372
4
        uds_proto_tree_add_address_name(uds_tree, pinfo, hf_uds_diag_target_addr_name, tvb, 0, 0, target_address);
2373
2374
4
        uds_proto_tree_add_address_item(uds_tree, hf_uds_diag_addr, tvb, 0, 0, target_address, true, true);
2375
4
        uds_proto_tree_add_address_name(uds_tree, pinfo, hf_uds_diag_addr_name, tvb, 0, 0, target_address);
2376
4
        break;
2377
4
    }
2378
2379
4
    proto_tree_add_item(uds_tree, hf_uds_service, tvb, offset, 1, ENC_NA);
2380
4
    proto_tree_add_item(uds_tree, hf_uds_reply, tvb, offset, 1, ENC_NA);
2381
4
    offset += 1;
2382
2383
4
    switch (service) {
2384
0
        case UDS_SERVICES_DSC:
2385
0
        {
2386
0
            bool suppress;
2387
0
            proto_tree_add_item_ret_boolean(uds_tree, hf_uds_dsc_suppress_pos_rsp_msg_ind, tvb, offset, 1, ENC_NA, &suppress);
2388
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_dsc_subfunction, tvb, offset, 1, ENC_NA, &enum_val);
2389
0
            col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", val_to_str(pinfo->pool, enum_val, uds_dsc_types, "Unknown (0x%02x)"));
2390
0
            if (suppress) {
2391
0
                col_append_str(pinfo->cinfo, COL_INFO, "   (Reply suppressed)");
2392
0
            }
2393
0
        }
2394
0
            offset += 1;
2395
2396
0
            if (sid & UDS_REPLY_MASK) {
2397
0
                ti = proto_tree_add_item(uds_tree, hf_uds_dsc_parameter_record, tvb, offset, data_length - offset, ENC_NA);
2398
0
                proto_tree *param_tree = proto_item_add_subtree(ti, ett_uds_dsc_parameter_record);
2399
2400
0
                uint32_t default_p2;
2401
0
                proto_tree_add_item_ret_uint(param_tree, hf_uds_dsc_default_p2_server_timer, tvb, offset, 2, ENC_BIG_ENDIAN, &default_p2);
2402
0
                offset += 2;
2403
2404
0
                uint32_t enhanced_p2 = tvb_get_uint16(tvb, offset, ENC_BIG_ENDIAN) * 10;
2405
0
                proto_tree_add_uint(param_tree, hf_uds_dsc_enhanced_p2_server_timer, tvb, offset, 2, enhanced_p2);
2406
0
                offset += 2;
2407
2408
0
                col_append_fstr(pinfo->cinfo, COL_INFO, "   P2-default:%5dms  P2-enhanced:%6dms", default_p2, enhanced_p2);
2409
0
            }
2410
0
            break;
2411
2412
0
        case UDS_SERVICES_ER:
2413
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_er_subfunction, tvb, offset, 1, ENC_NA, &enum_val);
2414
0
            col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", val_to_str(pinfo->pool, enum_val, uds_er_types, "Unknown (0x%02x)"));
2415
0
            offset += 1;
2416
2417
0
            if ((sid & UDS_REPLY_MASK) && (enum_val == UDS_ER_TYPES_ENABLE_RAPID_POWER_SHUTDOWN)) {
2418
0
                uint32_t tmp;
2419
0
                ti = proto_tree_add_item_ret_uint(uds_tree, hf_uds_er_power_down_time, tvb, offset, 1, ENC_NA, &tmp);
2420
0
                if (tmp == UDS_ER_TYPE_ENABLE_RAPID_POWER_SHUTDOWN_INVALID) {
2421
0
                    proto_item_append_text(ti, " (Failure or time not available!)");
2422
0
                }
2423
0
                offset += 1;
2424
0
            }
2425
0
            break;
2426
2427
0
        case UDS_SERVICES_CDTCI:
2428
0
            if (sid & UDS_REPLY_MASK) {
2429
                /* do nothing */
2430
0
            } else {
2431
0
                proto_tree_add_item(uds_tree, hf_uds_cdtci_group_of_dtc, tvb, offset, 3, ENC_BIG_ENDIAN);
2432
0
                offset += 3;
2433
2434
0
                if (offset + 1 <= data_length) {
2435
0
                    proto_tree_add_item(uds_tree, hf_uds_cdtci_memory_selection, tvb, offset, 1, ENC_NA);
2436
0
                }
2437
0
            }
2438
0
            break;
2439
2440
0
        case UDS_SERVICES_RDTCI:
2441
0
            offset = dissect_uds_rdtci(tvb, pinfo, uds_tree, ecu_address, sid, offset, data_length);
2442
0
            break;
2443
2444
0
        case UDS_SERVICES_RDBI:
2445
0
            if (sid & UDS_REPLY_MASK) {
2446
                /* Can't know the size of the data for each identifier, Decode like if there is only one identifier */
2447
0
                uint32_t data_identifier;
2448
0
                ti = proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdbi_data_identifier, tvb, offset, 2, ENC_BIG_ENDIAN, &data_identifier);
2449
0
                protoitem_append_data_name(ti, ecu_address, (uint16_t)data_identifier);
2450
0
                offset += 2;
2451
2452
0
                col_append_fstr(pinfo->cinfo, COL_INFO, "   0x%04x", data_identifier);
2453
0
                infocol_append_data_name(pinfo, ecu_address, data_identifier);
2454
2455
0
                bool dissection_ok = false;
2456
0
                if (data_length > offset) {
2457
0
                    col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", tvb_bytes_to_str_punct(pinfo->pool, tvb, offset, data_length - offset, ' '));
2458
2459
0
                    payload_tvb = tvb_new_subset_length(tvb, offset, data_length - offset);
2460
0
                    dissection_ok = call_heur_subdissector_uds(payload_tvb, pinfo, tree, uds_tree, service, true, data_identifier, ecu_address);
2461
0
                }
2462
2463
0
                if (!dissection_ok) {
2464
                    /* ISO14229: at least one byte for data record. Just make sure, we show an error, if less than 1 byte left! */
2465
0
                    proto_tree_add_item(uds_tree, hf_uds_data_record, tvb, offset, MAX(1, data_length - offset), ENC_NA);
2466
0
                }
2467
2468
0
                offset = data_length;
2469
2470
2471
0
            } else {
2472
                /* ISO14229: data identifiers are 2 bytes and at least one has to be present. */
2473
0
                do {
2474
0
                    uint32_t data_identifier;
2475
0
                    ti = proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdbi_data_identifier, tvb, offset, 2, ENC_BIG_ENDIAN, &data_identifier);
2476
0
                    protoitem_append_data_name(ti, ecu_address, (uint16_t)data_identifier);
2477
2478
0
                    col_append_fstr(pinfo->cinfo, COL_INFO, "   0x%04x", data_identifier);
2479
0
                    infocol_append_data_name(pinfo, ecu_address, data_identifier);
2480
0
                    offset += 2;
2481
0
                } while (data_length >= offset + 2);
2482
0
            }
2483
0
            break;
2484
2485
0
        case UDS_SERVICES_RMBA:
2486
0
            if (sid & UDS_REPLY_MASK) {
2487
0
                if (offset < data_length) {
2488
0
                    proto_tree_add_item(uds_tree, hf_uds_data_record, tvb, offset, data_length - offset, ENC_NA);
2489
0
                    col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", tvb_bytes_to_str_punct(pinfo->pool, tvb, offset, data_length - offset, ' '));
2490
0
                    offset = data_length;
2491
0
                }
2492
0
            } else {
2493
0
                offset = dissect_uds_memory_addr_size(tvb, pinfo, uds_tree, offset, false);
2494
0
            }
2495
0
            break;
2496
2497
0
        case UDS_SERVICES_RSDBI:
2498
0
            proto_tree_add_item(uds_tree, hf_uds_rsdbi_data_identifier, tvb, offset, 2, ENC_BIG_ENDIAN);
2499
0
            offset += 2;
2500
2501
0
            if (sid & UDS_REPLY_MASK) {
2502
0
                do {
2503
0
                    proto_tree *tmp_tree;
2504
0
                    ti = proto_tree_add_item(uds_tree, hf_uds_rsdbi_scaling_byte, tvb, offset, 1, ENC_NA);
2505
0
                    tmp_tree = proto_item_add_subtree(ti, ett_uds_rsdbi_scaling_byte);
2506
0
                    unsigned data_type, num_of_bytes;
2507
0
                    proto_tree_add_item_ret_uint(tmp_tree, hf_uds_rsdbi_scaling_byte_data_type, tvb, offset, 1, ENC_NA, &data_type);
2508
0
                    proto_tree_add_item_ret_uint(tmp_tree, hf_uds_rsdbi_scaling_byte_num_of_bytes, tvb, offset, 1, ENC_NA, &num_of_bytes);
2509
0
                    proto_item_append_text(ti, ", %s, %d", val_to_str(pinfo->pool, data_type, uds_rsdbi_data_types, "Unknown (0x%x)"), num_of_bytes);
2510
0
                    offset += 1;
2511
2512
                    /* lets parse the extension, if needed... */
2513
0
                    unsigned next_pos;
2514
0
                    switch (data_type) {
2515
0
                    case UDS_RSDBI_DATA_TYPE_BITMAPPED_REPORTED_WO_MAP:
2516
0
                        proto_tree_add_item(uds_tree, hf_uds_rsdbi_validity_mask, tvb, offset, num_of_bytes, ENC_NA);
2517
0
                        offset += num_of_bytes;
2518
0
                        break;
2519
0
                    case UDS_RSDBI_DATA_TYPE_FORMULA:
2520
0
                        proto_tree_add_item(uds_tree, hf_uds_rsdbi_formula_identifier, tvb, offset, 1, ENC_NA);
2521
0
                        next_pos = offset + num_of_bytes;
2522
0
                        while (offset + 2 <= next_pos) {
2523
0
                            ti = proto_tree_add_item(uds_tree, hf_uds_rsdbi_formula_constant, tvb, offset, 2, ENC_NA);
2524
0
                            proto_tree *const_tree = proto_item_add_subtree(ti, ett_uds_rsdbi_formula_constant);
2525
0
                            proto_tree_add_item(const_tree, hf_uds_rsdbi_formula_constant_exp, tvb, offset, 2, ENC_BIG_ENDIAN);
2526
0
                            proto_tree_add_item(const_tree, hf_uds_rsdbi_formula_constant_mantissa, tvb, offset, 2, ENC_BIG_ENDIAN);
2527
0
                            offset += 2;
2528
0
                        }
2529
0
                        break;
2530
0
                    case  UDS_RSDBI_DATA_TYPE_UNIT_FORMAT:
2531
0
                        proto_tree_add_item(uds_tree, hf_uds_rsdbi_unit, tvb, offset, 1, ENC_NA);
2532
0
                        offset += num_of_bytes;
2533
0
                        break;
2534
0
                    }
2535
0
                } while (offset < data_length);
2536
2537
0
            }
2538
0
            break;
2539
2540
0
        case UDS_SERVICES_SA:
2541
0
            ti = proto_tree_add_item_ret_uint(uds_tree, hf_uds_sa_subfunction, tvb, offset, 1, ENC_NA, &enum_val);
2542
0
            proto_item_append_text(ti, " (%s)", uds_sa_subfunction_to_string(enum_val));
2543
0
            col_append_fstr(pinfo->cinfo, COL_INFO, "   %s (0x%02x)", uds_sa_subfunction_to_string(enum_val), enum_val);
2544
0
            offset += 1;
2545
2546
0
            if (data_length > offset) {
2547
0
                if (sid & UDS_REPLY_MASK) {
2548
0
                    switch (uds_sa_subfunction_to_type(enum_val)) {
2549
0
                    case UDS_SA_TYPES_SEND_KEY: /* fall through */
2550
0
                    case UDS_SA_TYPES_SEND_KEY_ISO26021:
2551
                        /* do nothing */
2552
0
                        break;
2553
0
                    case UDS_SA_TYPES_REQUEST_SEED: /* fall through */
2554
0
                    case UDS_SA_TYPES_REQUEST_SEED_ISO26021:
2555
0
                        proto_tree_add_item(uds_tree, hf_uds_sa_seed, tvb, offset, data_length - offset, ENC_NA);
2556
0
                        col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", tvb_bytes_to_str_punct(pinfo->pool, tvb, offset, data_length - offset, ' '));
2557
0
                        break;
2558
0
                    default:
2559
0
                        proto_tree_add_item(uds_tree, hf_uds_data_record, tvb, offset, data_length - offset, ENC_NA);
2560
0
                        col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", tvb_bytes_to_str_punct(pinfo->pool, tvb, offset, data_length - offset, ' '));
2561
0
                    }
2562
0
                } else {
2563
0
                    switch (uds_sa_subfunction_to_type(enum_val)) {
2564
0
                    case UDS_SA_TYPES_SEND_KEY: /* fall through */
2565
0
                    case UDS_SA_TYPES_SEND_KEY_ISO26021:
2566
0
                        proto_tree_add_item(uds_tree, hf_uds_sa_key, tvb, offset, data_length - offset, ENC_NA);
2567
0
                        col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", tvb_bytes_to_str_punct(pinfo->pool, tvb, offset, data_length - offset, ' '));
2568
0
                        break;
2569
0
                    case UDS_SA_TYPES_REQUEST_SEED: /* fall through */
2570
0
                    case UDS_SA_TYPES_REQUEST_SEED_ISO26021:
2571
0
                    default:
2572
0
                        proto_tree_add_item(uds_tree, hf_uds_data_record, tvb, offset, data_length - offset, ENC_NA);
2573
0
                        col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", tvb_bytes_to_str_punct(pinfo->pool, tvb, offset, data_length - offset, ' '));
2574
0
                    }
2575
0
                }
2576
0
                offset = data_length;
2577
0
            }
2578
0
            break;
2579
2580
0
        case UDS_SERVICES_CC:
2581
0
            if (sid & UDS_REPLY_MASK) {
2582
0
                offset = dissect_uds_subfunction(tvb, pinfo, uds_tree, offset, &enum_val, hf_uds_cc_subfunction_no_suppress, uds_cc_types, false);
2583
0
            } else {
2584
0
                offset = dissect_uds_subfunction(tvb, pinfo, uds_tree, offset, &enum_val, hf_uds_cc_subfunction_no_suppress, uds_cc_types, true);
2585
2586
0
                proto_tree *comm_type_tree;
2587
0
                ti = proto_tree_add_item(uds_tree, hf_uds_cc_comm_type_and_subnet_number, tvb, offset, 1, ENC_NA);
2588
0
                comm_type_tree = proto_item_add_subtree(ti, ett_uds_cc_communication_type);
2589
0
                proto_tree_add_item(comm_type_tree, hf_uds_cc_communication_type, tvb, offset, 1, ENC_NA);
2590
0
                proto_tree_add_item(comm_type_tree, hf_uds_cc_subnet_number, tvb, offset, 1, ENC_NA);
2591
0
                offset += 1;
2592
2593
0
                if (enum_val == UDS_CC_TYPES_ENABLE_RX_AND_DISABLE_TX_WITH_ENH_ADDR_INFO || enum_val == UDS_CC_TYPES_ENABLE_RX_AND_TX_WITH_ENH_ADDR_INFO) {
2594
0
                    proto_tree_add_item(uds_tree, hf_uds_cc_node_identifier_number, tvb, offset, 2, ENC_BIG_ENDIAN);
2595
0
                    offset += 2;
2596
0
                }
2597
0
            }
2598
0
            break;
2599
2600
0
        case UDS_SERVICES_ARS:
2601
0
            if (sid & UDS_REPLY_MASK) {
2602
0
                unsigned length_field;
2603
0
                proto_tree *algo_tree;
2604
2605
0
                offset = dissect_uds_subfunction(tvb, pinfo, uds_tree, offset, &enum_val, hf_uds_ars_subfunction_no_suppress, uds_ars_types, false);
2606
2607
0
                switch (enum_val) {
2608
0
                case UDS_ARS_TYPES_DEAUTHENTICATE: /* fall through */
2609
0
                case UDS_ARS_TYPES_TRANSMIT_CERTIFICATE: /* fall through */
2610
0
                case UDS_ARS_TYPES_AUTH_CONFIGURATION:
2611
0
                    proto_tree_add_item(uds_tree, hf_uds_ars_auth_ret_param, tvb, offset, 1, ENC_NA);
2612
0
                    offset += 1;
2613
0
                    break;
2614
2615
0
                case UDS_ARS_TYPES_VERIFY_CERT_UNIDIRECTIONAL:
2616
0
                    proto_tree_add_item(uds_tree, hf_uds_ars_auth_ret_param, tvb, offset, 1, ENC_NA);
2617
0
                    offset += 1;
2618
2619
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_challenge_server, tvb, offset, 2, ENC_BIG_ENDIAN, &length_field);
2620
0
                    offset += 2;
2621
2622
0
                    proto_tree_add_item(uds_tree, hf_uds_ars_challenge_server, tvb, offset, length_field, ENC_NA);
2623
0
                    offset += length_field;
2624
2625
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_ephemeral_public_key_server, tvb, offset, 2, ENC_BIG_ENDIAN, &length_field);
2626
0
                    offset += 2;
2627
2628
0
                    if (length_field > 0) {
2629
0
                        proto_tree_add_item(uds_tree, hf_uds_ars_ephemeral_public_key_server, tvb, offset, length_field, ENC_NA);
2630
0
                        offset += length_field;
2631
0
                    }
2632
0
                    break;
2633
2634
0
                case UDS_ARS_TYPES_VERIFY_CERT_BIDIRECTIONAL:
2635
0
                    proto_tree_add_item(uds_tree, hf_uds_ars_auth_ret_param, tvb, offset, 1, ENC_NA);
2636
0
                    offset += 1;
2637
2638
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_challenge_server, tvb, offset, 2, ENC_BIG_ENDIAN, &length_field);
2639
0
                    offset += 2;
2640
2641
0
                    proto_tree_add_item(uds_tree, hf_uds_ars_challenge_server, tvb, offset, length_field, ENC_NA);
2642
0
                    offset += length_field;
2643
2644
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_cert_server, tvb, offset, 2, ENC_BIG_ENDIAN, &length_field);
2645
0
                    offset += 2;
2646
2647
0
                    ti = proto_tree_add_item(uds_tree, hf_uds_ars_cert_server, tvb, offset, length_field, ENC_NA);
2648
0
                    dissect_uds_certificates_into_tree(tvb, pinfo, uds_tree, ti, offset, length_field);
2649
0
                    offset += length_field;
2650
2651
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_proof_of_ownership_server, tvb, offset, 2, ENC_BIG_ENDIAN, &length_field);
2652
0
                    offset += 2;
2653
2654
0
                    proto_tree_add_item(uds_tree, hf_uds_ars_proof_of_ownership_server, tvb, offset, length_field, ENC_NA);
2655
0
                    offset += length_field;
2656
2657
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_ephemeral_public_key_server, tvb, offset, 2, ENC_BIG_ENDIAN, &length_field);
2658
0
                    offset += 2;
2659
2660
0
                    if (length_field > 0) {
2661
0
                        proto_tree_add_item(uds_tree, hf_uds_ars_ephemeral_public_key_server, tvb, offset, length_field, ENC_NA);
2662
0
                        offset += length_field;
2663
0
                    }
2664
0
                    break;
2665
2666
0
                case UDS_ARS_TYPES_PROOF_OF_OWNERSHIP:
2667
0
                    proto_tree_add_item(uds_tree, hf_uds_ars_auth_ret_param, tvb, offset, 1, ENC_NA);
2668
0
                    offset += 1;
2669
2670
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_session_key_info, tvb, offset, 2, ENC_BIG_ENDIAN, &length_field);
2671
0
                    offset += 2;
2672
2673
0
                    if (length_field > 0) {
2674
0
                        proto_tree_add_item(uds_tree, hf_uds_ars_session_key_info, tvb, offset, length_field, ENC_NA);
2675
0
                        offset += length_field;
2676
0
                    }
2677
0
                    break;
2678
2679
0
                case UDS_ARS_TYPES_REQUEST_CHALLENGE_FOR_AUTH:
2680
0
                    proto_tree_add_item(uds_tree, hf_uds_ars_auth_ret_param, tvb, offset, 1, ENC_NA);
2681
0
                    offset += 1;
2682
2683
0
                    ti = proto_tree_add_item(uds_tree, hf_uds_ars_algo_indicator, tvb, offset, 16, ENC_NA);
2684
0
                    algo_tree = proto_item_add_subtree(ti, ett_uds_ars_algo_indicator);
2685
0
                    dissect_unknown_ber(pinfo, tvb, offset, algo_tree);
2686
0
                    offset += 16;
2687
2688
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_challenge_server, tvb, offset, 2, ENC_BIG_ENDIAN, &length_field);
2689
0
                    offset += 2;
2690
2691
0
                    proto_tree_add_item(uds_tree, hf_uds_ars_challenge_server, tvb, offset, length_field, ENC_NA);
2692
0
                    offset += length_field;
2693
2694
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_needed_additional_parameter, tvb, offset, 2, ENC_BIG_ENDIAN, &length_field);
2695
0
                    offset += 2;
2696
2697
0
                    if (length_field > 0) {
2698
0
                        proto_tree_add_item(uds_tree, hf_uds_ars_needed_additional_parameter, tvb, offset, length_field, ENC_NA);
2699
0
                        offset += length_field;
2700
0
                    }
2701
0
                    break;
2702
2703
0
                case UDS_ARS_TYPES_VERIFY_PROOF_OF_OWN_UNIDIR:
2704
0
                    proto_tree_add_item(uds_tree, hf_uds_ars_auth_ret_param, tvb, offset, 1, ENC_NA);
2705
0
                    offset += 1;
2706
2707
0
                    ti = proto_tree_add_item(uds_tree, hf_uds_ars_algo_indicator, tvb, offset, 16, ENC_NA);
2708
0
                    algo_tree = proto_item_add_subtree(ti, ett_uds_ars_algo_indicator);
2709
0
                    dissect_unknown_ber(pinfo, tvb, offset, algo_tree);
2710
0
                    offset += 16;
2711
2712
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_session_key_info, tvb, offset, 2, ENC_BIG_ENDIAN, &length_field);
2713
0
                    offset += 2;
2714
2715
0
                    if (length_field > 0) {
2716
0
                        proto_tree_add_item(uds_tree, hf_uds_ars_session_key_info, tvb, offset, length_field, ENC_NA);
2717
0
                        offset += length_field;
2718
0
                    }
2719
0
                    break;
2720
2721
0
                case UDS_ARS_TYPES_VERIFY_PROOF_OF_OWN_BIDIR:
2722
0
                    proto_tree_add_item(uds_tree, hf_uds_ars_auth_ret_param, tvb, offset, 1, ENC_NA);
2723
0
                    offset += 1;
2724
2725
0
                    ti = proto_tree_add_item(uds_tree, hf_uds_ars_algo_indicator, tvb, offset, 16, ENC_NA);
2726
0
                    algo_tree = proto_item_add_subtree(ti, ett_uds_ars_algo_indicator);
2727
0
                    dissect_unknown_ber(pinfo, tvb, offset, algo_tree);
2728
0
                    offset += 16;
2729
2730
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_proof_of_ownership_server, tvb, offset, 2, ENC_BIG_ENDIAN, &length_field);
2731
0
                    offset += 2;
2732
2733
0
                    proto_tree_add_item(uds_tree, hf_uds_ars_proof_of_ownership_server, tvb, offset, length_field, ENC_NA);
2734
0
                    offset += length_field;
2735
2736
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_session_key_info, tvb, offset, 2, ENC_BIG_ENDIAN, &length_field);
2737
0
                    offset += 2;
2738
2739
0
                    if (length_field > 0) {
2740
0
                        proto_tree_add_item(uds_tree, hf_uds_ars_session_key_info, tvb, offset, length_field, ENC_NA);
2741
0
                        offset += length_field;
2742
0
                    }
2743
2744
0
                    break;
2745
0
                }
2746
0
            } else {
2747
0
                proto_tree *algo_tree;
2748
0
                offset = dissect_uds_subfunction(tvb, pinfo, uds_tree, offset, &enum_val, hf_uds_ars_subfunction_no_suppress, uds_ars_types, true);
2749
2750
0
                switch (enum_val) {
2751
0
                case UDS_ARS_TYPES_DEAUTHENTICATE: /* fall through */
2752
0
                case UDS_ARS_TYPES_AUTH_CONFIGURATION:
2753
                    /* do nothing */
2754
0
                    break;
2755
2756
0
                case UDS_ARS_TYPES_VERIFY_CERT_UNIDIRECTIONAL: /* fall through */
2757
0
                case UDS_ARS_TYPES_VERIFY_CERT_BIDIRECTIONAL: {
2758
0
                    proto_tree_add_item(uds_tree, hf_uds_ars_comm_config, tvb, offset, 1, ENC_NA);
2759
0
                    offset += 1;
2760
2761
0
                    unsigned length_cert_client;
2762
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_cert_client, tvb, offset, 2, ENC_BIG_ENDIAN, &length_cert_client);
2763
0
                    offset += 2;
2764
2765
0
                    ti = proto_tree_add_item(uds_tree, hf_uds_ars_cert_client, tvb, offset, length_cert_client, ENC_NA);
2766
0
                    dissect_uds_certificates_into_tree(tvb, pinfo, uds_tree, ti, offset, length_cert_client);
2767
0
                    offset += length_cert_client;
2768
2769
0
                    unsigned length_challenge_client;
2770
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_challenge_client, tvb, offset, 2, ENC_BIG_ENDIAN, &length_challenge_client);
2771
0
                    offset += 2;
2772
2773
0
                    if (length_challenge_client > 0 || enum_val == UDS_ARS_TYPES_VERIFY_CERT_BIDIRECTIONAL) {
2774
0
                        proto_tree_add_item(uds_tree, hf_uds_ars_challenge_client, tvb, offset, length_challenge_client, ENC_NA);
2775
0
                        offset += length_challenge_client;
2776
0
                    }
2777
0
                }
2778
0
                    break;
2779
2780
0
                case UDS_ARS_TYPES_PROOF_OF_OWNERSHIP: {
2781
0
                    unsigned length_proof_of_ownership_client;
2782
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_proof_of_ownership_client, tvb, offset, 2, ENC_BIG_ENDIAN, &length_proof_of_ownership_client);
2783
0
                    offset += 2;
2784
2785
0
                    proto_tree_add_item(uds_tree, hf_uds_ars_proof_of_ownership_client, tvb, offset, length_proof_of_ownership_client, ENC_NA);
2786
0
                    offset += length_proof_of_ownership_client;
2787
2788
0
                    unsigned length_ephemeral_public_key_client;
2789
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_ephemeral_public_key_client, tvb, offset, 2, ENC_BIG_ENDIAN, &length_ephemeral_public_key_client);
2790
0
                    offset += 2;
2791
2792
0
                    if (length_ephemeral_public_key_client > 0) {
2793
0
                        proto_tree_add_item(uds_tree, hf_uds_ars_ephemeral_public_key_client, tvb, offset, length_ephemeral_public_key_client, ENC_NA);
2794
0
                        offset += length_ephemeral_public_key_client;
2795
0
                    }
2796
0
                }
2797
0
                    break;
2798
2799
2800
0
                case UDS_ARS_TYPES_TRANSMIT_CERTIFICATE: {
2801
0
                    proto_tree_add_item(uds_tree, hf_uds_ars_cert_eval_id, tvb, offset, 2, ENC_NA);
2802
0
                    offset += 2;
2803
2804
0
                    unsigned length_cert_data;
2805
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_cert_data, tvb, offset, 2, ENC_BIG_ENDIAN, &length_cert_data);
2806
0
                    offset += 2;
2807
2808
0
                    proto_tree_add_item(uds_tree, hf_uds_ars_cert_data, tvb, offset, length_cert_data, ENC_NA);
2809
0
                    offset += length_cert_data;
2810
0
                }
2811
0
                    break;
2812
2813
0
                case UDS_ARS_TYPES_REQUEST_CHALLENGE_FOR_AUTH: {
2814
0
                    proto_tree_add_item(uds_tree, hf_uds_ars_comm_config, tvb, offset, 1, ENC_NA);
2815
0
                    offset += 1;
2816
2817
0
                    ti = proto_tree_add_item(uds_tree, hf_uds_ars_algo_indicator, tvb, offset, 16, ENC_NA);
2818
0
                    algo_tree = proto_item_add_subtree(ti, ett_uds_ars_algo_indicator);
2819
0
                    dissect_unknown_ber(pinfo, tvb, offset, algo_tree);
2820
0
                    offset += 16;
2821
0
                }
2822
0
                    break;
2823
2824
0
                case UDS_ARS_TYPES_VERIFY_PROOF_OF_OWN_UNIDIR: /* fall through */
2825
0
                case UDS_ARS_TYPES_VERIFY_PROOF_OF_OWN_BIDIR: {
2826
0
                    ti = proto_tree_add_item(uds_tree, hf_uds_ars_algo_indicator, tvb, offset, 16, ENC_NA);
2827
0
                    algo_tree = proto_item_add_subtree(ti, ett_uds_ars_algo_indicator);
2828
0
                    dissect_unknown_ber(pinfo, tvb, offset, algo_tree);
2829
0
                    offset += 16;
2830
2831
0
                    unsigned length_proof_of_ownership_client;
2832
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_proof_of_ownership_client, tvb, offset, 2, ENC_BIG_ENDIAN, &length_proof_of_ownership_client);
2833
0
                    offset += 2;
2834
2835
0
                    proto_tree_add_item(uds_tree, hf_uds_ars_proof_of_ownership_client, tvb, offset, length_proof_of_ownership_client, ENC_NA);
2836
0
                    offset += length_proof_of_ownership_client;
2837
2838
0
                    unsigned length_challenge_client;
2839
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_challenge_client, tvb, offset, 2, ENC_BIG_ENDIAN, &length_challenge_client);
2840
0
                    offset += 2;
2841
2842
0
                    if (length_challenge_client > 0 || enum_val == UDS_ARS_TYPES_VERIFY_PROOF_OF_OWN_BIDIR) {
2843
0
                        proto_tree_add_item(uds_tree, hf_uds_ars_challenge_client, tvb, offset, length_challenge_client, ENC_NA);
2844
0
                        offset += length_challenge_client;
2845
0
                    }
2846
2847
0
                    unsigned length_additional_parameter;
2848
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_ars_length_of_additional_parameter, tvb, offset, 2, ENC_BIG_ENDIAN, &length_additional_parameter);
2849
0
                    offset += 2;
2850
2851
0
                    if (length_additional_parameter > 0) {
2852
0
                        proto_tree_add_item(uds_tree, hf_uds_ars_additional_parameter, tvb, offset, length_additional_parameter, ENC_NA);
2853
0
                        offset += length_additional_parameter;
2854
0
                    }
2855
0
                }
2856
0
                    break;
2857
0
                }
2858
0
            }
2859
0
            break;
2860
2861
0
        case UDS_SERVICES_RDBPI:
2862
0
            if ((sid & UDS_REPLY_MASK) == 0) {
2863
0
                unsigned transmission_mode;
2864
0
                proto_tree_add_item_ret_uint(uds_tree, hf_uds_rdbpi_transmission_mode, tvb, offset, 1, ENC_NA, &transmission_mode);
2865
0
                offset += 1;
2866
2867
                /* For transmission mode 1 (send at slow rate), mode 2 (medium rate), and mode 3 (fast rate), require at least 1 pdid! */
2868
0
                if (1 <= transmission_mode && transmission_mode <= 3) {
2869
0
                    proto_tree_add_item(uds_tree, hf_uds_rdbpi_periodic_data_identifier, tvb, offset, 1, ENC_NA);
2870
0
                    offset += 1;
2871
0
                }
2872
2873
0
                while (offset < data_length) {
2874
0
                    proto_tree_add_item(uds_tree, hf_uds_rdbpi_periodic_data_identifier, tvb, offset, 1, ENC_NA);
2875
0
                    offset += 1;
2876
0
                }
2877
0
            }
2878
0
            break;
2879
2880
0
        case UDS_SERVICES_DDDI:
2881
0
            if (sid & UDS_REPLY_MASK) {
2882
0
                offset = dissect_uds_subfunction(tvb, pinfo, uds_tree, offset, &enum_val, hf_uds_dddi_subfunction_no_suppress, uds_dddi_types, false);
2883
2884
0
                if (offset + 2 <= data_length) {
2885
0
                    proto_tree_add_item(uds_tree, hf_uds_dddi_dyn_defined_data_identifier, tvb, offset, 2, ENC_BIG_ENDIAN);
2886
0
                    offset += 2;
2887
0
                }
2888
0
            } else {
2889
0
                offset = dissect_uds_subfunction(tvb, pinfo, uds_tree, offset, &enum_val, hf_uds_dddi_subfunction_no_suppress, uds_dddi_types, true);
2890
2891
0
                switch (enum_val) {
2892
0
                case UDS_DDDI_TYPES_DEFINE_BY_IDENTIFIER:
2893
0
                    proto_tree_add_item(uds_tree, hf_uds_dddi_dyn_defined_data_identifier, tvb, offset, 2, ENC_BIG_ENDIAN);
2894
0
                    offset += 2;
2895
2896
0
                    do {
2897
0
                        proto_tree *tmp_tree;
2898
0
                        tmp_tree = proto_tree_add_subtree(uds_tree, tvb, offset, 4, ett_uds_dddi_entry, &ti, "Element");
2899
2900
0
                        unsigned source_data_id;
2901
0
                        proto_tree_add_item_ret_uint(tmp_tree, hf_uds_dddi_source_data_identifier, tvb, offset, 2, ENC_BIG_ENDIAN, &source_data_id);
2902
0
                        offset += 2;
2903
2904
0
                        unsigned position;
2905
0
                        proto_tree_add_item_ret_uint(tmp_tree, hf_uds_dddi_position_in_source_data_record, tvb, offset, 1, ENC_NA, &position);
2906
0
                        offset += 1;
2907
2908
0
                        unsigned mem_size;
2909
0
                        proto_tree_add_item_ret_uint(tmp_tree, hf_uds_dddi_memory_size, tvb, offset, 1, ENC_NA, &mem_size);
2910
0
                        offset += 1;
2911
2912
0
                        proto_item_append_text(ti, " %d with Source ID 0x%04x and %d byte(s)", position, source_data_id, mem_size);
2913
0
                    } while (offset + 4 <= data_length);
2914
2915
0
                    break;
2916
2917
0
                case UDS_DDDI_TYPES_DEFINE_BY_MEM_ADDRESS:
2918
0
                    proto_tree_add_item(uds_tree, hf_uds_dddi_dyn_defined_data_identifier, tvb, offset, 2, ENC_BIG_ENDIAN);
2919
0
                    offset += 2;
2920
2921
0
                    uint32_t memory_size_length, memory_address_length;
2922
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_memory_size_length, tvb, offset, 1, ENC_NA, &memory_size_length);
2923
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_memory_address_length, tvb, offset, 1, ENC_NA, &memory_address_length);
2924
0
                    offset += 1;
2925
2926
0
                    do {
2927
0
                        uint64_t memory_address;
2928
0
                        proto_tree_add_item_ret_uint64(uds_tree, hf_uds_memory_address, tvb, offset, memory_address_length, ENC_BIG_ENDIAN, &memory_address);
2929
0
                        offset += memory_address_length;
2930
2931
0
                        uint64_t memory_size;
2932
0
                        proto_tree_add_item_ret_uint64(uds_tree, hf_uds_memory_size, tvb, offset, memory_size_length, ENC_BIG_ENDIAN, &memory_size);
2933
0
                        offset += memory_size_length;
2934
0
                    } while (offset + memory_address_length + memory_size_length <= data_length);
2935
0
                    break;
2936
2937
0
                case UDS_DDDI_TYPES_CLEAR_DYN_DEF_DATA_ID:
2938
0
                    if (offset + 2 <= data_length) {
2939
0
                        proto_tree_add_item(uds_tree, hf_uds_dddi_dyn_defined_data_identifier, tvb, offset, 2, ENC_BIG_ENDIAN);
2940
0
                        offset += 2;
2941
0
                    }
2942
0
                    break;
2943
0
                }
2944
0
            }
2945
0
            break;
2946
2947
0
        case UDS_SERVICES_WDBI:
2948
0
            ti = proto_tree_add_item_ret_uint(uds_tree, hf_uds_wdbi_data_identifier, tvb, offset, 2, ENC_BIG_ENDIAN, &enum_val);
2949
0
            protoitem_append_data_name(ti, ecu_address, (uint16_t)enum_val);
2950
0
            col_append_fstr(pinfo->cinfo, COL_INFO, "   0x%04x", enum_val);
2951
0
            infocol_append_data_name(pinfo, ecu_address, enum_val);
2952
0
            offset += 2;
2953
2954
0
            if (!(sid & UDS_REPLY_MASK)) {
2955
0
                bool dissection_ok = false;
2956
0
                if (data_length > offset) {
2957
0
                    col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", tvb_bytes_to_str_punct(pinfo->pool, tvb, offset, data_length - offset, ' '));
2958
2959
0
                    payload_tvb = tvb_new_subset_length(tvb, offset, data_length - offset);
2960
0
                    dissection_ok = call_heur_subdissector_uds(payload_tvb, pinfo, tree, uds_tree, service, false, enum_val, ecu_address);
2961
0
                }
2962
2963
0
                if (!dissection_ok) {
2964
                    /* ISO14229: at least one byte for data record. Just make sure, we show an error, if less than 1 byte left! */
2965
0
                    proto_tree_add_item(uds_tree, hf_uds_data_record, tvb, offset, MAX(1, data_length - offset), ENC_NA);
2966
0
                }
2967
2968
0
                offset = data_length;
2969
0
            }
2970
0
            break;
2971
2972
0
        case UDS_SERVICES_IOCBI: {
2973
0
            uint32_t data_identifier;
2974
0
            ti = proto_tree_add_item_ret_uint(uds_tree, hf_uds_iocbi_data_identifier, tvb, offset, 2, ENC_BIG_ENDIAN, &data_identifier);
2975
0
            protoitem_append_data_name(ti, ecu_address, (uint16_t)data_identifier);
2976
0
            col_append_fstr(pinfo->cinfo, COL_INFO, "   0x%04x", data_identifier);
2977
0
            infocol_append_data_name(pinfo, ecu_address, data_identifier);
2978
0
            offset += 2;
2979
2980
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_iocbi_parameter, tvb, offset, 1, ENC_NA, &enum_val);
2981
0
            col_append_fstr(pinfo->cinfo, COL_INFO, "  %s", val_to_str(pinfo->pool, enum_val, uds_iocbi_parameters, "Unknown (0x%02x)"));
2982
0
            offset += 1;
2983
2984
            /* The exact format depends on vehicle manufacturer and config. Not much we can do here. */
2985
0
            if (data_length > offset) {
2986
0
                proto_tree_add_item(uds_tree, hf_uds_iocbi_state, tvb, offset, data_length - offset, ENC_NA);
2987
0
                col_append_fstr(pinfo->cinfo, COL_INFO, " %s", tvb_bytes_to_str_punct(pinfo->pool, tvb, offset, data_length - offset, ' '));
2988
0
            }
2989
0
            offset = data_length;
2990
0
            break;
2991
0
        }
2992
2993
0
        case UDS_SERVICES_RC: {
2994
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_rc_subfunction, tvb, offset, 1, ENC_NA, &enum_val);
2995
0
            col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", val_to_str(pinfo->pool, enum_val, uds_rc_types, "Unknown (0x%02x)"));
2996
0
            offset += 1;
2997
2998
0
            uint32_t identifier;
2999
0
            ti = proto_tree_add_item_ret_uint(uds_tree, hf_uds_rc_identifier, tvb, offset, 2, ENC_BIG_ENDIAN, &identifier);
3000
0
            protoitem_append_routine_name(ti, ecu_address, identifier);
3001
0
            col_append_fstr(pinfo->cinfo, COL_INFO, " 0x%04x", identifier);
3002
0
            infocol_append_routine_name(pinfo, ecu_address, identifier);
3003
0
            offset += 2;
3004
3005
0
            if (sid & UDS_REPLY_MASK) {
3006
0
                if (data_length > offset) {
3007
0
                    uint32_t info;
3008
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_rc_info, tvb, offset, 1, ENC_NA, &info);
3009
0
                    col_append_fstr(pinfo->cinfo, COL_INFO, "   0x%x", info);
3010
0
                    offset += 1;
3011
3012
0
                    if (data_length > offset) {
3013
0
                        col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", tvb_bytes_to_str_punct(pinfo->pool, tvb, offset, data_length - offset, ' '));
3014
3015
0
                        payload_tvb = tvb_new_subset_length(tvb, offset, data_length - offset);
3016
0
                        if (!call_heur_subdissector_uds(payload_tvb, pinfo, tree, uds_tree, service, true, identifier, ecu_address)) {
3017
0
                            proto_tree_add_item(uds_tree, hf_uds_rc_status_record, tvb, offset, data_length - offset, ENC_NA);
3018
0
                        }
3019
3020
0
                        offset = data_length;
3021
0
                    }
3022
0
                }
3023
0
            } else {
3024
0
                if (data_length > offset) {
3025
0
                    col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", tvb_bytes_to_str_punct(pinfo->pool, tvb, offset, data_length - offset, ' '));
3026
3027
0
                    payload_tvb = tvb_new_subset_length(tvb, offset, data_length - offset);
3028
0
                    if (!call_heur_subdissector_uds(payload_tvb, pinfo, tree, uds_tree, service, false, identifier, ecu_address)) {
3029
0
                        proto_tree_add_item(uds_tree, hf_uds_rc_option_record, tvb, offset, data_length - offset, ENC_NA);
3030
0
                    }
3031
3032
0
                    offset = data_length;
3033
0
                }
3034
0
            }
3035
0
            break;
3036
0
        }
3037
3038
0
        case UDS_SERVICES_RD: /* fall through */
3039
0
        case UDS_SERVICES_RU:
3040
0
            if (sid & UDS_REPLY_MASK) {
3041
0
                uint32_t max_block_length_length;
3042
0
                proto_tree_add_item_ret_uint(uds_tree, hf_uds_max_block_len_len, tvb, offset, 1, ENC_NA, &max_block_length_length);
3043
0
                offset += 1;
3044
3045
0
                uint64_t max_block_length;
3046
0
                proto_tree_add_item_ret_uint64(uds_tree, hf_uds_max_block_len, tvb, offset, max_block_length_length, ENC_BIG_ENDIAN, &max_block_length);
3047
0
                offset += max_block_length_length;
3048
3049
0
                col_append_fstr(pinfo->cinfo, COL_INFO, "   Max Block Length 0x%" PRIx64, max_block_length);
3050
0
            } else {
3051
0
                offset = dissect_uds_memory_addr_size(tvb, pinfo, uds_tree, offset, true);
3052
0
            }
3053
0
            break;
3054
3055
0
        case UDS_SERVICES_TD: {
3056
0
            uint32_t sequence_no;
3057
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_td_sequence_counter, tvb, offset, 1, ENC_NA, &sequence_no);
3058
0
            col_append_fstr(pinfo->cinfo, COL_INFO, "   Block Sequence Counter %d", sequence_no);
3059
0
            offset += 1;
3060
3061
0
            if (data_length > offset) {
3062
0
                proto_tree_add_item(uds_tree, hf_uds_td_record_data, tvb, offset, data_length - offset, ENC_NA);
3063
0
                col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", tvb_bytes_to_str_punct(pinfo->pool, tvb, offset, data_length - offset, ' '));
3064
0
                offset = data_length;
3065
0
            }
3066
0
            break;
3067
0
        }
3068
3069
0
        case UDS_SERVICES_RTE:
3070
0
            if (data_length > offset) {
3071
0
                proto_tree_add_item(uds_tree, hf_uds_rte_record_data, tvb, offset, data_length - offset, ENC_NA);
3072
0
                col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", tvb_bytes_to_str_punct(pinfo->pool, tvb, offset, data_length - offset, ' '));
3073
0
                offset = data_length;
3074
0
            }
3075
0
            break;
3076
3077
0
        case UDS_SERVICES_RFT: {
3078
0
            unsigned mode_of_op;
3079
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_rft_mode_of_operation, tvb, offset, 1, ENC_NA, &mode_of_op);
3080
0
            offset += 1;
3081
3082
0
            if (sid & UDS_REPLY_MASK) {
3083
0
                if (mode_of_op != UDS_RFT_MODE_DELETE_FILE) {
3084
0
                    uint32_t length_max_num_block_len;
3085
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_rft_length_format_identifier, tvb, offset, 1, ENC_NA, &length_max_num_block_len);
3086
0
                    offset += 1;
3087
3088
0
                    proto_tree_add_item(uds_tree, hf_uds_rft_max_num_of_block_length, tvb, offset, length_max_num_block_len, ENC_BIG_ENDIAN);
3089
0
                    offset += length_max_num_block_len;
3090
0
                }
3091
3092
0
                if (mode_of_op != UDS_RFT_MODE_DELETE_FILE) {
3093
0
                    proto_tree_add_item(uds_tree, hf_uds_compression_method, tvb, offset, 1, ENC_NA);
3094
0
                    proto_tree_add_item(uds_tree, hf_uds_encrypting_method, tvb, offset, 1, ENC_NA);
3095
0
                    offset += 1;
3096
0
                }
3097
3098
0
                if (mode_of_op != UDS_RFT_MODE_ADD_FILE && mode_of_op != UDS_RFT_MODE_DELETE_FILE && mode_of_op != UDS_RFT_MODE_REPLACE_FILE && mode_of_op != UDS_RFT_MODE_RESUME_FILE) {
3099
0
                    unsigned length_field;
3100
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_rft_file_size_or_dir_info_param_length, tvb, offset, 2, ENC_BIG_ENDIAN, &length_field);
3101
0
                    offset += 2;
3102
3103
0
                    proto_tree_add_item(uds_tree, hf_uds_rft_file_size_uncompressed_or_dir_info_length, tvb, offset, length_field, ENC_BIG_ENDIAN);
3104
0
                    offset += length_field;
3105
3106
0
                    if (mode_of_op != UDS_RFT_MODE_READ_DIR) {
3107
0
                        proto_tree_add_item(uds_tree, hf_uds_rft_file_size_compressed, tvb, offset, length_field, ENC_BIG_ENDIAN);
3108
0
                        offset += length_field;
3109
0
                    }
3110
0
                }
3111
3112
0
                if (mode_of_op != UDS_RFT_MODE_ADD_FILE && mode_of_op != UDS_RFT_MODE_DELETE_FILE && mode_of_op != UDS_RFT_MODE_REPLACE_FILE && mode_of_op != UDS_RFT_MODE_READ_FILE
3113
0
                    && mode_of_op != UDS_RFT_MODE_READ_DIR) {
3114
0
                    proto_tree_add_item(uds_tree, hf_uds_rft_file_position, tvb, offset, 8, ENC_BIG_ENDIAN);
3115
0
                    offset += 8;
3116
0
                }
3117
0
            } else {
3118
0
                unsigned length_field;
3119
0
                proto_tree_add_item_ret_uint(uds_tree, hf_uds_rft_length_of_file_path_and_name, tvb, offset, 2, ENC_BIG_ENDIAN, &length_field);
3120
0
                offset += 2;
3121
3122
0
                proto_tree_add_item(uds_tree, hf_uds_rft_file_path_and_name, tvb, offset, length_field, ENC_ASCII);
3123
0
                offset += length_field;
3124
3125
0
                if (mode_of_op != UDS_RFT_MODE_DELETE_FILE && mode_of_op != UDS_RFT_MODE_READ_DIR) {
3126
0
                    proto_tree_add_item(uds_tree, hf_uds_compression_method, tvb, offset, 1, ENC_NA);
3127
0
                    proto_tree_add_item(uds_tree, hf_uds_encrypting_method, tvb, offset, 1, ENC_NA);
3128
0
                    offset += 1;
3129
0
                }
3130
3131
0
                if (mode_of_op != UDS_RFT_MODE_DELETE_FILE && mode_of_op != UDS_RFT_MODE_READ_FILE && mode_of_op != UDS_RFT_MODE_READ_DIR) {
3132
0
                    uint32_t fileSizeParameterLength;
3133
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_rft_file_size_param_length, tvb, offset, 1, ENC_NA, &fileSizeParameterLength);
3134
0
                    offset += 1;
3135
3136
0
                    uint64_t filesize_uncompressed, filesize_compressed;
3137
0
                    proto_tree_add_item_ret_uint64(uds_tree, hf_uds_rft_file_size_uncompressed, tvb, offset, fileSizeParameterLength, ENC_BIG_ENDIAN, &filesize_uncompressed);
3138
0
                    offset += fileSizeParameterLength;
3139
3140
0
                    proto_tree_add_item_ret_uint64(uds_tree, hf_uds_rft_file_size_compressed, tvb, offset, fileSizeParameterLength, ENC_BIG_ENDIAN, &filesize_compressed);
3141
0
                    offset += fileSizeParameterLength;
3142
0
                }
3143
3144
0
            }
3145
0
        }
3146
0
            break;
3147
3148
0
        case UDS_SERVICES_WMBA:
3149
0
            offset = dissect_uds_memory_addr_size(tvb, pinfo, uds_tree, offset, false);
3150
3151
0
            if (sid & UDS_REPLY_MASK) {
3152
                /* do nothing */
3153
0
            } else {
3154
0
                if (offset < data_length) {
3155
0
                    proto_tree_add_item(uds_tree, hf_uds_data_record, tvb, offset, data_length - offset, ENC_NA);
3156
0
                    col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", tvb_bytes_to_str_punct(pinfo->pool, tvb, offset, data_length - offset, ' '));
3157
0
                    offset = data_length;
3158
0
                }
3159
0
            }
3160
0
            break;
3161
3162
0
        case UDS_SERVICES_TP:
3163
0
            offset = dissect_uds_subfunction(tvb, pinfo, uds_tree, offset, &enum_val, hf_uds_tp_subfunction_no_suppress, NULL, !(sid & UDS_REPLY_MASK));
3164
0
            break;
3165
3166
0
        case UDS_SERVICES_ERR:
3167
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_err_sid, tvb, offset, 1, ENC_NA, &enum_val);
3168
0
            col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", val_to_str_ext(pinfo->pool, enum_val, &uds_services_ext, "Unknown (0x%02x)"));
3169
0
            offset += 1;
3170
3171
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_err_code, tvb, offset, 1, ENC_NA, &enum_val);
3172
0
            col_append_fstr(pinfo->cinfo, COL_INFO, " (NRC: %s)", val_to_str_ext(pinfo->pool, enum_val, &uds_response_codes_ext, "Unknown (0x%02x)"));
3173
0
            offset += 1;
3174
0
            break;
3175
3176
0
        case UDS_SERVICES_SDT: {
3177
0
            static int * const admin_param_flags[] = {
3178
0
                &hf_uds_sdt_administrative_param_resp_sign_req,
3179
0
                &hf_uds_sdt_administrative_param_signed,
3180
0
                &hf_uds_sdt_administrative_param_encrypted,
3181
0
                &hf_uds_sdt_administrative_param_pre_estab_key,
3182
0
                &hf_uds_sdt_administrative_param_req,
3183
0
                NULL
3184
0
            };
3185
3186
0
            uint64_t addmin_param;
3187
0
            proto_tree_add_bitmask_with_flags_ret_uint64(uds_tree, tvb, offset, hf_uds_sdt_administrative_param, ett_uds_sdt_admin_param, admin_param_flags, ENC_BIG_ENDIAN, BMT_NO_APPEND, &addmin_param);
3188
0
            offset += 2;
3189
3190
0
            proto_tree_add_item(uds_tree, hf_uds_sdt_signature_encryption_calculation, tvb, offset, 1, ENC_NA);
3191
0
            offset += 1;
3192
3193
0
            uint32_t sig_length;
3194
0
            proto_tree_add_item_ret_uint(uds_tree, hf_uds_sdt_signature_length, tvb, offset, 2, ENC_BIG_ENDIAN, &sig_length);
3195
0
            offset += 2;
3196
3197
0
            proto_tree_add_item(uds_tree, hf_uds_sdt_anti_replay_counter, tvb, offset, 2, ENC_BIG_ENDIAN);
3198
0
            offset += 2;
3199
3200
0
            if (offset + sig_length < data_length) {
3201
0
                uint32_t encap_length = data_length - offset - sig_length;
3202
0
                ti = proto_tree_add_item(uds_tree, hf_uds_sdt_encapsulated_message, tvb, offset, encap_length, ENC_NA);
3203
3204
0
                if ((addmin_param & UDS_SDT_ADMIN_PARAM_ENCRYPTED) == 0) {
3205
0
                    proto_tree *encap_tree = proto_item_add_subtree(ti, ett_uds_sdt_encap_message);
3206
0
                    proto_tree_add_item(encap_tree, hf_uds_sdt_encapsulated_message_sid, tvb, offset, 1, ENC_NA);
3207
0
                    proto_tree_add_item(encap_tree, hf_uds_sdt_encapsulated_message_sid_reply, tvb, offset, 1, ENC_NA);
3208
0
                }
3209
0
                offset += encap_length;
3210
0
            }
3211
3212
0
            proto_tree_add_item(uds_tree, hf_uds_sdt_signature_mac, tvb, offset, sig_length, ENC_NA);
3213
0
            offset += sig_length;
3214
3215
0
        }
3216
0
            break;
3217
3218
0
        case UDS_SERVICES_CDTCS:
3219
0
            if ((sid & UDS_REPLY_MASK)) {
3220
0
                proto_tree_add_item_ret_uint(uds_tree, hf_uds_cdtcs_type, tvb, offset, 1, ENC_NA, &enum_val);
3221
0
                col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", val_to_str(pinfo->pool, enum_val, uds_cdtcs_types, "Unknown (0x%02x)"));
3222
0
                offset += 1;
3223
0
            } else {
3224
0
                ti = proto_tree_add_item(uds_tree, hf_uds_cdtcs_subfunction, tvb, offset, 1, ENC_NA);
3225
0
                subfunction_tree = proto_item_add_subtree(ti, ett_uds_subfunction);
3226
0
                proto_tree_add_item_ret_uint(subfunction_tree, hf_uds_cdtcs_subfunction_no_suppress, tvb, offset, 1, ENC_NA, &enum_val);
3227
0
                proto_tree_add_item(subfunction_tree, hf_uds_cdtcs_subfunction_pos_rsp_msg_ind, tvb, offset, 1, ENC_NA);
3228
0
                col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", val_to_str(pinfo->pool, enum_val, uds_cdtcs_types, "Unknown (0x%02x)"));
3229
0
                offset += 1;
3230
3231
0
                if (data_length - offset > 0) {
3232
0
                    proto_tree_add_item(uds_tree, hf_uds_cdtcs_option_record, tvb, offset, data_length - offset, ENC_NA);
3233
0
                    col_append_fstr(pinfo->cinfo, COL_INFO, "  %s", tvb_bytes_to_str_punct(pinfo->pool, tvb, offset, data_length - offset, ' '));
3234
0
                    offset = data_length;
3235
0
                }
3236
0
            }
3237
0
            break;
3238
3239
2
        case UDS_SERVICES_ROE:
3240
2
        {
3241
2
            uint32_t eventTypeSubFunc;
3242
2
            proto_tree_add_item_ret_uint( uds_tree, hf_uds_roe_subfunction, tvb, offset, 1, ENC_BIG_ENDIAN, &eventTypeSubFunc);
3243
2
            proto_tree_add_item( uds_tree, hf_uds_roe_store_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
3244
2
            offset += 1;
3245
2
            col_add_fstr( pinfo->cinfo, COL_INFO, "%s %s : %s"
3246
2
                        , sid & UDS_REPLY_MASK ? "Replay " : "Request"
3247
2
                        , val_to_str_const( UDS_SERVICES_ROE, _uds_services, "")
3248
2
                        , val_to_str_const( eventTypeSubFunc & UDS_ROE_SUBFUNC_MASK, uds_roe_types, "Unknown subfunction"));
3249
2
            if( sid & UDS_REPLY_MASK)
3250
0
            {
3251
0
                uint32_t numOfEvents;
3252
0
                proto_tree_add_item_ret_uint( uds_tree, hf_uds_roe_NOIE, tvb, offset, 1, ENC_NA, &numOfEvents);
3253
0
                offset += 1;
3254
0
                if( eventTypeSubFunc != UDS_ROE_SUBF_RAE)
3255
0
                {
3256
0
                    proto_tree_add_item( uds_tree, hf_uds_roe_window_time, tvb, offset, 1, ENC_NA);
3257
0
                    offset += 1;
3258
0
                }
3259
0
                else
3260
0
                {
3261
0
                    if( numOfEvents)
3262
0
                    {
3263
                        /* here only the first head can be easy parsed, because information of the request is required */
3264
0
                        proto_tree_add_item( uds_tree, hf_uds_roe_EVOAE, tvb, offset, 1, ENC_NA);
3265
0
                        offset += 1;
3266
0
                        proto_tree_add_item( uds_tree, hf_uds_roe_window_time, tvb, offset, 1, ENC_NA);
3267
0
                        offset += 1;
3268
0
                    }
3269
0
                }
3270
0
            }
3271
2
            else /* request */
3272
2
            {
3273
2
                static int * const uds_roe_tdc_status_mask_fields[] = {
3274
2
                    &hf_uds_roe_dtc_status_mask_TF    ,
3275
2
                    &hf_uds_roe_dtc_status_mask_TFTOC ,
3276
2
                    &hf_uds_roe_dtc_status_mask_PDTC  ,
3277
2
                    &hf_uds_roe_dtc_status_mask_CDTC  ,
3278
2
                    &hf_uds_roe_dtc_status_mask_TNCSLC,
3279
2
                    &hf_uds_roe_dtc_status_mask_TFSLC ,
3280
2
                    &hf_uds_roe_dtc_status_mask_TNCTOC,
3281
2
                    &hf_uds_roe_dtc_status_mask_WIR   ,
3282
2
                    NULL
3283
2
                };
3284
3285
2
                proto_tree_add_item( uds_tree, hf_uds_roe_window_time, tvb, offset, 1, ENC_NA);
3286
2
                offset += 1;
3287
2
                switch( eventTypeSubFunc)
3288
2
                {
3289
0
                    case UDS_ROE_SUBF_ONDTCS:
3290
0
                    {
3291
0
                        proto_tree_add_bitmask( uds_tree, tvb, offset, hf_uds_roe_dtc_status_mask, ett_uds_roe_dtc_status_mask, uds_roe_tdc_status_mask_fields, ENC_NA);
3292
0
                        offset += 1;
3293
0
                        break;
3294
0
                    }
3295
0
                    case UDS_ROE_SUBF_OCODID:
3296
0
                    {
3297
0
                        proto_tree_add_item( uds_tree, hf_uds_roe_identifier, tvb, offset, 2, ENC_BIG_ENDIAN);
3298
0
                        offset += 2;
3299
0
                        break;
3300
0
                    }
3301
2
                    case UDS_ROE_SUBF_OCOV:
3302
2
                    {
3303
2
                        proto_tree_add_item( uds_tree, hf_uds_roe_did, tvb, offset, 2, ENC_BIG_ENDIAN);
3304
2
                        offset += 2;
3305
2
                        proto_tree_add_item( uds_tree, hf_uds_roe_comparison, tvb, offset, 1, ENC_NA);
3306
2
                        offset += 1;
3307
2
                        proto_tree_add_item( uds_tree, hf_uds_roe_comparison_value, tvb, offset, 4, ENC_BIG_ENDIAN);
3308
2
                        offset += 4;
3309
2
                        proto_tree_add_item( uds_tree, hf_uds_roe_hysteresis_value, tvb, offset, 1, ENC_NA);
3310
2
                        offset += 1;
3311
2
                        static int * const uds_roe_localization_fields[] = {
3312
2
                            &hf_uds_roe_localization_sign,
3313
2
                            &hf_uds_roe_localization_length,
3314
2
                            &hf_uds_roe_localization_offset,
3315
2
                            NULL
3316
2
                        };
3317
2
                        proto_tree_add_bitmask( uds_tree, tvb, offset, hf_uds_roe_localization, ett_uds_roe_localization, uds_roe_localization_fields, ENC_BIG_ENDIAN);
3318
2
                        offset += 2;
3319
2
                        break;
3320
0
                    }
3321
0
                    case UDS_ROE_SUBF_RMRDOSC:
3322
0
                    {
3323
0
                        proto_tree_add_item( uds_tree, hf_uds_rdtci_subfunction, tvb, offset, 1, ENC_NA);
3324
0
                        offset += 1;
3325
0
                        break;
3326
0
                    }
3327
0
                    case UDS_ROE_SUBF_RDRIODSC:
3328
0
                    {
3329
0
                        proto_tree_add_bitmask( uds_tree, tvb, offset, hf_uds_roe_dtc_status_mask, ett_uds_roe_dtc_status_mask, uds_roe_tdc_status_mask_fields, ENC_NA);
3330
0
                        offset += 1;
3331
0
                        uint32_t rdtci_subfunction;
3332
0
                        proto_tree_add_item_ret_uint( uds_tree, hf_uds_rdtci_subfunction, tvb, offset, 1, ENC_NA, &rdtci_subfunction);
3333
0
                        offset += 1;
3334
                        /* here a more detailed dissector can be implemented which covers the ReadDTCinformation similar to Service above*/
3335
0
                        break;
3336
0
                    }
3337
2
                }
3338
2
            }
3339
2
            break;
3340
2
        }
3341
2
        case UDS_SERVICES_LC:
3342
0
            ti = proto_tree_add_item(uds_tree, hf_uds_lc_subfunction, tvb, offset, 1, ENC_NA);
3343
            /* do not increase offset, since reply uses the same byte with different mask! */
3344
3345
0
            subfunction_tree = proto_item_add_subtree(ti, ett_uds_subfunction);
3346
0
            proto_tree_add_item_ret_uint(subfunction_tree, hf_uds_lc_subfunction_no_suppress, tvb, offset, 1, ENC_NA, &enum_val);
3347
3348
0
            col_append_fstr(pinfo->cinfo, COL_INFO, "   %s", val_to_str(pinfo->pool, enum_val, uds_lc_types, "Unknown (0x%02x)"));
3349
3350
0
            if (sid & UDS_REPLY_MASK) {
3351
0
                offset += 1;
3352
0
            } else {
3353
0
                proto_tree_add_item(subfunction_tree, hf_uds_lc_subfunction_pos_rsp_msg_ind, tvb, offset, 1, ENC_NA);
3354
0
                offset += 1;
3355
3356
0
                switch (enum_val) {
3357
0
                case UDS_LC_TYPES_VMTWFP: {
3358
0
                    unsigned control_mode_id;
3359
0
                    proto_tree_add_item_ret_uint(uds_tree, hf_uds_lc_control_mode_id, tvb, offset, 1, ENC_NA, &control_mode_id);
3360
0
                    col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", val_to_str(pinfo->pool, control_mode_id, uds_lc_lcmi_types, "Unknown (0x%02x)"));
3361
0
                    offset += 1;
3362
0
                }
3363
0
                    break;
3364
3365
0
                case UDS_LC_TYPES_VMTWSP:
3366
0
                    proto_tree_add_item(uds_tree, hf_uds_lc_link_record, tvb, offset, 3, ENC_BIG_ENDIAN);
3367
0
                    offset += 3;
3368
0
                    break;
3369
3370
0
                case UDS_LC_TYPES_TM:
3371
                    /* do nothing */
3372
0
                    break;
3373
0
                }
3374
0
            }
3375
0
            break;
3376
4
    }
3377
3378
4
    if (data_length - offset > 0) {
3379
4
        proto_tree_add_item(uds_tree, hf_uds_unparsed_bytes, tvb, offset, data_length - offset, ENC_NA);
3380
4
    }
3381
3382
4
    return data_length;
3383
4
}
3384
3385
static int
3386
0
dissect_uds_no_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) {
3387
0
    return dissect_uds_internal(tvb, pinfo, tree, 0, 0, 0, 0);
3388
0
}
3389
3390
static int
3391
4
dissect_uds_doip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
3392
4
    DISSECTOR_ASSERT(data);
3393
3394
4
    doip_info_t *doip_info = (doip_info_t *)data;
3395
4
    return dissect_uds_internal(tvb, pinfo, tree, doip_info->source_address, doip_info->target_address, 2, 2);
3396
4
}
3397
3398
static int
3399
0
dissect_uds_hsfz(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
3400
0
    DISSECTOR_ASSERT(data);
3401
3402
0
    hsfz_info_t *hsfz_info = (hsfz_info_t *)data;
3403
0
    return dissect_uds_internal(tvb, pinfo, tree, hsfz_info->source_address, hsfz_info->target_address, 2, 1);
3404
0
}
3405
3406
static int
3407
0
dissect_uds_iso15765(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
3408
0
    DISSECTOR_ASSERT(data);
3409
3410
0
    iso15765_info_t *info = (iso15765_info_t *)data;
3411
0
    return dissect_uds_internal(tvb, pinfo, tree, info->source_address, info->target_address, info->number_of_addresses_valid, info->address_length);
3412
0
}
3413
3414
static int
3415
0
dissect_uds_iso10681(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
3416
0
    DISSECTOR_ASSERT(data);
3417
3418
0
    iso10681_info_t *info = (iso10681_info_t *)data;
3419
0
    return dissect_uds_internal(tvb, pinfo, tree, info->source_address, info->target_address, 2, 2);
3420
0
}
3421
3422
void
3423
14
proto_register_uds(void) {
3424
14
    module_t *uds_module;
3425
14
    static hf_register_info hf[] = {
3426
14
        { &hf_uds_diag_addr, {
3427
14
            "Diagnostic Address", "uds.diag_addr", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3428
14
        { &hf_uds_diag_addr_name, {
3429
14
            "Diagnostic Address Name", "uds.diag_addr_name", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3430
14
        { &hf_uds_diag_source_addr, {
3431
14
            "Diagnostic Source Address", "uds.diag_addr_source", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3432
14
        { &hf_uds_diag_source_addr_name, {
3433
14
            "Diagnostic Source Address Name", "uds.diag_addr_source_name", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3434
14
        { &hf_uds_diag_target_addr, {
3435
14
            "Diagnostic Target Address", "uds.diag_addr_target", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3436
14
        { &hf_uds_diag_target_addr_name, {
3437
14
            "Diagnostic Target Address Name", "uds.diag_addr_target_name", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3438
14
        { &hf_uds_service, {
3439
14
            "Service Identifier", "uds.sid", FT_UINT8,  BASE_HEX | BASE_EXT_STRING, VALS_EXT_PTR(&uds_services_ext), UDS_SID_MASK, NULL, HFILL } },
3440
14
        { &hf_uds_reply, {
3441
14
            "Reply Flag", "uds.reply", FT_UINT8, BASE_HEX, NULL, UDS_REPLY_MASK, NULL, HFILL } },
3442
3443
14
        { &hf_uds_subfunction, {
3444
14
            "SubFunction", "uds.subfunction", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3445
14
        { &hf_uds_suppress_pos_rsp_msg_ind, {
3446
14
            "Suppress reply", "uds.suppress_reply.indication", FT_BOOLEAN, 8, NULL, UDS_SUPPRESS_POS_RSP_MSG_IND_MASK, NULL, HFILL } },
3447
14
        { &hf_uds_data_record, {
3448
14
            "Data Record", "uds.data_record", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3449
3450
14
        { &hf_uds_compression_method, {
3451
14
            "Compression Method", "uds.compression_method", FT_UINT8, BASE_HEX, NULL, UDS_RD_COMPRESSION_METHOD_MASK, NULL, HFILL } },
3452
14
        { &hf_uds_encrypting_method, {
3453
14
            "Encrypting Method", "uds.encrypting_method", FT_UINT8, BASE_HEX, NULL, UDS_RD_ENCRYPTING_METHOD_MASK, NULL, HFILL } },
3454
14
        { &hf_uds_memory_size_length, {
3455
14
            "Memory size length", "uds.memory_size_length", FT_UINT8, BASE_HEX, NULL, UDS_RD_MEMORY_SIZE_LENGTH_MASK, NULL, HFILL } },
3456
14
        { &hf_uds_memory_address_length, {
3457
14
            "Memory address length", "uds.memory_address_length", FT_UINT8, BASE_HEX, NULL, UDS_RD_MEMORY_ADDRESS_LENGTH_MASK, NULL, HFILL } },
3458
14
        { &hf_uds_memory_address, {
3459
14
            "Memory Address", "uds.memory_address", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3460
14
        { &hf_uds_memory_size, {
3461
14
            "Memory Size", "uds.memory_size", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3462
14
        { &hf_uds_max_block_len_len, {
3463
14
            "Length of Max Block Length", "uds.max_block_length_length", FT_UINT8, BASE_HEX, NULL, UDS_RD_MAX_BLOCK_LEN_LEN_MASK, NULL, HFILL } },
3464
14
        { &hf_uds_max_block_len, {
3465
14
            "Max Block Length", "uds.max_block_length", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3466
3467
14
        { &hf_uds_dsc_subfunction, {
3468
14
            "SubFunction", "uds.dsc.subfunction", FT_UINT8, BASE_HEX, VALS(uds_dsc_types), UDS_SUBFUNCTION_MASK, NULL, HFILL } },
3469
14
        { &hf_uds_dsc_suppress_pos_rsp_msg_ind, {
3470
14
            "Suppress reply", "uds.dsc.suppress_reply.indication", FT_BOOLEAN, 8, NULL, UDS_SUPPRESS_POS_RSP_MSG_IND_MASK, NULL, HFILL } },
3471
14
        { &hf_uds_dsc_parameter_record, {
3472
14
            "Parameter Record", "uds.dsc.parameter_record", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3473
14
        { &hf_uds_dsc_default_p2_server_timer, {
3474
14
            "Default P2 Server Timer", "uds.dsc.p2_server_time_default", FT_UINT16, BASE_DEC | BASE_UNIT_STRING, UNS(&units_milliseconds), 0x0, NULL, HFILL } },
3475
        /* Header field is actually only 16bit but has to be scaled up by 10x. */
3476
14
        { &hf_uds_dsc_enhanced_p2_server_timer, {
3477
14
            "Enhanced P2 Server Timer", "uds.dsc.p2_server_time_enhanced", FT_UINT32, BASE_DEC | BASE_UNIT_STRING, UNS(&units_milliseconds), 0x0, NULL, HFILL } },
3478
3479
14
        { &hf_uds_er_subfunction, {
3480
14
            "SubFunction", "uds.er.subfunction", FT_UINT8, BASE_HEX, VALS(uds_er_types), 0x0, NULL, HFILL } },
3481
14
        { &hf_uds_er_power_down_time, {
3482
14
            "Power Down Time", "uds.er.power_down_time", FT_UINT8, BASE_DEC | BASE_UNIT_STRING, UNS(&units_seconds), 0x0, NULL, HFILL } },
3483
3484
14
        { &hf_uds_cdtci_group_of_dtc, {
3485
14
            "Group of DTC", "uds.cdtci.group_of_dtc", FT_UINT24, BASE_HEX, VALS(uds_cdtci_group_of_dtc), 0x0, NULL, HFILL } },
3486
14
        { &hf_uds_cdtci_memory_selection, {
3487
14
            "Memory Selection", "uds.cdtci.memory_selection", FT_UINT8, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL } },
3488
3489
14
        { &hf_uds_rdtci_subfunction, {
3490
14
            "SubFunction", "uds.rdtci.subfunction", FT_UINT8, BASE_HEX | BASE_EXT_STRING, VALS_EXT_PTR(&uds_rdtci_types_ext), 0x0, NULL, HFILL } },
3491
14
        { &hf_uds_rdtci_dtc_status_mask, {
3492
14
            "DTC Status Mask", "uds.rdtci.dtc_status_mask", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3493
14
        { &hf_uds_rdtci_dtc_status_mask_tf, {
3494
14
            "(Last) Test Failed", "uds.rdtci.dtc_status_mask.tf", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_TEST_FAILED, NULL, HFILL } },
3495
14
        { &hf_uds_rdtci_dtc_status_mask_tftoc, {
3496
14
            "Test Failed This Operation Cycle", "uds.rdtci.dtc_status_mask.tftoc", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_TEST_FAILED_THIS_OPER_CYCLE, NULL, HFILL } },
3497
14
        { &hf_uds_rdtci_dtc_status_mask_pdtc, {
3498
14
            "Pending DTC", "uds.rdtci.dtc_status_mask.pdtc", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_PENDING_DTC, NULL, HFILL } },
3499
14
        { &hf_uds_rdtci_dtc_status_mask_cdtc, {
3500
14
            "Confirmed DTC", "uds.rdtci.dtc_status_mask.ctdc", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_CONFIRMED_DTC, NULL, HFILL } },
3501
14
        { &hf_uds_rdtci_dtc_status_mask_tncslc, {
3502
14
            "Test Not Completed Since Last Clear", "uds.rdtci.dtc_status_mask.tncslc", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_TEST_NOT_COMPL_SINCE_LAST_CLEAR, NULL, HFILL } },
3503
14
        { &hf_uds_rdtci_dtc_status_mask_tfslc, {
3504
14
            "Test Failed Since Last Clear", "uds.rdtci.dtc_status_mask.tfslc", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_TEST_FAILED_SINCE_LAST_CLEAR, NULL, HFILL } },
3505
14
        { &hf_uds_rdtci_dtc_status_mask_tnctoc, {
3506
14
            "Test Not Completed This Operation Cycle", "uds.rdtci.dtc_status_mask.tnctoc", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_TEST_NOT_COMPL_THIS_OPER_CYCLE, NULL, HFILL } },
3507
14
        { &hf_uds_rdtci_dtc_status_mask_wir, {
3508
14
            "Warning Indicator Requested", "uds.rdtci.dtc_status_mask.wir", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_WARNING_INDICATOR_REQUESTED, NULL, HFILL } },
3509
14
        { &hf_uds_rdtci_dtc_mask_record, {
3510
14
            "DTC Mask Record", "uds.rdtci.dtc_mask_record", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3511
14
        { &hf_uds_rdtci_dtc_snapshot_rec_no, {
3512
14
            "DTC Snapshot Record Number", "uds.rdtci.dtc_snapshot_record_number", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3513
14
        { &hf_uds_rdtci_dtc_stored_data_rec_no, {
3514
14
            "DTC Stored Data Record Number", "uds.rdtci.dtc_stored_data_record_number", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3515
14
        { &hf_uds_rdtci_dtc_ext_data_rec_no, {
3516
14
            "DTC Extended Data Record Number", "uds.rdtci.dtc_extended_data_record_number", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3517
14
        { &hf_uds_rdtci_dtc_severity_mask, {
3518
14
            "DTC Severity Mask", "uds.rdtci.dtc_severity_mask", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3519
14
        { &hf_uds_rdtci_memory_selection, {
3520
14
            "Memory Selection", "uds.rdtci.memory_selection", FT_UINT8, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL } },
3521
14
        { &hf_uds_rdtci_user_def_dtc_snapshot_rec_no, {
3522
14
            "User Defined DTC Snapshot Record Number", "uds.rdtci.user_def_dtc_snapshot_record_number", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3523
14
        { &hf_uds_rdtci_functional_group_id, {
3524
14
            "Functional Group Identifier", "uds.rdtci.functional_group_id", FT_UINT8, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL } },
3525
14
        { &hf_uds_rdtci_dtc_readiness_group_id, {
3526
14
            "DTC Readiness Group Identifier", "uds.rdtci.dtc_readiness_group_id", FT_UINT8, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL } },
3527
14
        { &hf_uds_rdtci_dtc_status_avail, {
3528
14
            "DTC Status Availability Mask", "uds.rdtci.dtc_status_availability_mask", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3529
14
        { &hf_uds_rdtci_dtc_status_avail_tf, {
3530
14
            "Test Failed", "uds.rdtci.dtc_status_avail_mask.tf", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_TEST_FAILED, NULL, HFILL } },
3531
14
        { &hf_uds_rdtci_dtc_status_avail_tftoc, {
3532
14
            "Test Failed This Operation Cycle", "uds.rdtci.dtc_status_avail_mask.tftoc", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_TEST_FAILED_THIS_OPER_CYCLE, NULL, HFILL } },
3533
14
        { &hf_uds_rdtci_dtc_status_avail_pdtc, {
3534
14
            "Pending DTC", "uds.rdtci.dtc_status_avail_mask.pdtc", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_PENDING_DTC, NULL, HFILL } },
3535
14
        { &hf_uds_rdtci_dtc_status_avail_cdtc, {
3536
14
            "Confirmed DTC", "uds.rdtci.dtc_status_avail_mask.ctdc", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_CONFIRMED_DTC, NULL, HFILL } },
3537
14
        { &hf_uds_rdtci_dtc_status_avail_tncslc,{
3538
14
            "Test Not Completed Since Last Clear", "uds.rdtci.dtc_status_avail_mask.tncslc", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_TEST_NOT_COMPL_SINCE_LAST_CLEAR, NULL, HFILL } },
3539
14
        { &hf_uds_rdtci_dtc_status_avail_tfslc, {
3540
14
            "Test Failed Since Last Clear", "uds.rdtci.dtc_status_avail_mask.tfslc", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_TEST_FAILED_SINCE_LAST_CLEAR, NULL, HFILL } },
3541
14
        { &hf_uds_rdtci_dtc_status_avail_tnctoc, {
3542
14
            "Test Not Completed This Operation Cycle", "uds.rdtci.dtc_status_avail_mask.tnctoc", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_TEST_NOT_COMPL_THIS_OPER_CYCLE, NULL, HFILL } },
3543
14
        { &hf_uds_rdtci_dtc_status_avail_wir, {
3544
14
            "Warning Indicator Requested", "uds.rdtci.dtc_status_avail_mask.wir", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_WARNING_INDICATOR_REQUESTED, NULL, HFILL } },
3545
14
        { &hf_uds_rdtci_dtc_id, {
3546
14
            "DTC Identifier", "uds.rdtci.dtc_id", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3547
14
        { &hf_uds_rdtci_dtc_status, {
3548
14
            "DTC Status", "uds.rdtci.dtc_status", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3549
14
        { &hf_uds_rdtci_dtc_status_tf, {
3550
14
            "Test Failed", "uds.rdtci.dtc_status.tf", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_TEST_FAILED, NULL, HFILL } },
3551
14
        { &hf_uds_rdtci_dtc_status_tftoc, {
3552
14
            "Test Failed This Operation Cycle", "uds.rdtci.dtc_status.tftoc", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_TEST_FAILED_THIS_OPER_CYCLE, NULL, HFILL } },
3553
14
        { &hf_uds_rdtci_dtc_status_pdtc, {
3554
14
            "Pending DTC", "uds.rdtci.dtc_status.pdtc", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_PENDING_DTC, NULL, HFILL } },
3555
14
        { &hf_uds_rdtci_dtc_status_cdtc, {
3556
14
            "Confirmed DTC", "uds.rdtci.dtc_status.ctdc", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_CONFIRMED_DTC, NULL, HFILL } },
3557
14
        { &hf_uds_rdtci_dtc_status_tncslc, {
3558
14
            "Test Not Completed Since Last Clear", "uds.rdtci.dtc_status.tncslc", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_TEST_NOT_COMPL_SINCE_LAST_CLEAR, NULL, HFILL } },
3559
14
        { &hf_uds_rdtci_dtc_status_tfslc, {
3560
14
            "Test Failed Since Last Clear", "uds.rdtci.dtc_status.tfslc", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_TEST_FAILED_SINCE_LAST_CLEAR, NULL, HFILL } },
3561
14
        { &hf_uds_rdtci_dtc_status_tnctoc, {
3562
14
            "Test Not Completed This Operation Cycle", "uds.rdtci.dtc_status.tnctoc", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_TEST_NOT_COMPL_THIS_OPER_CYCLE, NULL, HFILL } },
3563
14
        { &hf_uds_rdtci_dtc_status_wir, {
3564
14
            "Warning Indicator Requested", "uds.rdtci.dtc_status.wir", FT_BOOLEAN, 8, NULL, UDS_RDTCI_DTC_STATUS_WARNING_INDICATOR_REQUESTED, NULL, HFILL } },
3565
14
        { &hf_uds_rdtci_dtc_format_id, {
3566
14
            "DTC Format Identifier", "uds.rdtci.dtc_format_id", FT_UINT8, BASE_HEX_DEC, VALS(uds_rdtci_format_id_types), 0x0, NULL, HFILL } },
3567
14
        { &hf_uds_rdtci_dtc_count, {
3568
14
            "DTC Count", "uds.rdtci.dtc_count", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3569
14
        { &hf_uds_rdtci_dtc_snapshot_record_number_of_ids, {
3570
14
            "DTC Snapshot Record Number of IDs", "uds.rdtci.dtc_snapshot_record_number_of_ids", FT_UINT8, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL } },
3571
14
        { &hf_uds_rdtci_dtc_stored_data_record_number_of_ids, {
3572
14
            "DTC Stored Data Record Number of IDs", "uds.rdtci.dtc_stored_data_record_number_of_ids", FT_UINT8, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL } },
3573
14
        { &hf_uds_rdtci_dtc_severity, {
3574
14
            "DTC Severity", "uds.rdtci.dtc_severity", FT_UINT8, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL } },
3575
14
        { &hf_uds_rdtci_dtc_functional_unit, {
3576
14
            "DTC Functional Unit", "uds.rdtci.dtc_functional_unit", FT_UINT8, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL } },
3577
14
        { &hf_uds_rdtci_dtc_fault_detect_counter, {
3578
14
            "DTC Fault Detection Counter", "uds.rdtci.dtc_fault_detection_counter", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3579
14
        { &hf_uds_rdtci_dtc_severity_avail, {
3580
14
            "DTC Severity Availability Mask", "uds.rdtci.dtc_severity_availability_mask", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3581
14
        { &hf_uds_rdtci_record, {
3582
14
            "Record", "uds.rdtci.record", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3583
14
        { &hf_uds_rdtci_record_unparsed, {
3584
14
            "Unparsed Record", "uds.rdtci.record_unparsed", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3585
3586
14
        { &hf_uds_rdbi_data_identifier, {
3587
14
            "Data Identifier", "uds.rdbi.data_identifier", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3588
3589
14
        { &hf_uds_rsdbi_data_identifier, {
3590
14
            "Data Identifier", "uds.rsdbi.data_identifier", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3591
14
        { &hf_uds_rsdbi_scaling_byte, {
3592
14
            "Scaling Byte", "uds.rsdbi.scaling_byte", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3593
14
        { &hf_uds_rsdbi_scaling_byte_data_type, {
3594
14
            "Data Type", "uds.rsdbi.scaling_byte.data_type", FT_UINT8, BASE_HEX, VALS(uds_rsdbi_data_types), 0xF0, NULL, HFILL } },
3595
14
        { &hf_uds_rsdbi_scaling_byte_num_of_bytes, {
3596
14
            "Number of Bytes", "uds.rsdbi.scaling_byte.number_of_Bytes", FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL } },
3597
14
        { &hf_uds_rsdbi_validity_mask, {
3598
14
            "Validity Mask", "uds.rsdbi.scaling_byte_ext.validity_mask", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3599
14
        { &hf_uds_rsdbi_formula_identifier, {
3600
14
            "Formula Identifier", "uds.rsdbi.scaling_byte_ext.formula_identifier", FT_UINT8, BASE_HEX, VALS(uds_rsdbi_formulas), 0x0, NULL, HFILL } },
3601
14
        { &hf_uds_rsdbi_formula_constant, {
3602
14
            "Constant", "uds.rsdbi.scaling_byte_ext.formula_constant", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3603
14
        { &hf_uds_rsdbi_formula_constant_exp, {
3604
14
            "Exponent", "uds.rsdbi.scaling_byte_ext.formulat_constant_exp", FT_UINT16, BASE_HEX, NULL, 0xF000, NULL, HFILL } },
3605
14
        { &hf_uds_rsdbi_formula_constant_mantissa, {
3606
14
            "Constant", "uds.rsdbi.scaling_byte_ext.formulat_constant", FT_UINT16, BASE_HEX, NULL, 0x0FFF, NULL, HFILL } },
3607
14
        { &hf_uds_rsdbi_unit, {
3608
14
            "Unit Identifier", "uds.rsdbi.scaling_byte_ext.unit", FT_UINT8, BASE_HEX | BASE_EXT_STRING, VALS_EXT_PTR(&uds_rsdbi_units_ext), 0x0, NULL, HFILL } },
3609
3610
14
        { &hf_uds_sa_subfunction, {
3611
14
            "SubFunction", "uds.sa.subfunction", FT_UINT8, BASE_CUSTOM, CF_FUNC(uds_sa_subfunction_format), 0x0, NULL, HFILL } },
3612
14
        { &hf_uds_sa_key, {
3613
14
            "Key", "uds.sa.key", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3614
14
        { &hf_uds_sa_seed, {
3615
14
            "Seed", "uds.sa.seed", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3616
3617
14
        { &hf_uds_cc_subfunction_no_suppress, {
3618
14
            "SubFunction (without Suppress)", "uds.cc.subfunction_without_suppress", FT_UINT8, BASE_HEX, VALS(uds_cc_types), UDS_SUBFUNCTION_MASK, NULL, HFILL } },
3619
14
        { &hf_uds_cc_comm_type_and_subnet_number, {
3620
14
            "Communication Type/Subnet Number", "uds.cc.comm_type_and_subnet_number", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3621
14
        { &hf_uds_cc_communication_type, {
3622
14
            "Communication Type", "uds.cc.communication_type", FT_UINT8, BASE_HEX, VALS(uds_cc_comm_types), UDS_CC_COMM_TYPE_COMM_TYPE_MASK, NULL, HFILL } },
3623
14
        { &hf_uds_cc_subnet_number, {
3624
14
            "Subnet Number", "uds.cc.subnet_number", FT_UINT8, BASE_HEX, VALS(uds_cc_subnet_number_types), UDS_CC_COMM_TYPE_SUBNET_NUMBER_MASK, NULL, HFILL } },
3625
14
        { &hf_uds_cc_node_identifier_number, {
3626
14
            "Node Identifier Number", "uds.cc.node_identifier_number", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL } },
3627
3628
14
        { &hf_uds_ars_subfunction_no_suppress, {
3629
14
            "SubFunction (without Suppress)", "uds.ars.subfunction_without_suppress", FT_UINT8, BASE_HEX, VALS(uds_ars_types), UDS_SUBFUNCTION_MASK, NULL, HFILL } },
3630
14
        { &hf_uds_ars_comm_config, {
3631
14
            "Communication Configuration", "uds.ars.communication_configuration", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3632
14
        { &hf_uds_ars_length_of_cert_client, {
3633
14
            "Length of Certificate Client", "uds.ars.length_of_certificate_client", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3634
14
        { &hf_uds_ars_cert_client, {
3635
14
            "Certificate Client", "uds.ars.certificate_client", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3636
14
        { &hf_uds_ars_length_of_cert_server, {
3637
14
            "Length of Certificate Server", "uds.ars.length_of_certificate_server", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3638
14
        { &hf_uds_ars_cert_server, {
3639
14
            "Certificate Server", "uds.ars.certificate_server", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3640
14
        { &hf_uds_ars_length_of_challenge_client, {
3641
14
            "Length of Challenge Client", "uds.ars.length_of_challenge_client", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3642
14
        { &hf_uds_ars_challenge_client, {
3643
14
            "Challenge Client", "uds.ars.challenge_client", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3644
14
        { &hf_uds_ars_length_of_challenge_server, {
3645
14
            "Length of Challenge Server", "uds.ars.length_of_challenge_server", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3646
14
        { &hf_uds_ars_challenge_server, {
3647
14
            "Challenge Server", "uds.ars.challenge_server", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3648
14
        { &hf_uds_ars_length_of_proof_of_ownership_client, {
3649
14
            "Length of Proof of Ownership Client", "uds.ars.length_of_proof_of_ownership_client", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3650
14
        { &hf_uds_ars_proof_of_ownership_client, {
3651
14
            "Proof of Ownership Client", "uds.ars.proof_of_ownership_client", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3652
14
        { &hf_uds_ars_length_of_proof_of_ownership_server, {
3653
14
            "Length of Proof of Ownership Server", "uds.ars.length_of_proof_of_ownership_server", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3654
14
        { &hf_uds_ars_proof_of_ownership_server, {
3655
14
            "Proof of Ownership Server", "uds.ars.proof_of_ownership_server", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3656
14
        { &hf_uds_ars_length_of_ephemeral_public_key_client, {
3657
14
            "Length of Ephemeral Public Key Client", "uds.ars.length_of_ephemeral_public_key_client", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3658
14
        { &hf_uds_ars_ephemeral_public_key_client, {
3659
14
            "Ephemeral Public Key Client", "uds.ars.ephemeral_public_key_client", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3660
14
        { &hf_uds_ars_length_of_ephemeral_public_key_server, {
3661
14
            "Length of Ephemeral Public Key Server", "uds.ars.length_of_ephemeral_public_key_server", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3662
14
        { &hf_uds_ars_ephemeral_public_key_server, {
3663
14
            "Ephemeral Public Key Server", "uds.ars.ephemeral_public_key_server", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3664
14
        { &hf_uds_ars_cert_eval_id, {
3665
14
            "Certificate Evaluation ID", "uds.ars.certificate_evaluation_id", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3666
14
        { &hf_uds_ars_length_of_cert_data, {
3667
14
            "Length of Certificate Data", "uds.ars.length_of_certificate_data", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3668
14
        { &hf_uds_ars_cert_data, {
3669
14
            "Certificate Data", "uds.ars.certificate_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3670
14
        { &hf_uds_ars_algo_indicator, {
3671
14
            "Algorithm Indicator", "uds.ars.algorithm_indicator", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3672
14
        { &hf_uds_ars_length_of_additional_parameter, {
3673
14
            "Length of Additional Parameter", "uds.ars.length_of_additional_parameter", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3674
14
        { &hf_uds_ars_additional_parameter, {
3675
14
            "Additional Parameter", "uds.ars.additional_parameter", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3676
14
        { &hf_uds_ars_length_of_needed_additional_parameter, {
3677
14
            "Length of Needed Additional Parameter", "uds.ars.length_of_needed_additional_parameter", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3678
14
        { &hf_uds_ars_needed_additional_parameter, {
3679
14
            "Needed Additional Parameter", "uds.ars.needed_additional_parameter", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3680
14
        { &hf_uds_ars_auth_ret_param, {
3681
14
            "Authentication Return Parameter", "uds.ars.authentication_return_parameter", FT_UINT8, BASE_HEX, VALS(uds_ars_auth_ret_types), 0x0, NULL, HFILL } },
3682
14
        { &hf_uds_ars_length_of_session_key_info, {
3683
14
            "Length of Session Key Info", "uds.ars.length_of_session_key_info", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3684
14
        { &hf_uds_ars_session_key_info, {
3685
14
            "Session Key Info", "uds.ars.session_key_info", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3686
3687
14
        { &hf_uds_signedCertificate, {
3688
14
            "signedCertificate", "uds.signedCertificate_element", FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL } },
3689
3690
14
        { &hf_uds_rdbpi_transmission_mode, {
3691
14
            "Transmission Mode", "uds.rdbpi.transmission_mode", FT_UINT8, BASE_HEX, VALS(uds_rdbpi_transmission_mode), 0x0, NULL, HFILL } },
3692
14
        { &hf_uds_rdbpi_periodic_data_identifier, {
3693
14
            "Periodic Data Identifier", "uds.rdbpi.periodic_data_identifier", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3694
3695
14
        { &hf_uds_dddi_subfunction_no_suppress, {
3696
14
            "SubFunction (without Suppress)", "uds.dddi.subfunction_without_suppress", FT_UINT8, BASE_HEX, VALS(uds_dddi_types), UDS_SUBFUNCTION_MASK, NULL, HFILL } },
3697
14
        { &hf_uds_dddi_dyn_defined_data_identifier, {
3698
14
            "Dynamically Defined Data Identifier", "uds.dddi.dynamically_defined_data_identifier", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3699
14
        { &hf_uds_dddi_source_data_identifier, {
3700
14
            "Source Data Identifier", "uds.dddi.source_data_identifier", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3701
14
        { &hf_uds_dddi_position_in_source_data_record, {
3702
14
            "Position in Source Data Record", "uds.dddi.position_in_source_data_record", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3703
14
        { &hf_uds_dddi_memory_size, {
3704
14
            "Memory Size", "uds.dddi.memory_size", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3705
3706
14
        { &hf_uds_wdbi_data_identifier, {
3707
14
            "Data Identifier", "uds.wdbi.data_identifier", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3708
3709
14
        { &hf_uds_iocbi_data_identifier, {
3710
14
            "Data Identifier", "uds.iocbi.data_identifier", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3711
14
        { &hf_uds_iocbi_parameter, {
3712
14
            "Parameter", "uds.iocbi.parameter", FT_UINT8, BASE_HEX, VALS(uds_iocbi_parameters), 0x0, NULL, HFILL } },
3713
14
        { &hf_uds_iocbi_state, {
3714
14
            "State", "uds.iocbi.state", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3715
3716
14
        { &hf_uds_rc_subfunction, {
3717
14
            "SubFunction", "uds.rc.subfunction", FT_UINT8, BASE_HEX, VALS(uds_rc_types), 0x0, NULL, HFILL } },
3718
14
        { &hf_uds_rc_identifier, {
3719
14
            "Identifier", "uds.rc.identifier", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3720
14
        { &hf_uds_rc_option_record, {
3721
14
            "Option record", "uds.rc.option_record", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3722
14
        { &hf_uds_rc_info, {
3723
14
            "Info", "uds.rc.info", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3724
14
        { &hf_uds_rc_status_record, {
3725
14
            "Status Record", "uds.rc.status_record", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3726
3727
14
        { &hf_uds_td_sequence_counter, {
3728
14
            "Block Sequence Counter", "uds.td.block_sequence_counter", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3729
14
        { &hf_uds_td_record_data, {
3730
14
            "Parameter Record", "uds.td.parameter_record", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3731
3732
14
        { &hf_uds_rte_record_data, {
3733
14
            "Parameter Record", "uds.rte.parameter_record", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3734
3735
14
        { &hf_uds_rft_mode_of_operation, {
3736
14
            "Mode of Operation", "uds.rft.mode_of_operation", FT_UINT8, BASE_HEX, VALS(uds_rft_mode_types), 0x0, NULL, HFILL } },
3737
14
        { &hf_uds_rft_length_of_file_path_and_name, {
3738
14
            "Length of File Path and Name", "uds.rft.length_of_file_path_and_name", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3739
14
        { &hf_uds_rft_file_path_and_name, {
3740
14
            "File Path and Name", "uds.rft.file_path_and_name", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3741
14
        { &hf_uds_rft_file_size_param_length, {
3742
14
            "File Size Parameter Length", "uds.rft.file_size_parameter_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3743
14
        { &hf_uds_rft_file_size_uncompressed, {
3744
14
            "File Size Uncompressed", "uds.rft.file_size_uncompressed", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3745
14
        { &hf_uds_rft_file_size_compressed, {
3746
14
            "File Size Compressed", "uds.rft.file_size_compressed", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3747
14
        { &hf_uds_rft_length_format_identifier, {
3748
14
            "Length Format Identifier", "uds.rft.length_format_identifier", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3749
14
        { &hf_uds_rft_max_num_of_block_length, {
3750
14
            "Max Number of Block Length", "uds.rft.max_number_of_block_length", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3751
14
        { &hf_uds_rft_file_size_or_dir_info_param_length, {
3752
14
            "File Size or Dir Info Parameter Length", "uds.rft.file_size_or_dir_info_parameter_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3753
14
        { &hf_uds_rft_file_size_uncompressed_or_dir_info_length, {
3754
14
            "File Size Uncompressed or Dir Info Length", "uds.rft.file_size_uncompressed_or_dir_info_length", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3755
14
        { &hf_uds_rft_file_position, {
3756
14
            "File Position", "uds.rft.file_position", FT_UINT64, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL } },
3757
3758
14
        { &hf_uds_tp_subfunction_no_suppress, {
3759
14
            "SubFunction (without Suppress)", "uds.tp.subfunction_without_suppress", FT_UINT8, BASE_HEX, NULL, UDS_SUBFUNCTION_MASK, NULL, HFILL } },
3760
3761
14
        { &hf_uds_err_sid,  {
3762
14
            "Service Identifier", "uds.err.sid", FT_UINT8, BASE_HEX | BASE_EXT_STRING, VALS_EXT_PTR(&uds_services_ext), 0x0, NULL, HFILL } },
3763
14
        { &hf_uds_err_code, {
3764
14
            "Code", "uds.err.code",  FT_UINT8, BASE_HEX | BASE_EXT_STRING, VALS_EXT_PTR(&uds_response_codes_ext), 0x0, NULL, HFILL }  },
3765
3766
14
        { &hf_uds_sdt_administrative_param, {
3767
14
            "Administrative Parameter", "uds.sdt.admin_param",  FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3768
14
        { &hf_uds_sdt_administrative_param_req, {
3769
14
            "Request message", "uds.sdt.admin_param.request", FT_BOOLEAN, 16, NULL, UDS_SDT_ADMIN_PARAM_REQ, NULL, HFILL } },
3770
14
        { &hf_uds_sdt_administrative_param_pre_estab_key, {
3771
14
            "Pre-established key is used", "uds.sdt.admin_param.pre_estab_key", FT_BOOLEAN, 16, NULL, UDS_SDT_ADMIN_PARAM_PRE_ESTABL_KEY, NULL, HFILL } },
3772
14
        { &hf_uds_sdt_administrative_param_encrypted, {
3773
14
            "Message is encrypted", "uds.sdt.admin_param.encrypted", FT_BOOLEAN, 16, NULL, UDS_SDT_ADMIN_PARAM_ENCRYPTED, NULL, HFILL } },
3774
14
        { &hf_uds_sdt_administrative_param_signed, {
3775
14
            "Message is signed", "uds.sdt.admin_param.signed", FT_BOOLEAN, 16, NULL, UDS_SDT_ADMIN_PARAM_SIGNED, NULL, HFILL } },
3776
14
        { &hf_uds_sdt_administrative_param_resp_sign_req, {
3777
14
            "Signature on the response is requested", "uds.sdt.admin_param.resp_sign_req", FT_BOOLEAN, 16, NULL, UDS_SDT_ADMIN_PARAM_SIGN_ON_RESP_REQ, NULL, HFILL } },
3778
14
        { &hf_uds_sdt_signature_encryption_calculation, {
3779
14
            "Signature/Encryption Calculation", "uds.sdt.signature_encryption_calculation",  FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3780
14
        { &hf_uds_sdt_signature_length, {
3781
14
            "Signature/MAC Length", "uds.sdt.signature_length",  FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3782
14
        { &hf_uds_sdt_anti_replay_counter, {
3783
14
            "Anti-replay Counter", "uds.sdt.anti_replay_counter",  FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
3784
14
        { &hf_uds_sdt_encapsulated_message, {
3785
14
            "Encapsulated Message", "uds.sdt.encapsulated_message",  FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3786
14
        { &hf_uds_sdt_encapsulated_message_sid, {
3787
14
            "Service Identifier", "uds.sdt.encapsulated_message.sid",  FT_UINT8, BASE_HEX | BASE_EXT_STRING, VALS_EXT_PTR(&uds_services_ext), UDS_SID_MASK, NULL, HFILL } },
3788
14
        { &hf_uds_sdt_encapsulated_message_sid_reply, {
3789
14
            "Reply Flag", "uds.sdt.encapsulated_message.reply", FT_UINT8, BASE_HEX, NULL, UDS_REPLY_MASK, NULL, HFILL } },
3790
14
        { &hf_uds_sdt_signature_mac, {
3791
14
            "Signature/MAC", "uds.sdt.signature_mac",  FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3792
3793
14
        { &hf_uds_cdtcs_subfunction, {
3794
14
            "SubFunction", "uds.cdtcs.subfunction", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3795
14
        { &hf_uds_cdtcs_subfunction_no_suppress, {
3796
14
            "DTC Setting Type", "uds.cdtcs.subfunction_without_suppress", FT_UINT8, BASE_HEX, VALS(uds_cdtcs_types), UDS_SUBFUNCTION_MASK, NULL, HFILL } },
3797
14
        { &hf_uds_cdtcs_subfunction_pos_rsp_msg_ind, {
3798
14
            "Suppress reply", "uds.cdtcs.suppress_reply", FT_BOOLEAN, 8, NULL, UDS_SUPPRESS_POS_RSP_MSG_IND_MASK, NULL, HFILL } },
3799
14
        { &hf_uds_cdtcs_option_record, {
3800
14
            "Option Record", "uds.cdtcs.option_record", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3801
14
        { &hf_uds_cdtcs_type, {
3802
14
            "DTC Setting Type", "uds.cdtcs.dtc_setting_type", FT_UINT8, BASE_HEX, VALS(uds_cdtcs_types), 0x0, NULL, HFILL } },
3803
3804
14
        { &hf_uds_lc_subfunction, {
3805
14
            "SubFunction", "uds.lc.subfunction", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3806
14
        { &hf_uds_lc_subfunction_no_suppress, {
3807
14
            "SubFunction (without Suppress)", "uds.lc.subfunction_without_suppress", FT_UINT8, BASE_HEX, VALS(uds_lc_types), UDS_SUBFUNCTION_MASK, NULL, HFILL } },
3808
14
        { &hf_uds_lc_subfunction_pos_rsp_msg_ind, {
3809
14
            "Suppress reply", "uds.lc.suppress_reply", FT_BOOLEAN, 8, NULL, UDS_SUPPRESS_POS_RSP_MSG_IND_MASK, NULL, HFILL } },
3810
14
        { &hf_uds_lc_control_mode_id, {
3811
14
            "Link Control Mode Identifier", "uds.lc.link_control_mode_identifier", FT_UINT8, BASE_HEX, VALS(uds_lc_lcmi_types), 0x0, NULL, HFILL } },
3812
14
        { &hf_uds_lc_link_record, {
3813
14
            "Link Record", "uds.lc.link_record", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3814
3815
14
        { &hf_uds_did_reply_f186_diag_session, {
3816
14
            "Diagnostic Session", "uds.did_f186.diagnostic_session", FT_UINT8, BASE_HEX, VALS(uds_dsc_types), 0x0, NULL, HFILL } },
3817
14
        { &hf_uds_did_reply_f190_vin, {
3818
14
            "VIN", "uds.did_f190.vin", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3819
14
        { &hf_uds_did_reply_ff00_version, {
3820
14
            "Version", "uds.did_ff00.version", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
3821
14
        { &hf_uds_did_reply_ff01_dlc_support, {
3822
14
            "DLC Supports", "uds.did_ff01.dlc_supports", FT_UINT8, BASE_HEX, VALS(uds_did_resrvdcpadlc_types), 0x0, NULL, HFILL } },
3823
3824
14
        { &hf_uds_roe_subfunction, {
3825
14
            "SubFunction", "uds.roe.subfunction", FT_UINT8, BASE_HEX, VALS( uds_roe_types), UDS_ROE_SUBFUNC_MASK, NULL, HFILL }},
3826
14
        { &hf_uds_roe_store_flag, {
3827
14
            "Store Flag", "uds.roe.storeflag", FT_UINT8, BASE_HEX, 0, UDS_ROE_STORE_MASK, NULL, HFILL }},
3828
14
        { &hf_uds_roe_window_time, {
3829
14
            "EventWindowsTime", "uds.roe.window_time", FT_UINT8, BASE_HEX, VALS( uds_roe_windowtime_types), 0x0, NULL, HFILL}},
3830
14
        { &hf_uds_roe_NOIE, {
3831
14
            "Number of identified Events", "uds.roe.noie", FT_UINT8, BASE_DEC, 0, 0, NULL, HFILL}},
3832
14
        { &hf_uds_roe_EVOAE, {
3833
14
            "Event Type of active Event", "uds.roe.evoae", FT_UINT8, BASE_DEC, VALS( uds_roe_types), 0, NULL, HFILL}},
3834
14
        { &hf_uds_roe_identifier, {
3835
14
            "Identifier", "uds.roe.identifier", FT_UINT16, BASE_HEX, 0, 0, NULL, HFILL}},
3836
14
        { &hf_uds_roe_did, {
3837
14
            "DID", "uds.roe.did", FT_UINT16, BASE_HEX, 0, 0, NULL, HFILL}},
3838
14
        { &hf_uds_roe_comparison, {
3839
14
            "Comparison logic", "uds.roe.ocov.logic", FT_UINT8, BASE_DEC, VALS( uds_roe_ocov_logic_types), 0, NULL, HFILL }},
3840
14
        { &hf_uds_roe_comparison_value, {
3841
14
            "Comparison Value", "uds.roe.ocov.value", FT_UINT32, BASE_DEC_HEX, 0, 0, NULL, HFILL }},
3842
14
        { &hf_uds_roe_hysteresis_value, {
3843
14
            "hysteresis value[%]", "uds.roe.ocov.hysteresis", FT_UINT8, BASE_DEC, 0, 0, NULL, HFILL}},
3844
14
        { &hf_uds_roe_localization, {
3845
14
            "Localization", "uds.roe.ocov.localisation", FT_UINT16, BASE_HEX, 0, 0, NULL, HFILL}},
3846
14
        { &hf_uds_roe_localization_sign, {
3847
14
            "Localization sign", "uds.roe.ocov.localisation_sign", FT_UINT16, BASE_HEX, VALS( uds_roe_localisation_sign_types), UDS_ROE_OCOV_LOCAL_SIGN_MASK, NULL, HFILL}},
3848
14
        { &hf_uds_roe_localization_length, {
3849
14
            "Localization length", "uds.roe.ocov.localisation_len", FT_UINT16, BASE_HEX, 0, UDS_ROE_OCOV_LOCAL_LEN_MASK, NULL, HFILL}},
3850
14
        { &hf_uds_roe_localization_offset, {
3851
14
            "Localization offset", "uds.roe.ocov.localisation_offset", FT_UINT16, BASE_HEX, 0, UDS_ROE_OCOV_LOCAL_OFFSET_MASK, NULL, HFILL}},
3852
14
        { &hf_uds_roe_dtc_status_mask, {
3853
14
            "DTCStatusMask", "uds.roe.dtcstatusmask", FT_UINT8, BASE_HEX, 0, 0, NULL, HFILL}},
3854
14
        { &hf_uds_roe_dtc_status_mask_TF, {
3855
14
            "testFailed", "uds.roe.dtcstatusmask.tf", FT_UINT8, BASE_HEX, NULL, UDS_ROE_DTC_STATUS_MASK_TF, NULL, HFILL }},
3856
14
        { &hf_uds_roe_dtc_status_mask_TFTOC, {
3857
14
            "testFailedThisOperationCycle", "uds.roe.dtcstatusmask.fttoc", FT_UINT8, BASE_HEX, NULL, UDS_ROE_DTC_STATUS_MASK_TFTOC, NULL, HFILL }},
3858
14
        { &hf_uds_roe_dtc_status_mask_PDTC, {
3859
14
            "pendingDTC", "uds.roe.dtcstatusmask.dptc", FT_UINT8, BASE_HEX, NULL, UDS_ROE_DTC_STATUS_MASK_PDTC, NULL, HFILL }},
3860
14
        { &hf_uds_roe_dtc_status_mask_CDTC, {
3861
14
            "confirmedDTC", "uds.roe.dtcstatusmask.cdtc", FT_UINT8, BASE_HEX, NULL, UDS_ROE_DTC_STATUS_MASK_CDTC, NULL, HFILL }},
3862
14
        { &hf_uds_roe_dtc_status_mask_TNCSLC, {
3863
14
            "testNotCompletedSinceLastClear", "uds.roe.dtcstatusmask.tncslc", FT_UINT8, BASE_HEX, NULL, UDS_ROE_DTC_STATUS_MASK_TNCSLC, NULL, HFILL }},
3864
14
        { &hf_uds_roe_dtc_status_mask_TFSLC, {
3865
14
            "testFailedSinceLastClear", "uds.roe.dtcstatusmask.tfslc", FT_UINT8, BASE_HEX, NULL, UDS_ROE_DTC_STATUS_MASK_TFSLC, NULL, HFILL }},
3866
14
        { &hf_uds_roe_dtc_status_mask_TNCTOC, {
3867
14
            "testNotCompletedThisOperationCycle", "uds.roe.dtcstatusmask.tnctoc", FT_UINT8, BASE_HEX, NULL, UDS_ROE_DTC_STATUS_MASK_TNCTOC, NULL, HFILL }},
3868
14
        { &hf_uds_roe_dtc_status_mask_WIR, {
3869
14
            "warningIndicatorRequested", "uds.roe.dtcstatusmask.wir", FT_UINT8, BASE_HEX, NULL, UDS_ROE_DTC_STATUS_MASK_WIR, NULL, HFILL }},
3870
14
        { &hf_uds_unparsed_bytes, {
3871
14
            "Unparsed Bytes", "uds.unparsed_bytes", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
3872
14
    };
3873
3874
14
    uat_t *uds_routine_ids_uat;
3875
14
    uat_t *uds_data_ids_uat;
3876
14
    uat_t *uds_dtc_ids_uat;
3877
14
    uat_t *uds_address_uat;
3878
3879
    /* Setup protocol subtree array */
3880
14
    static int *ett[] = {
3881
14
        &ett_uds,
3882
14
        &ett_uds_subfunction,
3883
14
        &ett_uds_dtc_status_entry,
3884
14
        &ett_uds_dtc_status_bits,
3885
14
        &ett_uds_dtc_snapshot_entry,
3886
14
        &ett_uds_dtc_counter_entry,
3887
14
        &ett_uds_dsc_parameter_record,
3888
14
        &ett_uds_rsdbi_scaling_byte,
3889
14
        &ett_uds_rsdbi_formula_constant,
3890
14
        &ett_uds_cc_communication_type,
3891
14
        &ett_uds_ars_certificate,
3892
14
        &ett_uds_ars_algo_indicator,
3893
14
        &ett_uds_dddi_entry,
3894
14
        &ett_uds_sdt_admin_param,
3895
14
        &ett_uds_sdt_encap_message,
3896
14
        &ett_uds_roe_dtc_status_mask,
3897
14
        &ett_uds_roe_localization,
3898
14
    };
3899
3900
14
    proto_uds = proto_register_protocol ("Unified Diagnostic Services", "UDS", "uds");
3901
3902
14
    proto_register_field_array(proto_uds, hf, array_length(hf));
3903
14
    proto_register_subtree_array(ett, array_length(ett));
3904
3905
14
    uds_handle = register_dissector("uds", dissect_uds_no_data, proto_uds);
3906
14
    uds_handle_doip = register_dissector("uds_over_doip", dissect_uds_doip, proto_uds);
3907
14
    uds_handle_hsfz = register_dissector("uds_over_hsfz", dissect_uds_hsfz, proto_uds);
3908
14
    uds_handle_iso10681 = register_dissector("uds_over_iso10681", dissect_uds_iso10681, proto_uds);
3909
14
    uds_handle_iso15765 = register_dissector("uds_over_iso15765", dissect_uds_iso15765, proto_uds);
3910
3911
    /* Register preferences */
3912
14
    uds_module = prefs_register_protocol(proto_uds, NULL);
3913
3914
    /* UATs for user_data fields */
3915
14
    static uat_field_t uds_routine_id_uat_fields[] = {
3916
14
        UAT_FLD_HEX(uds_uat_routine_ids, address, "Address", "Address (16bit hex without leading 0x, 0xffffffff for 'any')"),
3917
14
        UAT_FLD_HEX(uds_uat_routine_ids, id, "Routine ID", "Routine Identifier (16bit hex without leading 0x)"),
3918
14
        UAT_FLD_CSTRING(uds_uat_routine_ids, name, "Routine Name", "Name of the Routine ID (string)"),
3919
14
        UAT_END_FIELDS
3920
14
    };
3921
3922
14
    uds_routine_ids_uat = uat_new("UDS Routine Identifier List",
3923
14
        sizeof(generic_addr_id_string_t),           /* record size           */
3924
14
        DATAFILE_UDS_ROUTINE_IDS,                   /* filename              */
3925
14
        true,                                       /* from profile          */
3926
14
        (void**)&uds_uat_routine_ids,               /* data_ptr              */
3927
14
        &uds_uat_routine_id_num,                    /* numitems_ptr          */
3928
14
        UAT_AFFECTS_DISSECTION,                     /* but not fields        */
3929
14
        NULL,                                       /* help                  */
3930
14
        copy_generic_one_id_string_cb,              /* copy callback         */
3931
14
        update_generic_addr_16bit_id_16bit,         /* update callback       */
3932
14
        free_generic_one_id_string_cb,              /* free callback         */
3933
14
        post_update_uds_routine_cb,                 /* post update callback  */
3934
14
        reset_update_uds_routine_cb,                /* reset callback        */
3935
14
        uds_routine_id_uat_fields                   /* UAT field definitions */
3936
14
    );
3937
3938
14
    prefs_register_uat_preference(uds_module, "_uds_routine_id_list", "UDS Routine Identifier List",
3939
14
        "A table to define names of UDS Routines", uds_routine_ids_uat);
3940
3941
3942
14
    static uat_field_t uds_data_id_uat_fields[] = {
3943
14
        UAT_FLD_HEX(uds_uat_data_ids, address, "Address", "Address (16bit hex without leading 0x, 0xffffffff for 'any')"),
3944
14
        UAT_FLD_HEX(uds_uat_data_ids, id, "Data ID", "Data Identifier (16bit hex without leading 0x)"),
3945
14
        UAT_FLD_CSTRING(uds_uat_data_ids, name, "Data Name", "Name of the Data ID (string)"),
3946
14
        UAT_END_FIELDS
3947
14
    };
3948
3949
14
    uds_data_ids_uat = uat_new("UDS Data Identifier List",
3950
14
        sizeof(generic_addr_id_string_t),           /* record size           */
3951
14
        DATAFILE_UDS_DATA_IDS,                      /* filename              */
3952
14
        true,                                       /* from profile          */
3953
14
        (void**)&uds_uat_data_ids,                  /* data_ptr              */
3954
14
        &uds_uat_data_id_num,                       /* numitems_ptr          */
3955
14
        UAT_AFFECTS_DISSECTION,                     /* but not fields        */
3956
14
        NULL,                                       /* help                  */
3957
14
        copy_generic_one_id_string_cb,              /* copy callback         */
3958
14
        update_generic_addr_16bit_id_16bit,         /* update callback       */
3959
14
        free_generic_one_id_string_cb,              /* free callback         */
3960
14
        post_update_uds_data_cb,                    /* post update callback  */
3961
14
        reset_update_uds_data_cb,                   /* reset callback        */
3962
14
        uds_data_id_uat_fields                      /* UAT field definitions */
3963
14
    );
3964
3965
14
    prefs_register_uat_preference(uds_module, "_uds_data_id_list", "UDS Data Identifier List",
3966
14
        "A table to define names of UDS Data Identifier", uds_data_ids_uat);
3967
3968
3969
14
    static uat_field_t uds_dtc_id_uat_fields[] = {
3970
14
        UAT_FLD_HEX(uds_uat_dtc_ids, address, "Address", "Address (16bit hex without leading 0x, 0xffffffff for 'any')"),
3971
14
        UAT_FLD_HEX(uds_uat_dtc_ids, id, "DTC ID", "Data Identifier (24bit hex without leading 0x)"),
3972
14
        UAT_FLD_CSTRING(uds_uat_dtc_ids, name, "DTC Name", "Name of the Data ID (string)"),
3973
14
        UAT_END_FIELDS
3974
14
    };
3975
3976
14
    uds_dtc_ids_uat = uat_new("UDS DTC Identifier List",
3977
14
        sizeof(generic_addr_id_string_t),           /* record size           */
3978
14
        DATAFILE_UDS_DTC_IDS,                       /* filename              */
3979
14
        true,                                       /* from profile          */
3980
14
        (void**)&uds_uat_dtc_ids,                   /* data_ptr              */
3981
14
        &uds_uat_dtc_id_num,                        /* numitems_ptr          */
3982
14
        UAT_AFFECTS_DISSECTION,                     /* but not fields        */
3983
14
        NULL,                                       /* help                  */
3984
14
        copy_generic_one_id_string_cb,              /* copy callback         */
3985
14
        update_generic_addr_16bit_id_24bit,         /* update callback       */
3986
14
        free_generic_one_id_string_cb,              /* free callback         */
3987
14
        post_update_uds_dtc_cb,                     /* post update callback  */
3988
14
        reset_update_uds_dtc_cb,                    /* reset callback        */
3989
14
        uds_dtc_id_uat_fields                       /* UAT field definitions */
3990
14
    );
3991
3992
14
    prefs_register_uat_preference(uds_module, "_uds_dtc_id_list", "UDS DTC Identifier List",
3993
14
        "A table to define names of UDS DTC Identifier", uds_dtc_ids_uat);
3994
3995
3996
14
    static uat_field_t uds_address_name_uat_fields[] = {
3997
14
        UAT_FLD_HEX(uds_uat_addresses, address, "Address", "Address (32bit hex without leading 0x)"),
3998
14
        UAT_FLD_CSTRING(uds_uat_addresses, name, "Name", "Name of the Address (string)"),
3999
14
        UAT_END_FIELDS
4000
14
    };
4001
4002
14
    uds_address_uat = uat_new("UDS Addresses",
4003
14
        sizeof(address_string_t),                   /* record size           */
4004
14
        DATAFILE_UDS_ADDRESSES,                     /* filename              */
4005
14
        true,                                       /* from profile          */
4006
14
        (void**)&uds_uat_addresses,                 /* data_ptr              */
4007
14
        &uds_uat_addresses_num,                     /* numitems_ptr          */
4008
14
        UAT_AFFECTS_DISSECTION,                     /* but not fields        */
4009
14
        NULL,                                       /* help                  */
4010
14
        copy_address_string_cb,                     /* copy callback         */
4011
14
        update_address_string_cb,                   /* update callback       */
4012
14
        free_address_string_cb,                     /* free callback         */
4013
14
        post_update_uds_address_cb,                 /* post update callback  */
4014
14
        reset_uds_address_cb,                       /* reset callback        */
4015
14
        uds_address_name_uat_fields                 /* UAT field definitions */
4016
14
    );
4017
4018
14
    prefs_register_uat_preference(uds_module, "_uds_address_list", "UDS Address List",
4019
14
        "A table to define names of UDS Addresses", uds_address_uat);
4020
4021
14
    prefs_register_bool_preference(uds_module, "dissect_small_sids_with_obd_ii",
4022
14
        "Dissect Service Identifiers smaller 0x10 with OBD II Dissector?",
4023
14
        "Dissect Service Identifiers smaller 0x10 with OBD II Dissector?",
4024
14
        &uds_dissect_small_sids_with_obd_ii);
4025
4026
14
    prefs_register_enum_preference(uds_module, "cert_decode_strategy",
4027
14
        "Certificate Decoding Strategy",
4028
14
        "Decide how the certificate bytes are decoded",
4029
14
        &uds_certificate_decoding_config, certificate_decoding_vals, false);
4030
4031
14
    prefs_register_bool_preference(uds_module, "do_clear_info_col",
4032
14
        "Show only UDS in the Info Column",
4033
14
        "Show only UDS in the Info Column?",
4034
14
        &uds_clear_info_col);
4035
4036
14
    heur_subdissector_list = register_heur_dissector_list_with_description("uds", "UDS RDBI data", proto_uds);
4037
14
}
4038
4039
void
4040
proto_reg_handoff_uds(void)
4041
14
{
4042
14
    dissector_add_for_decode_as("iso10681.subdissector", uds_handle_iso10681);
4043
14
    dissector_add_for_decode_as("iso15765.subdissector", uds_handle_iso15765);
4044
14
    obd_ii_handle = find_dissector("obd-ii-uds");
4045
14
}
4046
4047
/*
4048
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
4049
 *
4050
 * Local variables:
4051
 * c-basic-offset: 4
4052
 * tab-width: 8
4053
 * indent-tabs-mode: nil
4054
 * End:
4055
 *
4056
 * vi: set shiftwidth=4 tabstop=8 expandtab:
4057
 * :indentSize=4:tabSize=8:noTabs=true:
4058
 */