1 /* packet-adwin-config.c
2 * Routines for ADwin configuration protocol dissection
3 * Copyright 2010, Thomas Boehne <TBoehne[AT]ADwin.de>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include <epan/packet.h>
16 #include "packet-tcp.h"
18 /* Forward declarations */
19 void proto_register_adwin_config(void);
20 void proto_reg_handoff_adwin_config(void);
22 /* This is registered to a different protocol */
23 #define ADWIN_CONFIGURATION_PORT 7000
25 #define UDPStatusLENGTH 52
26 #define UDPExtStatusLENGTH 432
27 #define UDPMessageLENGTH 100
28 #define UDPMessageLENGTH_wrong 104
29 #define UDPInitAckLENGTH 96
30 #define UDPIXP425FlashUpdateLENGTH 92
31 #define UDPOutLENGTH 22
33 #define STATUS_WITH_BOOTLOADER 0x0001
34 #define STATUS_REPROGRAMMABLE 0x0002
35 #define STATUS_CONFIGURABLE 0x0004
36 #define STATUS_BOOTLOADER_BOOTS 0x0008
37 #define STATUS_BOOTLOADER_REPROGRAMMABLE 0x0010
38 #define STATUS_BOOTLOADER_RECEIVES_DATA 0x0020
39 #define STATUS_BOOTLOADER_REPROGRAMMING_DONE 0x0040
40 #define STATUS_WITH_EEPROM_SUPPORT 0x0080
42 static const value_string pattern_mapping[] = {
43 { 0x12343210, "Reset reset/socket counters"},
44 { 0x73241291, "Scan Netarm + IXP"},
45 { 0x37241291, "Scan IXP"},
49 static const value_string config_command_mapping[] = {
50 { 100, "Apply all config values except MAC if MAC matches."},
51 { 105, "Apply all config values including MAC if current MAC is 00:50:C2:0A:22:EE."},
52 { 110, "Apply all config values including MAC."},
53 { 120, "Enable/Disable bootloader if MAC matches."},
54 { 130, "Write extended hardware info to EEPROM."},
58 static const string_string system_type_mapping[] = {
67 static const string_string processor_type_mapping[] = {
74 /* Initialize the protocol and registered fields */
75 static int proto_adwin_config = -1;
77 static int hf_adwin_config_bootloader = -1;
78 static int hf_adwin_config_command = -1;
79 static int hf_adwin_config_data = -1;
80 static int hf_adwin_config_date = -1;
81 static int hf_adwin_config_description = -1;
82 static int hf_adwin_config_dhcp = -1;
83 static int hf_adwin_config_filename = -1;
84 static int hf_adwin_config_filesize = -1;
85 static int hf_adwin_config_filetime = -1;
86 static int hf_adwin_config_updatetime = -1;
87 static int hf_adwin_config_gateway = -1;
88 static int hf_adwin_config_mac = -1;
89 static int hf_adwin_config_netmask_count = -1;
90 static int hf_adwin_config_netmask = -1;
91 static int hf_adwin_config_password = -1;
92 static int hf_adwin_config_path = -1;
93 static int hf_adwin_config_pattern = -1;
94 static int hf_adwin_config_port16 = -1;
95 static int hf_adwin_config_port32 = -1;
96 static int hf_adwin_config_reboot = -1;
97 static int hf_adwin_config_scan_id = -1;
98 static int hf_adwin_config_reply_broadcast = -1;
99 static int hf_adwin_config_revision = -1;
100 static int hf_adwin_config_processor_type_raw = -1;
101 static int hf_adwin_config_system_type_raw = -1;
102 static int hf_adwin_config_processor_type = -1;
103 static int hf_adwin_config_system_type = -1;
104 static int hf_adwin_config_server_ip = -1;
105 static int hf_adwin_config_server_version = -1;
106 static int hf_adwin_config_server_version_beta = -1;
107 static int hf_adwin_config_socketshutdowns = -1;
108 static int hf_adwin_config_status = -1;
109 static int hf_adwin_config_status_bootloader = -1;
110 static int hf_adwin_config_status_reprogrammable = -1;
111 static int hf_adwin_config_status_configurable = -1;
112 static int hf_adwin_config_status_bootloader_boots = -1;
113 static int hf_adwin_config_status_bootloader_reprogrammable = -1;
114 static int hf_adwin_config_status_bootloader_receive = -1;
115 static int hf_adwin_config_status_bootloader_reprogramming_done = -1;
116 static int hf_adwin_config_status_eeprom_support = -1;
117 static int hf_adwin_config_stream_length = -1;
118 static int hf_adwin_config_eeprom_support = -1;
119 static int hf_adwin_config_timeout = -1;
120 static int hf_adwin_config_timerresets = -1;
121 static int hf_adwin_config_disk_free = -1;
122 static int hf_adwin_config_disk_size = -1;
123 static int hf_adwin_config_unused = -1;
124 static int hf_adwin_config_version = -1;
125 static int hf_adwin_config_xilinx_version = -1;
127 /* Initialize the subtree pointers */
128 static gint ett_adwin_config = -1;
129 static gint ett_adwin_config_status = -1;
130 static gint ett_adwin_config_debug = -1;
133 dissect_UDPStatus(tvbuff_t *tvb, proto_tree *adwin_tree)
135 proto_tree *debug_tree;
138 static const int * status_flags[] = {
139 &hf_adwin_config_status_bootloader,
140 &hf_adwin_config_status_reprogrammable,
141 &hf_adwin_config_status_configurable,
142 &hf_adwin_config_status_bootloader_boots,
143 &hf_adwin_config_status_bootloader_reprogrammable,
144 &hf_adwin_config_status_bootloader_receive,
145 &hf_adwin_config_status_bootloader_reprogramming_done,
146 &hf_adwin_config_status_eeprom_support,
153 dt = proto_tree_add_item(adwin_tree, proto_adwin_config, tvb, 0, -1, ENC_NA);
154 debug_tree = proto_item_add_subtree(dt, ett_adwin_config_debug);
155 proto_item_set_text(dt, "ADwin Debug information");
157 proto_tree_add_item(adwin_tree, hf_adwin_config_pattern, tvb, 0, 4, ENC_BIG_ENDIAN);
158 proto_tree_add_item(adwin_tree, hf_adwin_config_version, tvb, 4, 4, ENC_BIG_ENDIAN);
160 proto_tree_add_bitmask(adwin_tree, tvb, 8, hf_adwin_config_status, ett_adwin_config_status, status_flags, ENC_BIG_ENDIAN);
162 proto_tree_add_item(adwin_tree, hf_adwin_config_server_version_beta, tvb, 12, 2, ENC_BIG_ENDIAN);
163 proto_tree_add_item(adwin_tree, hf_adwin_config_server_version, tvb, 14, 2, ENC_BIG_ENDIAN);
164 proto_tree_add_item(adwin_tree, hf_adwin_config_xilinx_version, tvb, 16, 4, ENC_BIG_ENDIAN);
165 proto_tree_add_item(adwin_tree, hf_adwin_config_mac, tvb, 20, 6, ENC_NA);
166 proto_tree_add_item(debug_tree, hf_adwin_config_unused, tvb, 26, 2, ENC_NA);
167 proto_tree_add_item(adwin_tree, hf_adwin_config_port16, tvb, 28, 2, ENC_BIG_ENDIAN);
168 proto_tree_add_item(adwin_tree, hf_adwin_config_dhcp, tvb, 30, 1, ENC_LITTLE_ENDIAN);
169 proto_tree_add_item(adwin_tree, hf_adwin_config_netmask_count, tvb, 31, 1, ENC_LITTLE_ENDIAN);
170 proto_tree_add_item(adwin_tree, hf_adwin_config_gateway, tvb, 32, 4, ENC_BIG_ENDIAN);
171 proto_tree_add_item(debug_tree, hf_adwin_config_unused, tvb, 36, 11, ENC_NA);
172 proto_tree_add_item(adwin_tree, hf_adwin_config_reply_broadcast, tvb, 47, 1, ENC_LITTLE_ENDIAN);
173 proto_tree_add_item(adwin_tree, hf_adwin_config_scan_id, tvb, 48, 4, ENC_LITTLE_ENDIAN);
177 dissect_UDPExtStatus(tvbuff_t *tvb, proto_tree *adwin_tree)
179 const gchar *processor_type, *system_type;
184 proto_tree_add_item(adwin_tree, hf_adwin_config_mac, tvb, 0, 6, ENC_NA);
185 proto_tree_add_item(adwin_tree, hf_adwin_config_unused, tvb, 6, 2, ENC_NA);
186 proto_tree_add_item(adwin_tree, hf_adwin_config_pattern, tvb, 8, 4, ENC_BIG_ENDIAN);
187 proto_tree_add_item(adwin_tree, hf_adwin_config_version, tvb, 12, 4, ENC_BIG_ENDIAN);
188 proto_tree_add_item(adwin_tree, hf_adwin_config_description, tvb, 16, 16, ENC_ASCII|ENC_NA);
189 proto_tree_add_item(adwin_tree, hf_adwin_config_timerresets, tvb, 32, 4, ENC_BIG_ENDIAN);
190 proto_tree_add_item(adwin_tree, hf_adwin_config_socketshutdowns, tvb, 36, 4, ENC_BIG_ENDIAN);
191 proto_tree_add_item(adwin_tree, hf_adwin_config_disk_free, tvb, 40, 4, ENC_BIG_ENDIAN);
192 proto_tree_add_item(adwin_tree, hf_adwin_config_disk_size, tvb, 44, 4, ENC_BIG_ENDIAN);
193 proto_tree_add_item(adwin_tree, hf_adwin_config_date, tvb, 48, 8, ENC_ASCII|ENC_NA);
194 proto_tree_add_item(adwin_tree, hf_adwin_config_revision, tvb, 56, 8, ENC_ASCII|ENC_NA);
196 /* add the processor type raw values to the tree, to allow filtering */
197 proto_tree_add_item(adwin_tree, hf_adwin_config_processor_type_raw, tvb, 64, 2, ENC_ASCII|ENC_NA);
198 /* add the processor type as a pretty printed string */
199 processor_type = tvb_get_string_enc(wmem_packet_scope(), tvb, 64, 2, ENC_ASCII|ENC_NA);
200 processor_type = str_to_str(processor_type, processor_type_mapping, "Unknown (%s)");
201 proto_tree_add_string(adwin_tree, hf_adwin_config_processor_type, tvb, 64, 2, processor_type);
203 /* add system type as raw value and pretty printed string */
204 proto_tree_add_item(adwin_tree, hf_adwin_config_system_type_raw, tvb, 66, 2, ENC_ASCII|ENC_NA);
205 system_type = tvb_get_string_enc(wmem_packet_scope(), tvb, 66, 2, ENC_ASCII|ENC_NA);
206 system_type = str_to_str(system_type, system_type_mapping, "Unknown (%s)");
207 proto_tree_add_string(adwin_tree, hf_adwin_config_system_type, tvb, 66, 2, system_type);
209 proto_tree_add_item(adwin_tree, hf_adwin_config_unused, tvb, 68, 364, ENC_NA);
213 dissect_UDPMessage(tvbuff_t *tvb, proto_tree *adwin_tree)
215 const gchar *processor_type, *system_type;
220 proto_tree_add_item(adwin_tree, hf_adwin_config_command, tvb, 0, 4, ENC_LITTLE_ENDIAN);
221 proto_tree_add_item(adwin_tree, hf_adwin_config_version, tvb, 4, 4, ENC_LITTLE_ENDIAN);
222 proto_tree_add_item(adwin_tree, hf_adwin_config_mac, tvb, 8, 6, ENC_NA);
223 proto_tree_add_item(adwin_tree, hf_adwin_config_unused, tvb, 14, 2, ENC_NA);
224 proto_tree_add_item(adwin_tree, hf_adwin_config_server_ip, tvb, 16, 4, ENC_LITTLE_ENDIAN);
225 proto_tree_add_item(adwin_tree, hf_adwin_config_unused, tvb, 20, 4, ENC_NA);
226 proto_tree_add_item(adwin_tree, hf_adwin_config_netmask, tvb, 24, 4, ENC_LITTLE_ENDIAN);
227 proto_tree_add_item(adwin_tree, hf_adwin_config_unused, tvb, 28, 4, ENC_NA);
228 proto_tree_add_item(adwin_tree, hf_adwin_config_gateway, tvb, 32, 4, ENC_LITTLE_ENDIAN);
229 proto_tree_add_item(adwin_tree, hf_adwin_config_unused, tvb, 36, 4, ENC_NA);
230 proto_tree_add_item(adwin_tree, hf_adwin_config_dhcp, tvb, 40, 4, ENC_LITTLE_ENDIAN);
231 proto_tree_add_item(adwin_tree, hf_adwin_config_port32, tvb, 44, 4, ENC_LITTLE_ENDIAN);
232 proto_tree_add_item(adwin_tree, hf_adwin_config_password, tvb, 48, 10, ENC_ASCII|ENC_NA);
233 proto_tree_add_item(adwin_tree, hf_adwin_config_bootloader, tvb, 58, 1, ENC_LITTLE_ENDIAN);
234 proto_tree_add_item(adwin_tree, hf_adwin_config_unused, tvb, 59, 5, ENC_NA);
235 proto_tree_add_item(adwin_tree, hf_adwin_config_description, tvb, 64, 16, ENC_ASCII|ENC_NA);
236 proto_tree_add_item(adwin_tree, hf_adwin_config_date, tvb, 80, 8, ENC_ASCII|ENC_NA);
237 proto_tree_add_item(adwin_tree, hf_adwin_config_revision, tvb, 88, 8, ENC_ASCII|ENC_NA);
239 /* add the processor type raw values to the tree, to allow filtering */
240 proto_tree_add_item(adwin_tree, hf_adwin_config_processor_type_raw, tvb, 96, 2, ENC_ASCII|ENC_NA);
241 /* add the processor type as a pretty printed string */
242 processor_type = tvb_get_string_enc(wmem_packet_scope(), tvb, 96, 2, ENC_ASCII|ENC_NA);
243 processor_type = str_to_str(processor_type, processor_type_mapping, "Unknown");
244 proto_tree_add_string(adwin_tree, hf_adwin_config_processor_type, tvb, 96, 2, processor_type);
246 /* add system type as raw value and pretty printed string */
247 proto_tree_add_item(adwin_tree, hf_adwin_config_system_type_raw, tvb, 98, 2, ENC_ASCII|ENC_NA);
248 system_type = tvb_get_string_enc(wmem_packet_scope(), tvb, 98, 2, ENC_ASCII|ENC_NA);
249 system_type = str_to_str(system_type, system_type_mapping, "Unknown");
250 proto_tree_add_string(adwin_tree, hf_adwin_config_system_type, tvb, 98, 2, system_type);
254 dissect_UDPInitAck(tvbuff_t *tvb, proto_tree *adwin_tree)
260 proto_tree_add_item(adwin_tree, hf_adwin_config_pattern, tvb, 0, 4, ENC_BIG_ENDIAN);
261 proto_tree_add_item(adwin_tree, hf_adwin_config_reboot, tvb, 4, 4, ENC_LITTLE_ENDIAN);
262 proto_tree_add_item(adwin_tree, hf_adwin_config_mac, tvb, 8, 6, ENC_NA);
263 proto_tree_add_item(adwin_tree, hf_adwin_config_unused, tvb, 14, 2, ENC_NA);
264 proto_tree_add_item(adwin_tree, hf_adwin_config_unused, tvb, 16, 80, ENC_NA);
268 dissect_UDPIXP425FlashUpdate(tvbuff_t *tvb, proto_tree *adwin_tree)
274 proto_tree_add_item(adwin_tree, hf_adwin_config_pattern, tvb, 0, 4, ENC_BIG_ENDIAN);
275 proto_tree_add_item(adwin_tree, hf_adwin_config_version, tvb, 4, 4, ENC_BIG_ENDIAN);
276 proto_tree_add_item(adwin_tree, hf_adwin_config_scan_id, tvb, 8, 4, ENC_BIG_ENDIAN);
277 proto_tree_add_item(adwin_tree, hf_adwin_config_status, tvb, 12, 4, ENC_BIG_ENDIAN);
278 proto_tree_add_item(adwin_tree, hf_adwin_config_timeout, tvb, 16, 4, ENC_BIG_ENDIAN);
279 proto_tree_add_item(adwin_tree, hf_adwin_config_filename, tvb, 20, 24, ENC_ASCII|ENC_NA);
280 proto_tree_add_item(adwin_tree, hf_adwin_config_mac, tvb, 44, 6, ENC_NA);
281 proto_tree_add_item(adwin_tree, hf_adwin_config_unused, tvb, 50, 42, ENC_NA);
285 dissect_UDPOut(tvbuff_t *tvb, proto_tree *adwin_tree)
291 proto_tree_add_item(adwin_tree, hf_adwin_config_status, tvb, 0, 4, ENC_LITTLE_ENDIAN);
292 proto_tree_add_item(adwin_tree, hf_adwin_config_mac, tvb, 4, 6, ENC_NA);
293 proto_tree_add_item(adwin_tree, hf_adwin_config_netmask, tvb, 10, 4, ENC_LITTLE_ENDIAN);
294 proto_tree_add_item(adwin_tree, hf_adwin_config_gateway, tvb, 14, 4, ENC_BIG_ENDIAN);
295 proto_tree_add_item(adwin_tree, hf_adwin_config_dhcp, tvb, 18, 2, ENC_LITTLE_ENDIAN);
296 proto_tree_add_item(adwin_tree, hf_adwin_config_port16, tvb, 20, 2, ENC_BIG_ENDIAN);
300 get_adwin_TCPUpdate_len(packet_info *pinfo _U_, tvbuff_t *tvb,
301 int offset, void *data _U_)
304 * Return the length of the packet. (Doesn't include the length field itself)
306 return tvb_get_ntohl(tvb, offset);
310 dissect_TCPFlashUpdate(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
312 proto_tree *adwin_tree;
317 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ADwin Config");
318 col_set_str(pinfo->cinfo, COL_INFO, "TCPFlashUpdate");
320 ti = proto_tree_add_item(tree, proto_adwin_config, tvb, 0, -1, ENC_NA);
321 adwin_tree = proto_item_add_subtree(ti, ett_adwin_config);
323 proto_tree_add_item(adwin_tree, hf_adwin_config_stream_length, tvb, 0, 4, ENC_BIG_ENDIAN);
325 length = tvb_strnlen(tvb, offset, -1) + 1;
326 filename = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII|ENC_NA);
327 if (strncmp(filename, "eeprom_on", length) == 0) {
328 proto_tree_add_boolean(adwin_tree, hf_adwin_config_eeprom_support, tvb, offset, length, TRUE);
329 return offset+length;
331 if (strncmp(filename, "eeprom_off", length) == 0) {
332 proto_tree_add_boolean(adwin_tree, hf_adwin_config_eeprom_support, tvb, offset, length, FALSE);
333 return offset+length;
335 proto_tree_add_item(adwin_tree, hf_adwin_config_filename, tvb, 4, length, ENC_ASCII|ENC_NA);
337 length = tvb_strnlen(tvb, 4 + length, -1) + 1;
338 proto_tree_add_item(adwin_tree, hf_adwin_config_path, tvb, offset, length, ENC_ASCII|ENC_NA);
340 proto_tree_add_item(adwin_tree, hf_adwin_config_filesize, tvb, offset, 4, ENC_BIG_ENDIAN);
342 proto_tree_add_item(adwin_tree, hf_adwin_config_filetime, tvb, offset, 4, ENC_TIME_SECS|ENC_BIG_ENDIAN);
344 proto_tree_add_item(adwin_tree, hf_adwin_config_updatetime, tvb, offset, 4, ENC_TIME_SECS|ENC_BIG_ENDIAN);
346 proto_tree_add_item(adwin_tree, hf_adwin_config_unused, tvb, offset, 128, ENC_NA);
348 length = tvb_captured_length_remaining(tvb, offset);
349 proto_tree_add_item(adwin_tree, hf_adwin_config_data, tvb, offset, length, ENC_NA);
351 return tvb_captured_length(tvb);
354 /* 00:50:c2:0a:2*:** */
355 static const unsigned char mac_iab_start[] = { 0x00, 0x50, 0xc2, 0x0a, 0x20, 0x00 };
356 static const unsigned char mac_iab_end[] = { 0x00, 0x50, 0xc2, 0x0a, 0x2f, 0xff };
358 /* 00:22:71:**:**:** */
359 static const unsigned char mac_oui_start[] = { 0x00, 0x22, 0x71, 0x00, 0x00, 0x00 };
360 static const unsigned char mac_oui_end[] = { 0x00, 0x22, 0x71, 0xff, 0xff, 0xff };
362 /* ff:ff:ff:ff:ff:ff */
363 static const unsigned char mac_broadcast[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
365 /* return TRUE if mac is in mac address range assigned to ADwin or if
366 * mac is broadcast */
368 is_adwin_mac_or_broadcast(address mac)
370 if (mac.type != AT_ETHER)
373 if (mac.len != 6) /* length of MAC address */
376 if ((memcmp(mac.data, mac_iab_start, mac.len) >= 0) &&
377 (memcmp(mac.data, mac_iab_end , mac.len) <= 0))
380 if ((memcmp(mac.data, mac_oui_start, mac.len) >= 0) &&
381 (memcmp(mac.data, mac_oui_end, mac.len) <= 0))
384 /* adwin configuration protocol uses MAC broadcasts for
386 if (memcmp(mac.data, mac_broadcast, mac.len) == 0)
393 /* Here we determine which type of packet is sent by looking at its
394 size. Let's hope that future ADwin packets always differ in size.
395 They probably will, since the server classifies the packets
396 according to their sizes, too. */
398 static const value_string length_mapping[] = {
399 { UDPStatusLENGTH, "UDPStatus" },
400 { UDPExtStatusLENGTH, "UDPExtStatus" },
401 { UDPMessageLENGTH, "UDPMessage" },
402 { UDPMessageLENGTH_wrong, "UDPMessage (broken - upgrade ADConfig!)" },
403 { UDPInitAckLENGTH, "UDPInitAck" },
404 { UDPIXP425FlashUpdateLENGTH, "UDPIXP425FlashUpdate" },
405 { UDPOutLENGTH, "UDPOut" },
410 dissect_adwin_config_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
413 proto_tree *adwin_config_tree;
416 length = tvb_reported_length(tvb);
418 if (!(length == UDPStatusLENGTH
419 || length == UDPExtStatusLENGTH
420 || length == UDPMessageLENGTH
421 || length == UDPMessageLENGTH_wrong
422 || length == UDPInitAckLENGTH
423 || length == UDPIXP425FlashUpdateLENGTH
424 || length == UDPOutLENGTH))
427 if (! (is_adwin_mac_or_broadcast(pinfo->dl_src) || is_adwin_mac_or_broadcast(pinfo->dl_dst)))
430 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ADwin Config");
431 col_clear(pinfo->cinfo, COL_INFO);
433 ti = proto_tree_add_item(tree, proto_adwin_config, tvb, 0, -1, ENC_NA);
434 adwin_config_tree = proto_item_add_subtree(ti, ett_adwin_config);
437 case UDPStatusLENGTH:
438 dissect_UDPStatus(tvb, adwin_config_tree);
440 case UDPExtStatusLENGTH:
441 dissect_UDPExtStatus(tvb, adwin_config_tree);
443 case UDPMessageLENGTH:
444 dissect_UDPMessage(tvb, adwin_config_tree);
446 case UDPMessageLENGTH_wrong: /* incorrect packet length */
447 /* formerly used by adconfig */
448 dissect_UDPMessage(tvb, adwin_config_tree);
450 case UDPInitAckLENGTH:
451 dissect_UDPInitAck(tvb, adwin_config_tree);
453 case UDPIXP425FlashUpdateLENGTH:
454 dissect_UDPIXP425FlashUpdate(tvb, adwin_config_tree);
457 dissect_UDPOut(tvb, adwin_config_tree);
460 /* Heuristics above should mean we never get here */
461 col_add_str(pinfo->cinfo, COL_INFO,
462 val_to_str(length, length_mapping,
463 "Unknown ADwin Configuration packet, length: %d"));
466 return (tvb_reported_length(tvb));
470 dissect_adwin_config_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
472 if(!(pinfo->srcport == ADWIN_CONFIGURATION_PORT
473 || pinfo->destport == ADWIN_CONFIGURATION_PORT))
476 /* XXX - Is this possible for TCP? */
477 if (! (is_adwin_mac_or_broadcast(pinfo->dl_src) || is_adwin_mac_or_broadcast(pinfo->dl_dst)))
480 tcp_dissect_pdus(tvb, pinfo, tree, 1, 4, get_adwin_TCPUpdate_len, dissect_TCPFlashUpdate, NULL);
482 return (tvb_reported_length(tvb));
486 proto_register_adwin_config(void)
488 static hf_register_info hf[] = {
489 { &hf_adwin_config_bootloader,
490 { "Enable Bootloader", "adwin_config.bootloader",
491 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
494 { &hf_adwin_config_command,
495 { "Command", "adwin_config.command",
496 FT_UINT32, BASE_DEC, VALS(config_command_mapping), 0x0,
499 { &hf_adwin_config_data,
500 { "Data", "adwin_config.data",
501 FT_NONE, BASE_NONE, NULL, 0x0,
504 { &hf_adwin_config_date,
505 { "Date", "adwin_config.date",
506 FT_STRING, BASE_NONE, NULL, 0x0,
509 { &hf_adwin_config_description,
510 { "Description", "adwin_config.description",
511 FT_STRING, BASE_NONE, NULL, 0x0,
514 { &hf_adwin_config_dhcp,
515 { "DHCP enabled", "adwin_config.dhcp",
516 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
519 { &hf_adwin_config_filename,
520 { "File name", "adwin_config.filename",
521 FT_STRING, BASE_NONE, NULL, 0x0,
524 { &hf_adwin_config_filesize,
525 { "File size", "adwin_config.filesize",
526 FT_INT32, BASE_DEC, NULL, 0x0,
529 { &hf_adwin_config_filetime,
530 { "File time", "adwin_config.filetime",
531 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0,
534 { &hf_adwin_config_updatetime,
535 { "Update time", "adwin_config.updatetime",
536 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0,
539 { &hf_adwin_config_gateway,
540 { "Gateway IP", "adwin_config.gateway",
541 FT_IPv4, BASE_NONE, NULL, 0x0,
544 { &hf_adwin_config_mac,
545 { "MAC address", "adwin_config.mac",
546 FT_ETHER, BASE_NONE, NULL, 0x0,
549 { &hf_adwin_config_netmask,
550 { "Netmask", "adwin_config.netmask",
551 FT_IPv4, BASE_NETMASK, NULL, 0x0,
554 { &hf_adwin_config_netmask_count,
555 { "Netmask count", "adwin_config.netmask_count",
556 FT_UINT8, BASE_DEC, NULL, 0x0,
557 "The number of binary ones in the netmask.", HFILL }
559 { &hf_adwin_config_password,
560 { "Password", "adwin_config.password",
561 FT_STRING, BASE_NONE, NULL, 0x0,
562 "Password to set for ADwin system.", HFILL }
564 { &hf_adwin_config_pattern,
565 { "Pattern", "adwin_config.pattern",
566 FT_UINT32, BASE_HEX, VALS(pattern_mapping), 0x0,
569 { &hf_adwin_config_path,
570 { "Path", "adwin_config.path",
571 FT_STRING, BASE_NONE, NULL, 0x0,
574 { &hf_adwin_config_port16,
575 { "Port (16bit)", "adwin_config.port",
576 FT_UINT16, BASE_DEC, NULL, 0x0,
577 "The server port on which the ADwin system is listening on (16bit).", HFILL }
579 { &hf_adwin_config_port32,
580 { "Port (32bit)", "adwin_config.port",
581 FT_UINT32, BASE_DEC, NULL, 0x0,
582 "The server port on which the ADwin system is listening on (32bit).", HFILL }
584 { &hf_adwin_config_reboot,
585 { "Reboot", "adwin_config.reboot",
586 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
587 "Number of system reboots.", HFILL }
589 { &hf_adwin_config_scan_id,
590 { "Scan ID", "adwin_config.scan_id",
591 FT_UINT32, BASE_HEX, NULL, 0x0,
594 { &hf_adwin_config_reply_broadcast, /* send_normal in UDPStatus */
595 { "Reply with broadcast", "adwin_config.reply_broadcast",
596 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
597 "If this bit is set, the scanned system should reply with a broadcast.", HFILL }
599 { &hf_adwin_config_revision,
600 { "Revision", "adwin_config.revision",
601 FT_STRING, BASE_NONE, NULL, 0x0,
604 { &hf_adwin_config_processor_type_raw,
605 { "Processor Type (Raw value)", "adwin_config.processor_type_raw",
606 FT_STRING, BASE_NONE, NULL, 0x0,
607 "The DSP processor type of the ADwin system, e.g. T9, T10 or T11.", HFILL }
609 { &hf_adwin_config_system_type_raw,
610 { "System Type (Raw value)", "adwin_config.system_type_raw",
611 FT_STRING, BASE_NONE, NULL, 0x0,
612 "The system type of the ADwin system, e.g. Gold, Pro or Light.", HFILL }
614 { &hf_adwin_config_processor_type,
615 { "Processor Type", "adwin_config.processor_type",
616 FT_STRING, BASE_NONE, NULL, 0x0,
619 { &hf_adwin_config_system_type,
620 { "System Type", "adwin_config.system_type",
621 FT_STRING, BASE_NONE, NULL, 0x0,
624 { &hf_adwin_config_server_ip,
625 { "Server IP", "adwin_config.server_ip",
626 FT_IPv4, BASE_NONE, NULL, 0x0,
627 "In scan replies, this is the current IP address of the ADwin system. In configuration packets, this is the new IP to be used by the ADwin system.", HFILL }
629 { &hf_adwin_config_server_version,
630 { "Server version", "adwin_config.server_version",
631 FT_UINT32, BASE_DEC, NULL, 0x0,
632 "The version number of the server program. This number represents the complete firmware version, e.g. 2.74.", HFILL }
634 { &hf_adwin_config_server_version_beta,
635 { "server version (beta part)", "adwin_config.server_version_beta",
636 FT_UINT32, BASE_DEC, NULL, 0x0,
637 "A non-zero value of this field indicates a beta firmware version, where this number represents the current revision.", HFILL }
639 { &hf_adwin_config_socketshutdowns,
640 { "Socket shutdowns", "adwin_config.socketshutdowns",
641 FT_UINT32, BASE_DEC, NULL, 0x0,
642 "Number of socket errors that lead to a recreation of the socket (ethernet interface version 1 only).", HFILL }
644 { &hf_adwin_config_status,
645 { "Status", "adwin_config.status",
646 FT_UINT32, BASE_HEX, NULL, 0x0,
649 { &hf_adwin_config_status_bootloader,
650 { "Status Bootloader", "adwin_config.status_bootloader",
651 FT_BOOLEAN, 32, NULL, STATUS_WITH_BOOTLOADER,
652 "Indicates if the ADwin system has bootloader capabilities.", HFILL }
654 { &hf_adwin_config_status_reprogrammable,
655 { "Status Reprogrammable",
656 "adwin_config.status_reprogrammable",
657 FT_BOOLEAN, 32, NULL, STATUS_REPROGRAMMABLE,
660 { &hf_adwin_config_status_configurable,
661 { "Status Configurable", "adwin_config.status_configurable",
662 FT_BOOLEAN, 32, NULL, STATUS_CONFIGURABLE,
665 { &hf_adwin_config_status_bootloader_boots,
666 { "Status Bootloader boots",
667 "adwin_config.status_bootloader_boots",
668 FT_BOOLEAN, 32, NULL, STATUS_BOOTLOADER_BOOTS,
671 { &hf_adwin_config_status_bootloader_reprogrammable,
672 { "Status Bootloader reprogrammable",
673 "adwin_config.status_bootloader_reprogrammable",
674 FT_BOOLEAN, 32, NULL, STATUS_BOOTLOADER_REPROGRAMMABLE,
677 { &hf_adwin_config_status_bootloader_receive,
678 { "Status Bootloader receive",
679 "adwin_config.status_bootloader_receive",
680 FT_BOOLEAN, 32, NULL, STATUS_BOOTLOADER_RECEIVES_DATA,
683 { &hf_adwin_config_status_bootloader_reprogramming_done,
684 { "Status Bootloader reprogramming done",
685 "adwin_config.status_bootloader_reprogramming_done",
686 FT_BOOLEAN, 32, NULL, STATUS_BOOTLOADER_REPROGRAMMING_DONE,
689 { &hf_adwin_config_status_eeprom_support,
690 { "Status EEPROM Support",
691 "adwin_config.status_eeprom_support",
692 FT_BOOLEAN, 32, NULL, STATUS_WITH_EEPROM_SUPPORT,
695 { &hf_adwin_config_stream_length,
696 { "Stream length", "adwin_config.stream_length",
697 FT_INT32, BASE_DEC, NULL, 0x0,
700 { &hf_adwin_config_eeprom_support,
701 { "EEPROM Support", "adwin_config.eeprom_support",
702 FT_BOOLEAN, BASE_NONE, TFS(&tfs_enabled_disabled), 0x0,
705 { &hf_adwin_config_timeout,
706 { "Timeout", "adwin_config.timeout",
707 FT_UINT32, BASE_DEC, NULL, 0x0,
710 { &hf_adwin_config_timerresets,
711 { "Timer resets", "adwin_config.timerresets",
712 FT_UINT32, BASE_DEC, NULL, 0x0,
713 "Counter for resets of the timer (ethernet interface version 1 only).", HFILL }
715 { &hf_adwin_config_disk_free,
716 { "Free disk space (kb)", "adwin_config.disk_free",
717 FT_UINT32, BASE_DEC, NULL, 0x0,
718 "Free disk space in kb on flash (ethernet interface version 2 only).", HFILL }
720 { &hf_adwin_config_disk_size,
721 { "Disk size (kb)", "adwin_config.disk_size",
722 FT_UINT32, BASE_DEC, NULL, 0x0,
723 "Flash disk size in kb (ethernet interface version 2 only).", HFILL }
725 { &hf_adwin_config_unused,
726 { "Unused", "adwin_config.unused",
727 FT_NONE, BASE_NONE, NULL, 0x0,
730 { &hf_adwin_config_version,
731 { "Version", "adwin_config.version",
732 FT_UINT32, BASE_DEC, NULL, 0x0,
735 { &hf_adwin_config_xilinx_version,
736 { "XILINX Version", "adwin_config.xilinx_version",
737 FT_UINT32, BASE_HEX, NULL, 0x0,
738 "Version of XILINX program", HFILL }
742 /* Setup protocol subtree array */
743 static gint *ett[] = {
745 &ett_adwin_config_status,
746 &ett_adwin_config_debug,
749 /* Register the protocol name and description */
751 proto_register_protocol("ADwin configuration protocol",
752 "ADwin-Config", "adwin_config");
754 /* Required function calls to register the header fields and
756 proto_register_field_array(proto_adwin_config, hf, array_length(hf));
757 proto_register_subtree_array(ett, array_length(ett));
761 proto_reg_handoff_adwin_config(void)
763 heur_dissector_add("udp", dissect_adwin_config_udp, "ADwin-Config over UDP", "adwin_config_udp", proto_adwin_config, HEURISTIC_ENABLE);
764 heur_dissector_add("tcp", dissect_adwin_config_tcp, "ADwin-Config over TCP", "adwin_config_tcp", proto_adwin_config, HEURISTIC_ENABLE);
769 * Editor modelines - http://www.wireshark.org/tools/modelines.html
774 * indent-tabs-mode: t
777 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
778 * :indentSize=8:tabSize=8:noTabs=false: