Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-vxi11.c
blob3151ce5363dc68ce716043d181f3a27ee748953a
1 /* packet-vxi11.c
2 * Routines for VXI-11 (TCP/IP Instrument Protocol) dissection.
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * VXI-11 protocol dissector
9 * By Jens Kilian <jens.kilian@verigy.com>
10 * Copyright 2009 Verigy Deutschland GmbH
12 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include "config.h"
17 #include "packet-rpc.h"
18 #include <epan/to_str.h>
19 #include <epan/tfs.h>
20 #include <wsutil/array.h>
23 * For the protocol specifications, see
24 * http://www.vxibus.org/files/VXI_Specs/VXI-11.zip
26 * This dissector handles the basic Network Instrument protocol as defined
27 * in VXI-11, and parts of the TCP/IP-IEEE 488.1 Interface spec (VXI-11.2).
30 /* Core protocol. */
32 #define VXI11_CORE_ADDRESS_FAMILY_TCP 0
33 #define VXI11_CORE_ADDRESS_FAMILY_UDP 1
35 #define VXI11_CORE_CMD_SEND_COMMAND 0x020000
36 #define VXI11_CORE_CMD_BUS_STATUS 0x020001
37 #define VXI11_CORE_CMD_ATN_CONTROL 0x020002
38 #define VXI11_CORE_CMD_REN_CONTROL 0x020003
39 #define VXI11_CORE_CMD_PASS_CONTROL 0x020004
40 #define VXI11_CORE_CMD_BUS_ADDRESS 0x02000a
41 #define VXI11_CORE_CMD_IFC_CONTROL 0x020010
43 #define VXI11_CORE_ERROR_NO_ERROR 0
44 #define VXI11_CORE_ERROR_SYNTAX_ERROR 1
45 #define VXI11_CORE_ERROR_DEVICE_NOT_ACCESSIBLE 3
46 #define VXI11_CORE_ERROR_INVALID_ID 4
47 #define VXI11_CORE_ERROR_PARAMETER_ERROR 5
48 #define VXI11_CORE_ERROR_CHANNEL_NOT_ESTABLISHED 6
49 #define VXI11_CORE_ERROR_OPERATION_NOT_SUPPORTED 8
50 #define VXI11_CORE_ERROR_OUT_OF_RESOURCES 9
51 #define VXI11_CORE_ERROR_DEVICE_LOCKED 11
52 #define VXI11_CORE_ERROR_NO_LOCK_HELD 12
53 #define VXI11_CORE_ERROR_IO_TIMEOUT 15
54 #define VXI11_CORE_ERROR_IO_ERROR 17
55 #define VXI11_CORE_ERROR_INVALID_ADDRESS 21
56 #define VXI11_CORE_ERROR_ABORT 23
57 #define VXI11_CORE_ERROR_CHANNEL_ALREADY_ESTABLISHED 29
59 #define VXI11_CORE_FLAG_WAITLOCK (1 << 0)
60 #define VXI11_CORE_FLAG_END (1 << 3)
61 #define VXI11_CORE_FLAG_TERMCHRSET (1 << 7)
63 #define VXI11_CORE_REASON_REQCNT (1 << 0)
64 #define VXI11_CORE_REASON_CHR (1 << 1)
65 #define VXI11_CORE_REASON_END (1 << 2)
67 #define VXI11_CORE_PROC_NULL 0
68 #define VXI11_CORE_PROC_CREATE_LINK 10
69 #define VXI11_CORE_PROC_DEVICE_WRITE 11
70 #define VXI11_CORE_PROC_DEVICE_READ 12
71 #define VXI11_CORE_PROC_DEVICE_READSTB 13
72 #define VXI11_CORE_PROC_DEVICE_TRIGGER 14
73 #define VXI11_CORE_PROC_DEVICE_CLEAR 15
74 #define VXI11_CORE_PROC_DEVICE_REMOTE 16
75 #define VXI11_CORE_PROC_DEVICE_LOCAL 17
76 #define VXI11_CORE_PROC_DEVICE_LOCK 18
77 #define VXI11_CORE_PROC_DEVICE_UNLOCK 19
78 #define VXI11_CORE_PROC_DEVICE_ENABLE_SRQ 20
79 #define VXI11_CORE_PROC_DEVICE_DOCMD 22
80 #define VXI11_CORE_PROC_DESTROY_LINK 23
81 #define VXI11_CORE_PROC_CREATE_INTR_CHAN 25
82 #define VXI11_CORE_PROC_DESTROY_INTR_CHAN 26
84 #define VXI11_CORE_PROGRAM 0x0607AF
85 #define VXI11_CORE_VERSION 1
87 #define MAX_DATA_SHOW_SIZE 70
90 void proto_register_vxi11_core(void);
91 void proto_reg_handoff_vxi11_core(void);
92 void proto_register_vxi11_async(void);
93 void proto_reg_handoff_vxi11_async(void);
94 void proto_register_vxi11_intr(void);
95 void proto_reg_handoff_vxi11_intr(void);
97 static int proto_vxi11_core;
99 static int ett_vxi11_core;
100 static int ett_vxi11_core_flags;
101 static int ett_vxi11_core_reason;
103 static int hf_vxi11_core_procedure_v1;
104 static int hf_vxi11_core_abort_port;
105 static int hf_vxi11_core_client_id;
106 static int hf_vxi11_core_cmd;
107 static int hf_vxi11_core_data;
108 static int hf_vxi11_core_device;
109 static int hf_vxi11_core_enable;
110 static int hf_vxi11_core_error;
111 static int hf_vxi11_core_flags;
112 static int hf_vxi11_core_flag_wait_lock;
113 static int hf_vxi11_core_flag_end;
114 static int hf_vxi11_core_flag_term_chr_set;
115 static int hf_vxi11_core_handle;
116 static int hf_vxi11_core_host_addr;
117 static int hf_vxi11_core_host_port;
118 static int hf_vxi11_core_io_timeout;
119 static int hf_vxi11_core_lid;
120 static int hf_vxi11_core_lock_device;
121 static int hf_vxi11_core_lock_timeout;
122 static int hf_vxi11_core_max_recv_size;
123 static int hf_vxi11_core_network_order;
124 static int hf_vxi11_core_prog_family;
125 static int hf_vxi11_core_prog_num;
126 static int hf_vxi11_core_prog_vers;
127 static int hf_vxi11_core_reason;
128 static int hf_vxi11_core_reason_req_cnt;
129 static int hf_vxi11_core_reason_chr;
130 static int hf_vxi11_core_reason_end;
131 static int hf_vxi11_core_size;
132 static int hf_vxi11_core_stb;
133 static int hf_vxi11_core_term_char;
135 static const value_string vxi11_core_error_vals[] = {
136 { VXI11_CORE_ERROR_NO_ERROR, "No Error" },
137 { VXI11_CORE_ERROR_SYNTAX_ERROR, "Syntax Error" },
138 { VXI11_CORE_ERROR_DEVICE_NOT_ACCESSIBLE, "Device Not Accessible" },
139 { VXI11_CORE_ERROR_INVALID_ID, "Invalid ID" },
140 { VXI11_CORE_ERROR_PARAMETER_ERROR, "Parameter Error" },
141 { VXI11_CORE_ERROR_CHANNEL_NOT_ESTABLISHED, "Channel Not Established" },
142 { VXI11_CORE_ERROR_OPERATION_NOT_SUPPORTED, "Operation Not Supported" },
143 { VXI11_CORE_ERROR_OUT_OF_RESOURCES, "Out Of Resources" },
144 { VXI11_CORE_ERROR_DEVICE_LOCKED, "Device Locked" },
145 { VXI11_CORE_ERROR_NO_LOCK_HELD, "No Lock Held" },
146 { VXI11_CORE_ERROR_IO_TIMEOUT, "I/O Timeout" },
147 { VXI11_CORE_ERROR_IO_ERROR, "I/O Error" },
148 { VXI11_CORE_ERROR_INVALID_ADDRESS, "Invalid Address" },
149 { VXI11_CORE_ERROR_ABORT, "Abort" },
150 { VXI11_CORE_ERROR_CHANNEL_ALREADY_ESTABLISHED, "Channel Already Established" },
151 { 0, NULL }
154 static const value_string vxi11_core_cmd_vals[] = {
155 { VXI11_CORE_CMD_SEND_COMMAND, "SEND_COMMAND" },
156 { VXI11_CORE_CMD_BUS_STATUS, "BUS_STATUS" },
157 { VXI11_CORE_CMD_ATN_CONTROL, "ATN_CONTROL" },
158 { VXI11_CORE_CMD_REN_CONTROL, "REN_CONTROL" },
159 { VXI11_CORE_CMD_PASS_CONTROL, "PASS_CONTROL" },
160 { VXI11_CORE_CMD_BUS_ADDRESS, "BUS_ADDRESS" },
161 { VXI11_CORE_CMD_IFC_CONTROL, "IFC_CONTROL" },
162 { 0, NULL }
166 /* Asynchronous-abort protocol. */
168 #define VXI11_ASYNC_PROC_NULL 0
169 #define VXI11_ASYNC_PROC_DEVICE_ABORT 1
171 #define VXI11_ASYNC_PROGRAM 0x0607B0
172 #define VXI11_ASYNC_VERSION 1
174 static int proto_vxi11_async;
176 static int ett_vxi11_async;
178 static int hf_vxi11_async_procedure_v1;
181 /* Interrupt protocol. */
183 #define VXI11_INTR_PROC_NULL 0
184 #define VXI11_INTR_PROC_DEVICE_INTR_SRQ 30
186 #define VXI11_INTR_PROGRAM 0x0607B1
187 #define VXI11_INTR_VERSION 1
189 static int proto_vxi11_intr;
191 static int ett_vxi11_intr;
193 static int hf_vxi11_intr_procedure_v1;
194 static int hf_vxi11_intr_handle;
197 /* Helper routines for dissecting common fields. */
199 static int
200 dissect_error(tvbuff_t *tvb,
201 int offset,
202 packet_info *pinfo,
203 proto_tree *tree,
204 const char *packet_type,
205 uint32_t *error)
207 const char *errstr;
209 *error = tvb_get_ntohl(tvb, offset);
210 errstr = val_to_str(*error, vxi11_core_error_vals, "Error %d");
212 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_error, offset);
214 proto_item_append_text(tree, " (%s) %s", packet_type, errstr);
215 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", errstr);
217 return offset;
220 static int
221 dissect_flags(tvbuff_t *tvb, int offset, proto_tree *tree)
223 if (tree)
225 uint32_t flags =
226 tvb_get_ntohl(tvb, offset);
227 proto_item *flags_item =
228 proto_tree_add_item(tree, hf_vxi11_core_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
230 if (flags_item)
232 proto_tree *flags_tree =
233 proto_item_add_subtree(flags_item, ett_vxi11_core_flags);
235 proto_tree_add_item(flags_tree, hf_vxi11_core_flag_wait_lock, tvb, offset, 4, ENC_BIG_ENDIAN);
236 proto_tree_add_item(flags_tree, hf_vxi11_core_flag_end, tvb, offset, 4, ENC_BIG_ENDIAN);
237 proto_tree_add_item(flags_tree, hf_vxi11_core_flag_term_chr_set, tvb, offset, 4, ENC_BIG_ENDIAN);
239 if (flags != 0)
241 wmem_strbuf_t *strbuf = wmem_strbuf_create(wmem_packet_scope());
243 if (flags & VXI11_CORE_FLAG_WAITLOCK)
245 wmem_strbuf_append(strbuf, "WAIT_LOCK, ");
247 if (flags & VXI11_CORE_FLAG_END)
249 wmem_strbuf_append(strbuf, "END, ");
251 if (flags & VXI11_CORE_FLAG_TERMCHRSET)
253 wmem_strbuf_append(strbuf, "TERM_CHR_SET, ");
256 wmem_strbuf_truncate(strbuf, wmem_strbuf_get_len(strbuf) - 2);
257 proto_item_append_text(flags_item, " (%s)", wmem_strbuf_get_str(strbuf));
262 return offset + 4;
265 static int
266 dissect_reason(tvbuff_t *tvb, int offset, proto_tree *tree)
268 if (tree)
270 uint32_t reason =
271 tvb_get_ntohl(tvb, offset);
272 proto_item *reason_item =
273 proto_tree_add_item(tree, hf_vxi11_core_reason, tvb, offset, 4, ENC_BIG_ENDIAN);
275 if (reason_item)
277 proto_tree *reason_tree =
278 proto_item_add_subtree(reason_item, ett_vxi11_core_reason);
280 proto_tree_add_item(reason_tree, hf_vxi11_core_reason_req_cnt, tvb, offset, 4, ENC_BIG_ENDIAN);
281 proto_tree_add_item(reason_tree, hf_vxi11_core_reason_chr, tvb, offset, 4, ENC_BIG_ENDIAN);
282 proto_tree_add_item(reason_tree, hf_vxi11_core_reason_end, tvb, offset, 4, ENC_BIG_ENDIAN);
284 if (reason != 0)
286 wmem_strbuf_t *strbuf = wmem_strbuf_create(wmem_packet_scope());
288 if (reason & VXI11_CORE_REASON_REQCNT)
290 wmem_strbuf_append(strbuf, "REQ_CNT, ");
292 if (reason & VXI11_CORE_REASON_CHR)
294 wmem_strbuf_append(strbuf, "CHR, ");
296 if (reason & VXI11_CORE_REASON_END)
298 wmem_strbuf_append(strbuf, "END, ");
301 wmem_strbuf_truncate(strbuf, wmem_strbuf_get_len(strbuf) - 2);
302 proto_item_append_text(reason_item, " (%s)", wmem_strbuf_get_str(strbuf));
307 return offset + 4;
310 /* Dissectors for individual RPC requests and responses. */
312 static int
313 dissect_create_link_parms(tvbuff_t *tvb,
314 packet_info *pinfo,
315 proto_tree *tree, void* data _U_)
317 const char *str;
318 int offset = 0;
320 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_client_id, offset);
321 offset = dissect_rpc_bool(tvb, tree, hf_vxi11_core_lock_device, offset);
322 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lock_timeout, offset);
323 offset = dissect_rpc_string(tvb, tree, hf_vxi11_core_device, offset, &str);
325 proto_item_append_text(tree, " (Create_LinkParms) %s", str);
326 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", str);
328 return offset;
331 static int
332 dissect_create_link_resp(tvbuff_t *tvb,
333 packet_info *pinfo,
334 proto_tree *tree, void* data _U_)
336 uint32_t error, lid;
337 int offset = 0;
339 offset = dissect_error(tvb, offset, pinfo, tree, "Create_LinkResp", &error);
341 lid = tvb_get_ntohl(tvb, offset);
342 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lid, offset);
344 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_abort_port, offset);
345 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_max_recv_size, offset);
347 if (error == VXI11_CORE_ERROR_NO_ERROR)
349 proto_item_append_text(tree, " LID=%d", lid);
350 col_append_fstr(pinfo->cinfo, COL_INFO, " LID=%d", lid);
353 return offset;
356 static int
357 dissect_device_SRQ_parms(tvbuff_t *tvb,
358 packet_info *pinfo _U_,
359 proto_tree *tree, void* data _U_)
361 int offset = dissect_rpc_opaque_data(tvb, 0, tree, NULL, hf_vxi11_intr_handle, false, 0, false, NULL, NULL);
363 proto_item_append_text(tree, " (Device_SrqParms)");
365 return offset;
368 static int
369 dissect_device_docmd_parms(tvbuff_t *tvb,
370 packet_info *pinfo,
371 proto_tree *tree, void* data _U_)
373 uint32_t lid, cmd;
374 const char *cmdstr;
375 int offset = 0;
377 lid = tvb_get_ntohl(tvb, offset);
378 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lid, offset);
380 offset = dissect_flags(tvb, offset, tree);
381 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_io_timeout, offset);
382 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lock_timeout, offset);
384 cmd = tvb_get_ntohl(tvb, offset);
385 cmdstr = val_to_str(cmd, vxi11_core_cmd_vals, "Unknown(0x%x)");
386 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_cmd, offset);
388 offset = dissect_rpc_bool(tvb, tree, hf_vxi11_core_network_order, offset);
389 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_size, offset);
390 offset = dissect_rpc_opaque_data(tvb, offset, tree, NULL, hf_vxi11_core_data, false, 0, false, NULL, NULL);
392 proto_item_append_text(tree, " (Device_DocmdParms) LID=%d CMD=%s", lid, cmdstr);
393 col_append_fstr(pinfo->cinfo, COL_INFO, " LID=%d CMD=%s", lid, cmdstr);
395 return offset;
398 static int
399 dissect_device_docmd_resp(tvbuff_t *tvb,
400 packet_info *pinfo,
401 proto_tree *tree, void* data _U_)
403 uint32_t error;
404 int offset = 0;
406 offset = dissect_error(tvb, offset, pinfo, tree, "Device_DocmdResp", &error);
407 offset = dissect_rpc_opaque_data(tvb, offset, tree, NULL, hf_vxi11_core_data, false, 0, false, NULL, NULL);
409 return offset;
412 static int
413 dissect_device_enable_SRQ_parms(tvbuff_t *tvb,
414 packet_info *pinfo,
415 proto_tree *tree, void* data _U_)
417 int offset = 0;
418 uint32_t lid = tvb_get_ntohl(tvb, offset);
420 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lid, offset);
421 offset = dissect_rpc_bool(tvb, tree, hf_vxi11_core_enable, offset);
422 offset = dissect_rpc_opaque_data(tvb, offset, tree, NULL, hf_vxi11_core_handle, false, 0, false, NULL, NULL);
424 proto_item_append_text(tree, " (Device_EnableSrqParms) LID=%d", lid);
425 col_append_fstr(pinfo->cinfo, COL_INFO, " LID=%d", lid);
427 return offset;
430 static int
431 dissect_device_error(tvbuff_t *tvb,
432 packet_info *pinfo,
433 proto_tree *tree, void* data _U_)
435 uint32_t error;
437 return dissect_error(tvb, 0, pinfo, tree, "Device_Error", &error);
440 static int
441 dissect_device_generic_parms(tvbuff_t *tvb,
442 packet_info *pinfo,
443 proto_tree *tree, void* data _U_)
445 int offset = 0;
446 uint32_t lid = tvb_get_ntohl(tvb, offset);
448 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lid, offset);
449 offset = dissect_flags(tvb, offset, tree);
450 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_io_timeout, offset);
451 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lock_timeout, offset);
453 proto_item_append_text(tree, " (Device_GenericParms) LID=%d", lid);
454 col_append_fstr(pinfo->cinfo, COL_INFO, " LID=%d", lid);
456 return offset;
459 static int
460 dissect_device_link(tvbuff_t *tvb,
461 packet_info *pinfo,
462 proto_tree *tree, void* data _U_)
464 int offset = 0;
465 uint32_t lid = tvb_get_ntohl(tvb, offset);
467 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lid, offset);
469 proto_item_append_text(tree, " (Device_Link) LID=%d", lid);
470 col_append_fstr(pinfo->cinfo, COL_INFO, " LID=%d", lid);
472 return offset;
475 static int
476 dissect_device_lock_parms(tvbuff_t *tvb,
477 packet_info *pinfo,
478 proto_tree *tree, void* data _U_)
480 int offset = 0;
481 uint32_t lid = tvb_get_ntohl(tvb, offset);
483 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lid, offset);
484 offset = dissect_flags(tvb, offset, tree);
485 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lock_timeout, offset);
487 proto_item_append_text(tree, " (Device_LockParms) LID=%d", lid);
488 col_append_fstr(pinfo->cinfo, COL_INFO, " LID=%d", lid);
490 return offset;
493 static int
494 dissect_device_read_parms(tvbuff_t *tvb,
495 packet_info *pinfo,
496 proto_tree *tree, void* data _U_)
498 int offset = 0;
499 uint32_t lid = tvb_get_ntohl(tvb, offset);
501 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lid, offset);
502 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_size, offset);
503 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_io_timeout, offset);
504 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lock_timeout, offset);
505 offset = dissect_flags(tvb, offset, tree);
506 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_term_char, offset);
508 proto_item_append_text(tree, " (Device_ReadParms) LID=%d", lid);
509 col_append_fstr(pinfo->cinfo, COL_INFO, " LID=%d", lid);
511 return offset;
514 static int
515 dissect_device_read_resp(tvbuff_t *tvb,
516 packet_info *pinfo,
517 proto_tree *tree, void* data _U_)
519 uint32_t error;
520 int offset = 0;
521 uint32_t datalength = 0;
523 offset = dissect_error(tvb, offset, pinfo, tree, "Device_ReadResp", &error);
524 offset = dissect_reason(tvb, offset, tree);
526 datalength = tvb_get_ntohl( tvb, offset);
527 if(MAX_DATA_SHOW_SIZE <=datalength)
528 datalength = MAX_DATA_SHOW_SIZE;
529 col_append_fstr( pinfo->cinfo, COL_INFO," %s",tvb_format_text(pinfo->pool, tvb, offset+4,(uint32_t) datalength));
531 offset = dissect_rpc_opaque_data(tvb, offset, tree, NULL, hf_vxi11_core_data, false, 0, false, NULL, NULL);
533 return offset;
536 static int
537 dissect_device_readstb_resp(tvbuff_t *tvb,
538 packet_info *pinfo,
539 proto_tree *tree, void* data _U_)
541 uint32_t error, stb;
542 int offset = 0;
544 offset = dissect_error(tvb, offset, pinfo, tree, "Device_ReadStbResp", &error);
546 stb = tvb_get_ntohl(tvb, offset);
547 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_stb, offset);
549 if (error == VXI11_CORE_ERROR_NO_ERROR)
551 proto_item_append_text(tree, " STB=0x%02x", stb);
552 col_append_fstr(pinfo->cinfo, COL_INFO, " STB=0x%02x", stb);
555 return offset;
558 static int
559 dissect_device_remote_func(tvbuff_t *tvb,
560 packet_info *pinfo,
561 proto_tree *tree, void* data _U_)
563 uint32_t port;
564 const char *addrstr;
565 int offset = 0;
567 addrstr = tvb_ip_to_str(pinfo->pool, tvb, offset);
568 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_host_addr, offset);
570 port = tvb_get_ntohl(tvb, offset);
571 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_host_port, offset);
573 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_prog_num, offset);
574 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_prog_vers, offset);
575 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_prog_family, offset);
577 proto_item_append_text(tree, " (Device_RemoteFunc) %s:%d", addrstr, port);
578 col_append_fstr(pinfo->cinfo, COL_INFO, " %s:%d", addrstr, port);
580 return offset;
583 static int
584 dissect_device_write_parms(tvbuff_t *tvb,
585 packet_info *pinfo,
586 proto_tree *tree, void* data _U_)
588 uint32_t datalength = 0;
589 int offset = 0;
590 uint32_t lid = tvb_get_ntohl(tvb, offset);
592 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lid, offset);
593 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_io_timeout, offset);
594 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lock_timeout, offset);
595 offset = dissect_flags(tvb, offset, tree);
596 col_append_fstr(pinfo->cinfo, COL_INFO, " LID=%d", lid);
598 datalength = tvb_get_ntohl( tvb, offset);
599 if(MAX_DATA_SHOW_SIZE <=datalength)
600 datalength = MAX_DATA_SHOW_SIZE;
601 col_append_fstr( pinfo->cinfo, COL_INFO," %s",tvb_format_text(pinfo->pool, tvb, offset+4,(uint32_t) datalength));
603 offset = dissect_rpc_opaque_data(tvb, offset, tree, NULL, hf_vxi11_core_data, false, 0, false, NULL, NULL);
604 proto_item_append_text(tree, " (Device_WriteParms) LID=%d", lid);
606 return offset;
609 static int
610 dissect_device_write_resp(tvbuff_t *tvb,
611 packet_info *pinfo,
612 proto_tree *tree, void* data _U_)
614 uint32_t error;
615 int offset = 0;
617 offset = dissect_error(tvb, offset, pinfo, tree, "Device_WriteResp", &error);
618 offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_size, offset);
620 return offset;
624 /* Initialization & registration. */
626 void
627 proto_register_vxi11_core(void)
629 static const value_string vxi11_core_v1_proc_vals[] = {
630 { VXI11_CORE_PROC_NULL, "NULL" },
631 { VXI11_CORE_PROC_CREATE_LINK, "CREATE_LINK" },
632 { VXI11_CORE_PROC_DEVICE_WRITE, "DEVICE_WRITE" },
633 { VXI11_CORE_PROC_DEVICE_READ, "DEVICE_READ" },
634 { VXI11_CORE_PROC_DEVICE_READSTB, "DEVICE_READSTB" },
635 { VXI11_CORE_PROC_DEVICE_TRIGGER, "DEVICE_TRIGGER" },
636 { VXI11_CORE_PROC_DEVICE_CLEAR, "DEVICE_CLEAR" },
637 { VXI11_CORE_PROC_DEVICE_REMOTE, "DEVICE_REMOTE" },
638 { VXI11_CORE_PROC_DEVICE_LOCAL, "DEVICE_LOCAL" },
639 { VXI11_CORE_PROC_DEVICE_LOCK, "DEVICE_LOCK" },
640 { VXI11_CORE_PROC_DEVICE_UNLOCK, "DEVICE_UNLOCK" },
641 { VXI11_CORE_PROC_DEVICE_ENABLE_SRQ, "DEVICE_ENABLE_SRQ" },
642 { VXI11_CORE_PROC_DEVICE_DOCMD, "DEVICE_DOCMD" },
643 { VXI11_CORE_PROC_DESTROY_LINK, "DESTROY_LINK" },
644 { VXI11_CORE_PROC_CREATE_INTR_CHAN, "CREATE_INTR_CHAN" },
645 { VXI11_CORE_PROC_DESTROY_INTR_CHAN, "DESTROY_INTR_CHAN" },
646 { 0, NULL }
649 static const value_string vxi11_core_addr_family_vals[] = {
650 { VXI11_CORE_ADDRESS_FAMILY_TCP, "TCP" },
651 { VXI11_CORE_ADDRESS_FAMILY_UDP, "UDP" },
652 { 0, NULL }
655 static hf_register_info vxi11_core_hf[] = {
656 { &hf_vxi11_core_procedure_v1,
658 "V1 Procedure", "vxi11_core.procedure_v1", FT_UINT32, BASE_DEC,
659 VALS(vxi11_core_v1_proc_vals), 0, NULL, HFILL
662 { &hf_vxi11_core_abort_port,
664 "Abort Port", "vxi11_core.abort_port", FT_UINT16, BASE_DEC,
665 NULL, 0, NULL, HFILL
668 { &hf_vxi11_core_client_id,
670 "Client ID", "vxi11_core.client_id", FT_UINT32, BASE_DEC,
671 NULL, 0, NULL, HFILL
674 { &hf_vxi11_core_cmd,
676 "Command", "vxi11_core.cmd", FT_UINT32, BASE_HEX,
677 VALS(vxi11_core_cmd_vals), 0, NULL, HFILL
680 { &hf_vxi11_core_data,
682 "Data", "vxi11_core.data", FT_BYTES, BASE_NONE,
683 NULL, 0, NULL, HFILL
686 { &hf_vxi11_core_device,
688 "Device Name", "vxi11_core.device", FT_STRING, BASE_NONE,
689 NULL, 0, NULL, HFILL
692 { &hf_vxi11_core_enable,
694 "Enable", "vxi11_core.enable", FT_BOOLEAN, BASE_NONE,
695 TFS(&tfs_yes_no), 0, NULL, HFILL
698 { &hf_vxi11_core_error,
700 "Error Code", "vxi11_core.error", FT_UINT32, BASE_DEC,
701 VALS(vxi11_core_error_vals), 0, NULL, HFILL
704 { &hf_vxi11_core_flags,
706 "Flags", "vxi11_core.flags", FT_UINT32, BASE_HEX,
707 NULL, 0, NULL, HFILL
710 { &hf_vxi11_core_flag_wait_lock,
712 "Wait Until Locked", "vxi11_core.flags.wait_lock", FT_BOOLEAN, 32,
713 NULL, VXI11_CORE_FLAG_WAITLOCK, NULL, HFILL
716 { &hf_vxi11_core_flag_end,
718 "Set EOI", "vxi11_core.flags.end", FT_BOOLEAN, 32,
719 NULL, VXI11_CORE_FLAG_END, NULL, HFILL
722 { &hf_vxi11_core_flag_term_chr_set,
724 "Termination Character Set", "vxi11_core.flags.term_chr_set", FT_BOOLEAN, 32,
725 NULL, VXI11_CORE_FLAG_TERMCHRSET, NULL, HFILL
728 { &hf_vxi11_core_handle,
730 "Handle", "vxi11_core.handle", FT_BYTES, BASE_NONE,
731 NULL, 0, NULL, HFILL
734 { &hf_vxi11_core_host_addr,
736 "Host Address", "vxi11_core.host_addr", FT_UINT32, BASE_HEX,
737 NULL, 0, NULL, HFILL
740 { &hf_vxi11_core_host_port,
742 "Host Port", "vxi11_core.host_port", FT_UINT32, BASE_DEC,
743 NULL, 0, NULL, HFILL
746 { &hf_vxi11_core_io_timeout,
748 "I/O Timeout", "vxi11_core.io_timeout", FT_UINT32, BASE_DEC,
749 NULL, 0, NULL, HFILL
752 { &hf_vxi11_core_lid,
754 "Link ID", "vxi11_core.lid", FT_UINT32, BASE_DEC,
755 NULL, 0, NULL, HFILL
758 { &hf_vxi11_core_lock_device,
760 "Lock Device", "vxi11_core.lock_device", FT_BOOLEAN, BASE_NONE,
761 TFS(&tfs_yes_no), 0, NULL, HFILL
764 { &hf_vxi11_core_lock_timeout,
766 "Lock Timeout", "vxi11_core.lock_timeout", FT_UINT32, BASE_DEC,
767 NULL, 0, NULL, HFILL
770 { &hf_vxi11_core_max_recv_size,
772 "Maximum Receive Size", "vxi11_core.max_recv_size", FT_UINT32, BASE_DEC,
773 NULL, 0, NULL, HFILL
776 { &hf_vxi11_core_network_order,
778 "Network Byte Order", "vxi11_core.network_order", FT_BOOLEAN, BASE_NONE,
779 TFS(&tfs_yes_no), 0, NULL, HFILL
782 { &hf_vxi11_core_prog_family,
784 "Address Family", "vxi11_core.prog_family", FT_UINT32, BASE_DEC,
785 VALS(vxi11_core_addr_family_vals), 0, NULL, HFILL
788 { &hf_vxi11_core_prog_num,
790 "Program", "vxi11_core.prog_num", FT_UINT32, BASE_HEX,
791 NULL, 0, NULL, HFILL
794 { &hf_vxi11_core_prog_vers,
796 "Version", "vxi11_core.prog_vers", FT_UINT32, BASE_DEC,
797 NULL, 0, NULL, HFILL
800 { &hf_vxi11_core_reason,
802 "Reason", "vxi11_core.reason", FT_UINT32, BASE_HEX,
803 NULL, 0, NULL, HFILL
806 { &hf_vxi11_core_reason_req_cnt,
808 "Requested Count Reached", "vxi11_core.reason.req_cnt", FT_BOOLEAN, 32,
809 NULL, VXI11_CORE_REASON_REQCNT, NULL, HFILL
812 { &hf_vxi11_core_reason_chr,
814 "Termination Character Seen", "vxi11_core.reason.chr", FT_BOOLEAN, 32,
815 NULL, VXI11_CORE_REASON_CHR, NULL, HFILL
818 { &hf_vxi11_core_reason_end,
820 "EOI Set", "vxi11_core.reason.end", FT_BOOLEAN, 32,
821 NULL, VXI11_CORE_REASON_END, NULL, HFILL
824 { &hf_vxi11_core_size,
826 "Size", "vxi11_core.size", FT_UINT32, BASE_DEC,
827 NULL, 0, NULL, HFILL
830 { &hf_vxi11_core_stb,
832 "Status Byte", "vxi11_core.stb", FT_UINT8, BASE_HEX,
833 NULL, 0, NULL, HFILL
836 { &hf_vxi11_core_term_char,
838 "Termination Character", "vxi11_core.term_char", FT_UINT8, BASE_HEX,
839 NULL, 0, NULL, HFILL
843 static int *vxi11_core_ett[] = {
844 &ett_vxi11_core,
845 &ett_vxi11_core_flags,
846 &ett_vxi11_core_reason
849 proto_vxi11_core = proto_register_protocol("VXI-11 Core Protocol",
850 "VXI-11 Core",
851 "vxi11_core");
852 proto_register_field_array(proto_vxi11_core, vxi11_core_hf, array_length(vxi11_core_hf));
853 proto_register_subtree_array(vxi11_core_ett, array_length(vxi11_core_ett));
856 void
857 proto_reg_handoff_vxi11_core(void)
859 /* proc number, "proc name", dissect_request, dissect_reply */
860 static const vsff vxi111_core_proc[] = {
861 { VXI11_CORE_PROC_NULL, "NULL",
862 dissect_rpc_void, dissect_rpc_void },
863 { VXI11_CORE_PROC_CREATE_LINK, "CREATE_LINK",
864 dissect_create_link_parms, dissect_create_link_resp },
865 { VXI11_CORE_PROC_DEVICE_WRITE, "DEVICE_WRITE",
866 dissect_device_write_parms, dissect_device_write_resp },
867 { VXI11_CORE_PROC_DEVICE_READ, "DEVICE_READ",
868 dissect_device_read_parms, dissect_device_read_resp },
869 { VXI11_CORE_PROC_DEVICE_READSTB, "DEVICE_READSTB",
870 dissect_device_generic_parms, dissect_device_readstb_resp },
871 { VXI11_CORE_PROC_DEVICE_TRIGGER, "DEVICE_TRIGGER",
872 dissect_device_generic_parms, dissect_device_error },
873 { VXI11_CORE_PROC_DEVICE_CLEAR, "DEVICE_CLEAR",
874 dissect_device_generic_parms, dissect_device_error },
875 { VXI11_CORE_PROC_DEVICE_REMOTE, "DEVICE_REMOTE",
876 dissect_device_generic_parms, dissect_device_error },
877 { VXI11_CORE_PROC_DEVICE_LOCAL, "DEVICE_LOCAL",
878 dissect_device_generic_parms, dissect_device_error },
879 { VXI11_CORE_PROC_DEVICE_LOCK, "DEVICE_LOCK",
880 dissect_device_lock_parms, dissect_device_error },
881 { VXI11_CORE_PROC_DEVICE_UNLOCK, "DEVICE_UNLOCK",
882 dissect_device_link, dissect_device_error },
883 { VXI11_CORE_PROC_DEVICE_ENABLE_SRQ, "DEVICE_ENABLE_SRQ",
884 dissect_device_enable_SRQ_parms, dissect_device_error },
885 { VXI11_CORE_PROC_DEVICE_DOCMD, "DEVICE_DOCMD",
886 dissect_device_docmd_parms, dissect_device_docmd_resp },
887 { VXI11_CORE_PROC_DESTROY_LINK, "DESTROY_LINK",
888 dissect_device_link, dissect_device_error },
889 { VXI11_CORE_PROC_CREATE_INTR_CHAN, "CREATE_INTR_CHAN",
890 dissect_device_remote_func, dissect_device_error },
891 { VXI11_CORE_PROC_DESTROY_INTR_CHAN, "DESTROY_INTR_CHAN",
892 dissect_rpc_void, dissect_device_error },
893 { 0, NULL, NULL, NULL }
895 static const rpc_prog_vers_info vxi11_core_vers_info[] = {
896 { VXI11_CORE_VERSION, vxi111_core_proc, &hf_vxi11_core_procedure_v1 },
899 rpc_init_prog(proto_vxi11_core, VXI11_CORE_PROGRAM, ett_vxi11_core,
900 G_N_ELEMENTS(vxi11_core_vers_info), vxi11_core_vers_info);
904 void
905 proto_register_vxi11_async(void)
907 static const value_string vxi11_async_v1_proc_vals[] = {
908 { VXI11_ASYNC_PROC_NULL, "NULL" },
909 { VXI11_ASYNC_PROC_DEVICE_ABORT, "DEVICE_ABORT" },
910 { 0, NULL }
913 static hf_register_info vxi11_async_hf[] = {
914 { &hf_vxi11_async_procedure_v1,
916 "V1 Procedure", "vxi11_async.procedure_v1", FT_UINT32, BASE_DEC,
917 VALS(vxi11_async_v1_proc_vals), 0, NULL, HFILL
921 static int *vxi11_async_ett[] = {
922 &ett_vxi11_async,
925 proto_vxi11_async = proto_register_protocol("VXI-11 Asynchronous Abort",
926 "VXI-11 Async",
927 "vxi11_async");
928 proto_register_field_array(proto_vxi11_async, vxi11_async_hf, array_length(vxi11_async_hf));
929 proto_register_subtree_array(vxi11_async_ett, array_length(vxi11_async_ett));
932 void
933 proto_reg_handoff_vxi11_async(void)
935 static const vsff vxi111_async_proc[] = {
936 { VXI11_ASYNC_PROC_NULL, "NULL",
937 dissect_rpc_void, dissect_rpc_void },
938 { VXI11_ASYNC_PROC_DEVICE_ABORT, "DEVICE_ABORT",
939 dissect_device_link, dissect_device_error },
940 { 0, NULL, NULL, NULL }
942 static const rpc_prog_vers_info vxi11_async_vers_info[] = {
943 { VXI11_ASYNC_VERSION, vxi111_async_proc, &hf_vxi11_async_procedure_v1 },
946 rpc_init_prog(proto_vxi11_async, VXI11_ASYNC_PROGRAM, ett_vxi11_async,
947 G_N_ELEMENTS(vxi11_async_vers_info), vxi11_async_vers_info);
951 void
952 proto_register_vxi11_intr(void)
954 static const value_string vxi11_intr_v1_proc_vals[] = {
955 { VXI11_INTR_PROC_NULL, "NULL" },
956 { VXI11_INTR_PROC_DEVICE_INTR_SRQ, "DEVICE_INTR_SRQ" },
957 { 0, NULL }
960 static hf_register_info vxi11_intr_hf[] = {
961 { &hf_vxi11_intr_procedure_v1,
963 "V1 Procedure", "vxi11_intr.procedure_v1", FT_UINT32, BASE_DEC,
964 VALS(vxi11_intr_v1_proc_vals), 0, NULL, HFILL
967 { &hf_vxi11_intr_handle,
969 "Handle", "vxi11_intr.handle", FT_BYTES, BASE_NONE,
970 NULL, 0, NULL, HFILL
974 static int *vxi11_intr_ett[] = {
975 &ett_vxi11_intr,
978 proto_vxi11_intr = proto_register_protocol("VXI-11 Interrupt",
979 "VXI-11 Intr",
980 "vxi11_intr");
981 proto_register_field_array(proto_vxi11_intr, vxi11_intr_hf, array_length(vxi11_intr_hf));
982 proto_register_subtree_array(vxi11_intr_ett, array_length(vxi11_intr_ett));
985 void
986 proto_reg_handoff_vxi11_intr(void)
988 static const vsff vxi111_intr_proc[] = {
989 { VXI11_INTR_PROC_NULL, "NULL",
990 dissect_rpc_void, dissect_rpc_void },
991 { VXI11_INTR_PROC_DEVICE_INTR_SRQ, "DEVICE_INTR_SRQ",
992 dissect_device_SRQ_parms, dissect_rpc_void },
993 { 0, NULL, NULL, NULL }
995 static const rpc_prog_vers_info vxi11_intr_vers_info[] = {
996 { VXI11_INTR_VERSION, vxi111_intr_proc, &hf_vxi11_intr_procedure_v1 },
999 rpc_init_prog(proto_vxi11_intr, VXI11_INTR_PROGRAM, ett_vxi11_intr,
1000 G_N_ELEMENTS(vxi11_intr_vers_info), vxi11_intr_vers_info);
1004 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1006 * Local variables:
1007 * c-basic-offset: 4
1008 * tab-width: 8
1009 * indent-tabs-mode: nil
1010 * End:
1012 * vi: set shiftwidth=4 tabstop=8 expandtab:
1013 * :indentSize=4:tabSize=8:noTabs=true: