Coverage Report

Created: 2026-07-12 07:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-adwin.c
Line
Count
Source
1
/* packet-adwin.c
2
 * Routines for ADwin protocol dissection
3
 * Copyright 2010, Thomas Boehne <TBoehne[AT]ADwin.de>
4
 *
5
 * Wireshark - Network traffic analyzer
6
 * By Gerald Combs <gerald@wireshark.org>
7
 * Copyright 1998 Gerald Combs
8
 *
9
 * SPDX-License-Identifier: GPL-2.0-or-later
10
 */
11
12
#include "config.h"
13
14
/* includes needed for wireshark */
15
#include <epan/packet.h>
16
#include <epan/prefs.h>
17
#include <epan/conversation.h>
18
void proto_reg_handoff_adwin(void);
19
void proto_register_adwin(void);
20
static dissector_handle_t adwin_handle;
21
22
15
#define ADWIN_COMM_PORT 6543 /* Not IANA registered */
23
24
/* lengths of valid packet structures */
25
16
#define UDPH1_OLD_LENGTH              52
26
14
#define UDPH1_NEW_LENGTH              56
27
10
#define UDPR1_LENGTH                  32
28
10
#define UDPH2_LENGTH                 412 /* AFAIK: unused */
29
10
#define UDPR2_LENGTH                1008
30
10
#define UDPR3_LENGTH                1408
31
10
#define UDPR4_LENGTH                1416
32
10
#define GetDataSHPacket_LENGTH      1356
33
4
#define GetDataSHRequest_LENGTH       64
34
35
/* operating systems */
36
#define OS_WINDOWS                  0x00
37
#define OS_LINUX                    0x10
38
#define OS_JAVA                     0x20
39
#define OS_DOT_NET                  0x40
40
#define OS_GENERIC                  0x80
41
static const value_string osys_mapping[] = {
42
  { OS_WINDOWS, "Windows"},
43
  { OS_LINUX,   "Linux"},
44
  { OS_JAVA,    "Java"},
45
  { OS_DOT_NET, ".Net"},
46
  { OS_GENERIC, "Generic TCP/IP Driver"},
47
  { 0,          NULL },
48
};
49
static value_string_ext osys_mapping_ext = VALUE_STRING_EXT_INIT(osys_mapping);
50
51
/* error codes */
52
#define EC_OK                          0
53
#define EC_TIMEOUT_TO_LINK             1
54
#define EC_TIMEOUT_FROM_LINK           2
55
#define EC_TIMEOUT_FAST_TO_LINK        3
56
#define EC_TIMEOUT_FAST_FROM_LINK      4
57
#define EC_TIMEOUT                     5
58
#define EC_MEMORY_ERROR             -100
59
#define EC_RETRY_UNKNOWN             -41
60
#define EC_ALREADY_PROCESSED         -40
61
#define EC_WRONG_BINARY_FILE         -35
62
#define EC_INVALID_PACKET_ORDER      -33
63
#define EC_FIFO_NOT_ENOUGH_DATA      -32
64
#define EC_DATA_TOO_SMALL            -31
65
#define EC_WRONG_VERSION             -30
66
#define EC_WRONG_SIZE                -26
67
#define EC_PACKET_TOO_LARGE          -25
68
#define EC_PACKET_ERROR              -20
69
#define EC_FILE_ERROR                -15
70
#define EC_TRY_LATER                 -10
71
#define EC_WRONG_PASSWORD             -5
72
#define EC_UDP_TIMEOUT                -1
73
static const value_string error_code_mapping[] = {
74
  { EC_OK,                     "OK"},
75
  { EC_TIMEOUT_TO_LINK,        "Timeout to link"},
76
  { EC_TIMEOUT_FROM_LINK,      "Timeout from link"},
77
  { EC_TIMEOUT_FAST_TO_LINK,   "Timeout fast to link"},
78
  { EC_TIMEOUT_FAST_FROM_LINK, "Timeout fast from link"},
79
  { EC_TIMEOUT,                "Timeout"},
80
  { EC_MEMORY_ERROR,           "Memory error"},
81
  { EC_RETRY_UNKNOWN,          "Retry unknown"},
82
  { EC_ALREADY_PROCESSED,      "Already processed"},
83
  { EC_WRONG_BINARY_FILE,      "Binary/Processor mismatch"},
84
  { EC_INVALID_PACKET_ORDER,   "Invalid Packet order"},
85
  { EC_FIFO_NOT_ENOUGH_DATA,   "Fifo has not enough data"},
86
  { EC_DATA_TOO_SMALL,         "Data too small"},
87
  { EC_WRONG_VERSION,          "Wrong version"},
88
  { EC_WRONG_SIZE,             "Wrong size"},
89
  { EC_PACKET_ERROR,           "Packet error"},
90
  { EC_FILE_ERROR,             "File error"},
91
  { EC_TRY_LATER,              "Try later"},
92
  { EC_WRONG_PASSWORD,         "Wrong password"},
93
  { EC_UDP_TIMEOUT,            "UDP timeout"},
94
  { 0, NULL },
95
};
96
static value_string_ext error_code_mapping_ext = VALUE_STRING_EXT_INIT(error_code_mapping);
97
98
static const value_string data_type_mapping[] = {
99
  { 2, "short / int"},
100
  { 3, "int"},
101
  { 4, "long"},
102
  { 5, "float"},
103
  { 6, "double"},
104
  { 20, "variant"},
105
  { 0, NULL },
106
};
107
static value_string_ext data_type_mapping_ext = VALUE_STRING_EXT_INIT(data_type_mapping);
108
109
4
#define I_3PLUS1                           0
110
0
#define I_LOAD_BIN_FILE                    4
111
0
#define I_GET_DATA                         7
112
0
#define I_SET_DATA                         8
113
#define I_CREATE_DATA                     10
114
0
#define I_GET_PAR_ALL                     13
115
0
#define I_GET_WORKLOAD                    20
116
0
#define I_GET_FIFO                        24
117
0
#define I_SET_FIFO                        25
118
0
#define I_BOOT                            50
119
0
#define I_GET_DATA_TYPE                  100
120
0
#define I_GET_DATA_SHIFTED_HANDSHAKE     107
121
0
#define I_SET_DATA_LAST_STATUS           108
122
0
#define I_GET_FIFO_RETRY                 124
123
0
#define I_SET_FIFO_RETRY                 125
124
0
#define I_GET_DATA_SMALL                 207
125
1
#define I_TEST_VERSION                   255
126
0
#define I_GET_ARM_VERSION               1000
127
0
#define I_GET_MEMORY                 1000000
128
129
static const value_string instruction_mapping[] = {
130
  { I_3PLUS1,                     "3+1 instruction" },
131
  { I_LOAD_BIN_FILE,              "Load binary file" },
132
  { I_GET_DATA,                   "Get data" },
133
  { I_SET_DATA,                   "Set data" },
134
  { I_CREATE_DATA,                "Create data" },
135
  { I_GET_PAR_ALL,                "Get all parameters" },
136
  { I_GET_WORKLOAD,               "Get workload"},
137
  { I_GET_FIFO,                   "Get fifo" },
138
  { I_SET_FIFO,                   "Set fifo" },
139
  { I_BOOT,                       "Boot" },
140
  { I_GET_DATA_TYPE,              "Get data type" },
141
  { I_GET_DATA_SHIFTED_HANDSHAKE, "Get data (shifted handshake)" },
142
  { I_SET_DATA_LAST_STATUS,       "Get status of last set data" },
143
  { I_GET_FIFO_RETRY,             "Get fifo - retry" },
144
  { I_SET_FIFO_RETRY,             "Set fifo - retry" },
145
  { I_GET_DATA_SMALL,             "Get data (small/fast)" },
146
  { I_TEST_VERSION,               "Get/test version information" },
147
  { I_GET_ARM_VERSION,            "Get ARM-Version" },
148
  { I_GET_MEMORY,                 "Get memory DSP" },
149
  { 0, NULL },
150
};
151
static value_string_ext instruction_mapping_ext = VALUE_STRING_EXT_INIT(instruction_mapping);
152
153
/* 3+1 instructions */
154
0
#define I_3P1_GET_PAR                     1
155
0
#define I_3P1_START                       2
156
0
#define I_3P1_STOP                        3
157
0
#define I_3P1_GET_MEMORY_INFO             5
158
0
#define I_3P1_SET_PAR                     6
159
#define I_3P1_CLEAR_DATA                  9
160
0
#define I_3P1_GET_DATA_LENGTH            11
161
0
#define I_3P1_GET_DETAILED_MEM_INFO      12
162
0
#define I_3P1_CLEAR_PROCESS              14
163
#define I_3P1_ADC                        15
164
#define I_3P1_DAC                        16
165
#define I_3P1_GET_DIGIN                  17
166
#define I_3P1_SET_DIGOUT                 18
167
#define I_3P1_GET_DIGOUT                 19
168
0
#define I_3P1_CLEAR_FIFO                 21
169
0
#define I_3P1_GET_FIFO_EMPTY             22
170
0
#define I_3P1_GET_FIFO_COUNT             23
171
static const value_string instruction_3plus1_mapping[] = {
172
  { I_3P1_GET_PAR,               "Get parameter"},
173
  { I_3P1_START,                 "Start process"},
174
  { I_3P1_STOP,                  "Stop process"},
175
  { I_3P1_GET_MEMORY_INFO,       "Get memory info"},
176
  { I_3P1_SET_PAR,               "Set parameter"},
177
  { I_3P1_CLEAR_DATA,            "Clear data"},
178
  { I_3P1_GET_DATA_LENGTH,       "Get data length"},
179
  { I_3P1_GET_DETAILED_MEM_INFO, "Get detailed memory info"},
180
  { I_3P1_CLEAR_PROCESS,         "Clear process"},
181
  { I_3P1_ADC,                   "Get ADC value"},
182
  { I_3P1_DAC,                   "Set DAC value"},
183
  { I_3P1_GET_DIGIN,             "Get digital in"},
184
  { I_3P1_SET_DIGOUT,            "Set digital out"},
185
  { I_3P1_GET_DIGOUT,            "Get digital out"},
186
  { I_3P1_CLEAR_FIFO,            "Clear fifo"},
187
  { I_3P1_GET_FIFO_EMPTY,        "Get fifo empty"},
188
  { I_3P1_GET_FIFO_COUNT,        "Get fifo full/count"},
189
  { 0,               NULL },
190
};
191
static value_string_ext instruction_3plus1_mapping_ext = VALUE_STRING_EXT_INIT(instruction_3plus1_mapping);
192
193
static const value_string parameter_mapping[] = {
194
  { 901 , "Status of Process No. 01"},
195
  { 902 , "Status of Process No. 02"},
196
  { 903 , "Status of Process No. 03"},
197
  { 904 , "Status of Process No. 04"},
198
  { 905 , "Status of Process No. 05"},
199
  { 906 , "Status of Process No. 06"},
200
  { 907 , "Status of Process No. 07"},
201
  { 908 , "Status of Process No. 08"},
202
  { 909 , "Status of Process No. 09"},
203
  { 910 , "Status of Process No. 10"},
204
  { 911 , "GlobalDelay for Process No. 01"},
205
  { 912 , "GlobalDelay for Process No. 02"},
206
  { 913 , "GlobalDelay for Process No. 03"},
207
  { 914 , "GlobalDelay for Process No. 04"},
208
  { 915 , "GlobalDelay for Process No. 05"},
209
  { 916 , "GlobalDelay for Process No. 06"},
210
  { 917 , "GlobalDelay for Process No. 07"},
211
  { 918 , "GlobalDelay for Process No. 08"},
212
  { 919 , "GlobalDelay for Process No. 09"},
213
  { 920 , "GlobalDelay for Process No. 10"},
214
  { 921 , "GlobalDelay for Process No. 11"},
215
  { 922 , "GlobalDelay for Process No. 12"},
216
  { 923 , "GlobalDelay for Process No. 13"},
217
  { 924 , "GlobalDelay for Process No. 14"},
218
  { 925 , "GlobalDelay for Process No. 15"},
219
  { 926 , "GlobalDelay for Process No. 16"},
220
  { 951 , "Debug Information of Process No. 01"},
221
  { 952 , "Debug Information of Process No. 02"},
222
  { 953 , "Debug Information of Process No. 03"},
223
  { 954 , "Debug Information of Process No. 04"},
224
  { 955 , "Debug Information of Process No. 05"},
225
  { 956 , "Debug Information of Process No. 06"},
226
  { 957 , "Debug Information of Process No. 07"},
227
  { 958 , "Debug Information of Process No. 08"},
228
  { 959 , "Debug Information of Process No. 09"},
229
  { 960 , "Debug Information of Process No. 10"},
230
  { 961 , "Debug Information of Process No. 11"},
231
  { 962 , "Debug Information of Process No. 12"},
232
  { 963 , "Debug Information of Process No. 13"},
233
  { 964 , "Debug Information of Process No. 14"},
234
  { 965 , "Debug Information of Process No. 15"},
235
  { 966 , "Debug Information of Process No. 16"},
236
  { 1001 , "Parameter No. 01"},
237
  { 1002 , "Parameter No. 02"},
238
  { 1003 , "Parameter No. 03"},
239
  { 1004 , "Parameter No. 04"},
240
  { 1005 , "Parameter No. 05"},
241
  { 1006 , "Parameter No. 06"},
242
  { 1007 , "Parameter No. 07"},
243
  { 1008 , "Parameter No. 08"},
244
  { 1009 , "Parameter No. 09"},
245
  { 1010 , "Parameter No. 10"},
246
  { 1011 , "Parameter No. 11"},
247
  { 1012 , "Parameter No. 12"},
248
  { 1013 , "Parameter No. 13"},
249
  { 1014 , "Parameter No. 14"},
250
  { 1015 , "Parameter No. 15"},
251
  { 1016 , "Parameter No. 16"},
252
  { 1017 , "Parameter No. 17"},
253
  { 1018 , "Parameter No. 18"},
254
  { 1019 , "Parameter No. 19"},
255
  { 1020 , "Parameter No. 20"},
256
  { 1021 , "Parameter No. 21"},
257
  { 1022 , "Parameter No. 22"},
258
  { 1023 , "Parameter No. 23"},
259
  { 1024 , "Parameter No. 24"},
260
  { 1025 , "Parameter No. 25"},
261
  { 1026 , "Parameter No. 26"},
262
  { 1027 , "Parameter No. 27"},
263
  { 1028 , "Parameter No. 28"},
264
  { 1029 , "Parameter No. 29"},
265
  { 1030 , "Parameter No. 30"},
266
  { 1031 , "Parameter No. 31"},
267
  { 1032 , "Parameter No. 32"},
268
  { 1033 , "Parameter No. 33"},
269
  { 1034 , "Parameter No. 34"},
270
  { 1035 , "Parameter No. 35"},
271
  { 1036 , "Parameter No. 36"},
272
  { 1037 , "Parameter No. 37"},
273
  { 1038 , "Parameter No. 38"},
274
  { 1039 , "Parameter No. 39"},
275
  { 1040 , "Parameter No. 40"},
276
  { 1041 , "Parameter No. 41"},
277
  { 1042 , "Parameter No. 42"},
278
  { 1043 , "Parameter No. 43"},
279
  { 1044 , "Parameter No. 44"},
280
  { 1045 , "Parameter No. 45"},
281
  { 1046 , "Parameter No. 46"},
282
  { 1047 , "Parameter No. 47"},
283
  { 1048 , "Parameter No. 48"},
284
  { 1049 , "Parameter No. 49"},
285
  { 1050 , "Parameter No. 50"},
286
  { 1051 , "Parameter No. 51"},
287
  { 1052 , "Parameter No. 52"},
288
  { 1053 , "Parameter No. 53"},
289
  { 1054 , "Parameter No. 54"},
290
  { 1055 , "Parameter No. 55"},
291
  { 1056 , "Parameter No. 56"},
292
  { 1057 , "Parameter No. 57"},
293
  { 1058 , "Parameter No. 58"},
294
  { 1059 , "Parameter No. 59"},
295
  { 1060 , "Parameter No. 60"},
296
  { 1061 , "Parameter No. 61"},
297
  { 1062 , "Parameter No. 62"},
298
  { 1063 , "Parameter No. 63"},
299
  { 1064 , "Parameter No. 64"},
300
  { 1065 , "Parameter No. 65"},
301
  { 1066 , "Parameter No. 66"},
302
  { 1067 , "Parameter No. 67"},
303
  { 1068 , "Parameter No. 68"},
304
  { 1069 , "Parameter No. 69"},
305
  { 1070 , "Parameter No. 70"},
306
  { 1071 , "Parameter No. 71"},
307
  { 1072 , "Parameter No. 72"},
308
  { 1073 , "Parameter No. 73"},
309
  { 1074 , "Parameter No. 74"},
310
  { 1075 , "Parameter No. 75"},
311
  { 1076 , "Parameter No. 76"},
312
  { 1077 , "Parameter No. 77"},
313
  { 1078 , "Parameter No. 78"},
314
  { 1079 , "Parameter No. 79"},
315
  { 1080 , "Parameter No. 80"},
316
  { 1101 , "Float-Parameter No. 01"},
317
  { 1102 , "Float-Parameter No. 02"},
318
  { 1103 , "Float-Parameter No. 03"},
319
  { 1104 , "Float-Parameter No. 04"},
320
  { 1105 , "Float-Parameter No. 05"},
321
  { 1106 , "Float-Parameter No. 06"},
322
  { 1107 , "Float-Parameter No. 07"},
323
  { 1108 , "Float-Parameter No. 08"},
324
  { 1109 , "Float-Parameter No. 09"},
325
  { 1110 , "Float-Parameter No. 10"},
326
  { 1111 , "Float-Parameter No. 11"},
327
  { 1112 , "Float-Parameter No. 12"},
328
  { 1113 , "Float-Parameter No. 13"},
329
  { 1114 , "Float-Parameter No. 14"},
330
  { 1115 , "Float-Parameter No. 15"},
331
  { 1116 , "Float-Parameter No. 16"},
332
  { 1117 , "Float-Parameter No. 17"},
333
  { 1118 , "Float-Parameter No. 18"},
334
  { 1119 , "Float-Parameter No. 19"},
335
  { 1120 , "Float-Parameter No. 20"},
336
  { 1121 , "Float-Parameter No. 21"},
337
  { 1122 , "Float-Parameter No. 22"},
338
  { 1123 , "Float-Parameter No. 23"},
339
  { 1124 , "Float-Parameter No. 24"},
340
  { 1125 , "Float-Parameter No. 25"},
341
  { 1126 , "Float-Parameter No. 26"},
342
  { 1127 , "Float-Parameter No. 27"},
343
  { 1128 , "Float-Parameter No. 28"},
344
  { 1129 , "Float-Parameter No. 29"},
345
  { 1130 , "Float-Parameter No. 30"},
346
  { 1131 , "Float-Parameter No. 31"},
347
  { 1132 , "Float-Parameter No. 32"},
348
  { 1133 , "Float-Parameter No. 33"},
349
  { 1134 , "Float-Parameter No. 34"},
350
  { 1135 , "Float-Parameter No. 35"},
351
  { 1136 , "Float-Parameter No. 36"},
352
  { 1137 , "Float-Parameter No. 37"},
353
  { 1138 , "Float-Parameter No. 38"},
354
  { 1139 , "Float-Parameter No. 39"},
355
  { 1140 , "Float-Parameter No. 40"},
356
  { 1141 , "Float-Parameter No. 41"},
357
  { 1142 , "Float-Parameter No. 42"},
358
  { 1143 , "Float-Parameter No. 43"},
359
  { 1144 , "Float-Parameter No. 44"},
360
  { 1145 , "Float-Parameter No. 45"},
361
  { 1146 , "Float-Parameter No. 46"},
362
  { 1147 , "Float-Parameter No. 47"},
363
  { 1148 , "Float-Parameter No. 48"},
364
  { 1149 , "Float-Parameter No. 49"},
365
  { 1150 , "Float-Parameter No. 50"},
366
  { 1151 , "Float-Parameter No. 51"},
367
  { 1152 , "Float-Parameter No. 52"},
368
  { 1153 , "Float-Parameter No. 53"},
369
  { 1154 , "Float-Parameter No. 54"},
370
  { 1155 , "Float-Parameter No. 55"},
371
  { 1156 , "Float-Parameter No. 56"},
372
  { 1157 , "Float-Parameter No. 57"},
373
  { 1158 , "Float-Parameter No. 58"},
374
  { 1159 , "Float-Parameter No. 59"},
375
  { 1160 , "Float-Parameter No. 60"},
376
  { 1161 , "Float-Parameter No. 61"},
377
  { 1162 , "Float-Parameter No. 62"},
378
  { 1163 , "Float-Parameter No. 63"},
379
  { 1164 , "Float-Parameter No. 64"},
380
  { 1165 , "Float-Parameter No. 65"},
381
  { 1166 , "Float-Parameter No. 66"},
382
  { 1167 , "Float-Parameter No. 67"},
383
  { 1168 , "Float-Parameter No. 68"},
384
  { 1169 , "Float-Parameter No. 69"},
385
  { 1170 , "Float-Parameter No. 70"},
386
  { 1171 , "Float-Parameter No. 71"},
387
  { 1172 , "Float-Parameter No. 72"},
388
  { 1173 , "Float-Parameter No. 73"},
389
  { 1174 , "Float-Parameter No. 74"},
390
  { 1175 , "Float-Parameter No. 75"},
391
  { 1176 , "Float-Parameter No. 76"},
392
  { 1177 , "Float-Parameter No. 77"},
393
  { 1178 , "Float-Parameter No. 78"},
394
  { 1179 , "Float-Parameter No. 79"},
395
  { 1180 , "Float-Parameter No. 80"},
396
  { 4891 , "Status of Process No. 11"},
397
  { 4892 , "Status of Process No. 12"},
398
  { 4893 , "Status of Process No. 13"},
399
  { 4894 , "Status of Process No. 14"},
400
  { 4895 , "Status of Process No. 15"},
401
  { 4896 , "Status of Process No. 16"},
402
  {10000 , "Start Timing Analyzer"},
403
  {10001 , "Stop Timing Analyzer"},
404
  { 0, NULL },
405
};
406
static value_string_ext parameter_mapping_ext = VALUE_STRING_EXT_INIT(parameter_mapping);
407
408
typedef enum {
409
  APT_UDPH1_old, APT_UDPH1_new, APT_UDPR1, APT_UDPR2, APT_UDPR3,
410
  APT_UDPR4, APT_GDSHP, APT_GDSHR
411
} adwin_packet_types_t;
412
413
static const value_string packet_type_mapping[] = {
414
  { APT_UDPH1_old, "UDPH1 old"},
415
  { APT_UDPH1_new, "UDPH1 new"},
416
  { APT_UDPR1,   "UDPR1"},
417
  { APT_UDPR2,   "UDPR2"},
418
  { APT_UDPR3,   "UDPR3"},
419
  { APT_UDPR4,   "UDPR4"},
420
  { APT_GDSHP,   "GDSHP"},
421
  { APT_GDSHR,   "GDSHR"},
422
  { 0, NULL },
423
};
424
static value_string_ext packet_type_mapping_ext = VALUE_STRING_EXT_INIT(packet_type_mapping);
425
426
#define SET_PACKET_TYPE(tree, type)                              \
427
7
  proto_tree_add_int(tree, hf_adwin_packet_type, tvb, 0, tvb_captured_length(tvb), type);
428
429
430
/* Initialize the protocol and registered fields */
431
static int proto_adwin;
432
433
static bool global_adwin_dissect_data = true;
434
435
static int hf_adwin_address;
436
static int hf_adwin_armVersion;
437
static int hf_adwin_binfilesize;
438
static int hf_adwin_blocksize;
439
static int hf_adwin_count;
440
static int hf_adwin_complete_packets;
441
static int hf_adwin_data;
442
static int hf_adwin_data_int;
443
static int hf_adwin_data_float;
444
static int hf_adwin_data_hex;
445
static int hf_adwin_data_no16;
446
static int hf_adwin_data_no32;
447
static int hf_adwin_data_packet_index;
448
static int hf_adwin_data_type;
449
static int hf_adwin_dll_version;
450
static int hf_adwin_fifo_no16;
451
static int hf_adwin_fifo_no32;
452
static int hf_adwin_instruction;
453
static int hf_adwin_is_range;
454
static int hf_adwin_i3plus1;
455
static int hf_adwin_link_addr;
456
static int hf_adwin_mem_type;
457
static int hf_adwin_memsize;
458
static int hf_adwin_osys;
459
static int hf_adwin_packet_index;
460
static int hf_adwin_packet_no;
461
static int hf_adwin_packet_start;
462
static int hf_adwin_packet_end;
463
static int hf_adwin_gdsh_status;
464
static int hf_adwin_packet_type;
465
static int hf_adwin_parameter;
466
static int hf_adwin_password;
467
static int hf_adwin_process_no;
468
static int hf_adwin_processor;
469
static int hf_adwin_response_in;
470
static int hf_adwin_response_to;
471
static int hf_adwin_response_time;
472
static int hf_adwin_retry_packet_index;
473
static int hf_adwin_request_no;
474
static int hf_adwin_start_index;
475
static int hf_adwin_status;
476
static int hf_adwin_timeout;
477
static int hf_adwin_unused;
478
static int hf_adwin_val1;
479
static int hf_adwin_val1f;
480
static int hf_adwin_val2;
481
static int hf_adwin_val3;
482
static int hf_adwin_val4;
483
484
/* Initialize the subtree pointers */
485
static int ett_adwin;
486
static int ett_adwin_debug;
487
488
/* response/request tracking */
489
typedef struct _adwin_transaction_t {
490
  uint32_t req_frame;
491
  uint32_t rep_frame;
492
  nstime_t req_time;
493
} adwin_transaction_t;
494
495
/* response/request tracking */
496
typedef struct _adwin_conv_info_t {
497
  wmem_map_t *pdus;
498
} adwin_conv_info_t;
499
500
typedef enum {
501
  ADWIN_REQUEST,
502
  ADWIN_RESPONSE
503
} adwin_direction_t;
504
505
static void
506
adwin_request_response_handling(tvbuff_t *tvb, packet_info *pinfo,
507
        proto_tree *adwin_tree, uint32_t seq_num, adwin_direction_t direction)
508
5
{
509
5
  conversation_t *conversation;
510
5
  adwin_conv_info_t *adwin_info;
511
5
  adwin_transaction_t *adwin_trans;
512
513
  /*
514
   * Find or create a conversation for this connection.
515
   */
516
5
  conversation = find_or_create_conversation(pinfo);
517
518
  /*
519
   * Do we already have a state structure for this conv
520
   */
521
5
  adwin_info = (adwin_conv_info_t *)conversation_get_proto_data(conversation, proto_adwin);
522
5
  if (!adwin_info) {
523
    /*
524
     * No.  Attach that information to the conversation, and add
525
     * it to the list of information structures.
526
     */
527
4
    adwin_info = wmem_new(wmem_file_scope(), adwin_conv_info_t);
528
4
    adwin_info->pdus = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal);
529
530
4
    conversation_add_proto_data(conversation, proto_adwin, adwin_info);
531
4
  }
532
5
  if (!pinfo->fd->visited) {
533
5
    if (direction == ADWIN_REQUEST) {
534
      /* This is a request */
535
4
      adwin_trans = wmem_new(wmem_file_scope(), adwin_transaction_t);
536
4
      adwin_trans->req_frame = pinfo->num;
537
4
      adwin_trans->rep_frame = 0;
538
4
      adwin_trans->req_time = pinfo->abs_ts;
539
4
      wmem_map_insert(adwin_info->pdus, GUINT_TO_POINTER(seq_num), (void *)adwin_trans);
540
4
    } else {
541
1
      adwin_trans = (adwin_transaction_t *)wmem_map_lookup(adwin_info->pdus, GUINT_TO_POINTER(seq_num));
542
1
      if (adwin_trans) {
543
0
        adwin_trans->rep_frame = pinfo->num;
544
0
      }
545
1
    }
546
5
  } else {
547
0
    adwin_trans = (adwin_transaction_t *)wmem_map_lookup(adwin_info->pdus, GUINT_TO_POINTER(seq_num));
548
0
  }
549
5
  if (!adwin_trans) {
550
    /* create a "fake" adwin_trans structure */
551
1
    adwin_trans = wmem_new(pinfo->pool, adwin_transaction_t);
552
1
    adwin_trans->req_frame = 0;
553
1
    adwin_trans->rep_frame = 0;
554
1
    adwin_trans->req_time = pinfo->abs_ts;
555
1
  }
556
557
  /* print state tracking in the tree */
558
5
  if (direction == ADWIN_REQUEST) {
559
    /* This is a request */
560
4
    if (adwin_trans->rep_frame) {
561
0
      proto_item *it;
562
563
0
      it = proto_tree_add_uint(adwin_tree, hf_adwin_response_in,
564
0
          tvb, 0, 0, adwin_trans->rep_frame);
565
0
      proto_item_set_generated(it);
566
0
    }
567
4
  } else {
568
    /* This is a reply */
569
1
    if (adwin_trans->req_frame) {
570
0
      proto_item *it;
571
0
      nstime_t ns;
572
573
0
      it = proto_tree_add_uint(adwin_tree, hf_adwin_response_to,
574
0
          tvb, 0, 0, adwin_trans->req_frame);
575
0
      proto_item_set_generated(it);
576
577
0
      nstime_delta(&ns, &pinfo->abs_ts, &adwin_trans->req_time);
578
0
      it = proto_tree_add_time(adwin_tree, hf_adwin_response_time, tvb, 0, 0, &ns);
579
0
      proto_item_set_generated(it);
580
0
    }
581
1
  }
582
5
}
583
584
static void
585
dissect_UDPH1_generic(tvbuff_t *tvb, packet_info *pinfo,
586
          proto_tree *adwin_tree, proto_tree *adwin_debug_tree, char** info_string, const char* packet_name)
587
4
{
588
4
  uint32_t i3plus1code =  0, instructionID, seq_num;
589
590
4
  instructionID = tvb_get_letohl(tvb, 0);
591
4
  *info_string = wmem_strdup_printf(pinfo->pool, "%s: %s", packet_name,
592
4
                val_to_str_ext(pinfo->pool, instructionID, &instruction_mapping_ext, "unknown instruction: %d"));
593
594
4
  if (instructionID == I_3PLUS1) {
595
0
    char *tmp = *info_string;
596
597
0
    i3plus1code = tvb_get_letohl(tvb, 20);
598
0
    *info_string = wmem_strdup_printf(pinfo->pool, "%s: %s", tmp, val_to_str_ext(pinfo->pool, i3plus1code, &instruction_3plus1_mapping_ext, "unknown 3+1 code: %d"));
599
0
  }
600
601
  /* Get the transaction identifier */
602
4
  seq_num = tvb_get_letohl(tvb, 4);
603
4
  adwin_request_response_handling(tvb, pinfo, adwin_tree, seq_num, ADWIN_REQUEST);
604
605
4
  if (! adwin_tree)
606
0
    return;
607
608
4
  SET_PACKET_TYPE(adwin_tree, APT_UDPH1_old);
609
610
4
  proto_tree_add_item(adwin_tree, hf_adwin_instruction,          tvb, 0,  4, ENC_LITTLE_ENDIAN);
611
4
  proto_tree_add_item(adwin_tree, hf_adwin_packet_index,         tvb, 4,  4, ENC_LITTLE_ENDIAN);
612
4
  proto_tree_add_item(adwin_tree, hf_adwin_password,             tvb, 8, 10, ENC_ASCII);
613
4
  proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,        tvb, 18,  2, ENC_NA);
614
615
4
  switch(instructionID) {
616
0
  case I_3PLUS1:
617
0
    proto_tree_add_item(adwin_tree, hf_adwin_i3plus1,      tvb, 20,  4, ENC_LITTLE_ENDIAN);
618
0
    switch (i3plus1code) {
619
0
    case I_3P1_SET_PAR:
620
0
      proto_tree_add_item(adwin_tree, hf_adwin_parameter,     tvb, 24,  4, ENC_LITTLE_ENDIAN);
621
0
      proto_tree_add_item(adwin_tree, hf_adwin_val1,          tvb, 28,  4, ENC_LITTLE_ENDIAN);
622
0
      proto_tree_add_item(adwin_tree, hf_adwin_val1f,         tvb, 28,  4, ENC_LITTLE_ENDIAN);
623
0
      proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 32,  4, ENC_NA);
624
0
      break;
625
0
    case I_3P1_GET_PAR:
626
0
      proto_tree_add_item(adwin_tree, hf_adwin_parameter,     tvb, 24,  4, ENC_LITTLE_ENDIAN);
627
0
      proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 28,  8, ENC_NA);
628
0
      break;
629
0
    case I_3P1_GET_MEMORY_INFO:
630
0
    case I_3P1_GET_DETAILED_MEM_INFO:
631
0
      proto_tree_add_item(adwin_tree, hf_adwin_mem_type,      tvb, 24,  4, ENC_LITTLE_ENDIAN);
632
0
      proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 28,  8, ENC_NA);
633
0
      break;
634
0
    case I_3P1_START:
635
0
    case I_3P1_STOP:
636
0
    case I_3P1_CLEAR_PROCESS:
637
0
      proto_tree_add_item(adwin_tree, hf_adwin_process_no,    tvb, 24,  4, ENC_LITTLE_ENDIAN);
638
0
      proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 28,  8, ENC_NA);
639
0
      break;
640
0
    case I_3P1_GET_DATA_LENGTH:
641
0
      proto_tree_add_item(adwin_tree, hf_adwin_data_no32,     tvb, 24,  4, ENC_LITTLE_ENDIAN);
642
0
      proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 28,  8, ENC_NA);
643
0
      break;
644
0
    case I_3P1_CLEAR_FIFO:
645
0
    case I_3P1_GET_FIFO_EMPTY:
646
0
    case I_3P1_GET_FIFO_COUNT:
647
0
      proto_tree_add_item(adwin_tree, hf_adwin_fifo_no32,     tvb, 24,  4, ENC_LITTLE_ENDIAN);
648
0
      proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 28,  8, ENC_NA);
649
0
      break;
650
0
    default: ; /* should not happen */
651
      /* illegal values should be displayed properly
652
         by 3plus1_mapping */
653
0
    }
654
0
    break;
655
0
  case I_BOOT:
656
0
    proto_tree_add_item(adwin_tree, hf_adwin_memsize,       tvb, 20,  4, ENC_LITTLE_ENDIAN);
657
0
    proto_tree_add_item(adwin_tree, hf_adwin_blocksize,     tvb, 24,  2, ENC_LITTLE_ENDIAN);
658
0
    proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 26,  2, ENC_NA);
659
0
    proto_tree_add_item(adwin_tree, hf_adwin_processor,     tvb, 28,  4, ENC_LITTLE_ENDIAN);
660
0
    proto_tree_add_item(adwin_tree, hf_adwin_binfilesize,   tvb, 32,  4, ENC_LITTLE_ENDIAN);
661
0
    break;
662
0
  case I_LOAD_BIN_FILE:
663
0
    proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 20,  6, ENC_NA);
664
0
    proto_tree_add_item(adwin_tree, hf_adwin_blocksize,     tvb, 26,  2, ENC_LITTLE_ENDIAN);
665
0
    proto_tree_add_item(adwin_tree, hf_adwin_processor,     tvb, 28,  4, ENC_LITTLE_ENDIAN);
666
0
    proto_tree_add_item(adwin_tree, hf_adwin_binfilesize,   tvb, 32,  4, ENC_LITTLE_ENDIAN);
667
0
    break;
668
0
  case I_GET_WORKLOAD:
669
0
    proto_tree_add_item(adwin_tree, hf_adwin_instruction,   tvb, 20,  4, ENC_LITTLE_ENDIAN);
670
0
    proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 24, 12, ENC_NA);
671
0
    break;
672
0
  case I_GET_DATA_TYPE:
673
0
    proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 20,  4, ENC_NA);
674
0
    proto_tree_add_item(adwin_tree, hf_adwin_data_no32,     tvb, 24,  4, ENC_LITTLE_ENDIAN);
675
0
    proto_tree_add_item(adwin_tree, hf_adwin_start_index,   tvb, 28,  4, ENC_LITTLE_ENDIAN);
676
0
    proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 32,  4, ENC_NA);
677
0
    break;
678
0
  case I_GET_DATA:
679
0
  case I_SET_DATA:
680
0
    proto_tree_add_item(adwin_tree, hf_adwin_data_type,     tvb, 20,  4, ENC_LITTLE_ENDIAN);
681
0
    proto_tree_add_item(adwin_tree, hf_adwin_data_no16,     tvb, 24,  2, ENC_LITTLE_ENDIAN);
682
0
    proto_tree_add_item(adwin_tree, hf_adwin_blocksize,     tvb, 26,  2, ENC_LITTLE_ENDIAN);
683
0
    proto_tree_add_item(adwin_tree, hf_adwin_start_index,   tvb, 28,  4, ENC_LITTLE_ENDIAN);
684
0
    proto_tree_add_item(adwin_tree, hf_adwin_count,         tvb, 32,  4, ENC_LITTLE_ENDIAN);
685
0
    break;
686
0
  case I_GET_DATA_SHIFTED_HANDSHAKE:
687
0
    proto_tree_add_item(adwin_tree, hf_adwin_data_no16,     tvb, 20,  2, ENC_BIG_ENDIAN);
688
0
    proto_tree_add_item(adwin_tree, hf_adwin_blocksize,     tvb, 22,  2, ENC_BIG_ENDIAN);
689
0
    proto_tree_add_item(adwin_tree, hf_adwin_start_index,   tvb, 24,  4, ENC_BIG_ENDIAN);
690
0
    proto_tree_add_item(adwin_tree, hf_adwin_count,         tvb, 28,  4, ENC_BIG_ENDIAN);
691
0
    proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 32,  4, ENC_NA);
692
0
    break;
693
0
  case I_GET_DATA_SMALL:
694
0
    proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 20,  4, ENC_NA);
695
0
    proto_tree_add_item(adwin_tree, hf_adwin_data_no16,     tvb, 24,  2, ENC_LITTLE_ENDIAN);
696
0
    proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 26,  2, ENC_NA);
697
0
    proto_tree_add_item(adwin_tree, hf_adwin_start_index,   tvb, 28,  4, ENC_LITTLE_ENDIAN);
698
0
    proto_tree_add_item(adwin_tree, hf_adwin_count,         tvb, 32,  4, ENC_LITTLE_ENDIAN);
699
0
    break;
700
0
  case I_GET_PAR_ALL:
701
0
    proto_tree_add_item(adwin_tree, hf_adwin_start_index,   tvb, 20,  4, ENC_LITTLE_ENDIAN);
702
0
    proto_tree_add_item(adwin_tree, hf_adwin_count,         tvb, 24,  4, ENC_LITTLE_ENDIAN);
703
0
    proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 28,  8, ENC_NA);
704
0
    break;
705
0
  case I_SET_DATA_LAST_STATUS:
706
0
    proto_tree_add_item(adwin_tree, hf_adwin_data_packet_index, tvb, 20,  4, ENC_LITTLE_ENDIAN);
707
0
    proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 24,  12, ENC_NA);
708
0
    break;
709
0
  case I_GET_ARM_VERSION:
710
0
    proto_tree_add_item(adwin_tree, hf_adwin_armVersion,  tvb, 20,  4, ENC_LITTLE_ENDIAN);
711
0
    proto_tree_add_item(adwin_debug_tree, hf_adwin_unused, tvb, 24, 12, ENC_NA);
712
0
    break;
713
0
  case I_GET_FIFO:
714
0
  case I_SET_FIFO:
715
0
    proto_tree_add_item(adwin_tree, hf_adwin_data_type,     tvb, 20,  4, ENC_LITTLE_ENDIAN);
716
0
    proto_tree_add_item(adwin_tree, hf_adwin_fifo_no16,     tvb, 24,  2, ENC_LITTLE_ENDIAN);
717
0
    proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 26,  6, ENC_NA);
718
0
    proto_tree_add_item(adwin_tree, hf_adwin_count,         tvb, 32,  4, ENC_LITTLE_ENDIAN);
719
0
    break;
720
0
  case I_GET_FIFO_RETRY:
721
0
  case I_SET_FIFO_RETRY:
722
0
    proto_tree_add_item(adwin_tree, hf_adwin_data_type,     tvb, 20,  4, ENC_LITTLE_ENDIAN);
723
0
    proto_tree_add_item(adwin_tree, hf_adwin_fifo_no16,     tvb, 24,  2, ENC_LITTLE_ENDIAN);
724
0
    proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 26,  2, ENC_NA);
725
0
    proto_tree_add_item(adwin_tree, hf_adwin_retry_packet_index, tvb, 28,  4, ENC_LITTLE_ENDIAN);
726
0
    proto_tree_add_item(adwin_tree, hf_adwin_count,         tvb, 32,  4, ENC_LITTLE_ENDIAN);
727
0
    break;
728
1
  case I_TEST_VERSION:
729
1
    proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 20,  16, ENC_NA);
730
1
    break;
731
0
  case I_GET_MEMORY:
732
0
    proto_tree_add_item(adwin_tree, hf_adwin_address,       tvb, 20,  4, ENC_LITTLE_ENDIAN);
733
0
    proto_tree_add_item(adwin_tree, hf_adwin_count,         tvb, 24,  4, ENC_LITTLE_ENDIAN);
734
0
    proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 28,  8, ENC_NA);
735
0
    break;
736
3
  default: ; /* should not happen */
737
    /* illegal values should be displayed properly by
738
       instruction_mapping */
739
4
  }
740
741
4
  proto_tree_add_item(adwin_debug_tree, hf_adwin_link_addr, tvb, 36,  4, ENC_LITTLE_ENDIAN);
742
4
  proto_tree_add_item(adwin_tree, hf_adwin_timeout,        tvb, 40,  4, ENC_LITTLE_ENDIAN);
743
4
  proto_tree_add_item(adwin_debug_tree, hf_adwin_osys,     tvb, 44,  4, ENC_LITTLE_ENDIAN);
744
4
  proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,   tvb, 48,  4, ENC_NA);
745
746
4
}
747
748
749
static void
750
dissect_UDPH1_old(tvbuff_t *tvb, packet_info *pinfo,
751
      proto_tree *adwin_tree, proto_tree *adwin_debug_tree, char** info_string)
752
2
{
753
2
  dissect_UDPH1_generic(tvb, pinfo, adwin_tree, adwin_debug_tree, info_string, "UDPH1 (old)");
754
2
}
755
756
static void
757
dissect_UDPH1_new(tvbuff_t *tvb, packet_info *pinfo,
758
      proto_tree *adwin_tree, proto_tree *adwin_debug_tree,
759
      char** info_string)
760
2
{
761
2
  char* dll_version_s;
762
2
  int32_t dll_i;
763
764
2
  dissect_UDPH1_generic(tvb, pinfo, adwin_tree, adwin_debug_tree, info_string, "UDPH1 (new)");
765
766
2
  if (! adwin_tree)
767
0
    return;
768
769
2
  SET_PACKET_TYPE(adwin_tree, APT_UDPH1_new);
770
2
  dll_i = tvb_get_letohl(tvb, 52);
771
2
  dll_version_s = wmem_strdup_printf(pinfo->pool, "%d.%d.%d",
772
2
          dll_i / 1000000,
773
2
          (dll_i - dll_i / 1000000 * 1000000) / 1000,
774
2
          dll_i % 1000);
775
776
2
  proto_tree_add_string(adwin_debug_tree, hf_adwin_dll_version,
777
2
            tvb, 52, 4, dll_version_s);
778
2
}
779
780
static void
781
dissect_UDPR1(tvbuff_t *tvb, packet_info *pinfo,
782
        proto_tree *adwin_tree, proto_tree *adwin_debug_tree,
783
        char** info_string)
784
0
{
785
0
  const char *status_string;
786
0
  uint32_t seq_num, status;
787
788
0
  status = tvb_get_letohl(tvb, 0);
789
0
  status_string = try_val_to_str_ext(status, &error_code_mapping_ext);
790
0
  if (status_string) {
791
0
    *info_string = wmem_strdup_printf(pinfo->pool, "UDPR1 Status: %s", status_string);
792
0
  } else {
793
0
    *info_string = wmem_strdup_printf(pinfo->pool, "UDPR1 Undefined error code %d", status);
794
0
  }
795
796
  /* Get the transaction identifier */
797
0
  seq_num = tvb_get_letohl(tvb, 4);
798
0
  adwin_request_response_handling(tvb, pinfo, adwin_tree, seq_num, ADWIN_RESPONSE);
799
800
0
  if (! adwin_tree)
801
0
    return;
802
803
0
  SET_PACKET_TYPE(adwin_tree, APT_UDPR1);
804
0
  proto_tree_add_item(adwin_tree, hf_adwin_status,         tvb, 0,  4, ENC_LITTLE_ENDIAN);
805
0
  proto_tree_add_item(adwin_tree, hf_adwin_packet_index,   tvb, 4,  4, ENC_LITTLE_ENDIAN);
806
0
  proto_tree_add_item(adwin_tree, hf_adwin_val1,           tvb, 8,  4, ENC_LITTLE_ENDIAN);
807
0
  proto_tree_add_item(adwin_tree, hf_adwin_val1f,          tvb, 8,  4, ENC_LITTLE_ENDIAN);
808
0
  proto_tree_add_item(adwin_tree, hf_adwin_val2,          tvb, 12,  4, ENC_LITTLE_ENDIAN);
809
0
  proto_tree_add_item(adwin_tree, hf_adwin_val3,          tvb, 16,  4, ENC_LITTLE_ENDIAN);
810
0
  proto_tree_add_item(adwin_tree, hf_adwin_val4,          tvb, 20,  4, ENC_LITTLE_ENDIAN);
811
0
  proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 24,  8, ENC_NA);
812
0
}
813
814
static void
815
dissect_UDPR2(tvbuff_t *tvb, packet_info *pinfo,
816
        proto_tree *adwin_tree, proto_tree *adwin_debug_tree,
817
        char** info_string)
818
0
{
819
0
  const char *status_string;
820
0
  uint32_t i, status, seq_num;
821
822
0
  status = tvb_get_letohl(tvb, 0);
823
0
  status_string = try_val_to_str_ext(status, &error_code_mapping_ext);
824
0
  if (status_string) {
825
0
          *info_string = wmem_strdup_printf(pinfo->pool, "UDPR2 Status: %s", status_string);
826
0
  } else {
827
0
    *info_string = wmem_strdup_printf(pinfo->pool, "UDPR2 Undefined error code %d", status);
828
0
  }
829
830
  /* Get the transaction identifier */
831
0
  seq_num = tvb_get_letohl(tvb, 4);
832
0
  adwin_request_response_handling(tvb, pinfo, adwin_tree, seq_num, ADWIN_RESPONSE);
833
834
0
  if (! adwin_tree)
835
0
    return;
836
837
0
  SET_PACKET_TYPE(adwin_tree, APT_UDPR2);
838
0
  proto_tree_add_item(adwin_tree, hf_adwin_status,         tvb, 0,  4, ENC_LITTLE_ENDIAN);
839
0
  proto_tree_add_item(adwin_tree, hf_adwin_packet_index,   tvb, 4,  4, ENC_LITTLE_ENDIAN);
840
841
0
  if (! global_adwin_dissect_data) {
842
0
    call_data_dissector(tvb_new_subset_length(tvb, 8, 250*4), pinfo, adwin_debug_tree);
843
0
    return;
844
0
  }
845
846
0
  for (i = 0; i < 250; i++) {
847
0
    proto_item *item;
848
0
    uint32_t offset = 8 + i * (int)sizeof(uint32_t);
849
0
    int32_t value = tvb_get_letohl(tvb, offset);
850
0
    void * fvalue = &value;
851
0
    proto_tree_add_none_format(adwin_debug_tree, hf_adwin_data, tvb, offset, 4,
852
0
            "Data[%3d]: %10d - %10f - 0x%08x",
853
0
            i, value, *(float*)fvalue, value);
854
0
    item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_int,   tvb, offset, 4, ENC_LITTLE_ENDIAN);
855
0
    proto_item_set_hidden(item);
856
0
    item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_float, tvb, offset, 4, ENC_LITTLE_ENDIAN);
857
0
    proto_item_set_hidden(item);
858
0
    item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_hex,   tvb, offset, 4, ENC_LITTLE_ENDIAN);
859
0
    proto_item_set_hidden(item);
860
0
  }
861
0
}
862
863
static void
864
dissect_UDPR3(tvbuff_t *tvb, packet_info *pinfo,
865
        proto_tree *adwin_tree, proto_tree *adwin_debug_tree)
866
0
{
867
0
  uint32_t i, seq_num;
868
869
  /* Get the transaction identifier */
870
0
  seq_num = tvb_get_letohl(tvb, 0);
871
0
  adwin_request_response_handling(tvb, pinfo, adwin_tree, seq_num, ADWIN_RESPONSE);
872
873
0
  if (! adwin_tree)
874
0
    return;
875
876
0
  SET_PACKET_TYPE(adwin_tree, APT_UDPR3);
877
0
  proto_tree_add_item(adwin_tree, hf_adwin_packet_index,   tvb, 0,  4, ENC_LITTLE_ENDIAN);
878
0
  proto_tree_add_item(adwin_tree, hf_adwin_packet_no,      tvb, 4,  4, ENC_LITTLE_ENDIAN);
879
880
0
  if (! global_adwin_dissect_data) {
881
0
    call_data_dissector(tvb_new_subset_length(tvb, 8, 350*4), pinfo, adwin_debug_tree);
882
0
    return;
883
0
  }
884
885
0
  for (i = 0; i < 350; i++) {
886
0
    proto_item *item;
887
0
    uint32_t offset = 8 + i * (int)sizeof(uint32_t);
888
0
    int32_t value = tvb_get_letohl(tvb, offset);
889
0
    void * fvalue = &value;
890
0
    proto_tree_add_none_format(adwin_debug_tree, hf_adwin_data, tvb, offset, 4,
891
0
            "Data[%3d]: %10d - %10f - 0x%08x",
892
0
            i, value, *(float*)fvalue, value);
893
0
    item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_int,   tvb, offset, 4, ENC_LITTLE_ENDIAN);
894
0
    proto_item_set_hidden(item);
895
0
    item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_float, tvb, offset, 4, ENC_LITTLE_ENDIAN);
896
0
    proto_item_set_hidden(item);
897
0
    item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_hex,   tvb, offset, 4, ENC_LITTLE_ENDIAN);
898
0
    proto_item_set_hidden(item);
899
0
  }
900
0
}
901
902
static void
903
dissect_UDPR4(tvbuff_t *tvb, packet_info *pinfo,
904
        proto_tree *adwin_tree, proto_tree *adwin_debug_tree, char** info_string)
905
0
{
906
0
  const char *status_string;
907
0
  uint32_t data_type, i, status, seq_num;
908
909
0
  status = tvb_get_letohl(tvb, 0);
910
0
  status_string = try_val_to_str_ext(status, &error_code_mapping_ext);
911
0
  if (status_string) {
912
0
    *info_string = wmem_strdup_printf(pinfo->pool, "UDPR4 Status: %s", status_string);
913
0
  } else {
914
0
    *info_string = wmem_strdup_printf(pinfo->pool, "UDPR4 Undefined error code %d", status);
915
0
  }
916
917
  /* Get the transaction identifier */
918
0
  seq_num = tvb_get_letohl(tvb, 4);
919
0
  adwin_request_response_handling(tvb, pinfo, adwin_tree, seq_num, ADWIN_RESPONSE);
920
921
0
  if (! adwin_tree)
922
0
    return;
923
924
0
  SET_PACKET_TYPE(adwin_tree, APT_UDPR4);
925
0
  proto_tree_add_item(adwin_tree, hf_adwin_status,         tvb, 0,  4, ENC_LITTLE_ENDIAN);
926
0
  proto_tree_add_item(adwin_tree, hf_adwin_packet_index,   tvb, 4,  4, ENC_LITTLE_ENDIAN);
927
0
  proto_tree_add_item(adwin_tree, hf_adwin_packet_no,      tvb, 1408,  4, ENC_LITTLE_ENDIAN);
928
0
  proto_tree_add_item_ret_uint(adwin_tree, hf_adwin_data_type, tvb, 1412,  4, ENC_LITTLE_ENDIAN, &data_type);
929
930
0
  if (! global_adwin_dissect_data) {
931
0
    call_data_dissector(tvb_new_subset_length(tvb, 8, 350*4), pinfo, adwin_debug_tree);
932
0
    return;
933
0
  }
934
935
0
  for (i = 0; i < 350; i++) {
936
0
    proto_item *item;
937
0
    uint32_t offset = 8 + i * (int)sizeof(uint32_t);
938
0
    int32_t value = tvb_get_letohl(tvb, offset);
939
0
    void * fvalue = &value;
940
0
    switch (data_type) {
941
0
    case 2:
942
0
    case 3:
943
0
    case 4:  /* some kind of int, usually int/long */
944
0
      proto_tree_add_none_format(adwin_debug_tree, hf_adwin_data, tvb, offset, 4,
945
0
              "Data[%3d]: %10d - 0x%08x",
946
0
              i, value, value);
947
0
      item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_int,   tvb, offset, 4, ENC_LITTLE_ENDIAN);
948
0
      proto_item_set_hidden(item);
949
0
      item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_hex,   tvb, offset, 4, ENC_LITTLE_ENDIAN);
950
0
      proto_item_set_hidden(item);
951
0
      break;
952
0
    case 5: /* float */
953
0
      proto_tree_add_none_format(adwin_debug_tree, hf_adwin_data, tvb, offset, 4,
954
0
              "Data[%3d]: %10f - 0x%08x",
955
0
              i, *(float*)fvalue, value);
956
0
      item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_float, tvb, offset, 4, ENC_LITTLE_ENDIAN);
957
0
      proto_item_set_hidden(item);
958
0
      item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_hex,   tvb, offset, 4, ENC_LITTLE_ENDIAN);
959
0
      proto_item_set_hidden(item);
960
0
      break;
961
0
    default: /* string, double, variant, something funny... */
962
0
      proto_tree_add_none_format(adwin_debug_tree, hf_adwin_data, tvb, offset, 4,
963
0
              "Data[%3d]: 0x%08x",
964
0
              i, value);
965
0
      item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_hex,   tvb, offset, 4, ENC_LITTLE_ENDIAN);
966
0
      proto_item_set_hidden(item);
967
0
    }
968
0
  }
969
0
}
970
971
static void
972
dissect_GDSHP(tvbuff_t *tvb, packet_info *pinfo,
973
        proto_tree *adwin_tree, proto_tree *adwin_debug_tree)
974
0
{
975
0
  uint32_t i, seq_num;
976
977
  /* Get the transaction identifier */
978
0
  seq_num = tvb_get_ntohl(tvb, 0);
979
0
  adwin_request_response_handling(tvb, pinfo, adwin_tree, seq_num, ADWIN_RESPONSE);
980
981
0
  if (! adwin_tree)
982
0
    return;
983
984
0
  SET_PACKET_TYPE(adwin_tree, APT_GDSHP);
985
0
  proto_tree_add_item(adwin_tree, hf_adwin_packet_index,   tvb, 0,  4, ENC_BIG_ENDIAN);
986
0
  proto_tree_add_item(adwin_tree, hf_adwin_packet_no,      tvb, 4,  4, ENC_BIG_ENDIAN);
987
0
  proto_tree_add_item(adwin_tree, hf_adwin_unused,         tvb, 8,  4, ENC_NA);
988
989
0
  if (! global_adwin_dissect_data) {
990
0
    call_data_dissector(tvb_new_subset_length(tvb, 12, 336*4), pinfo, adwin_debug_tree);
991
0
    return;
992
0
  }
993
994
0
  for (i = 0; i < 336; i++) {
995
0
    proto_item *item;
996
0
    uint32_t offset = 12 + i * (int)sizeof(uint32_t);
997
0
    int32_t value = tvb_get_letohl(tvb, offset);
998
0
    void * fvalue = &value;
999
0
    proto_tree_add_none_format(adwin_debug_tree, hf_adwin_data, tvb, offset, 4,
1000
0
            "Data[%3d]: %10d - %10f - 0x%08x",
1001
0
            i, value, *(float*)fvalue, value);
1002
0
    item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_int,   tvb, offset, 4, ENC_LITTLE_ENDIAN);
1003
0
    proto_item_set_hidden(item);
1004
0
    item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_float, tvb, offset, 4, ENC_LITTLE_ENDIAN);
1005
0
    proto_item_set_hidden(item);
1006
0
    item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_hex,   tvb, offset, 4, ENC_LITTLE_ENDIAN);
1007
0
    proto_item_set_hidden(item);
1008
0
  }
1009
0
}
1010
1011
static void
1012
dissect_GDSHR(tvbuff_t *tvb, packet_info *pinfo,
1013
        proto_tree *adwin_tree, proto_tree *adwin_debug_tree)
1014
1
{
1015
1
  uint32_t is_range, packet_start, packet_end, seq_num;
1016
1
  proto_item *ti;
1017
1018
  /* Get the transaction identifier */
1019
1
  seq_num = tvb_get_ntohl(tvb, 0);
1020
1
  adwin_request_response_handling(tvb, pinfo, adwin_tree, seq_num, ADWIN_RESPONSE);
1021
1022
1
  if (! adwin_tree)
1023
0
    return;
1024
1025
1
  SET_PACKET_TYPE(adwin_tree, APT_GDSHR);
1026
1
  proto_tree_add_item(adwin_tree, hf_adwin_packet_index,        tvb, 0,  4, ENC_BIG_ENDIAN);
1027
1
  proto_tree_add_item(adwin_tree, hf_adwin_request_no,          tvb, 4,  4, ENC_BIG_ENDIAN);
1028
1
  proto_tree_add_item(adwin_tree, hf_adwin_complete_packets,    tvb, 8,  4, ENC_BIG_ENDIAN);
1029
1
  proto_tree_add_item(adwin_debug_tree, hf_adwin_is_range,     tvb, 12,  4, ENC_BIG_ENDIAN);
1030
1
  proto_tree_add_item(adwin_debug_tree, hf_adwin_packet_start, tvb, 16,  4, ENC_BIG_ENDIAN);
1031
1
  proto_tree_add_item(adwin_debug_tree, hf_adwin_packet_end,   tvb, 20,  4, ENC_BIG_ENDIAN);
1032
1033
1
  is_range = tvb_get_ntohl(tvb, 12);
1034
1
  packet_start = tvb_get_ntohl(tvb, 16);
1035
1036
1
  switch(is_range) {
1037
1
  case 0:
1038
1
    ti = proto_tree_add_uint_format_value(adwin_tree, hf_adwin_gdsh_status, tvb, 12, 4,
1039
1
            is_range, "get single packet no %d", packet_start);
1040
1
    break;
1041
0
  case 1:
1042
0
    packet_end = tvb_get_ntohl(tvb, 20);
1043
0
    ti = proto_tree_add_uint_format_value(adwin_tree, hf_adwin_gdsh_status, tvb, 12, 4,
1044
0
            is_range, "get packets %d - %d",
1045
0
            packet_start, packet_end);
1046
0
    break;
1047
0
  case 2:
1048
0
    ti = proto_tree_add_uint_format_value(adwin_tree, hf_adwin_gdsh_status, tvb, 12, 4,
1049
0
            is_range, "finished");
1050
0
    break;
1051
0
  default: /* should not happen */
1052
0
    ti = proto_tree_add_uint_format_value(adwin_tree, hf_adwin_gdsh_status, tvb, 12, 4,
1053
0
            is_range, "unknown code %d", is_range);
1054
1
  }
1055
1
  proto_item_set_len(ti, 12);
1056
1
  proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,       tvb, 24, 40, ENC_NA);
1057
1
}
1058
1059
/* here we determine which type of packet is sent by looking at its
1060
   size. That is safe since the main server application that processes
1061
   these packets does it this way, too.
1062
1063
   Depending on the packet type, the appropriate dissector is
1064
   called. */
1065
1066
static int
1067
dissect_adwin(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1068
7
{
1069
7
  proto_item *ti, *ti2;
1070
7
  proto_tree *adwin_tree, *adwin_debug_tree;
1071
7
  char *info_string;
1072
7
  uint32_t length;
1073
1074
7
  length = tvb_reported_length(tvb);
1075
1076
  /* First do some heuristics to see if this packet belongs to us */
1077
7
  if(! (length == UDPH1_OLD_LENGTH
1078
5
        || length == UDPH1_NEW_LENGTH
1079
3
        || length == UDPR1_LENGTH
1080
3
        || length == UDPH2_LENGTH
1081
3
        || length == UDPR2_LENGTH
1082
3
        || length == UDPR3_LENGTH
1083
3
        || length == UDPR4_LENGTH
1084
3
        || length == GetDataSHPacket_LENGTH
1085
3
        || length == GetDataSHRequest_LENGTH))
1086
2
    return 0;
1087
1088
5
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "ADwin");
1089
5
  col_clear(pinfo->cinfo, COL_INFO);
1090
1091
5
  ti = proto_tree_add_item(tree, proto_adwin, tvb, 0, -1, ENC_NA);
1092
5
  adwin_tree = proto_item_add_subtree(ti, ett_adwin);
1093
1094
5
  ti2 = proto_tree_add_item(adwin_tree, proto_adwin, tvb, 0, -1, ENC_NA);
1095
5
  adwin_debug_tree = proto_item_add_subtree(ti2, ett_adwin_debug);
1096
5
  proto_item_set_text(ti2, "ADwin Debug information");
1097
1098
5
  switch (length) {
1099
2
  case UDPH1_OLD_LENGTH:
1100
2
    dissect_UDPH1_old(tvb, pinfo, adwin_tree, adwin_debug_tree, &info_string);
1101
2
    break;
1102
2
  case UDPH1_NEW_LENGTH:
1103
2
    dissect_UDPH1_new(tvb, pinfo, adwin_tree, adwin_debug_tree, &info_string);
1104
2
    break;
1105
0
  case UDPR1_LENGTH:
1106
0
    dissect_UDPR1(tvb, pinfo, adwin_tree, adwin_debug_tree, &info_string);
1107
0
    break;
1108
0
  case UDPH2_LENGTH: /* to the best of my knowledge, this struct
1109
          * has never been used publicly! */
1110
    /* dissect_UDPH2(tvb, pinfo, adwin_tree, adwin_debug_tree); */
1111
0
    info_string = wmem_strdup(pinfo->pool, "UDPH2 - UNUSED");
1112
0
    break;
1113
0
  case UDPR2_LENGTH:
1114
0
    dissect_UDPR2(tvb, pinfo, adwin_tree, adwin_debug_tree, &info_string);
1115
0
    break;
1116
0
  case UDPR3_LENGTH:
1117
0
    dissect_UDPR3(tvb, pinfo, adwin_tree, adwin_debug_tree);
1118
0
    info_string = wmem_strdup(pinfo->pool, "UDPR3");
1119
0
    break;
1120
0
  case UDPR4_LENGTH:
1121
0
    dissect_UDPR4(tvb, pinfo, adwin_tree, adwin_debug_tree, &info_string);
1122
0
    break;
1123
0
  case GetDataSHPacket_LENGTH:
1124
0
    dissect_GDSHP(tvb, pinfo, adwin_tree, adwin_debug_tree);
1125
0
    info_string = wmem_strdup(pinfo->pool, "GDSHP");
1126
0
    break;
1127
1
  case GetDataSHRequest_LENGTH:
1128
1
    dissect_GDSHR(tvb, pinfo, adwin_tree, adwin_debug_tree);
1129
1
    info_string = wmem_strdup(pinfo->pool, "GDSHR");
1130
1
    break;
1131
0
  default:
1132
0
    info_string = wmem_strdup_printf(pinfo->pool, "Unknown ADwin packet, length: %d", length);
1133
0
    break;
1134
5
  }
1135
1136
5
  col_add_str(pinfo->cinfo, COL_INFO, info_string);
1137
1138
5
  return (tvb_reported_length(tvb));
1139
5
}
1140
1141
1142
void
1143
proto_reg_handoff_adwin(void)
1144
15
{
1145
15
  dissector_add_uint_with_preference("udp.port", ADWIN_COMM_PORT, adwin_handle);
1146
15
}
1147
1148
void
1149
proto_register_adwin(void)
1150
15
{
1151
15
  static hf_register_info hf[] = {
1152
15
    { &hf_adwin_address,
1153
15
      { "memory address", "adwin.address",
1154
15
        FT_UINT32, BASE_HEX, NULL, 0x0,
1155
15
        "Memory address to read on DSP", HFILL }
1156
15
    },
1157
15
    { &hf_adwin_armVersion,
1158
15
      { "Get ARM Version", "adwin.armVersion",
1159
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1160
15
        NULL, HFILL }
1161
15
    },
1162
15
    { &hf_adwin_binfilesize,
1163
15
      { "File size", "adwin.binfilesize",
1164
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1165
15
        "Size of binary file", HFILL }
1166
15
    },
1167
15
    { &hf_adwin_blocksize,
1168
15
      { "Blocksize", "adwin.blocksize",
1169
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1170
15
        "Maximum number of unacknowledged packets", HFILL }
1171
15
    },
1172
15
    { &hf_adwin_complete_packets,
1173
15
      { "Complete packets", "adwin.complete_packets",
1174
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1175
15
        "Highest sequential package number", HFILL }
1176
15
    },
1177
15
    { &hf_adwin_count,
1178
15
      { "Count", "adwin.count",
1179
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1180
15
        "Number of longs", HFILL }
1181
15
    },
1182
15
    { &hf_adwin_data,
1183
15
      { "Data", "adwin.data",
1184
15
        FT_NONE, BASE_NONE, NULL, 0x0,
1185
15
        NULL, HFILL }
1186
15
    },
1187
15
    { &hf_adwin_data_int,
1188
15
      { "Data element int", "adwin.data_int",
1189
15
        FT_INT32, BASE_DEC, NULL, 0x0,
1190
15
        NULL, HFILL }
1191
15
    },
1192
15
    { &hf_adwin_data_float,
1193
15
      { "Data element float", "adwin.data_float",
1194
15
        FT_FLOAT, BASE_NONE, NULL, 0x0,
1195
15
        NULL, HFILL }
1196
15
    },
1197
15
    { &hf_adwin_data_hex,
1198
15
      { "Data element hex", "adwin.data_hex",
1199
15
        FT_UINT32, BASE_HEX, NULL, 0x0,
1200
15
        NULL, HFILL }
1201
15
    },
1202
15
    { &hf_adwin_data_no16,
1203
15
      { "Data No. (16bit)", "adwin.data_no16",
1204
15
        FT_UINT16, BASE_DEC, NULL, 0x0,
1205
15
        NULL, HFILL }
1206
15
    },
1207
15
    { &hf_adwin_data_no32,
1208
15
      { "Data No. (32bit)", "adwin.data_no32",
1209
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1210
15
        NULL, HFILL }
1211
15
    },
1212
15
    { &hf_adwin_data_type,
1213
15
      { "Data type", "adwin.data_type",
1214
15
        FT_UINT32, BASE_DEC|BASE_EXT_STRING, &data_type_mapping_ext, 0x0,
1215
15
        NULL, HFILL }
1216
15
    },
1217
15
    { &hf_adwin_data_packet_index,
1218
15
      { "Data packet index", "adwin.data_packet_index",
1219
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1220
15
        NULL, HFILL }
1221
15
    },
1222
15
    { &hf_adwin_dll_version,
1223
15
      { "DLL Version", "adwin.dll_version",
1224
15
        FT_STRINGZ, BASE_NONE, NULL, 0x0,
1225
15
        NULL, HFILL }
1226
15
    },
1227
15
    { &hf_adwin_fifo_no16,
1228
15
      { "FiFo No. (16bit)", "adwin.fifo_no",
1229
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1230
15
        NULL, HFILL }
1231
15
    },
1232
15
    { &hf_adwin_fifo_no32,
1233
15
      { "FiFo No. (32bit)", "adwin.fifo_no",
1234
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1235
15
        NULL, HFILL }
1236
15
    },
1237
15
    { &hf_adwin_instruction,
1238
15
      { "Instruction", "adwin.instruction",
1239
15
        FT_UINT32, BASE_DEC|BASE_EXT_STRING, &instruction_mapping_ext, 0x0,
1240
15
        NULL, HFILL }
1241
15
    },
1242
15
    { &hf_adwin_is_range,
1243
15
      { "packets are a range", "adwin.is_range",
1244
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1245
15
        NULL, HFILL }
1246
15
    },
1247
15
    { &hf_adwin_i3plus1,
1248
15
      { "3+1 Instruction", "adwin.i3plus1",
1249
15
        FT_UINT32, BASE_DEC|BASE_EXT_STRING, &instruction_3plus1_mapping_ext, 0x0,
1250
15
        NULL, HFILL }
1251
15
    },
1252
15
    { &hf_adwin_link_addr,
1253
15
      { "Link address", "adwin.link_addr",
1254
15
        FT_UINT32, BASE_HEX, NULL, 0x0,
1255
15
        "Link address (TCP/IP Server only)", HFILL }
1256
15
    },
1257
15
    { &hf_adwin_mem_type,
1258
15
      { "Memory type", "adwin.mem_type",
1259
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1260
15
        NULL, HFILL }
1261
15
    },
1262
15
    { &hf_adwin_memsize,
1263
15
      { "Memory size", "adwin.memsize",
1264
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1265
15
        NULL, HFILL }
1266
15
    },
1267
15
    { &hf_adwin_osys,
1268
15
      { "Operating system", "adwin.osys",
1269
15
        FT_UINT32, BASE_DEC|BASE_EXT_STRING, &osys_mapping_ext, 0x0,
1270
15
        "Operating system / environment", HFILL }
1271
15
    },
1272
15
    { &hf_adwin_packet_end,
1273
15
      { "End packet", "adwin.packet_end",
1274
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1275
15
        "GDSH: End Packet", HFILL }
1276
15
    },
1277
15
    { &hf_adwin_gdsh_status,
1278
15
      { "GDSH status", "adwin.gdsh_status",
1279
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1280
15
        NULL, HFILL }
1281
15
    },
1282
15
    { &hf_adwin_packet_index,
1283
15
      { "Packet index", "adwin.packet_index",
1284
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1285
15
        NULL, HFILL }
1286
15
    },
1287
15
    { &hf_adwin_packet_no,
1288
15
      { "Packet No.", "adwin.packet_no",
1289
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1290
15
        NULL, HFILL }
1291
15
    },
1292
15
    { &hf_adwin_packet_start,
1293
15
      { "Starting packet", "adwin.packet_start",
1294
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1295
15
        "GDSH: Starting Packet", HFILL }
1296
15
    },
1297
15
    { &hf_adwin_packet_type,
1298
15
      { "Packet type", "adwin.packet_type",
1299
15
        FT_INT32, BASE_DEC|BASE_EXT_STRING, &packet_type_mapping_ext, 0x0,
1300
15
        NULL, HFILL }
1301
15
    },
1302
15
    { &hf_adwin_parameter,
1303
15
      { "Parameter", "adwin.parameter",
1304
15
        FT_UINT32, BASE_DEC|BASE_EXT_STRING, &parameter_mapping_ext, 0x0,
1305
15
        NULL, HFILL }
1306
15
    },
1307
15
    { &hf_adwin_password,
1308
15
      { "Password", "adwin.password",
1309
15
        FT_STRING, BASE_NONE, NULL, 0x0,
1310
15
        "Password for ADwin system", HFILL }
1311
15
    },
1312
15
    { &hf_adwin_process_no,
1313
15
      { "Process No.", "adwin.process_no",
1314
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1315
15
        NULL, HFILL }
1316
15
    },
1317
15
    { &hf_adwin_processor,
1318
15
      { "Processor", "adwin.processor",
1319
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1320
15
        NULL, HFILL }
1321
15
    },
1322
15
    { &hf_adwin_response_in,
1323
15
      { "Response In", "adwin.response_in",
1324
15
        FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE), 0x0,
1325
15
        "The response to this ADwin request is in this frame", HFILL }
1326
15
    },
1327
15
    { &hf_adwin_response_to,
1328
15
      { "Request In", "adwin.response_to",
1329
15
        FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_REQUEST), 0x0,
1330
15
        "This is a response to the ADwin request in this frame", HFILL }
1331
15
    },
1332
15
    { &hf_adwin_response_time,
1333
15
      { "Response time", "adwin.response_time",
1334
15
        FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
1335
15
        "The time between the Request and the Reply", HFILL }
1336
15
    },
1337
15
    { &hf_adwin_retry_packet_index,
1338
15
      { "Retry packet index", "adwin.retry_packet_index",
1339
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1340
15
        NULL, HFILL }
1341
15
    },
1342
15
    { &hf_adwin_request_no,
1343
15
      { "Request Number", "adwin.request_no",
1344
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1345
15
        "Request number index", HFILL }
1346
15
    },
1347
15
    { &hf_adwin_start_index,
1348
15
      { "Start index", "adwin.start_index",
1349
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1350
15
        NULL, HFILL }
1351
15
    },
1352
15
    { &hf_adwin_status,
1353
15
      { "Status", "adwin.status",
1354
15
        FT_INT32, BASE_DEC|BASE_EXT_STRING, &error_code_mapping_ext, 0x0,
1355
15
        NULL, HFILL }
1356
15
    },
1357
15
    { &hf_adwin_timeout,
1358
15
      { "Timeout", "adwin.timeout",
1359
15
        FT_UINT32, BASE_DEC, NULL, 0x0,
1360
15
        "Timeout in ms", HFILL }
1361
15
    },
1362
15
    { &hf_adwin_unused,
1363
15
      { "Unused", "adwin.unused",
1364
15
        FT_NONE, BASE_NONE, NULL, 0x0,
1365
15
        NULL, HFILL }
1366
15
    },
1367
15
    { &hf_adwin_val1,
1368
15
      { "Value 1 (as int)", "adwin.val1",
1369
15
        FT_INT32, BASE_DEC, NULL, 0x0,
1370
15
        "Generic return value 1 interpreted as integer (correct interpretation depends on request).", HFILL }
1371
15
    },
1372
15
    { &hf_adwin_val1f,
1373
15
      { "Value 1 (as float)", "adwin.val1f",
1374
15
        FT_FLOAT, BASE_NONE, NULL, 0x0,
1375
15
        "Generic return value 1 interpreted as float (correct interpretation depends on request).", HFILL }
1376
15
    },
1377
15
    { &hf_adwin_val2,
1378
15
      { "Value 2", "adwin.val2",
1379
15
        FT_INT32, BASE_DEC, NULL, 0x0,
1380
15
        "Generic return value 2 (interpretation depends on request).", HFILL }
1381
15
    },
1382
15
    { &hf_adwin_val3,
1383
15
      { "Value 3", "adwin.val3",
1384
15
        FT_INT32, BASE_DEC, NULL, 0x0,
1385
15
        "Generic return value 3 (interpretation depends on request).", HFILL }
1386
15
    },
1387
15
    { &hf_adwin_val4,
1388
15
      { "Value 4", "adwin.val4",
1389
15
        FT_INT32, BASE_DEC, NULL, 0x0,
1390
15
        "Generic return value 4 (interpretation depends on request).", HFILL }
1391
15
    },
1392
15
  };
1393
1394
  /* Setup protocol subtree array */
1395
15
  static int *ett[] = {
1396
15
    &ett_adwin,
1397
15
    &ett_adwin_debug,
1398
15
  };
1399
15
  module_t *adwin_module;
1400
1401
  /* Register the protocol name and description */
1402
15
  proto_adwin = proto_register_protocol("ADwin communication protocol",
1403
15
                "ADwin", "adwin");
1404
1405
  /* Required function calls to register the header fields and
1406
     subtrees used */
1407
15
  proto_register_field_array(proto_adwin, hf, array_length(hf));
1408
15
  proto_register_subtree_array(ett, array_length(ett));
1409
1410
  /* Register our configuration options for ADwin */
1411
15
  adwin_module = prefs_register_protocol(proto_adwin, NULL);
1412
1413
15
  prefs_register_bool_preference(adwin_module, "dissect_data",
1414
15
               "Dissect Data sections",
1415
15
               "Specify if the Data sections of packets "
1416
15
               "should be dissected or not",
1417
15
               &global_adwin_dissect_data);
1418
1419
15
  adwin_handle = register_dissector("adwin", dissect_adwin, proto_adwin);
1420
15
}
1421
1422
/*
1423
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
1424
 *
1425
 * Local variables:
1426
 * c-basic-offset: 8
1427
 * tab-width: 8
1428
 * indent-tabs-mode: t
1429
 * End:
1430
 *
1431
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
1432
 * :indentSize=8:tabSize=8:noTabs=false:
1433
 */