Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-hiqnet.c
blob139b4c90ade837cfda58e3d6a5d1147f6d2417e3
1 /* packet-hiqnet.c
2 * Harman HiQnet protocol dissector for Wireshark
3 * By Raphael Doursenaud <rdoursenaud@free.fr>
4 * Copyright 2014 Raphael Doursenaud
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 #include "config.h"
15 #include <epan/packet.h>
16 #include <epan/expert.h>
17 #include "packet-tcp.h"
20 * See
21 * https://adn.harmanpro.com/site_elements/resources/487_1411413911/HiQnet_third-party_programmers_quick-start_guide_original.pdf
22 * https://adn.harmanpro.com/site_elements/resources/515_1414083576/HiQnet_Third_Party_Programmers_Guide_v2_original.pdf
25 #define HIQNET_PORT 3804
27 #define HIQNET_FLAGS_MASK 0x016f
29 #define HIQNET_REQACK_FLAG 0x0001
30 #define HIQNET_ACK_FLAG 0x0002
31 #define HIQNET_INFO_FLAG 0x0004
32 #define HIQNET_ERROR_FLAG 0x0008
33 #define HIQNET_GUARANTEED_FLAG 0x0020
34 #define HIQNET_MULTIPART_FLAG 0x0040
35 #define HIQNET_SESSION_NUMBER_FLAG 0x0100
37 #define HIQNET_SUBSCRIPTION_TYPE_MASK 0x07
39 #define HIQNET_SUBSCRIPTION_FLAGS_MASK 0x0001
41 #define HIQNET_CATEGORIES_MASK 0x00004ffe
43 #define HIQNET_APPLICATION_CAT 0x00000002
44 #define HIQNET_CONF_CAT 0x00000004
45 #define HIQNET_AUDIONET_CAT 0x00000008
46 #define HIQNET_CTRLNET_CAT 0x00000010
47 #define HIQNET_VENDNET_CAT 0x00000020
48 #define HIQNET_STARTUP_CAT 0x00000040
49 #define HIQNET_DSP_CAT 0x00000080
50 #define HIQNET_MISC_CAT 0x00000100
51 #define HIQNET_CTRLLOG_CAT 0x00000200
52 #define HIQNET_FOREIGNPROTO_CAT 0x00000400
53 #define HIQNET_DIGIO_CAT 0x00000800
54 #define HIQNET_CTRLSURF_CAT 0x00004000
56 /* Routing layer message IDs */
57 #define HIQNET_DISCOINFO_MSG 0x0000
58 #define HIQNET_RESERVED0_MSG 0x0001
59 #define HIQNET_GETNETINFO_MSG 0x0002
60 #define HIQNET_RESERVED1_MSG 0x0003
61 #define HIQNET_REQADDR_MSG 0x0004
62 #define HIQNET_ADDRUSED_MSG 0x0005
63 #define HIQNET_SETADDR_MSG 0x0006
64 #define HIQNET_GOODBYE_MSG 0x0007
65 #define HIQNET_HELLO_MSG 0x0008
67 /* Other message IDs */
68 #define HIQNET_MULTPARMSET_MSG 0x0100
69 #define HIQNET_MULTOBJPARMSET_MSG 0x0101
70 #define HIQNET_PARMSETPCT_MSG 0x0102
71 #define HIQNET_MULTPARMGET_MSG 0x0103
72 #define HIQNET_GETATTR_MSG 0x010d
73 #define HIQNET_SETATTR_MSG 0x010e /* Reverse engineered. Not part of the official spec. */
74 #define HIQNET_MULTPARMSUB_MSG 0x010f
75 #define HIQNET_PARMSUBPCT_MSG 0x0111
76 #define HIQNET_MULTPARMUNSUB_MSG 0x0112
77 #define HIQNET_PARMSUBALL_MSG 0x0113
78 #define HIQNET_PARMUNSUBALL_MSG 0x0114
79 #define HIQNET_SUBEVTLOGMSGS_MSG 0x0115
80 #define HIQNET_GETVDLIST_MSG 0x011a
81 #define HIQNET_STORE_MSG 0x0124
82 #define HIQNET_RECALL_MSG 0x0125
83 #define HIQNET_LOCATE_MSG 0x0129
84 #define HIQNET_UNSUBEVTLOGMSGS_MSG 0x012b
85 #define HIQNET_REQEVTLOG_MSG 0x012c
87 #define HIQNET_TCPIP_NET 1
88 #define HIQNET_RS232_NET 4
90 static const value_string device_attributes_names[] = {
91 { 0, "Class Name" },
92 { 1, "Name String" },
93 /* Device Manager attributes */
94 { 2, "Flags" },
95 { 3, "Serial Number" },
96 { 4, "Software Version" },
97 { 0, NULL }
100 static const value_string messageidnames[] = {
101 { HIQNET_DISCOINFO_MSG, "DiscoInfo" },
102 { HIQNET_RESERVED0_MSG, "Reserved" },
103 { HIQNET_GETNETINFO_MSG, "GetNetworkInfo" },
104 { HIQNET_RESERVED1_MSG, "Reserved" },
105 { HIQNET_REQADDR_MSG, "RequestAddress" },
106 { HIQNET_ADDRUSED_MSG, "AddressUsed" },
107 { HIQNET_SETADDR_MSG, "SetAddress" },
108 { HIQNET_GOODBYE_MSG, "Goodbye" },
109 { HIQNET_HELLO_MSG, "Hello" },
110 { HIQNET_MULTPARMSET_MSG, "MultiParamSet" },
111 { HIQNET_MULTOBJPARMSET_MSG, "MultiObjectParamSet" },
112 { HIQNET_PARMSETPCT_MSG, "ParamSetPercent" },
113 { HIQNET_MULTPARMGET_MSG, "MultiParamGet" },
114 { HIQNET_GETATTR_MSG, "GetAttributes" },
115 { HIQNET_MULTPARMSUB_MSG, "MultiParamSubscribe" },
116 { HIQNET_PARMSUBPCT_MSG, "ParamSubscribePercent" },
117 { HIQNET_SETATTR_MSG, "SetAttribute" }, /* Reverse engineered. Not part of the official spec. */
118 { HIQNET_MULTPARMUNSUB_MSG, "MultiParamUnsubscribe" },
119 { HIQNET_PARMSUBALL_MSG, "ParameterSubscribeAll" },
120 { HIQNET_PARMUNSUBALL_MSG, "ParameterUnSubscribeAll" },
121 { HIQNET_SUBEVTLOGMSGS_MSG, "Subscribe Event Log Messages" },
122 { HIQNET_GETVDLIST_MSG, "GetVDList" },
123 { HIQNET_STORE_MSG, "Store" },
124 { HIQNET_RECALL_MSG, "Recall" },
125 { HIQNET_LOCATE_MSG, "Locate" },
126 { HIQNET_UNSUBEVTLOGMSGS_MSG, "Unsubscribe Event Log Messages" },
127 { HIQNET_REQEVTLOG_MSG, "Request Event Log" },
128 { 0, NULL }
131 #if 0
132 static const value_string flagnames[] = {
133 { HIQNET_REQACK_FLAG, "Request Acknowledgement" },
134 { HIQNET_ACK_FLAG, "Acknowledgement" },
135 { HIQNET_INFO_FLAG, "Information" },
136 { HIQNET_ERROR_FLAG, "Error" },
137 { HIQNET_GUARANTEED_FLAG, "Guaranteed" },
138 { HIQNET_MULTIPART_FLAG, "Multi-part" },
139 { HIQNET_SESSION_NUMBER_FLAG, "Session Number" },
140 { 0, NULL }
142 #endif
144 #define HIQNET_DATATYPE_BYTE 0
145 #define HIQNET_DATATYPE_UBYTE 1
146 #define HIQNET_DATATYPE_WORD 2
147 #define HIQNET_DATATYPE_UWORD 3
148 #define HIQNET_DATATYPE_LONG 4
149 #define HIQNET_DATATYPE_ULONG 5
150 #define HIQNET_DATATYPE_FLOAT32 6
151 #define HIQNET_DATATYPE_FLOAT64 7
152 #define HIQNET_DATATYPE_BLOCK 8
153 #define HIQNET_DATATYPE_STRING 9
154 #define HIQNET_DATATYPE_LONG64 10
155 #define HIQNET_DATATYPE_ULONG64 11
157 static const value_string datatypenames[] = {
158 { HIQNET_DATATYPE_BYTE, "BYTE" },
159 { HIQNET_DATATYPE_UBYTE, "UBYTE" },
160 { HIQNET_DATATYPE_WORD, "WORD" },
161 { HIQNET_DATATYPE_UWORD, "UWORD" },
162 { HIQNET_DATATYPE_LONG, "LONG" },
163 { HIQNET_DATATYPE_ULONG, "ULONG" },
164 { HIQNET_DATATYPE_FLOAT32, "FLOAT32" },
165 { HIQNET_DATATYPE_FLOAT64, "FLOAT64" },
166 { HIQNET_DATATYPE_BLOCK, "BLOCK" },
167 { HIQNET_DATATYPE_STRING, "STRING" },
168 { HIQNET_DATATYPE_LONG64, "LONG64" },
169 { HIQNET_DATATYPE_ULONG64, "ULONG64" },
170 { 0, NULL }
173 static const value_string actionnames[] = {
174 { 0, "Parameters" },
175 { 1, "Subscriptions" },
176 { 2, "Scenes" },
177 { 3, "Snapshots" },
178 { 4, "Presets" },
179 { 5, "Venue" },
180 { 0, NULL }
183 static const value_string timenames[] = {
184 { 0x0000, "Turn off locate LEDs" },
185 { 0xffff, "Turn on locate LEDs" },
186 { 0, NULL }
189 static const value_string eventcategorynames[] = {
190 { 0, "Unassigned" },
191 { 1, "Application" },
192 { 2, "Configuration" },
193 { 3, "Audio Network" },
194 { 4, "Control Network" },
195 { 5, "Vendor Network" },
196 { 6, "Startup" },
197 { 7, "DSP" },
198 { 8, "Miscellaneous" },
199 { 9, "Control Logic" },
200 { 10, "Foreign Protocol" },
201 { 11, "Digital I/O" },
202 { 12, "Unassigned" },
203 { 13, "Unassigned" },
204 { 14, "Control Surface" },
205 { 15, "Unassigned" },
206 { 16, "Unassigned" },
207 { 17, "Unassigned" },
208 { 18, "Unassigned" },
209 { 19, "Unassigned" },
210 { 20, "Unassigned" },
211 { 21, "Unassigned" },
212 { 22, "Unassigned" },
213 { 23, "Unassigned" },
214 { 24, "Unassigned" },
215 { 25, "Unassigned" },
216 { 26, "Unassigned" },
217 { 27, "Unassigned" },
218 { 28, "Unassigned" },
219 { 29, "Unassigned" },
220 { 30, "Unassigned" },
221 { 31, "Unassigned" },
222 { 0, NULL }
225 static const value_string eventidnames[] = {
226 { 0x0001, "Invalid Version" },
227 { 0x0002, "Invalid Length" },
228 { 0x0003, "Invalid Virtual Device" },
229 { 0x0004, "Invalid Object" },
230 { 0x0005, "Invalid Parameter" },
231 { 0x0006, "Invalid Message ID" },
232 { 0x0007, "Invalid Value" },
233 { 0x0008, "Resource Unavailable" },
234 { 0x0009, "Unsupported" },
235 { 0x000a, "Invalid Virtual Device Class" },
236 { 0x000b, "Invalid Object Class" },
237 { 0x000c, "Invalid Parameter Class" },
238 { 0x000d, "Invalid Attribute ID" },
239 { 0x000e, "Invalid DataType" },
240 { 0x000f, "Invalid Configuration" },
241 { 0x0010, "Flash Error" },
242 { 0x0011, "Not a Router" },
243 { 0, NULL }
246 static const value_string prioritynames[] = {
247 { 0, "Fault" },
248 { 1, "Warning" },
249 { 2, "Information" },
250 { 0, NULL }
253 static const value_string networknames[] = {
254 { HIQNET_TCPIP_NET, "TCP/IP" },
255 { 2, "Reserved" },
256 { 3, "Reserved" },
257 { HIQNET_RS232_NET, "RS232" },
258 { 0, NULL }
261 static const value_string paritynames[] = {
262 { 0, "None" },
263 { 1, "Odd" },
264 { 2, "Even" },
265 { 3, "Mark" },
266 { 4, "Space" },
267 { 0, NULL }
270 static const value_string stopbitsnames[] = {
271 { 0, "1 Bits" },
272 { 1, "1.5 Bits" },
273 { 2, "2 Bits" },
274 { 0, NULL }
277 static const value_string flowcontrolnames[] = {
278 { 0, "None" },
279 { 1, "Hardware" },
280 { 2, "XON/OFF" },
281 { 0, NULL }
284 static int proto_hiqnet;
286 static int hf_hiqnet_version;
288 static int ett_hiqnet;
289 static int ett_hiqnet_flags;
290 static int ett_hiqnet_cats;
292 static int hf_hiqnet_headerlen;
293 static int hf_hiqnet_messagelen;
294 static int hf_hiqnet_sourcedev;
295 static int hf_hiqnet_sourceaddr;
296 static int hf_hiqnet_destdev;
297 static int hf_hiqnet_destaddr;
298 static int hf_hiqnet_messageid;
299 static int hf_hiqnet_flags;
300 static int hf_hiqnet_reqack_flag;
301 static int hf_hiqnet_ack_flag;
302 static int hf_hiqnet_info_flag;
303 static int hf_hiqnet_error_flag;
304 static int hf_hiqnet_guaranteed_flag;
305 static int hf_hiqnet_multipart_flag;
306 static int hf_hiqnet_session_number_flag;
307 static int hf_hiqnet_hopcnt;
308 static int hf_hiqnet_seqnum;
309 static int hf_hiqnet_errcode;
310 static int hf_hiqnet_errstr;
311 static int hf_hiqnet_startseqno;
312 static int hf_hiqnet_rembytes;
313 static int hf_hiqnet_sessnum;
314 static int hf_hiqnet_cost;
315 static int hf_hiqnet_sernumlen;
316 static int hf_hiqnet_sernum;
317 static int hf_hiqnet_maxmsgsize;
318 static int hf_hiqnet_keepaliveperiod;
319 static int hf_hiqnet_netid;
320 static int hf_hiqnet_macaddr;
321 static int hf_hiqnet_dhcp;
322 static int hf_hiqnet_ipaddr;
323 static int hf_hiqnet_subnetmsk;
324 static int hf_hiqnet_gateway;
325 static int hf_hiqnet_flagmask;
326 static int hf_hiqnet_paramcount;
327 static int hf_hiqnet_paramid;
328 static int hf_hiqnet_vdobject;
329 static int hf_hiqnet_subtype;
330 static int hf_hiqnet_sensrate;
331 static int hf_hiqnet_subflags;
332 static int hf_hiqnet_subcount;
333 static int hf_hiqnet_pubparmid;
334 static int hf_hiqnet_subaddr;
335 static int hf_hiqnet_subparmid;
336 static int hf_hiqnet_reserved0;
337 static int hf_hiqnet_reserved1;
338 static int hf_hiqnet_attrcount;
339 static int hf_hiqnet_attrid;
340 static int hf_hiqnet_datatype;
341 static int hf_hiqnet_datalen;
342 static int hf_hiqnet_byte_value;
343 static int hf_hiqnet_ubyte_value;
344 static int hf_hiqnet_word_value;
345 static int hf_hiqnet_uword_value;
346 static int hf_hiqnet_long_value;
347 static int hf_hiqnet_ulong_value;
348 static int hf_hiqnet_float32_value;
349 static int hf_hiqnet_float64_value;
350 static int hf_hiqnet_block_value;
351 static int hf_hiqnet_string_value;
352 static int hf_hiqnet_long64_value;
353 static int hf_hiqnet_ulong64_value;
354 static int hf_hiqnet_wrkgrppath;
355 static int hf_hiqnet_numvds;
356 static int hf_hiqnet_vdaddr;
357 static int hf_hiqnet_vdclassid;
358 static int hf_hiqnet_stract;
359 static int hf_hiqnet_strnum;
360 static int hf_hiqnet_scope;
361 static int hf_hiqnet_recact;
362 static int hf_hiqnet_recnum;
363 static int hf_hiqnet_strlen;
364 static int hf_hiqnet_time;
365 static int hf_hiqnet_maxdatasize;
366 static int hf_hiqnet_catfilter;
367 static int hf_hiqnet_app_cat;
368 static int hf_hiqnet_conf_cat;
369 static int hf_hiqnet_audionet_cat;
370 static int hf_hiqnet_ctrlnet_cat;
371 static int hf_hiqnet_vendnet_cat;
372 static int hf_hiqnet_startup_cat;
373 static int hf_hiqnet_dsp_cat;
374 static int hf_hiqnet_misc_cat;
375 static int hf_hiqnet_ctrlog_cat;
376 static int hf_hiqnet_foreignproto_cat;
377 static int hf_hiqnet_digio_cat;
378 static int hf_hiqnet_ctrlsurf_cat;
379 static int hf_hiqnet_entrieslen;
380 static int hf_hiqnet_category;
381 static int hf_hiqnet_eventid;
382 static int hf_hiqnet_priority;
383 static int hf_hiqnet_eventseqnum;
384 static int hf_hiqnet_eventtime;
385 static int hf_hiqnet_eventdate;
386 static int hf_hiqnet_eventinfo;
387 static int hf_hiqnet_eventadddata;
388 static int hf_hiqnet_objcount;
389 static int hf_hiqnet_paramval;
390 static int hf_hiqnet_ifacecount;
391 static int hf_hiqnet_comid;
392 static int hf_hiqnet_baudrate;
393 static int hf_hiqnet_parity;
394 static int hf_hiqnet_stopbits;
395 static int hf_hiqnet_databits;
396 static int hf_hiqnet_flowcontrol;
397 static int hf_hiqnet_devaddr;
398 static int hf_hiqnet_newdevaddr;
400 static expert_field ei_hiqnet_datatype;
402 static int * const hiqnet_flag_fields[] = {
403 &hf_hiqnet_reqack_flag,
404 &hf_hiqnet_ack_flag,
405 &hf_hiqnet_info_flag,
406 &hf_hiqnet_error_flag,
407 &hf_hiqnet_guaranteed_flag,
408 &hf_hiqnet_multipart_flag,
409 &hf_hiqnet_session_number_flag,
410 NULL
413 static int * const hiqnet_cat_fields[] = {
414 &hf_hiqnet_app_cat,
415 &hf_hiqnet_conf_cat,
416 &hf_hiqnet_audionet_cat,
417 &hf_hiqnet_ctrlnet_cat,
418 &hf_hiqnet_vendnet_cat,
419 &hf_hiqnet_startup_cat,
420 &hf_hiqnet_dsp_cat,
421 &hf_hiqnet_misc_cat,
422 &hf_hiqnet_ctrlog_cat,
423 &hf_hiqnet_foreignproto_cat,
424 &hf_hiqnet_digio_cat,
425 &hf_hiqnet_ctrlsurf_cat,
426 NULL
429 void proto_register_hiqnet(void);
430 void proto_reg_handoff_hiqnet(void);
432 static dissector_handle_t hiqnet_udp_handle;
433 static dissector_handle_t hiqnet_tcp_handle;
435 static void
436 hiqnet_display_vdobjectaddr(proto_tree *hiqnet_tree, int hf_hiqnet, tvbuff_t *tvb, int offset) {
437 proto_tree_add_bytes_format_value(hiqnet_tree, hf_hiqnet, tvb, offset, 4, NULL,
438 "%u.%u.%u.%u",
439 tvb_get_uint8(tvb, offset), /* Virtual Device address */
440 tvb_get_uint8(tvb, offset + 1), /* Object address part 1 */
441 tvb_get_uint8(tvb, offset + 2), /* Object address part 2 */
442 tvb_get_uint8(tvb, offset + 3)); /* Object address part 3 */
446 static int
447 hiqnet_display_tcpipnetinfo(proto_tree *hiqnet_payload_tree, tvbuff_t *tvb, int offset) {
448 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_macaddr, tvb, offset, 6, ENC_NA);
449 offset += 6;
450 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_dhcp, tvb, offset, 1, ENC_BIG_ENDIAN);
451 offset += 1;
452 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_ipaddr, tvb, offset, 4, ENC_BIG_ENDIAN);
453 offset += 4;
454 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_subnetmsk, tvb, offset, 4, ENC_BIG_ENDIAN);
455 offset += 4;
456 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_gateway, tvb, offset, 4, ENC_BIG_ENDIAN);
457 offset += 4;
458 return offset;
462 static int
463 hiqnet_display_rs232netinfo(proto_tree *hiqnet_payload_tree, tvbuff_t *tvb, int offset) {
464 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_comid, tvb, offset, 1, ENC_BIG_ENDIAN);
465 offset += 1;
466 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_baudrate, tvb, offset, 4, ENC_BIG_ENDIAN);
467 offset += 4;
468 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_parity, tvb, offset, 1, ENC_BIG_ENDIAN);
469 offset += 1;
470 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_stopbits, tvb, offset, 1, ENC_BIG_ENDIAN);
471 offset += 1;
472 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_databits, tvb, offset, 1, ENC_BIG_ENDIAN);
473 offset += 1;
474 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_flowcontrol, tvb, offset, 1, ENC_BIG_ENDIAN);
475 offset += 1;
476 return offset;
480 static int
481 hiqnet_display_netinfo(proto_tree *hiqnet_payload_tree, tvbuff_t *tvb, int offset) {
482 unsigned netid = 0;
483 netid = tvb_get_uint8(tvb, offset);
484 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_netid, tvb, offset, 1, ENC_BIG_ENDIAN);
485 offset += 1;
486 if (netid == HIQNET_TCPIP_NET) {
487 offset = hiqnet_display_tcpipnetinfo(hiqnet_payload_tree, tvb, offset);
489 if (netid == HIQNET_RS232_NET) {
490 offset = hiqnet_display_rs232netinfo(hiqnet_payload_tree, tvb, offset);
492 return offset;
496 static int
497 hiqnet_display_sernum(proto_tree *hiqnet_payload_tree, tvbuff_t *tvb, int offset) {
498 int str_len;
499 str_len = tvb_get_ntohs(tvb, offset);
500 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_sernumlen, tvb, offset, 2, ENC_BIG_ENDIAN);
501 offset += 2;
502 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_sernum, tvb, offset, str_len, ENC_NA);
503 offset += str_len;
504 return offset;
508 static int
509 hiqnet_display_paramsub(proto_tree *hiqnet_payload_tree, tvbuff_t *tvb, int offset) {
510 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_pubparmid, tvb, offset, 2, ENC_BIG_ENDIAN);
511 offset += 2;
512 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_subtype, tvb, offset, 1, ENC_BIG_ENDIAN);
513 offset += 1;
514 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_subaddr, tvb, offset, 6, ENC_NA);
515 offset += 6;
516 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_subparmid, tvb, offset, 2, ENC_BIG_ENDIAN);
517 offset += 2;
518 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_reserved0, tvb, offset, 1, ENC_NA);
519 offset += 1;
520 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_reserved1, tvb, offset, 2, ENC_NA);
521 offset += 2;
522 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_sensrate, tvb, offset, 2, ENC_BIG_ENDIAN);
523 offset += 2;
524 return offset;
528 /* TODO: decode flags for attributes and parameters */
529 static int
530 hiqnet_display_data(proto_tree *hiqnet_payload_tree, packet_info *pinfo, tvbuff_t *tvb, int offset) {
531 uint32_t datatype;
532 uint32_t datalen;
533 proto_item* ti;
535 ti = proto_tree_add_item_ret_uint(hiqnet_payload_tree, hf_hiqnet_datatype, tvb, offset, 1, ENC_BIG_ENDIAN, &datatype);
536 offset += 1;
537 switch (datatype) {
539 case HIQNET_DATATYPE_BYTE:
540 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_byte_value, tvb, offset, 1, ENC_BIG_ENDIAN);
541 offset += 1;
542 break;
544 case HIQNET_DATATYPE_UBYTE:
545 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_ubyte_value, tvb, offset, 1, ENC_BIG_ENDIAN);
546 offset += 1;
547 break;
549 case HIQNET_DATATYPE_WORD:
550 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_word_value, tvb, offset, 2, ENC_BIG_ENDIAN);
551 offset += 2;
552 break;
554 case HIQNET_DATATYPE_UWORD:
555 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_uword_value, tvb, offset, 2, ENC_BIG_ENDIAN);
556 offset += 2;
557 break;
559 case HIQNET_DATATYPE_LONG:
560 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_long_value, tvb, offset, 4, ENC_BIG_ENDIAN);
561 offset += 4;
562 break;
564 case HIQNET_DATATYPE_ULONG:
565 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_ulong_value, tvb, offset, 4, ENC_BIG_ENDIAN);
566 offset += 4;
567 break;
569 case HIQNET_DATATYPE_FLOAT32:
570 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_float32_value, tvb, offset, 4, ENC_BIG_ENDIAN);
571 offset += 4;
572 break;
574 case HIQNET_DATATYPE_FLOAT64:
575 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_float64_value, tvb, offset, 8, ENC_BIG_ENDIAN);
576 offset += 8;
577 break;
579 case HIQNET_DATATYPE_BLOCK:
580 proto_tree_add_item_ret_uint(hiqnet_payload_tree, hf_hiqnet_datalen, tvb, offset, 2, ENC_BIG_ENDIAN, &datalen);
581 offset += 2;
582 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_block_value, tvb, offset, datalen, ENC_NA);
583 offset += datalen;
584 break;
586 case HIQNET_DATATYPE_STRING:
587 proto_tree_add_item_ret_uint(hiqnet_payload_tree, hf_hiqnet_datalen, tvb, offset, 2, ENC_BIG_ENDIAN, &datalen);
588 offset += 2;
589 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_string_value, tvb, offset, datalen, ENC_UCS_2|ENC_BIG_ENDIAN);
590 offset += datalen;
591 break;
593 case HIQNET_DATATYPE_LONG64:
594 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_long64_value, tvb, offset, 8, ENC_BIG_ENDIAN);
595 offset += 8;
596 break;
598 case HIQNET_DATATYPE_ULONG64:
599 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_ulong64_value, tvb, offset, 8, ENC_BIG_ENDIAN);
600 offset += 8;
601 break;
603 default:
604 /* Flag an error, and punt and assume these values have no length. */
605 expert_add_info(pinfo, ti, &ei_hiqnet_datatype);
606 break;
608 return offset;
611 static int
612 dissect_hiqnet_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
614 uint8_t headerlen = 0;
615 uint32_t messagelen = 0;
616 uint16_t srcdev = 0;
617 uint8_t srcvdaddr = 0;
618 uint8_t srcob0addr = 0;
619 uint8_t srcob1addr = 0;
620 uint8_t srcob2addr = 0;
621 uint16_t dstdev = 0;
622 uint8_t dstvdaddr = 0;
623 uint8_t dstob0addr = 0;
624 uint8_t dstob1addr = 0;
625 uint8_t dstob2addr = 0;
626 uint16_t messageid = 0;
627 uint16_t flags = 0;
628 uint16_t paramcount = 0;
629 uint16_t subcount = 0;
630 uint16_t attrcount = 0;
631 int str_len = 0;
632 uint16_t vdscount = 0;
633 uint16_t eventscount = 0;
634 uint16_t objcount = 0;
635 uint16_t ifacecount = 0;
637 col_set_str(pinfo->cinfo, COL_PROTOCOL, "HiQnet");
638 /* Clear out stuff in the info column */
639 col_clear(pinfo->cinfo,COL_INFO);
641 srcdev = tvb_get_ntohs(tvb, 6);
642 srcvdaddr = tvb_get_uint8(tvb, 8);
643 srcob0addr = tvb_get_uint8(tvb, 9);
644 srcob1addr = tvb_get_uint8(tvb, 10);
645 srcob2addr = tvb_get_uint8(tvb, 11);
646 dstdev = tvb_get_ntohs(tvb, 12);
647 dstvdaddr = tvb_get_uint8(tvb, 14);
648 dstob0addr = tvb_get_uint8(tvb, 15);
649 dstob1addr = tvb_get_uint8(tvb, 16);
650 dstob2addr = tvb_get_uint8(tvb, 17);
651 messageid = tvb_get_ntohs(tvb, 18);
652 col_add_fstr(pinfo->cinfo, COL_INFO, "Msg: %s, Src: %u.%u.%u.%u.%u, Dst: %u.%u.%u.%u.%u",
653 val_to_str(messageid, messageidnames, "Unknown (0x%04x)"),
654 srcdev, srcvdaddr, srcob0addr, srcob1addr, srcob2addr,
655 dstdev, dstvdaddr, dstob0addr, dstob1addr, dstob2addr);
657 if (tree) { /* we are being asked for details */
658 proto_item *ti = NULL;
659 proto_item *item = NULL;
660 proto_tree *hiqnet_tree = NULL;
661 proto_tree *hiqnet_header_tree = NULL;
662 proto_tree *hiqnet_session_tree = NULL;
663 proto_tree *hiqnet_error_tree = NULL;
664 proto_tree *hiqnet_multipart_tree = NULL;
665 proto_tree *hiqnet_payload_tree = NULL;
666 proto_tree *hiqnet_parameter_tree = NULL;
667 proto_tree *hiqnet_attribute_tree = NULL;
668 proto_tree *hiqnet_vds_tree = NULL;
669 proto_tree *hiqnet_event_tree = NULL;
670 proto_tree *hiqnet_subscription_tree = NULL;
671 proto_tree *hiqnet_object_tree = NULL;
672 proto_tree *hiqnet_ifaces_tree = NULL;
673 int offset = 0;
675 messagelen = tvb_get_ntohl(tvb, 2);
676 ti = proto_tree_add_item(tree, proto_hiqnet, tvb, 0, messagelen, ENC_NA);
677 proto_item_append_text(ti, ", Msg: %s",
678 val_to_str(messageid, messageidnames, "Unknown (0x%04x)"));
679 proto_item_append_text(ti, ", Src %u.%u.%u.%u.%u",
680 srcdev, srcvdaddr, srcob0addr, srcob1addr, srcob2addr);
681 proto_item_append_text(ti, ", Dst: %u.%u.%u.%u.%u",
682 dstdev, dstvdaddr, dstob0addr, dstob1addr, dstob2addr);
683 hiqnet_tree = proto_item_add_subtree(ti, ett_hiqnet);
685 /* Header subtree */
686 headerlen = tvb_get_uint8(tvb, 1);
687 hiqnet_header_tree = proto_tree_add_subtree(hiqnet_tree, tvb, 0, headerlen, ett_hiqnet, NULL, "Header");
689 /* Standard header */
690 proto_tree_add_item(hiqnet_header_tree, hf_hiqnet_version, tvb, offset, 1, ENC_BIG_ENDIAN);
691 offset += 1;
692 proto_tree_add_item(hiqnet_header_tree, hf_hiqnet_headerlen, tvb, offset, 1, ENC_BIG_ENDIAN);
693 offset += 1;
694 proto_tree_add_item(hiqnet_header_tree, hf_hiqnet_messagelen, tvb, offset, 4, ENC_BIG_ENDIAN);
695 offset += 4;
696 proto_tree_add_item(hiqnet_header_tree, hf_hiqnet_sourcedev, tvb, offset, 2, ENC_BIG_ENDIAN);
697 item = proto_tree_add_item(hiqnet_header_tree, hf_hiqnet_devaddr, tvb, offset, 2, ENC_BIG_ENDIAN);
698 proto_item_set_hidden(item);
699 offset += 2;
700 hiqnet_display_vdobjectaddr(hiqnet_header_tree, hf_hiqnet_sourceaddr, tvb, offset);
701 offset += 4;
702 proto_tree_add_item(hiqnet_header_tree, hf_hiqnet_destdev, tvb, offset, 2, ENC_BIG_ENDIAN);
703 item = proto_tree_add_item(hiqnet_header_tree, hf_hiqnet_devaddr, tvb, offset, 2, ENC_BIG_ENDIAN);
704 proto_item_set_hidden(item);
705 offset += 2;
706 hiqnet_display_vdobjectaddr(hiqnet_header_tree, hf_hiqnet_destaddr, tvb, offset);
707 offset += 4;
708 proto_tree_add_item(hiqnet_header_tree, hf_hiqnet_messageid, tvb, offset, 2, ENC_BIG_ENDIAN);
709 offset += 2;
710 flags = tvb_get_ntohs(tvb, offset);
711 proto_tree_add_bitmask(hiqnet_header_tree, tvb, offset, hf_hiqnet_flags,
712 ett_hiqnet_flags, hiqnet_flag_fields, ENC_BIG_ENDIAN);
713 offset += 2;
714 proto_tree_add_item(hiqnet_header_tree, hf_hiqnet_hopcnt, tvb, offset, 1, ENC_BIG_ENDIAN);
715 offset += 1;
716 proto_tree_add_item(hiqnet_header_tree, hf_hiqnet_seqnum, tvb, offset, 2, ENC_BIG_ENDIAN);
717 offset += 2;
719 /* Optional headers */
720 if (flags & HIQNET_ERROR_FLAG) {
721 /* TODO: mark the erroneous frame */
722 hiqnet_error_tree = proto_tree_add_subtree(hiqnet_header_tree, tvb, offset, 2, ett_hiqnet, NULL, "Error");
723 proto_tree_add_item(hiqnet_error_tree, hf_hiqnet_errcode, tvb, offset, 1, ENC_BIG_ENDIAN);
724 offset += 1;
725 proto_tree_add_item(hiqnet_error_tree, hf_hiqnet_errstr, tvb, offset, headerlen - offset, ENC_UCS_2|ENC_BIG_ENDIAN);
727 if (flags & HIQNET_MULTIPART_FLAG) {
728 /* TODO: rebuild the full message */
729 hiqnet_multipart_tree = proto_tree_add_subtree(hiqnet_header_tree, tvb, offset, 2, ett_hiqnet, NULL, "Multi-part");
730 proto_tree_add_item(hiqnet_multipart_tree, hf_hiqnet_startseqno, tvb, offset, 1, ENC_BIG_ENDIAN);
731 offset += 1;
732 proto_tree_add_item(hiqnet_multipart_tree, hf_hiqnet_rembytes, tvb, offset, 4, ENC_BIG_ENDIAN);
733 offset += 4;
735 if (flags & HIQNET_SESSION_NUMBER_FLAG) {
736 hiqnet_session_tree = proto_tree_add_subtree(hiqnet_header_tree, tvb, offset, 2, ett_hiqnet, NULL, "Session");
737 proto_tree_add_item(hiqnet_session_tree, hf_hiqnet_sessnum, tvb, offset, 2, ENC_BIG_ENDIAN);
740 /* Payload(s) */
741 offset = headerlen; /* Make sure we are at the payload start */
742 hiqnet_payload_tree = proto_tree_add_subtree(
743 hiqnet_tree, tvb, offset, messagelen - headerlen, ett_hiqnet, NULL, "Payload");
744 switch(messageid) {
745 case HIQNET_DISCOINFO_MSG :
746 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_devaddr, tvb, offset, 2, ENC_BIG_ENDIAN);
747 offset += 2;
748 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_cost, tvb, offset, 1, ENC_BIG_ENDIAN);
749 offset += 1;
750 offset = hiqnet_display_sernum(hiqnet_payload_tree, tvb, offset);
751 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_maxmsgsize, tvb, offset, 4, ENC_BIG_ENDIAN);
752 offset += 4;
753 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_keepaliveperiod, tvb, offset, 2, ENC_BIG_ENDIAN);
754 offset += 2;
755 hiqnet_display_netinfo(hiqnet_payload_tree, tvb, offset);
756 break;
757 case HIQNET_HELLO_MSG :
758 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_sessnum, tvb, offset, 2, ENC_BIG_ENDIAN);
759 offset += 2;
760 proto_tree_add_bitmask(hiqnet_payload_tree, tvb, offset, hf_hiqnet_flagmask,
761 ett_hiqnet_flags, hiqnet_flag_fields, ENC_BIG_ENDIAN);
762 break;
763 case HIQNET_MULTPARMGET_MSG :
764 paramcount = tvb_get_ntohs(tvb, offset);
765 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_paramcount, tvb, offset, 2, ENC_BIG_ENDIAN);
766 offset += 2;
767 while (paramcount > 0) {
768 hiqnet_parameter_tree = proto_tree_add_subtree(
769 hiqnet_payload_tree, tvb, offset, -1, ett_hiqnet, NULL, "Parameter");
770 proto_tree_add_item(hiqnet_parameter_tree, hf_hiqnet_paramid, tvb, offset, 2, ENC_BIG_ENDIAN);
771 offset += 2;
772 if (flags & HIQNET_INFO_FLAG) { /* This is not a request */
773 offset = hiqnet_display_data(hiqnet_parameter_tree, pinfo, tvb, offset);
775 paramcount -= 1;
777 break;
778 case HIQNET_MULTPARMSET_MSG :
779 paramcount = tvb_get_ntohs(tvb, offset);
780 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_paramcount, tvb, offset, 2, ENC_BIG_ENDIAN);
781 offset += 2;
782 while (paramcount > 0) {
783 hiqnet_parameter_tree = proto_tree_add_subtree(
784 hiqnet_payload_tree, tvb, offset, -1, ett_hiqnet, NULL, "Parameter");
785 proto_tree_add_item(hiqnet_parameter_tree, hf_hiqnet_paramid, tvb, offset, 2, ENC_BIG_ENDIAN);
786 offset += 2;
787 offset = hiqnet_display_data(hiqnet_parameter_tree, pinfo, tvb, offset);
788 paramcount -= 1;
790 break;
791 case HIQNET_PARMSUBALL_MSG :
792 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_devaddr, tvb, offset, 2, ENC_BIG_ENDIAN);
793 offset += 2;
794 hiqnet_display_vdobjectaddr(hiqnet_payload_tree, hf_hiqnet_vdobject, tvb, offset);
795 offset += 4;
796 /* TODO: can be decoded in two ways (old and new) */
797 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_subtype, tvb, offset, 1, ENC_BIG_ENDIAN);
798 offset += 1;
799 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_sensrate, tvb, offset, 2, ENC_BIG_ENDIAN);
800 offset += 2;
801 /* TODO: decode and display */
802 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_subflags, tvb, offset, 2, ENC_BIG_ENDIAN);
803 break;
804 case HIQNET_PARMUNSUBALL_MSG : /* Reverse engineered. Not part of the official spec. */
805 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_devaddr, tvb, offset, 2, ENC_BIG_ENDIAN);
806 offset += 2;
807 hiqnet_display_vdobjectaddr(hiqnet_payload_tree, hf_hiqnet_vdobject, tvb, offset);
808 offset += 4;
809 /* TODO: can be decoded in two ways (old and new) */
810 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_subtype, tvb, offset, 1, ENC_BIG_ENDIAN);
811 break;
812 case HIQNET_MULTPARMSUB_MSG :
813 /* FIXME: Not tested, straight from the spec, never occurred with the devices I own */
814 subcount = tvb_get_ntohs(tvb, offset);
815 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_subcount, tvb, offset, 2, ENC_BIG_ENDIAN);
816 offset += 2;
817 while (subcount > 0) {
818 hiqnet_subscription_tree = proto_tree_add_subtree(
819 hiqnet_payload_tree, tvb, offset, -1, ett_hiqnet, NULL, "Subscription");
820 offset = hiqnet_display_paramsub(hiqnet_subscription_tree, tvb, offset);
821 subcount -= 1;
823 break;
824 case HIQNET_GOODBYE_MSG :
825 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_devaddr, tvb, offset, 2, ENC_BIG_ENDIAN);
826 break;
827 case HIQNET_GETATTR_MSG :
828 attrcount = tvb_get_ntohs(tvb, offset);
829 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_attrcount, tvb, offset, 2, ENC_BIG_ENDIAN);
830 offset += 2;
831 if (flags & HIQNET_INFO_FLAG) { /* This not a request */
832 while (attrcount > 0) {
833 hiqnet_attribute_tree = proto_tree_add_subtree(
834 hiqnet_payload_tree, tvb, offset, -1, ett_hiqnet, NULL, "Attribute");
835 proto_tree_add_item(hiqnet_attribute_tree, hf_hiqnet_attrid, tvb, offset, 2, ENC_BIG_ENDIAN);
836 offset += 2;
837 offset = hiqnet_display_data(hiqnet_attribute_tree, pinfo, tvb, offset);
838 attrcount -= 1;
840 } else { /* This may be a request */
841 while (attrcount > 0) {
842 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_attrid, tvb, offset, 2, ENC_BIG_ENDIAN);
843 offset += 2;
844 attrcount -= 1;
847 break;
848 case HIQNET_GETVDLIST_MSG :
849 /* FIXME: Not tested, straight from the spec, never occurred with the devices I own */
850 str_len = tvb_get_ntohs(tvb, offset);
851 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_strlen, tvb, offset, 2, ENC_BIG_ENDIAN);
852 offset += 2;
853 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_wrkgrppath, tvb, offset, str_len, ENC_UCS_2|ENC_BIG_ENDIAN);
854 offset += str_len;
855 if (flags & HIQNET_INFO_FLAG) { /* This is not a request */
856 vdscount = tvb_get_ntohs(tvb, offset);
857 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_numvds, tvb, offset, 2, ENC_BIG_ENDIAN);
858 offset += 2;
859 while (vdscount > 0) {
860 hiqnet_vds_tree = proto_tree_add_subtree(
861 hiqnet_payload_tree, tvb, offset, -1, ett_hiqnet, NULL, "Virtual Devices");
862 proto_tree_add_item(hiqnet_vds_tree, hf_hiqnet_vdaddr, tvb, offset, 1, ENC_BIG_ENDIAN);
863 offset += 1;
864 proto_tree_add_item(hiqnet_vds_tree, hf_hiqnet_vdclassid, tvb, offset, 2, ENC_BIG_ENDIAN);
865 offset += 2;
866 vdscount -= 1;
869 break;
870 case HIQNET_STORE_MSG :
871 /* FIXME: Not tested, straight from the spec, never occurred with the devices I own */
872 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_stract, tvb, offset, 1, ENC_BIG_ENDIAN);
873 offset += 1;
874 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_strnum, tvb, offset, 2, ENC_BIG_ENDIAN);
875 offset += 2;
876 str_len = tvb_get_ntohs(tvb, offset);
877 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_strlen, tvb, offset, 2, ENC_BIG_ENDIAN);
878 offset += 2;
879 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_wrkgrppath, tvb, offset, str_len, ENC_UCS_2|ENC_BIG_ENDIAN);
880 offset += str_len;
881 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_scope, tvb, offset, 1, ENC_BIG_ENDIAN);
882 break;
883 case HIQNET_RECALL_MSG :
884 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_recact, tvb, offset, 1, ENC_BIG_ENDIAN);
885 offset += 1;
886 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_recnum, tvb, offset, 2, ENC_BIG_ENDIAN);
887 offset += 2;
888 str_len = tvb_get_ntohs(tvb, offset);
889 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_strlen, tvb, offset, 2, ENC_BIG_ENDIAN);
890 offset += 2;
891 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_wrkgrppath, tvb, offset, str_len, ENC_UCS_2|ENC_BIG_ENDIAN);
892 offset += str_len;
893 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_scope, tvb, offset, 1, ENC_BIG_ENDIAN);
894 break;
895 case HIQNET_LOCATE_MSG :
896 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_time, tvb, offset, 2, ENC_BIG_ENDIAN);
897 offset += 2;
898 hiqnet_display_sernum(hiqnet_payload_tree, tvb, offset);
899 break;
900 case HIQNET_SUBEVTLOGMSGS_MSG :
901 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_maxdatasize, tvb, offset, 2, ENC_BIG_ENDIAN);
902 offset += 2;
903 proto_tree_add_bitmask(hiqnet_payload_tree, tvb, offset, hf_hiqnet_catfilter,
904 ett_hiqnet_cats, hiqnet_cat_fields, ENC_BIG_ENDIAN);
905 break;
906 case HIQNET_UNSUBEVTLOGMSGS_MSG :
907 proto_tree_add_bitmask(hiqnet_payload_tree, tvb, offset, hf_hiqnet_catfilter,
908 ett_hiqnet_cats, hiqnet_cat_fields, ENC_BIG_ENDIAN);
909 break;
910 case HIQNET_REQEVTLOG_MSG :
911 /* FIXME: Not tested, straight from the spec, never occurred with the devices I own */
912 if (flags & HIQNET_INFO_FLAG) { /* This is not a request */
913 eventscount = tvb_get_ntohs(tvb, offset);
914 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_entrieslen, tvb, offset, 2, ENC_BIG_ENDIAN);
915 offset += 2;
916 while (eventscount > 0) {
917 hiqnet_event_tree = proto_tree_add_subtree(
918 hiqnet_payload_tree, tvb, offset, -1, ett_hiqnet, NULL, "Event");
920 proto_tree_add_item(hiqnet_event_tree, hf_hiqnet_category, tvb, offset, 2, ENC_BIG_ENDIAN);
921 offset += 2;
923 proto_tree_add_item(hiqnet_event_tree, hf_hiqnet_eventid, tvb, offset, 2, ENC_BIG_ENDIAN);
924 offset += 2;
925 proto_tree_add_item(hiqnet_event_tree, hf_hiqnet_priority, tvb, offset, 1, ENC_BIG_ENDIAN);
926 offset += 1;
927 proto_tree_add_item(hiqnet_event_tree, hf_hiqnet_eventseqnum, tvb, offset, 4, ENC_BIG_ENDIAN);
928 offset += 4;
929 str_len = tvb_get_ntohs(tvb, offset);
930 proto_tree_add_item(hiqnet_event_tree, hf_hiqnet_eventtime, tvb, offset, str_len, ENC_UCS_2|ENC_BIG_ENDIAN);
931 offset += str_len;
932 str_len = tvb_get_ntohs(tvb, offset);
933 proto_tree_add_item(hiqnet_event_tree, hf_hiqnet_eventdate, tvb, offset, str_len, ENC_UCS_2|ENC_BIG_ENDIAN);
934 offset += str_len;
935 str_len = tvb_get_ntohs(tvb, offset);
936 proto_tree_add_item(hiqnet_event_tree, hf_hiqnet_eventinfo, tvb, offset, str_len, ENC_UCS_2|ENC_BIG_ENDIAN);
937 offset += str_len;
938 str_len = tvb_get_ntohs(tvb, offset);
939 proto_tree_add_item(
940 hiqnet_event_tree, hf_hiqnet_eventadddata, tvb, offset, str_len, ENC_NA);
941 offset += str_len;
942 eventscount -= 1;
945 break;
946 case HIQNET_MULTPARMUNSUB_MSG :
947 /* FIXME: Not tested, straight from the spec, never occurred with the devices I own */
948 subcount = tvb_get_ntohs(tvb, offset);
949 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_subcount, tvb, offset, 2, ENC_BIG_ENDIAN);
950 offset += 2;
951 while (subcount > 0) {
952 hiqnet_subscription_tree = proto_tree_add_subtree(
953 hiqnet_payload_tree, tvb, offset, -1, ett_hiqnet, NULL, "Subscription");
954 proto_tree_add_item(hiqnet_subscription_tree, hf_hiqnet_pubparmid, tvb, offset, 2, ENC_BIG_ENDIAN);
955 offset += 2;
956 proto_tree_add_item(hiqnet_subscription_tree, hf_hiqnet_subparmid, tvb, offset, 2, ENC_BIG_ENDIAN);
957 offset += 2;
958 subcount -= 1;
960 break;
961 case HIQNET_MULTOBJPARMSET_MSG :
962 /* FIXME: Not tested, straight from the spec, never occurred with the devices I own */
963 objcount = tvb_get_ntohs(tvb, offset);
964 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_objcount, tvb, offset, 2, ENC_BIG_ENDIAN);
965 offset += 2;
966 while (objcount > 0) {
967 hiqnet_object_tree = proto_tree_add_subtree(
968 hiqnet_payload_tree, tvb, offset, -1, ett_hiqnet, NULL, "Object");
969 hiqnet_display_vdobjectaddr(hiqnet_header_tree, hf_hiqnet_vdobject, tvb, offset);
970 offset += 4;
971 paramcount = tvb_get_ntohs(tvb, offset);
972 proto_tree_add_item(hiqnet_object_tree, hf_hiqnet_paramcount, tvb, offset, 2, ENC_BIG_ENDIAN);
973 offset += 2;
974 while (paramcount > 0) {
975 hiqnet_parameter_tree = proto_tree_add_subtree(
976 hiqnet_object_tree, tvb, offset, -1, ett_hiqnet, NULL, "Parameter");
977 proto_tree_add_item(hiqnet_parameter_tree, hf_hiqnet_paramid, tvb, offset, 2, ENC_BIG_ENDIAN);
978 offset += 2;
979 offset = hiqnet_display_data(hiqnet_parameter_tree, pinfo, tvb, offset);
980 paramcount -= 1;
982 objcount -= 1;
984 break;
985 case HIQNET_PARMSETPCT_MSG :
986 /* FIXME: Not tested, straight from the spec, never occurred with the devices I own */
987 paramcount = tvb_get_ntohs(tvb, offset);
988 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_paramcount, tvb, offset, 2, ENC_BIG_ENDIAN);
989 offset += 2;
990 while (paramcount > 0) {
991 hiqnet_parameter_tree = proto_tree_add_subtree(
992 hiqnet_payload_tree, tvb, offset, -1, ett_hiqnet, NULL, "Parameter");
993 proto_tree_add_item(hiqnet_parameter_tree, hf_hiqnet_paramid, tvb, offset, 2, ENC_BIG_ENDIAN);
994 offset += 2;
995 /* TODO: docode paramval is in percentage represented as a 1.15 signed fixed point format */
996 proto_tree_add_item(hiqnet_parameter_tree, hf_hiqnet_paramval, tvb, offset, 2, ENC_BIG_ENDIAN);
997 offset += 2;
998 paramcount -= 1;
1000 break;
1001 case HIQNET_PARMSUBPCT_MSG :
1002 /* FIXME: Not tested, straight from the spec, never occurred with the devices I own */
1003 subcount = tvb_get_ntohs(tvb, offset);
1004 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_subcount, tvb, offset, 2, ENC_BIG_ENDIAN);
1005 offset += 2;
1006 while (subcount > 0) {
1007 hiqnet_subscription_tree = proto_tree_add_subtree(
1008 hiqnet_payload_tree, tvb, offset, -1, ett_hiqnet, NULL, "Subscription");
1009 offset = hiqnet_display_paramsub(hiqnet_subscription_tree, tvb, offset);
1010 subcount -= 1;
1012 break;
1013 case HIQNET_GETNETINFO_MSG :
1014 /* FIXME: Not tested, straight from the spec, never occurred with the devices I own */
1015 offset = hiqnet_display_sernum(hiqnet_payload_tree, tvb, offset);
1016 if (flags & HIQNET_INFO_FLAG) { /* This is not a request */
1017 ifacecount = tvb_get_ntohs(tvb, offset);
1018 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_ifacecount, tvb, offset, 2, ENC_BIG_ENDIAN);
1019 offset += 2;
1020 while (ifacecount > 0) {
1021 hiqnet_ifaces_tree = proto_tree_add_subtree(
1022 hiqnet_payload_tree, tvb, offset, -1, ett_hiqnet, NULL, "Interface");
1023 proto_tree_add_item(hiqnet_ifaces_tree, hf_hiqnet_maxmsgsize, tvb, offset, 4, ENC_BIG_ENDIAN);
1024 offset += 4;
1025 offset = hiqnet_display_netinfo(hiqnet_ifaces_tree, tvb, offset);
1026 ifacecount -= 1;
1029 break;
1030 case HIQNET_REQADDR_MSG :
1031 /* FIXME: Not tested, straight from the spec, never occurred with the devices I own */
1032 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_devaddr, tvb, offset, 2, ENC_BIG_ENDIAN);
1033 break;
1034 case HIQNET_SETADDR_MSG :
1035 offset = hiqnet_display_sernum(hiqnet_payload_tree, tvb, offset);
1036 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_newdevaddr, tvb, offset, 2, ENC_BIG_ENDIAN);
1037 offset += 2;
1038 hiqnet_display_netinfo(hiqnet_payload_tree, tvb, offset);
1039 break;
1040 case HIQNET_SETATTR_MSG : /* Reverse engineered. Not part of the official spec. */
1041 attrcount = tvb_get_ntohs(tvb, offset);
1042 proto_tree_add_item(hiqnet_payload_tree, hf_hiqnet_attrcount, tvb, offset, 2, ENC_BIG_ENDIAN);
1043 offset += 2;
1044 while (attrcount > 0) {
1045 hiqnet_attribute_tree = proto_tree_add_subtree(
1046 hiqnet_payload_tree, tvb, offset, -1, ett_hiqnet, NULL, "Attribute");
1047 proto_tree_add_item(hiqnet_attribute_tree, hf_hiqnet_attrid, tvb, offset, 2, ENC_BIG_ENDIAN);
1048 offset += 2;
1049 offset = hiqnet_display_data(hiqnet_attribute_tree, pinfo, tvb, offset);
1050 attrcount -= 1;
1052 break;
1053 /* FIXME: Messages unknown, assumed without payload */
1054 case HIQNET_RESERVED0_MSG:
1055 case HIQNET_RESERVED1_MSG:
1056 /* Message without payload */
1057 case HIQNET_ADDRUSED_MSG:
1058 break;
1059 default : /* Unknown message or malformed packet */
1060 /* TODO: display something useful? */
1061 break;
1064 return tvb_reported_length(tvb);
1068 static unsigned
1069 get_hiqnet_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
1071 /* length is at offset + 2 */
1072 return tvb_get_ntohl(tvb, offset + 2);
1075 /* Fixme: For multiple hiqnet PDUS in a single TCP or UDP packet,
1076 the INFO column shows the information only for the last PDU */
1078 static int
1079 dissect_hiqnet_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
1081 tcp_dissect_pdus(tvb, pinfo, tree, true, 6,
1082 get_hiqnet_pdu_len, dissect_hiqnet_pdu, data);
1083 return tvb_captured_length(tvb);
1086 static int
1087 dissect_hiqnet_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
1089 int offset = 0;
1090 tvbuff_t *next_tvb;
1091 int offset_before;
1092 unsigned plen;
1093 unsigned captured_length;
1095 /* loop on (possibly multiple) hiqnet PDUs in UDP payload */
1096 while (tvb_reported_length_remaining(tvb, offset) > 0) {
1097 plen = get_hiqnet_pdu_len(pinfo, tvb, offset, NULL);
1098 captured_length = tvb_captured_length_remaining(tvb, offset);
1100 if (captured_length > plen)
1101 captured_length = plen;
1102 next_tvb = tvb_new_subset_length_caplen(tvb, offset, captured_length, plen);
1104 dissect_hiqnet_pdu(next_tvb, pinfo, tree, data);
1107 * Step to the next PDU.
1108 * Make sure we don't overflow.
1110 offset_before = offset;
1111 offset += plen;
1112 if (offset <= offset_before)
1113 break;
1115 return tvb_captured_length(tvb);
1118 void
1119 proto_register_hiqnet(void)
1121 static hf_register_info hf[] = {
1122 { &hf_hiqnet_version,
1123 { "Version", "hiqnet.version",
1124 FT_UINT8, BASE_DEC,
1125 NULL, 0x0,
1126 NULL, HFILL }
1128 { &hf_hiqnet_headerlen,
1129 { "Header length", "hiqnet.hlen",
1130 FT_UINT16, BASE_DEC,
1131 NULL, 0x0,
1132 NULL, HFILL }
1134 { &hf_hiqnet_messagelen,
1135 { "Message length", "hiqnet.mlen",
1136 FT_UINT32, BASE_DEC,
1137 NULL, 0x0,
1138 NULL, HFILL }
1140 { &hf_hiqnet_sourcedev,
1141 { "Source device", "hiqnet.srcdev",
1142 FT_UINT16, BASE_DEC_HEX,
1143 NULL, 0x0,
1144 NULL, HFILL }
1146 { &hf_hiqnet_sourceaddr,
1147 { "Source address", "hiqnet.srcaddr",
1148 FT_BYTES, BASE_NONE,
1149 NULL, 0x0,
1150 NULL, HFILL }
1152 { &hf_hiqnet_destdev,
1153 { "Destination device", "hiqnet.dstdev",
1154 FT_UINT16, BASE_DEC_HEX,
1155 NULL, 0x0,
1156 NULL, HFILL }
1158 { &hf_hiqnet_destaddr,
1159 { "Destination address", "hiqnet.dstaddr",
1160 FT_BYTES, BASE_NONE,
1161 NULL, 0x0,
1162 NULL, HFILL }
1164 { &hf_hiqnet_messageid,
1165 { "Message ID", "hiqnet.msgid",
1166 FT_UINT16, BASE_HEX,
1167 VALS(messageidnames), 0x0,
1168 NULL, HFILL }
1170 { &hf_hiqnet_flags,
1171 { "Flags", "hiqnet.flags",
1172 FT_UINT16, BASE_HEX,
1173 NULL, HIQNET_FLAGS_MASK,
1174 NULL, HFILL }
1176 { &hf_hiqnet_reqack_flag,
1177 { "Request Acknowledgement", "hiqnet.flags.reqack",
1178 FT_BOOLEAN, 16,
1179 NULL, HIQNET_REQACK_FLAG,
1180 NULL, HFILL }
1182 { &hf_hiqnet_ack_flag,
1183 { "Acknowledgement", "hiqnet.flags.ack",
1184 FT_BOOLEAN, 16,
1185 NULL, HIQNET_ACK_FLAG,
1186 NULL, HFILL }
1188 { &hf_hiqnet_info_flag,
1189 { "Information", "hiqnet.flags.info",
1190 FT_BOOLEAN, 16,
1191 NULL, HIQNET_INFO_FLAG,
1192 NULL, HFILL }
1194 { &hf_hiqnet_error_flag,
1195 { "Error", "hiqnet.flags.error",
1196 FT_BOOLEAN, 16,
1197 NULL, HIQNET_ERROR_FLAG,
1198 NULL, HFILL }
1200 { &hf_hiqnet_guaranteed_flag,
1201 { "Guaranteed", "hiqnet.flags.guar",
1202 FT_BOOLEAN, 16,
1203 NULL, HIQNET_GUARANTEED_FLAG,
1204 NULL, HFILL }
1206 { &hf_hiqnet_multipart_flag,
1207 { "Multipart", "hiqnet.flags.multi",
1208 FT_BOOLEAN, 16,
1209 NULL, HIQNET_MULTIPART_FLAG,
1210 NULL, HFILL }
1212 { &hf_hiqnet_session_number_flag,
1213 { "Session Number", "hiqnet.flags.session_number",
1214 FT_BOOLEAN, 16,
1215 NULL, HIQNET_SESSION_NUMBER_FLAG,
1216 NULL, HFILL }
1218 { &hf_hiqnet_hopcnt,
1219 { "Hop count", "hiqnet.hc",
1220 FT_UINT8, BASE_DEC,
1221 NULL, 0x0,
1222 NULL, HFILL }
1224 { &hf_hiqnet_seqnum,
1225 { "Sequence number", "hiqnet.seqnum",
1226 FT_UINT16, BASE_DEC,
1227 NULL, 0x0,
1228 NULL, HFILL }
1230 { &hf_hiqnet_errcode,
1231 { "Error code", "hiqnet.errcode",
1232 FT_UINT8, BASE_DEC_HEX,
1233 NULL, 0x0,
1234 NULL, HFILL }
1236 { &hf_hiqnet_errstr,
1237 { "Error string", "hiqnet.errstr",
1238 FT_STRINGZ, BASE_NONE,
1239 NULL, 0x0,
1240 NULL, HFILL }
1242 { &hf_hiqnet_startseqno,
1243 { "Start seq. no.", "hiqnet.ssno",
1244 FT_UINT8, BASE_DEC,
1245 NULL, 0x0,
1246 NULL, HFILL }
1248 { &hf_hiqnet_rembytes,
1249 { "Remaining bytes", "hiqnet.rembytes",
1250 FT_UINT32, BASE_DEC,
1251 NULL, 0x0,
1252 NULL, HFILL }
1254 { &hf_hiqnet_sessnum,
1255 { "Session number", "hiqnet.sessnum",
1256 FT_UINT16, BASE_DEC,
1257 NULL, 0x0,
1258 NULL, HFILL }
1260 { &hf_hiqnet_cost,
1261 { "Cost", "hiqnet.cost",
1262 FT_UINT8, BASE_DEC,
1263 NULL, 0x0,
1264 NULL, HFILL }
1266 { &hf_hiqnet_sernumlen,
1267 { "Serial number length", "hiqnet.sernumlen",
1268 FT_UINT16, BASE_DEC,
1269 NULL, 0x0,
1270 NULL, HFILL }
1272 { &hf_hiqnet_sernum,
1273 { "Serial number", "hiqnet.sernum",
1274 FT_BYTES, BASE_NONE,
1275 NULL, 0x0,
1276 NULL, HFILL }
1278 { &hf_hiqnet_maxmsgsize,
1279 { "Max message size", "hiqnet.maxmsgsize",
1280 FT_UINT32, BASE_DEC,
1281 NULL, 0x0,
1282 NULL, HFILL }
1284 { &hf_hiqnet_keepaliveperiod,
1285 { "Keepalive period (ms)", "hiqnet.keepaliveperiod",
1286 FT_UINT16, BASE_DEC,
1287 NULL, 0x0,
1288 NULL, HFILL }
1290 { &hf_hiqnet_netid,
1291 { "Network ID", "hiqnet.netid",
1292 FT_UINT8, BASE_DEC,
1293 VALS(networknames), 0x0,
1294 NULL, HFILL }
1296 { &hf_hiqnet_macaddr,
1297 { "MAC address", "hiqnet.macaddr",
1298 FT_ETHER, BASE_NONE,
1299 NULL, 0x0,
1300 NULL, HFILL }
1302 { &hf_hiqnet_dhcp,
1303 { "DHCP", "hiqnet.dhcp",
1304 FT_BOOLEAN, BASE_NONE,
1305 NULL, 0x0,
1306 NULL, HFILL }
1308 { &hf_hiqnet_ipaddr,
1309 { "IP Address", "hiqnet.ipaddr",
1310 FT_IPv4, BASE_NONE,
1311 NULL, 0x0,
1312 NULL, HFILL }
1314 { &hf_hiqnet_subnetmsk,
1315 { "Subnet mask", "hiqnet.subnetmsk",
1316 FT_IPv4, BASE_NONE,
1317 NULL, 0x0,
1318 NULL, HFILL }
1320 { &hf_hiqnet_gateway,
1321 { "Gateway", "hiqnet.gateway",
1322 FT_IPv4, BASE_NONE,
1323 NULL, 0x0,
1324 NULL, HFILL }
1326 { &hf_hiqnet_flagmask,
1327 { "Flag mask", "hiqnet.flagmask",
1328 FT_UINT16, BASE_HEX,
1329 NULL, HIQNET_FLAGS_MASK,
1330 NULL, HFILL }
1332 { &hf_hiqnet_paramcount,
1333 { "Parameter count", "hiqnet.paramcount",
1334 FT_UINT16, BASE_DEC,
1335 NULL, 0x0,
1336 NULL, HFILL }
1338 { &hf_hiqnet_paramid,
1339 { "Parameter ID", "hiqnet.paramid",
1340 FT_UINT16, BASE_DEC,
1341 NULL, 0x0,
1342 NULL, HFILL }
1344 { &hf_hiqnet_vdobject,
1345 { "Virtual Device Object", "hiqnet.vdobject",
1346 FT_BYTES, BASE_NONE,
1347 NULL, 0x0,
1348 NULL, HFILL }
1350 { &hf_hiqnet_subtype,
1351 { "Subscription Type (New Style)", "hiqnet.subtype",
1352 FT_UINT8, BASE_DEC,
1353 NULL, HIQNET_SUBSCRIPTION_TYPE_MASK,
1354 NULL, HFILL }
1356 /* FIXME: decode old style subscription type
1357 { &hf_hiqnet_subtypeold,
1358 { "Subscription Type (Old Style)", "hiqnet.subtype",
1359 FT_UINT8, BASE_DEC,
1360 VALS(subscription_types_oldstyle_names), 0x0,
1361 NULL, HFILL }
1364 { &hf_hiqnet_sensrate,
1365 { "Sensor Rate (ms)", "hiqnet.sensrate",
1366 FT_UINT16, BASE_DEC,
1367 NULL, 0x0,
1368 NULL, HFILL }
1370 { &hf_hiqnet_subflags,
1371 { "Subscription Flags", "hiqnet.subflags",
1372 FT_UINT16, BASE_HEX,
1373 NULL, HIQNET_SUBSCRIPTION_FLAGS_MASK,
1374 NULL, HFILL }
1376 { &hf_hiqnet_subcount,
1377 { "No of Subscriptions", "hiqnet.subcount",
1378 FT_UINT16, BASE_DEC,
1379 NULL, 0x0,
1380 NULL, HFILL }
1382 { &hf_hiqnet_pubparmid,
1383 { "Publisher Parameter ID", "hiqnet.pubparmid",
1384 FT_UINT16, BASE_DEC,
1385 NULL, 0x0,
1386 NULL, HFILL }
1388 { &hf_hiqnet_subaddr,
1389 { "Subscriber Address", "hiqnet.subaddr",
1390 FT_BYTES, BASE_NONE,
1391 NULL, 0x0,
1392 NULL, HFILL }
1394 { &hf_hiqnet_subparmid,
1395 { "Subscriber Parameter ID", "hiqnet.subparmid",
1396 FT_UINT16, BASE_DEC,
1397 NULL, 0x0,
1398 NULL, HFILL }
1400 { &hf_hiqnet_reserved0,
1401 { "Reserved", "hiqnet.reserved0",
1402 FT_BYTES, BASE_NONE,
1403 NULL, 0x0,
1404 NULL, HFILL }
1406 { &hf_hiqnet_reserved1,
1407 { "Reserved", "hiqnet.reserved1",
1408 FT_BYTES, BASE_NONE,
1409 NULL, 0x0,
1410 NULL, HFILL }
1412 { &hf_hiqnet_attrcount,
1413 { "Attribute count", "hiqnet.attrcount",
1414 FT_UINT16, BASE_DEC,
1415 NULL, 0x0,
1416 NULL, HFILL }
1418 { &hf_hiqnet_attrid,
1419 { "Attribute ID", "hiqnet.attrid",
1420 FT_UINT16, BASE_DEC,
1421 VALS(device_attributes_names), 0x0,
1422 NULL, HFILL }
1424 { &hf_hiqnet_datatype,
1425 { "Data type", "hiqnet.datatype",
1426 FT_UINT8, BASE_HEX,
1427 VALS(datatypenames), 0x0,
1428 NULL, HFILL }
1430 { &hf_hiqnet_datalen,
1431 { "Data length", "hiqnet.datalen",
1432 FT_UINT16, BASE_DEC,
1433 NULL, 0x0,
1434 NULL, HFILL }
1436 { &hf_hiqnet_byte_value,
1437 { "Value", "hiqnet.byte_value",
1438 FT_INT8, BASE_DEC,
1439 NULL, 0x0,
1440 NULL, HFILL }
1442 { &hf_hiqnet_ubyte_value,
1443 { "Value", "hiqnet.ubyte_value",
1444 FT_UINT8, BASE_DEC_HEX,
1445 NULL, 0x0,
1446 NULL, HFILL }
1448 { &hf_hiqnet_word_value,
1449 { "Value", "hiqnet.word_value",
1450 FT_INT16, BASE_DEC,
1451 NULL, 0x0,
1452 NULL, HFILL }
1454 { &hf_hiqnet_uword_value,
1455 { "Value", "hiqnet.uword_value",
1456 FT_UINT16, BASE_DEC_HEX,
1457 NULL, 0x0,
1458 NULL, HFILL }
1460 { &hf_hiqnet_long_value,
1461 { "Value", "hiqnet.long_value",
1462 FT_INT32, BASE_DEC,
1463 NULL, 0x0,
1464 NULL, HFILL }
1466 { &hf_hiqnet_ulong_value,
1467 { "Value", "hiqnet.ulong_value",
1468 FT_UINT32, BASE_DEC_HEX,
1469 NULL, 0x0,
1470 NULL, HFILL }
1472 { &hf_hiqnet_float32_value,
1473 { "Value", "hiqnet.float32_value",
1474 FT_FLOAT, BASE_NONE,
1475 NULL, 0x0,
1476 NULL, HFILL }
1478 { &hf_hiqnet_float64_value,
1479 { "Value", "hiqnet.float64_value",
1480 FT_DOUBLE, BASE_NONE,
1481 NULL, 0x0,
1482 NULL, HFILL }
1484 { &hf_hiqnet_block_value,
1485 { "Value", "hiqnet.block_value",
1486 FT_BYTES, BASE_NONE,
1487 NULL, 0x0,
1488 NULL, HFILL }
1490 /* Counted *and* null-terminated */
1491 { &hf_hiqnet_string_value,
1492 { "Value", "hiqnet.string_value",
1493 FT_STRINGZ, BASE_NONE,
1494 NULL, 0x0,
1495 NULL, HFILL }
1497 { &hf_hiqnet_long64_value,
1498 { "Value", "hiqnet.long64_value",
1499 FT_INT64, BASE_DEC,
1500 NULL, 0x0,
1501 NULL, HFILL }
1503 { &hf_hiqnet_ulong64_value,
1504 { "Value", "hiqnet.ulong64_value",
1505 FT_UINT64 , BASE_DEC_HEX,
1506 NULL, 0x0,
1507 NULL, HFILL }
1509 { &hf_hiqnet_wrkgrppath,
1510 { "Workgroup Path", "hiqnet.wrkgrppath",
1511 FT_STRINGZ, BASE_NONE,
1512 NULL, 0x0,
1513 NULL, HFILL }
1515 { &hf_hiqnet_numvds,
1516 { "Number of Virtual Devices", "hiqnet.numvds",
1517 FT_UINT16, BASE_DEC,
1518 NULL, 0x0,
1519 NULL, HFILL }
1521 { &hf_hiqnet_vdaddr,
1522 { "Virtual Device Address", "hiqnet.vdaddr",
1523 FT_UINT8, BASE_DEC,
1524 NULL, 0x0,
1525 NULL, HFILL }
1527 { &hf_hiqnet_vdclassid,
1528 { "Virtual Device Class ID", "hiqnet.vdclassid",
1529 FT_UINT16, BASE_HEX,
1530 NULL, 0x0,
1531 NULL, HFILL }
1533 { &hf_hiqnet_stract,
1534 { "Store Action", "hiqnet.stract",
1535 FT_UINT8, BASE_DEC,
1536 VALS(actionnames), 0x0,
1537 NULL, HFILL }
1539 { &hf_hiqnet_strnum,
1540 { "Store Number", "hiqnet.strnum",
1541 FT_UINT16, BASE_DEC,
1542 NULL, 0x0,
1543 NULL, HFILL }
1545 { &hf_hiqnet_scope,
1546 { "Scope", "hiqnet.scope",
1547 FT_UINT8, BASE_HEX,
1548 NULL, 0x0,
1549 NULL, HFILL }
1551 { &hf_hiqnet_recact,
1552 { "Recall Action", "hiqnet.rec.act",
1553 FT_UINT8, BASE_DEC,
1554 VALS(actionnames), 0x0,
1555 NULL, HFILL }
1557 { &hf_hiqnet_recnum,
1558 { "Recall Number", "hiqnet.recnum",
1559 FT_UINT16, BASE_DEC,
1560 NULL, 0x0,
1561 NULL, HFILL }
1563 { &hf_hiqnet_strlen,
1564 { "String length", "hiqnet.strlen",
1565 FT_UINT16, BASE_DEC,
1566 NULL, 0x0,
1567 NULL, HFILL }
1569 { &hf_hiqnet_time,
1570 { "Locate time (ms)", "hiqnet.time",
1571 FT_UINT16, BASE_DEC,
1572 VALS(timenames), 0x0,
1573 NULL, HFILL }
1575 { &hf_hiqnet_maxdatasize,
1576 { "Maximum Data Size", "hiqnet.maxdatasize",
1577 FT_UINT16, BASE_DEC,
1578 NULL, 0x0,
1579 NULL, HFILL }
1581 { &hf_hiqnet_catfilter,
1582 { "Category Filter", "hiqnet.catfilter",
1583 FT_UINT32, BASE_HEX,
1584 NULL, HIQNET_CATEGORIES_MASK,
1585 NULL, HFILL }
1587 { &hf_hiqnet_app_cat,
1588 { "Application", "hiqnet.appcat",
1589 FT_BOOLEAN, 32,
1590 NULL, HIQNET_APPLICATION_CAT,
1591 NULL, HFILL }
1593 { &hf_hiqnet_conf_cat,
1594 { "Configuration", "hiqnet.confcat",
1595 FT_BOOLEAN, 32,
1596 NULL, HIQNET_CONF_CAT,
1597 NULL, HFILL }
1599 { &hf_hiqnet_audionet_cat,
1600 { "Audio Network", "hiqnet.audionetcat",
1601 FT_BOOLEAN, 32,
1602 NULL, HIQNET_AUDIONET_CAT,
1603 NULL, HFILL }
1605 { &hf_hiqnet_ctrlnet_cat,
1606 { "Control Network", "hiqnet.ctrlnetcat",
1607 FT_BOOLEAN, 32,
1608 NULL, HIQNET_CTRLNET_CAT,
1609 NULL, HFILL }
1611 { &hf_hiqnet_vendnet_cat,
1612 { "Vendor Network", "hiqnet.vendnetcat",
1613 FT_BOOLEAN, 32,
1614 NULL, HIQNET_VENDNET_CAT,
1615 NULL, HFILL }
1617 { &hf_hiqnet_startup_cat,
1618 { "Startup", "hiqnet.startupcat",
1619 FT_BOOLEAN, 32,
1620 NULL, HIQNET_STARTUP_CAT,
1621 NULL, HFILL }
1623 { &hf_hiqnet_dsp_cat,
1624 { "DSP", "hiqnet.dspcat",
1625 FT_BOOLEAN, 32,
1626 NULL, HIQNET_DSP_CAT,
1627 NULL, HFILL }
1629 { &hf_hiqnet_misc_cat,
1630 { "Miscellaneous", "hiqnet.misccat",
1631 FT_BOOLEAN, 32,
1632 NULL, HIQNET_MISC_CAT,
1633 NULL, HFILL }
1635 { &hf_hiqnet_ctrlog_cat,
1636 { "Control Logic", "hiqnet.crtllogcat",
1637 FT_BOOLEAN, 32,
1638 NULL, HIQNET_CTRLLOG_CAT,
1639 NULL, HFILL }
1641 { &hf_hiqnet_foreignproto_cat,
1642 { "Foreign Protocol", "hiqnet.foreignprotocat",
1643 FT_BOOLEAN, 32,
1644 NULL, HIQNET_FOREIGNPROTO_CAT,
1645 NULL, HFILL }
1647 { &hf_hiqnet_digio_cat,
1648 { "Digital I/O", "hiqnet.digiocat",
1649 FT_BOOLEAN, 32,
1650 NULL, HIQNET_DIGIO_CAT,
1651 NULL, HFILL }
1653 { &hf_hiqnet_ctrlsurf_cat,
1654 { "Control Surface", "hiqnet.ctrlsurfcat",
1655 FT_BOOLEAN, 32,
1656 NULL, HIQNET_CTRLSURF_CAT,
1657 NULL, HFILL }
1659 { &hf_hiqnet_entrieslen,
1660 { "Number of Entries", "hiqnet.entrieslen",
1661 FT_UINT16, BASE_DEC,
1662 NULL, 0x0,
1663 NULL, HFILL }
1665 { &hf_hiqnet_category,
1666 { "Category", "hiqnet.cat",
1667 FT_UINT16, BASE_HEX,
1668 VALS(eventcategorynames), 0x0,
1669 NULL, HFILL }
1671 { &hf_hiqnet_eventid,
1672 { "Event ID", "hiqnet.eventid",
1673 FT_UINT16, BASE_DEC,
1674 VALS(eventidnames), 0x0,
1675 NULL, HFILL }
1677 { &hf_hiqnet_priority,
1678 { "Priority", "hiqnet.priority",
1679 FT_UINT8, BASE_DEC,
1680 VALS(prioritynames), 0x0,
1681 NULL, HFILL }
1683 { &hf_hiqnet_eventseqnum,
1684 { "Sequence Number", "hiqnet.eventseqnum",
1685 FT_UINT32, BASE_DEC,
1686 NULL, 0x0,
1687 NULL, HFILL }
1689 { &hf_hiqnet_eventtime,
1690 { "Time", "hiqnet.eventtime",
1691 FT_STRING, BASE_NONE,
1692 NULL, 0x0,
1693 NULL, HFILL }
1695 { &hf_hiqnet_eventdate,
1696 { "Date", "hiqnet.eventdate",
1697 FT_STRING, BASE_NONE,
1698 NULL, 0x0,
1699 NULL, HFILL }
1701 { &hf_hiqnet_eventinfo,
1702 { "Information", "hiqnet.information",
1703 FT_STRING, BASE_NONE,
1704 NULL, 0x0,
1705 NULL, HFILL }
1707 { &hf_hiqnet_eventadddata,
1708 { "Additional Data", "hiqnet.eventadddata",
1709 FT_BYTES, BASE_NONE,
1710 NULL, 0x0,
1711 NULL, HFILL }
1713 { &hf_hiqnet_objcount,
1714 { "Object Count", "hiqnet.objcount",
1715 FT_UINT16, BASE_DEC,
1716 NULL, 0x0,
1717 NULL, HFILL }
1719 { &hf_hiqnet_paramval,
1720 { "Parameter Value (%)", "hiqnet.paramval",
1721 FT_INT16, BASE_DEC,
1722 NULL, 0x0,
1723 NULL, HFILL }
1725 { &hf_hiqnet_ifacecount,
1726 { "Interface Count", "hiqnet.ifacecount",
1727 FT_UINT16, BASE_DEC,
1728 NULL, 0x0,
1729 NULL, HFILL }
1731 { &hf_hiqnet_comid,
1732 { "Com Port Identifier", "hiqnet.comid",
1733 FT_UINT8, BASE_DEC,
1734 NULL, 0x0,
1735 NULL, HFILL }
1737 { &hf_hiqnet_baudrate,
1738 { "Baud Rate", "hiqnet.baudrate",
1739 FT_UINT32, BASE_DEC,
1740 NULL, 0x0,
1741 NULL, HFILL }
1743 { &hf_hiqnet_parity,
1744 { "Parity", "hiqnet.parity",
1745 FT_UINT8, BASE_DEC,
1746 VALS(paritynames), 0x0,
1747 NULL, HFILL }
1749 { &hf_hiqnet_stopbits,
1750 { "Stop Bits", "hiqnet.stopbits",
1751 FT_UINT8, BASE_DEC,
1752 VALS(stopbitsnames), 0x0,
1753 NULL, HFILL }
1755 { &hf_hiqnet_databits,
1756 { "Data Bits", "hiqnet.databits",
1757 FT_UINT8, BASE_DEC,
1758 NULL, 0x0,
1759 NULL, HFILL }
1761 { &hf_hiqnet_flowcontrol,
1762 { "Flowcontrol", "hiqnet.flowcontrol",
1763 FT_UINT8, BASE_DEC,
1764 VALS(flowcontrolnames), 0x0,
1765 NULL, HFILL }
1767 { &hf_hiqnet_devaddr,
1768 { "Device Address", "hiqnet.device",
1769 FT_UINT16, BASE_DEC_HEX,
1770 NULL, 0x0,
1771 NULL, HFILL }
1773 { &hf_hiqnet_newdevaddr,
1774 { "New Device Address", "hiqnet.device",
1775 FT_UINT16, BASE_DEC_HEX,
1776 NULL, 0x0,
1777 NULL, HFILL }
1781 /* Setup protocol subtree array */
1782 static int *ett[] = {
1783 &ett_hiqnet,
1784 &ett_hiqnet_flags,
1785 &ett_hiqnet_cats
1788 static ei_register_info ei[] = {
1789 { &ei_hiqnet_datatype, { "hiqnet.datatype.invalid", PI_PROTOCOL, PI_WARN, "Invalid datatype", EXPFILL }},
1792 expert_module_t* expert_hiqnet;
1794 proto_hiqnet = proto_register_protocol ("Harman HiQnet", "HiQnet", "hiqnet");
1796 proto_register_field_array(proto_hiqnet, hf, array_length(hf));
1797 proto_register_subtree_array(ett, array_length(ett));
1798 expert_hiqnet = expert_register_protocol(proto_hiqnet);
1799 expert_register_field_array(expert_hiqnet, ei, array_length(ei));
1801 hiqnet_udp_handle = register_dissector("hiqnet.udp", dissect_hiqnet_udp, proto_hiqnet);
1802 hiqnet_tcp_handle = register_dissector("hiqnet.tcp", dissect_hiqnet_tcp, proto_hiqnet);
1806 void
1807 proto_reg_handoff_hiqnet(void)
1809 dissector_add_uint_with_preference("udp.port", HIQNET_PORT, hiqnet_udp_handle);
1810 dissector_add_uint_with_preference("tcp.port", HIQNET_PORT, hiqnet_tcp_handle);
1814 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1816 * Local variables:
1817 * c-basic-offset: 4
1818 * indent-tabs-mode: nil
1819 * End:
1821 * vi: set shiftwidth=4 expandtab:
1822 * :indentSize=4:noTabs=true: