Coverage Report

Created: 2026-01-02 06:13

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
14
#define ADWIN_COMM_PORT 6543 /* Not IANA registered */
23
24
/* lengths of valid packet structures */
25
17
#define UDPH1_OLD_LENGTH              52
26
16
#define UDPH1_NEW_LENGTH              56
27
15
#define UDPR1_LENGTH                  32
28
13
#define UDPH2_LENGTH                 412 /* AFAIK: unused */
29
13
#define UDPR2_LENGTH                1008
30
13
#define UDPR3_LENGTH                1408
31
13
#define UDPR4_LENGTH                1416
32
13
#define GetDataSHPacket_LENGTH      1356
33
6
#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
2
#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
5
  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
4
{
509
4
  conversation_t *conversation;
510
4
  adwin_conv_info_t *adwin_info;
511
4
  adwin_transaction_t *adwin_trans;
512
513
  /*
514
   * Find or create a conversation for this connection.
515
   */
516
4
  conversation = find_or_create_conversation(pinfo);
517
518
  /*
519
   * Do we already have a state structure for this conv
520
   */
521
4
  adwin_info = (adwin_conv_info_t *)conversation_get_proto_data(conversation, proto_adwin);
522
4
  if (!adwin_info) {
523
    /*
524
     * No.  Attach that information to the conversation, and add
525
     * it to the list of information structures.
526
     */
527
2
    adwin_info = wmem_new(wmem_file_scope(), adwin_conv_info_t);
528
2
    adwin_info->pdus = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal);
529
530
2
    conversation_add_proto_data(conversation, proto_adwin, adwin_info);
531
2
  }
532
4
  if (!pinfo->fd->visited) {
533
4
    if (direction == ADWIN_REQUEST) {
534
      /* This is a request */
535
2
      adwin_trans = wmem_new(wmem_file_scope(), adwin_transaction_t);
536
2
      adwin_trans->req_frame = pinfo->num;
537
2
      adwin_trans->rep_frame = 0;
538
2
      adwin_trans->req_time = pinfo->abs_ts;
539
2
      wmem_map_insert(adwin_info->pdus, GUINT_TO_POINTER(seq_num), (void *)adwin_trans);
540
2
    } else {
541
2
      adwin_trans = (adwin_transaction_t *)wmem_map_lookup(adwin_info->pdus, GUINT_TO_POINTER(seq_num));
542
2
      if (adwin_trans) {
543
0
        adwin_trans->rep_frame = pinfo->num;
544
0
      }
545
2
    }
546
4
  } else {
547
0
    adwin_trans = (adwin_transaction_t *)wmem_map_lookup(adwin_info->pdus, GUINT_TO_POINTER(seq_num));
548
0
  }
549
4
  if (!adwin_trans) {
550
    /* create a "fake" adwin_trans structure */
551
2
    adwin_trans = wmem_new(pinfo->pool, adwin_transaction_t);
552
2
    adwin_trans->req_frame = 0;
553
2
    adwin_trans->rep_frame = 0;
554
2
    adwin_trans->req_time = pinfo->abs_ts;
555
2
  }
556
557
  /* print state tracking in the tree */
558
4
  if (direction == ADWIN_REQUEST) {
559
    /* This is a request */
560
2
    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
2
  } else {
568
    /* This is a reply */
569
2
    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
2
  }
582
4
}
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
2
{
588
2
  uint32_t i3plus1code =  0, instructionID, seq_num;
589
590
2
  instructionID = tvb_get_letohl(tvb, 0);
591
2
  *info_string = wmem_strdup_printf(pinfo->pool, "%s: %s", packet_name,
592
2
                val_to_str_ext(pinfo->pool, instructionID, &instruction_mapping_ext, "unknown instruction: %d"));
593
594
2
  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
2
  seq_num = tvb_get_letohl(tvb, 4);
603
2
  adwin_request_response_handling(tvb, pinfo, adwin_tree, seq_num, ADWIN_REQUEST);
604
605
2
  if (! adwin_tree)
606
0
    return;
607
608
2
  SET_PACKET_TYPE(adwin_tree, APT_UDPH1_old);
609
610
2
  proto_tree_add_item(adwin_tree, hf_adwin_instruction,          tvb, 0,  4, ENC_LITTLE_ENDIAN);
611
2
  proto_tree_add_item(adwin_tree, hf_adwin_packet_index,         tvb, 4,  4, ENC_LITTLE_ENDIAN);
612
2
  proto_tree_add_item(adwin_tree, hf_adwin_password,             tvb, 8, 10, ENC_ASCII);
613
2
  proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,        tvb, 18,  2, ENC_NA);
614
615
2
  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
1
  default: ; /* should not happen */
737
    /* illegal values should be displayed properly by
738
       instruction_mapping */
739
2
  }
740
741
2
  proto_tree_add_item(adwin_debug_tree, hf_adwin_link_addr, tvb, 36,  4, ENC_LITTLE_ENDIAN);
742
2
  proto_tree_add_item(adwin_tree, hf_adwin_timeout,        tvb, 40,  4, ENC_LITTLE_ENDIAN);
743
2
  proto_tree_add_item(adwin_debug_tree, hf_adwin_osys,     tvb, 44,  4, ENC_LITTLE_ENDIAN);
744
2
  proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,   tvb, 48,  4, ENC_NA);
745
746
2
}
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
1
{
753
1
  dissect_UDPH1_generic(tvb, pinfo, adwin_tree, adwin_debug_tree, info_string, "UDPH1 (old)");
754
1
}
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
1
{
761
1
  char* dll_version_s;
762
1
  int32_t dll_i;
763
764
1
  dissect_UDPH1_generic(tvb, pinfo, adwin_tree, adwin_debug_tree, info_string, "UDPH1 (new)");
765
766
1
  if (! adwin_tree)
767
0
    return;
768
769
1
  SET_PACKET_TYPE(adwin_tree, APT_UDPH1_new);
770
1
  dll_i = tvb_get_letohl(tvb, 52);
771
1
  dll_version_s = wmem_strdup_printf(pinfo->pool, "%d.%d.%d",
772
1
          dll_i / 1000000,
773
1
          (dll_i - dll_i / 1000000 * 1000000) / 1000,
774
1
          dll_i % 1000);
775
776
1
  proto_tree_add_string(adwin_debug_tree, hf_adwin_dll_version,
777
1
            tvb, 52, 4, dll_version_s);
778
1
}
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
1
{
785
1
  const char *status_string;
786
1
  uint32_t seq_num, status;
787
788
1
  status = tvb_get_letohl(tvb, 0);
789
1
  status_string = try_val_to_str_ext(status, &error_code_mapping_ext);
790
1
  if (status_string) {
791
0
    *info_string = wmem_strdup_printf(pinfo->pool, "UDPR1 Status: %s", status_string);
792
1
  } else {
793
1
    *info_string = wmem_strdup_printf(pinfo->pool, "UDPR1 Undefined error code %d", status);
794
1
  }
795
796
  /* Get the transaction identifier */
797
1
  seq_num = tvb_get_letohl(tvb, 4);
798
1
  adwin_request_response_handling(tvb, pinfo, adwin_tree, seq_num, ADWIN_RESPONSE);
799
800
1
  if (! adwin_tree)
801
0
    return;
802
803
1
  SET_PACKET_TYPE(adwin_tree, APT_UDPR1);
804
1
  proto_tree_add_item(adwin_tree, hf_adwin_status,         tvb, 0,  4, ENC_LITTLE_ENDIAN);
805
1
  proto_tree_add_item(adwin_tree, hf_adwin_packet_index,   tvb, 4,  4, ENC_LITTLE_ENDIAN);
806
1
  proto_tree_add_item(adwin_tree, hf_adwin_val1,           tvb, 8,  4, ENC_LITTLE_ENDIAN);
807
1
  proto_tree_add_item(adwin_tree, hf_adwin_val1f,          tvb, 8,  4, ENC_LITTLE_ENDIAN);
808
1
  proto_tree_add_item(adwin_tree, hf_adwin_val2,          tvb, 12,  4, ENC_LITTLE_ENDIAN);
809
1
  proto_tree_add_item(adwin_tree, hf_adwin_val3,          tvb, 16,  4, ENC_LITTLE_ENDIAN);
810
1
  proto_tree_add_item(adwin_tree, hf_adwin_val4,          tvb, 20,  4, ENC_LITTLE_ENDIAN);
811
1
  proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,  tvb, 24,  8, ENC_NA);
812
1
}
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(adwin_tree, hf_adwin_data_type,      tvb, 1412,  4, ENC_LITTLE_ENDIAN);
929
930
0
  data_type = tvb_get_letohl(tvb, 1412);
931
932
0
  if (! global_adwin_dissect_data) {
933
0
    call_data_dissector(tvb_new_subset_length(tvb, 8, 350*4), pinfo, adwin_debug_tree);
934
0
    return;
935
0
  }
936
937
0
  for (i = 0; i < 350; i++) {
938
0
    proto_item *item;
939
0
    uint32_t offset = 8 + i * (int)sizeof(uint32_t);
940
0
    int32_t value = tvb_get_letohl(tvb, offset);
941
0
    void * fvalue = &value;
942
0
    switch (data_type) {
943
0
    case 2:
944
0
    case 3:
945
0
    case 4:  /* some kind of int, usually int/long */
946
0
      proto_tree_add_none_format(adwin_debug_tree, hf_adwin_data, tvb, offset, 4,
947
0
              "Data[%3d]: %10d - 0x%08x",
948
0
              i, value, value);
949
0
      item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_int,   tvb, offset, 4, ENC_LITTLE_ENDIAN);
950
0
      proto_item_set_hidden(item);
951
0
      item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_hex,   tvb, offset, 4, ENC_LITTLE_ENDIAN);
952
0
      proto_item_set_hidden(item);
953
0
      break;
954
0
    case 5: /* float */
955
0
      proto_tree_add_none_format(adwin_debug_tree, hf_adwin_data, tvb, offset, 4,
956
0
              "Data[%3d]: %10f - 0x%08x",
957
0
              i, *(float*)fvalue, value);
958
0
      item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_float, tvb, offset, 4, ENC_LITTLE_ENDIAN);
959
0
      proto_item_set_hidden(item);
960
0
      item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_hex,   tvb, offset, 4, ENC_LITTLE_ENDIAN);
961
0
      proto_item_set_hidden(item);
962
0
      break;
963
0
    default: /* string, double, variant, something funny... */
964
0
      proto_tree_add_none_format(adwin_debug_tree, hf_adwin_data, tvb, offset, 4,
965
0
              "Data[%3d]: 0x%08x",
966
0
              i, value);
967
0
      item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_hex,   tvb, offset, 4, ENC_LITTLE_ENDIAN);
968
0
      proto_item_set_hidden(item);
969
0
    }
970
0
  }
971
0
}
972
973
static void
974
dissect_GDSHP(tvbuff_t *tvb, packet_info *pinfo,
975
        proto_tree *adwin_tree, proto_tree *adwin_debug_tree)
976
0
{
977
0
  uint32_t i, seq_num;
978
979
  /* Get the transaction identifier */
980
0
  seq_num = tvb_get_ntohl(tvb, 0);
981
0
  adwin_request_response_handling(tvb, pinfo, adwin_tree, seq_num, ADWIN_RESPONSE);
982
983
0
  if (! adwin_tree)
984
0
    return;
985
986
0
  SET_PACKET_TYPE(adwin_tree, APT_GDSHP);
987
0
  proto_tree_add_item(adwin_tree, hf_adwin_packet_index,   tvb, 0,  4, ENC_BIG_ENDIAN);
988
0
  proto_tree_add_item(adwin_tree, hf_adwin_packet_no,      tvb, 4,  4, ENC_BIG_ENDIAN);
989
0
  proto_tree_add_item(adwin_tree, hf_adwin_unused,         tvb, 8,  4, ENC_NA);
990
991
0
  if (! global_adwin_dissect_data) {
992
0
    call_data_dissector(tvb_new_subset_length(tvb, 12, 336*4), pinfo, adwin_debug_tree);
993
0
    return;
994
0
  }
995
996
0
  for (i = 0; i < 336; i++) {
997
0
    proto_item *item;
998
0
    uint32_t offset = 12 + i * (int)sizeof(uint32_t);
999
0
    int32_t value = tvb_get_letohl(tvb, offset);
1000
0
    void * fvalue = &value;
1001
0
    proto_tree_add_none_format(adwin_debug_tree, hf_adwin_data, tvb, offset, 4,
1002
0
            "Data[%3d]: %10d - %10f - 0x%08x",
1003
0
            i, value, *(float*)fvalue, value);
1004
0
    item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_int,   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_float, tvb, offset, 4, ENC_LITTLE_ENDIAN);
1007
0
    proto_item_set_hidden(item);
1008
0
    item = proto_tree_add_item(adwin_debug_tree, hf_adwin_data_hex,   tvb, offset, 4, ENC_LITTLE_ENDIAN);
1009
0
    proto_item_set_hidden(item);
1010
0
  }
1011
0
}
1012
1013
static void
1014
dissect_GDSHR(tvbuff_t *tvb, packet_info *pinfo,
1015
        proto_tree *adwin_tree, proto_tree *adwin_debug_tree)
1016
1
{
1017
1
  uint32_t is_range, packet_start, packet_end, seq_num;
1018
1
  proto_item *ti;
1019
1020
  /* Get the transaction identifier */
1021
1
  seq_num = tvb_get_ntohl(tvb, 0);
1022
1
  adwin_request_response_handling(tvb, pinfo, adwin_tree, seq_num, ADWIN_RESPONSE);
1023
1024
1
  if (! adwin_tree)
1025
0
    return;
1026
1027
1
  SET_PACKET_TYPE(adwin_tree, APT_GDSHR);
1028
1
  proto_tree_add_item(adwin_tree, hf_adwin_packet_index,        tvb, 0,  4, ENC_BIG_ENDIAN);
1029
1
  proto_tree_add_item(adwin_tree, hf_adwin_request_no,          tvb, 4,  4, ENC_BIG_ENDIAN);
1030
1
  proto_tree_add_item(adwin_tree, hf_adwin_complete_packets,    tvb, 8,  4, ENC_BIG_ENDIAN);
1031
1
  proto_tree_add_item(adwin_debug_tree, hf_adwin_is_range,     tvb, 12,  4, ENC_BIG_ENDIAN);
1032
1
  proto_tree_add_item(adwin_debug_tree, hf_adwin_packet_start, tvb, 16,  4, ENC_BIG_ENDIAN);
1033
1
  proto_tree_add_item(adwin_debug_tree, hf_adwin_packet_end,   tvb, 20,  4, ENC_BIG_ENDIAN);
1034
1035
1
  is_range = tvb_get_ntohl(tvb, 12);
1036
1
  packet_start = tvb_get_ntohl(tvb, 16);
1037
1038
1
  switch(is_range) {
1039
1
  case 0:
1040
1
    ti = proto_tree_add_uint_format_value(adwin_tree, hf_adwin_gdsh_status, tvb, 12, 4,
1041
1
            is_range, "get single packet no %d", packet_start);
1042
1
    break;
1043
0
  case 1:
1044
0
    packet_end = tvb_get_ntohl(tvb, 20);
1045
0
    ti = proto_tree_add_uint_format_value(adwin_tree, hf_adwin_gdsh_status, tvb, 12, 4,
1046
0
            is_range, "get packets %d - %d",
1047
0
            packet_start, packet_end);
1048
0
    break;
1049
0
  case 2:
1050
0
    ti = proto_tree_add_uint_format_value(adwin_tree, hf_adwin_gdsh_status, tvb, 12, 4,
1051
0
            is_range, "finished");
1052
0
    break;
1053
0
  default: /* should not happen */
1054
0
    ti = proto_tree_add_uint_format_value(adwin_tree, hf_adwin_gdsh_status, tvb, 12, 4,
1055
0
            is_range, "unknown code %d", is_range);
1056
1
  }
1057
1
  proto_item_set_len(ti, 12);
1058
1
  proto_tree_add_item(adwin_debug_tree, hf_adwin_unused,       tvb, 24, 40, ENC_NA);
1059
1
}
1060
1061
/* here we determine which type of packet is sent by looking at its
1062
   size. That is safe since the main server application that processes
1063
   these packets does it this way, too.
1064
1065
   Depending on the packet type, the appropriate dissector is
1066
   called. */
1067
1068
static int
1069
dissect_adwin(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1070
8
{
1071
8
  proto_item *ti, *ti2;
1072
8
  proto_tree *adwin_tree, *adwin_debug_tree;
1073
8
  char *info_string;
1074
8
  uint32_t length;
1075
1076
8
  length = tvb_reported_length(tvb);
1077
1078
  /* First do some heuristics to see if this packet belongs to us */
1079
8
  if(! (length == UDPH1_OLD_LENGTH
1080
7
        || length == UDPH1_NEW_LENGTH
1081
6
        || length == UDPR1_LENGTH
1082
5
        || length == UDPH2_LENGTH
1083
5
        || length == UDPR2_LENGTH
1084
5
        || length == UDPR3_LENGTH
1085
5
        || length == UDPR4_LENGTH
1086
5
        || length == GetDataSHPacket_LENGTH
1087
5
        || length == GetDataSHRequest_LENGTH))
1088
4
    return 0;
1089
1090
4
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "ADwin");
1091
4
  col_clear(pinfo->cinfo, COL_INFO);
1092
1093
4
  ti = proto_tree_add_item(tree, proto_adwin, tvb, 0, -1, ENC_NA);
1094
4
  adwin_tree = proto_item_add_subtree(ti, ett_adwin);
1095
1096
4
  ti2 = proto_tree_add_item(adwin_tree, proto_adwin, tvb, 0, -1, ENC_NA);
1097
4
  adwin_debug_tree = proto_item_add_subtree(ti2, ett_adwin_debug);
1098
4
  proto_item_set_text(ti2, "ADwin Debug information");
1099
1100
4
  switch (length) {
1101
1
  case UDPH1_OLD_LENGTH:
1102
1
    dissect_UDPH1_old(tvb, pinfo, adwin_tree, adwin_debug_tree, &info_string);
1103
1
    break;
1104
1
  case UDPH1_NEW_LENGTH:
1105
1
    dissect_UDPH1_new(tvb, pinfo, adwin_tree, adwin_debug_tree, &info_string);
1106
1
    break;
1107
1
  case UDPR1_LENGTH:
1108
1
    dissect_UDPR1(tvb, pinfo, adwin_tree, adwin_debug_tree, &info_string);
1109
1
    break;
1110
0
  case UDPH2_LENGTH: /* to the best of my knowledge, this struct
1111
          * has never been used publicly! */
1112
    /* dissect_UDPH2(tvb, pinfo, adwin_tree, adwin_debug_tree); */
1113
0
    info_string = wmem_strdup(pinfo->pool, "UDPH2 - UNUSED");
1114
0
    break;
1115
0
  case UDPR2_LENGTH:
1116
0
    dissect_UDPR2(tvb, pinfo, adwin_tree, adwin_debug_tree, &info_string);
1117
0
    break;
1118
0
  case UDPR3_LENGTH:
1119
0
    dissect_UDPR3(tvb, pinfo, adwin_tree, adwin_debug_tree);
1120
0
    info_string = wmem_strdup(pinfo->pool, "UDPR3");
1121
0
    break;
1122
0
  case UDPR4_LENGTH:
1123
0
    dissect_UDPR4(tvb, pinfo, adwin_tree, adwin_debug_tree, &info_string);
1124
0
    break;
1125
0
  case GetDataSHPacket_LENGTH:
1126
0
    dissect_GDSHP(tvb, pinfo, adwin_tree, adwin_debug_tree);
1127
0
    info_string = wmem_strdup(pinfo->pool, "GDSHP");
1128
0
    break;
1129
1
  case GetDataSHRequest_LENGTH:
1130
1
    dissect_GDSHR(tvb, pinfo, adwin_tree, adwin_debug_tree);
1131
1
    info_string = wmem_strdup(pinfo->pool, "GDSHR");
1132
1
    break;
1133
0
  default:
1134
0
    info_string = wmem_strdup_printf(pinfo->pool, "Unknown ADwin packet, length: %d", length);
1135
0
    break;
1136
4
  }
1137
1138
4
  col_add_str(pinfo->cinfo, COL_INFO, info_string);
1139
1140
4
  return (tvb_reported_length(tvb));
1141
4
}
1142
1143
1144
void
1145
proto_reg_handoff_adwin(void)
1146
14
{
1147
14
  dissector_add_uint_with_preference("udp.port", ADWIN_COMM_PORT, adwin_handle);
1148
14
}
1149
1150
void
1151
proto_register_adwin(void)
1152
14
{
1153
14
  static hf_register_info hf[] = {
1154
14
    { &hf_adwin_address,
1155
14
      { "memory address", "adwin.address",
1156
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
1157
14
        "Memory address to read on DSP", HFILL }
1158
14
    },
1159
14
    { &hf_adwin_armVersion,
1160
14
      { "Get ARM Version", "adwin.armVersion",
1161
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1162
14
        NULL, HFILL }
1163
14
    },
1164
14
    { &hf_adwin_binfilesize,
1165
14
      { "File size", "adwin.binfilesize",
1166
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1167
14
        "Size of binary file", HFILL }
1168
14
    },
1169
14
    { &hf_adwin_blocksize,
1170
14
      { "Blocksize", "adwin.blocksize",
1171
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1172
14
        "Maximum number of unacknowledged packets", HFILL }
1173
14
    },
1174
14
    { &hf_adwin_complete_packets,
1175
14
      { "Complete packets", "adwin.complete_packets",
1176
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1177
14
        "Highest sequential package number", HFILL }
1178
14
    },
1179
14
    { &hf_adwin_count,
1180
14
      { "Count", "adwin.count",
1181
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1182
14
        "Number of longs", HFILL }
1183
14
    },
1184
14
    { &hf_adwin_data,
1185
14
      { "Data", "adwin.data",
1186
14
        FT_NONE, BASE_NONE, NULL, 0x0,
1187
14
        NULL, HFILL }
1188
14
    },
1189
14
    { &hf_adwin_data_int,
1190
14
      { "Data element int", "adwin.data_int",
1191
14
        FT_INT32, BASE_DEC, NULL, 0x0,
1192
14
        NULL, HFILL }
1193
14
    },
1194
14
    { &hf_adwin_data_float,
1195
14
      { "Data element float", "adwin.data_float",
1196
14
        FT_FLOAT, BASE_NONE, NULL, 0x0,
1197
14
        NULL, HFILL }
1198
14
    },
1199
14
    { &hf_adwin_data_hex,
1200
14
      { "Data element hex", "adwin.data_hex",
1201
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
1202
14
        NULL, HFILL }
1203
14
    },
1204
14
    { &hf_adwin_data_no16,
1205
14
      { "Data No. (16bit)", "adwin.data_no16",
1206
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
1207
14
        NULL, HFILL }
1208
14
    },
1209
14
    { &hf_adwin_data_no32,
1210
14
      { "Data No. (32bit)", "adwin.data_no32",
1211
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1212
14
        NULL, HFILL }
1213
14
    },
1214
14
    { &hf_adwin_data_type,
1215
14
      { "Data type", "adwin.data_type",
1216
14
        FT_UINT32, BASE_DEC|BASE_EXT_STRING, &data_type_mapping_ext, 0x0,
1217
14
        NULL, HFILL }
1218
14
    },
1219
14
    { &hf_adwin_data_packet_index,
1220
14
      { "Data packet index", "adwin.data_packet_index",
1221
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1222
14
        NULL, HFILL }
1223
14
    },
1224
14
    { &hf_adwin_dll_version,
1225
14
      { "DLL Version", "adwin.dll_version",
1226
14
        FT_STRINGZ, BASE_NONE, NULL, 0x0,
1227
14
        NULL, HFILL }
1228
14
    },
1229
14
    { &hf_adwin_fifo_no16,
1230
14
      { "FiFo No. (16bit)", "adwin.fifo_no",
1231
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1232
14
        NULL, HFILL }
1233
14
    },
1234
14
    { &hf_adwin_fifo_no32,
1235
14
      { "FiFo No. (32bit)", "adwin.fifo_no",
1236
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1237
14
        NULL, HFILL }
1238
14
    },
1239
14
    { &hf_adwin_instruction,
1240
14
      { "Instruction", "adwin.instruction",
1241
14
        FT_UINT32, BASE_DEC|BASE_EXT_STRING, &instruction_mapping_ext, 0x0,
1242
14
        NULL, HFILL }
1243
14
    },
1244
14
    { &hf_adwin_is_range,
1245
14
      { "packets are a range", "adwin.is_range",
1246
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1247
14
        NULL, HFILL }
1248
14
    },
1249
14
    { &hf_adwin_i3plus1,
1250
14
      { "3+1 Instruction", "adwin.i3plus1",
1251
14
        FT_UINT32, BASE_DEC|BASE_EXT_STRING, &instruction_3plus1_mapping_ext, 0x0,
1252
14
        NULL, HFILL }
1253
14
    },
1254
14
    { &hf_adwin_link_addr,
1255
14
      { "Link address", "adwin.link_addr",
1256
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
1257
14
        "Link address (TCP/IP Server only)", HFILL }
1258
14
    },
1259
14
    { &hf_adwin_mem_type,
1260
14
      { "Memory type", "adwin.mem_type",
1261
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1262
14
        NULL, HFILL }
1263
14
    },
1264
14
    { &hf_adwin_memsize,
1265
14
      { "Memory size", "adwin.memsize",
1266
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1267
14
        NULL, HFILL }
1268
14
    },
1269
14
    { &hf_adwin_osys,
1270
14
      { "Operating system", "adwin.osys",
1271
14
        FT_UINT32, BASE_DEC|BASE_EXT_STRING, &osys_mapping_ext, 0x0,
1272
14
        "Operating system / environment", HFILL }
1273
14
    },
1274
14
    { &hf_adwin_packet_end,
1275
14
      { "End packet", "adwin.packet_end",
1276
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1277
14
        "GDSH: End Packet", HFILL }
1278
14
    },
1279
14
    { &hf_adwin_gdsh_status,
1280
14
      { "GDSH status", "adwin.gdsh_status",
1281
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1282
14
        NULL, HFILL }
1283
14
    },
1284
14
    { &hf_adwin_packet_index,
1285
14
      { "Packet index", "adwin.packet_index",
1286
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1287
14
        NULL, HFILL }
1288
14
    },
1289
14
    { &hf_adwin_packet_no,
1290
14
      { "Packet No.", "adwin.packet_no",
1291
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1292
14
        NULL, HFILL }
1293
14
    },
1294
14
    { &hf_adwin_packet_start,
1295
14
      { "Starting packet", "adwin.packet_start",
1296
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1297
14
        "GDSH: Starting Packet", HFILL }
1298
14
    },
1299
14
    { &hf_adwin_packet_type,
1300
14
      { "Packet type", "adwin.packet_type",
1301
14
        FT_INT32, BASE_DEC|BASE_EXT_STRING, &packet_type_mapping_ext, 0x0,
1302
14
        NULL, HFILL }
1303
14
    },
1304
14
    { &hf_adwin_parameter,
1305
14
      { "Parameter", "adwin.parameter",
1306
14
        FT_UINT32, BASE_DEC|BASE_EXT_STRING, &parameter_mapping_ext, 0x0,
1307
14
        NULL, HFILL }
1308
14
    },
1309
14
    { &hf_adwin_password,
1310
14
      { "Password", "adwin.password",
1311
14
        FT_STRING, BASE_NONE, NULL, 0x0,
1312
14
        "Password for ADwin system", HFILL }
1313
14
    },
1314
14
    { &hf_adwin_process_no,
1315
14
      { "Process No.", "adwin.process_no",
1316
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1317
14
        NULL, HFILL }
1318
14
    },
1319
14
    { &hf_adwin_processor,
1320
14
      { "Processor", "adwin.processor",
1321
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1322
14
        NULL, HFILL }
1323
14
    },
1324
14
    { &hf_adwin_response_in,
1325
14
      { "Response In", "adwin.response_in",
1326
14
        FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE), 0x0,
1327
14
        "The response to this ADwin request is in this frame", HFILL }
1328
14
    },
1329
14
    { &hf_adwin_response_to,
1330
14
      { "Request In", "adwin.response_to",
1331
14
        FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_REQUEST), 0x0,
1332
14
        "This is a response to the ADwin request in this frame", HFILL }
1333
14
    },
1334
14
    { &hf_adwin_response_time,
1335
14
      { "Response time", "adwin.response_time",
1336
14
        FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
1337
14
        "The time between the Request and the Reply", HFILL }
1338
14
    },
1339
14
    { &hf_adwin_retry_packet_index,
1340
14
      { "Retry packet index", "adwin.retry_packet_index",
1341
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1342
14
        NULL, HFILL }
1343
14
    },
1344
14
    { &hf_adwin_request_no,
1345
14
      { "Request Number", "adwin.request_no",
1346
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1347
14
        "Request number index", HFILL }
1348
14
    },
1349
14
    { &hf_adwin_start_index,
1350
14
      { "Start index", "adwin.start_index",
1351
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1352
14
        NULL, HFILL }
1353
14
    },
1354
14
    { &hf_adwin_status,
1355
14
      { "Status", "adwin.status",
1356
14
        FT_INT32, BASE_DEC|BASE_EXT_STRING, &error_code_mapping_ext, 0x0,
1357
14
        NULL, HFILL }
1358
14
    },
1359
14
    { &hf_adwin_timeout,
1360
14
      { "Timeout", "adwin.timeout",
1361
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
1362
14
        "Timeout in ms", HFILL }
1363
14
    },
1364
14
    { &hf_adwin_unused,
1365
14
      { "Unused", "adwin.unused",
1366
14
        FT_NONE, BASE_NONE, NULL, 0x0,
1367
14
        NULL, HFILL }
1368
14
    },
1369
14
    { &hf_adwin_val1,
1370
14
      { "Value 1 (as int)", "adwin.val1",
1371
14
        FT_INT32, BASE_DEC, NULL, 0x0,
1372
14
        "Generic return value 1 interpreted as integer (correct interpretation depends on request).", HFILL }
1373
14
    },
1374
14
    { &hf_adwin_val1f,
1375
14
      { "Value 1 (as float)", "adwin.val1f",
1376
14
        FT_FLOAT, BASE_NONE, NULL, 0x0,
1377
14
        "Generic return value 1 interpreted as float (correct interpretation depends on request).", HFILL }
1378
14
    },
1379
14
    { &hf_adwin_val2,
1380
14
      { "Value 2", "adwin.val2",
1381
14
        FT_INT32, BASE_DEC, NULL, 0x0,
1382
14
        "Generic return value 2 (interpretation depends on request).", HFILL }
1383
14
    },
1384
14
    { &hf_adwin_val3,
1385
14
      { "Value 3", "adwin.val3",
1386
14
        FT_INT32, BASE_DEC, NULL, 0x0,
1387
14
        "Generic return value 3 (interpretation depends on request).", HFILL }
1388
14
    },
1389
14
    { &hf_adwin_val4,
1390
14
      { "Value 4", "adwin.val4",
1391
14
        FT_INT32, BASE_DEC, NULL, 0x0,
1392
14
        "Generic return value 4 (interpretation depends on request).", HFILL }
1393
14
    },
1394
14
  };
1395
1396
  /* Setup protocol subtree array */
1397
14
  static int *ett[] = {
1398
14
    &ett_adwin,
1399
14
    &ett_adwin_debug,
1400
14
  };
1401
14
  module_t *adwin_module;
1402
1403
  /* Register the protocol name and description */
1404
14
  proto_adwin = proto_register_protocol("ADwin communication protocol",
1405
14
                "ADwin", "adwin");
1406
1407
  /* Required function calls to register the header fields and
1408
     subtrees used */
1409
14
  proto_register_field_array(proto_adwin, hf, array_length(hf));
1410
14
  proto_register_subtree_array(ett, array_length(ett));
1411
1412
  /* Register our configuration options for ADwin */
1413
14
  adwin_module = prefs_register_protocol(proto_adwin, NULL);
1414
1415
14
  prefs_register_bool_preference(adwin_module, "dissect_data",
1416
14
               "Dissect Data sections",
1417
14
               "Specify if the Data sections of packets "
1418
14
               "should be dissected or not",
1419
14
               &global_adwin_dissect_data);
1420
1421
14
  adwin_handle = register_dissector("adwin", dissect_adwin, proto_adwin);
1422
14
}
1423
1424
/*
1425
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
1426
 *
1427
 * Local variables:
1428
 * c-basic-offset: 8
1429
 * tab-width: 8
1430
 * indent-tabs-mode: t
1431
 * End:
1432
 *
1433
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
1434
 * :indentSize=8:tabSize=8:noTabs=false:
1435
 */