1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
|
/* packet-vxi11.c
* Routines for VXI-11 (TCP/IP Instrument Protocol) dissection.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* VXI-11 protocol dissector
* By Jens Kilian <jens.kilian@verigy.com>
* Copyright 2009 Verigy Deutschland GmbH
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include "packet-rpc.h"
#include <epan/to_str.h>
/*
* For the protocol specifications, see
* http://www.vxibus.org/files/VXI_Specs/VXI-11.zip
*
* This dissector handles the basic Network Instrument protocol as defined
* in VXI-11, and parts of the TCP/IP-IEEE 488.1 Interface spec (VXI-11.2).
*/
/* Core protocol. */
#define VXI11_CORE_ADDRESS_FAMILY_TCP 0
#define VXI11_CORE_ADDRESS_FAMILY_UDP 1
#define VXI11_CORE_CMD_SEND_COMMAND 0x020000
#define VXI11_CORE_CMD_BUS_STATUS 0x020001
#define VXI11_CORE_CMD_ATN_CONTROL 0x020002
#define VXI11_CORE_CMD_REN_CONTROL 0x020003
#define VXI11_CORE_CMD_PASS_CONTROL 0x020004
#define VXI11_CORE_CMD_BUS_ADDRESS 0x02000a
#define VXI11_CORE_CMD_IFC_CONTROL 0x020010
#define VXI11_CORE_ERROR_NO_ERROR 0
#define VXI11_CORE_ERROR_SYNTAX_ERROR 1
#define VXI11_CORE_ERROR_DEVICE_NOT_ACCESSIBLE 3
#define VXI11_CORE_ERROR_INVALID_ID 4
#define VXI11_CORE_ERROR_PARAMETER_ERROR 5
#define VXI11_CORE_ERROR_CHANNEL_NOT_ESTABLISHED 6
#define VXI11_CORE_ERROR_OPERATION_NOT_SUPPORTED 8
#define VXI11_CORE_ERROR_OUT_OF_RESOURCES 9
#define VXI11_CORE_ERROR_DEVICE_LOCKED 11
#define VXI11_CORE_ERROR_NO_LOCK_HELD 12
#define VXI11_CORE_ERROR_IO_TIMEOUT 15
#define VXI11_CORE_ERROR_IO_ERROR 17
#define VXI11_CORE_ERROR_INVALID_ADDRESS 21
#define VXI11_CORE_ERROR_ABORT 23
#define VXI11_CORE_ERROR_CHANNEL_ALREADY_ESTABLISHED 29
#define VXI11_CORE_FLAG_WAITLOCK (1 << 0)
#define VXI11_CORE_FLAG_END (1 << 3)
#define VXI11_CORE_FLAG_TERMCHRSET (1 << 7)
#define VXI11_CORE_REASON_REQCNT (1 << 0)
#define VXI11_CORE_REASON_CHR (1 << 1)
#define VXI11_CORE_REASON_END (1 << 2)
#define VXI11_CORE_PROC_NULL 0
#define VXI11_CORE_PROC_CREATE_LINK 10
#define VXI11_CORE_PROC_DEVICE_WRITE 11
#define VXI11_CORE_PROC_DEVICE_READ 12
#define VXI11_CORE_PROC_DEVICE_READSTB 13
#define VXI11_CORE_PROC_DEVICE_TRIGGER 14
#define VXI11_CORE_PROC_DEVICE_CLEAR 15
#define VXI11_CORE_PROC_DEVICE_REMOTE 16
#define VXI11_CORE_PROC_DEVICE_LOCAL 17
#define VXI11_CORE_PROC_DEVICE_LOCK 18
#define VXI11_CORE_PROC_DEVICE_UNLOCK 19
#define VXI11_CORE_PROC_DEVICE_ENABLE_SRQ 20
#define VXI11_CORE_PROC_DEVICE_DOCMD 22
#define VXI11_CORE_PROC_DESTROY_LINK 23
#define VXI11_CORE_PROC_CREATE_INTR_CHAN 25
#define VXI11_CORE_PROC_DESTROY_INTR_CHAN 26
#define VXI11_CORE_PROGRAM 0x0607AF
#define VXI11_CORE_VERSION 1
#define MAX_DATA_SHOW_SIZE 70
void proto_register_vxi11_core(void);
void proto_reg_handoff_vxi11_core(void);
void proto_register_vxi11_async(void);
void proto_reg_handoff_vxi11_async(void);
void proto_register_vxi11_intr(void);
void proto_reg_handoff_vxi11_intr(void);
static int proto_vxi11_core;
static int ett_vxi11_core;
static int ett_vxi11_core_flags;
static int ett_vxi11_core_reason;
static int hf_vxi11_core_procedure_v1;
static int hf_vxi11_core_abort_port;
static int hf_vxi11_core_client_id;
static int hf_vxi11_core_cmd;
static int hf_vxi11_core_data;
static int hf_vxi11_core_device;
static int hf_vxi11_core_enable;
static int hf_vxi11_core_error;
static int hf_vxi11_core_flags;
static int hf_vxi11_core_flag_wait_lock;
static int hf_vxi11_core_flag_end;
static int hf_vxi11_core_flag_term_chr_set;
static int hf_vxi11_core_handle;
static int hf_vxi11_core_host_addr;
static int hf_vxi11_core_host_port;
static int hf_vxi11_core_io_timeout;
static int hf_vxi11_core_lid;
static int hf_vxi11_core_lock_device;
static int hf_vxi11_core_lock_timeout;
static int hf_vxi11_core_max_recv_size;
static int hf_vxi11_core_network_order;
static int hf_vxi11_core_prog_family;
static int hf_vxi11_core_prog_num;
static int hf_vxi11_core_prog_vers;
static int hf_vxi11_core_reason;
static int hf_vxi11_core_reason_req_cnt;
static int hf_vxi11_core_reason_chr;
static int hf_vxi11_core_reason_end;
static int hf_vxi11_core_size;
static int hf_vxi11_core_stb;
static int hf_vxi11_core_term_char;
static const value_string vxi11_core_error_vals[] = {
{ VXI11_CORE_ERROR_NO_ERROR, "No Error" },
{ VXI11_CORE_ERROR_SYNTAX_ERROR, "Syntax Error" },
{ VXI11_CORE_ERROR_DEVICE_NOT_ACCESSIBLE, "Device Not Accessible" },
{ VXI11_CORE_ERROR_INVALID_ID, "Invalid ID" },
{ VXI11_CORE_ERROR_PARAMETER_ERROR, "Parameter Error" },
{ VXI11_CORE_ERROR_CHANNEL_NOT_ESTABLISHED, "Channel Not Established" },
{ VXI11_CORE_ERROR_OPERATION_NOT_SUPPORTED, "Operation Not Supported" },
{ VXI11_CORE_ERROR_OUT_OF_RESOURCES, "Out Of Resources" },
{ VXI11_CORE_ERROR_DEVICE_LOCKED, "Device Locked" },
{ VXI11_CORE_ERROR_NO_LOCK_HELD, "No Lock Held" },
{ VXI11_CORE_ERROR_IO_TIMEOUT, "I/O Timeout" },
{ VXI11_CORE_ERROR_IO_ERROR, "I/O Error" },
{ VXI11_CORE_ERROR_INVALID_ADDRESS, "Invalid Address" },
{ VXI11_CORE_ERROR_ABORT, "Abort" },
{ VXI11_CORE_ERROR_CHANNEL_ALREADY_ESTABLISHED, "Channel Already Established" },
{ 0, NULL }
};
static const value_string vxi11_core_cmd_vals[] = {
{ VXI11_CORE_CMD_SEND_COMMAND, "SEND_COMMAND" },
{ VXI11_CORE_CMD_BUS_STATUS, "BUS_STATUS" },
{ VXI11_CORE_CMD_ATN_CONTROL, "ATN_CONTROL" },
{ VXI11_CORE_CMD_REN_CONTROL, "REN_CONTROL" },
{ VXI11_CORE_CMD_PASS_CONTROL, "PASS_CONTROL" },
{ VXI11_CORE_CMD_BUS_ADDRESS, "BUS_ADDRESS" },
{ VXI11_CORE_CMD_IFC_CONTROL, "IFC_CONTROL" },
{ 0, NULL }
};
/* Asynchronous-abort protocol. */
#define VXI11_ASYNC_PROC_NULL 0
#define VXI11_ASYNC_PROC_DEVICE_ABORT 1
#define VXI11_ASYNC_PROGRAM 0x0607B0
#define VXI11_ASYNC_VERSION 1
static int proto_vxi11_async;
static int ett_vxi11_async;
static int hf_vxi11_async_procedure_v1;
/* Interrupt protocol. */
#define VXI11_INTR_PROC_NULL 0
#define VXI11_INTR_PROC_DEVICE_INTR_SRQ 30
#define VXI11_INTR_PROGRAM 0x0607B1
#define VXI11_INTR_VERSION 1
static int proto_vxi11_intr;
static int ett_vxi11_intr;
static int hf_vxi11_intr_procedure_v1;
static int hf_vxi11_intr_handle;
/* Helper routines for dissecting common fields. */
static int
dissect_error(tvbuff_t *tvb,
int offset,
packet_info *pinfo,
proto_tree *tree,
const char *packet_type,
uint32_t *error)
{
const char *errstr;
*error = tvb_get_ntohl(tvb, offset);
errstr = val_to_str(*error, vxi11_core_error_vals, "Error %d");
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_error, offset);
proto_item_append_text(tree, " (%s) %s", packet_type, errstr);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", errstr);
return offset;
}
static int
dissect_flags(tvbuff_t *tvb, int offset, proto_tree *tree)
{
if (tree)
{
uint32_t flags =
tvb_get_ntohl(tvb, offset);
proto_item *flags_item =
proto_tree_add_item(tree, hf_vxi11_core_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
if (flags_item)
{
proto_tree *flags_tree =
proto_item_add_subtree(flags_item, ett_vxi11_core_flags);
proto_tree_add_item(flags_tree, hf_vxi11_core_flag_wait_lock, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(flags_tree, hf_vxi11_core_flag_end, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(flags_tree, hf_vxi11_core_flag_term_chr_set, tvb, offset, 4, ENC_BIG_ENDIAN);
if (flags != 0)
{
wmem_strbuf_t *strbuf = wmem_strbuf_create(wmem_packet_scope());
if (flags & VXI11_CORE_FLAG_WAITLOCK)
{
wmem_strbuf_append(strbuf, "WAIT_LOCK, ");
}
if (flags & VXI11_CORE_FLAG_END)
{
wmem_strbuf_append(strbuf, "END, ");
}
if (flags & VXI11_CORE_FLAG_TERMCHRSET)
{
wmem_strbuf_append(strbuf, "TERM_CHR_SET, ");
}
wmem_strbuf_truncate(strbuf, wmem_strbuf_get_len(strbuf) - 2);
proto_item_append_text(flags_item, " (%s)", wmem_strbuf_get_str(strbuf));
}
}
}
return offset + 4;
}
static int
dissect_reason(tvbuff_t *tvb, int offset, proto_tree *tree)
{
if (tree)
{
uint32_t reason =
tvb_get_ntohl(tvb, offset);
proto_item *reason_item =
proto_tree_add_item(tree, hf_vxi11_core_reason, tvb, offset, 4, ENC_BIG_ENDIAN);
if (reason_item)
{
proto_tree *reason_tree =
proto_item_add_subtree(reason_item, ett_vxi11_core_reason);
proto_tree_add_item(reason_tree, hf_vxi11_core_reason_req_cnt, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(reason_tree, hf_vxi11_core_reason_chr, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(reason_tree, hf_vxi11_core_reason_end, tvb, offset, 4, ENC_BIG_ENDIAN);
if (reason != 0)
{
wmem_strbuf_t *strbuf = wmem_strbuf_create(wmem_packet_scope());
if (reason & VXI11_CORE_REASON_REQCNT)
{
wmem_strbuf_append(strbuf, "REQ_CNT, ");
}
if (reason & VXI11_CORE_REASON_CHR)
{
wmem_strbuf_append(strbuf, "CHR, ");
}
if (reason & VXI11_CORE_REASON_END)
{
wmem_strbuf_append(strbuf, "END, ");
}
wmem_strbuf_truncate(strbuf, wmem_strbuf_get_len(strbuf) - 2);
proto_item_append_text(reason_item, " (%s)", wmem_strbuf_get_str(strbuf));
}
}
}
return offset + 4;
}
/* Dissectors for individual RPC requests and responses. */
static int
dissect_create_link_parms(tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree, void* data _U_)
{
const char *str;
int offset = 0;
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_client_id, offset);
offset = dissect_rpc_bool(tvb, tree, hf_vxi11_core_lock_device, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lock_timeout, offset);
offset = dissect_rpc_string(tvb, tree, hf_vxi11_core_device, offset, &str);
proto_item_append_text(tree, " (Create_LinkParms) %s", str);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", str);
return offset;
}
static int
dissect_create_link_resp(tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree, void* data _U_)
{
uint32_t error, lid;
int offset = 0;
offset = dissect_error(tvb, offset, pinfo, tree, "Create_LinkResp", &error);
lid = tvb_get_ntohl(tvb, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lid, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_abort_port, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_max_recv_size, offset);
if (error == VXI11_CORE_ERROR_NO_ERROR)
{
proto_item_append_text(tree, " LID=%d", lid);
col_append_fstr(pinfo->cinfo, COL_INFO, " LID=%d", lid);
}
return offset;
}
static int
dissect_device_SRQ_parms(tvbuff_t *tvb,
packet_info *pinfo _U_,
proto_tree *tree, void* data _U_)
{
int offset = dissect_rpc_opaque_data(tvb, 0, tree, NULL, hf_vxi11_intr_handle, false, 0, false, NULL, NULL);
proto_item_append_text(tree, " (Device_SrqParms)");
return offset;
}
static int
dissect_device_docmd_parms(tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree, void* data _U_)
{
uint32_t lid, cmd;
const char *cmdstr;
int offset = 0;
lid = tvb_get_ntohl(tvb, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lid, offset);
offset = dissect_flags(tvb, offset, tree);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_io_timeout, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lock_timeout, offset);
cmd = tvb_get_ntohl(tvb, offset);
cmdstr = val_to_str(cmd, vxi11_core_cmd_vals, "Unknown(0x%x)");
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_cmd, offset);
offset = dissect_rpc_bool(tvb, tree, hf_vxi11_core_network_order, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_size, offset);
offset = dissect_rpc_opaque_data(tvb, offset, tree, NULL, hf_vxi11_core_data, false, 0, false, NULL, NULL);
proto_item_append_text(tree, " (Device_DocmdParms) LID=%d CMD=%s", lid, cmdstr);
col_append_fstr(pinfo->cinfo, COL_INFO, " LID=%d CMD=%s", lid, cmdstr);
return offset;
}
static int
dissect_device_docmd_resp(tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree, void* data _U_)
{
uint32_t error;
int offset = 0;
offset = dissect_error(tvb, offset, pinfo, tree, "Device_DocmdResp", &error);
offset = dissect_rpc_opaque_data(tvb, offset, tree, NULL, hf_vxi11_core_data, false, 0, false, NULL, NULL);
return offset;
}
static int
dissect_device_enable_SRQ_parms(tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree, void* data _U_)
{
int offset = 0;
uint32_t lid = tvb_get_ntohl(tvb, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lid, offset);
offset = dissect_rpc_bool(tvb, tree, hf_vxi11_core_enable, offset);
offset = dissect_rpc_opaque_data(tvb, offset, tree, NULL, hf_vxi11_core_handle, false, 0, false, NULL, NULL);
proto_item_append_text(tree, " (Device_EnableSrqParms) LID=%d", lid);
col_append_fstr(pinfo->cinfo, COL_INFO, " LID=%d", lid);
return offset;
}
static int
dissect_device_error(tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree, void* data _U_)
{
uint32_t error;
return dissect_error(tvb, 0, pinfo, tree, "Device_Error", &error);
}
static int
dissect_device_generic_parms(tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree, void* data _U_)
{
int offset = 0;
uint32_t lid = tvb_get_ntohl(tvb, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lid, offset);
offset = dissect_flags(tvb, offset, tree);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_io_timeout, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lock_timeout, offset);
proto_item_append_text(tree, " (Device_GenericParms) LID=%d", lid);
col_append_fstr(pinfo->cinfo, COL_INFO, " LID=%d", lid);
return offset;
}
static int
dissect_device_link(tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree, void* data _U_)
{
int offset = 0;
uint32_t lid = tvb_get_ntohl(tvb, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lid, offset);
proto_item_append_text(tree, " (Device_Link) LID=%d", lid);
col_append_fstr(pinfo->cinfo, COL_INFO, " LID=%d", lid);
return offset;
}
static int
dissect_device_lock_parms(tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree, void* data _U_)
{
int offset = 0;
uint32_t lid = tvb_get_ntohl(tvb, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lid, offset);
offset = dissect_flags(tvb, offset, tree);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lock_timeout, offset);
proto_item_append_text(tree, " (Device_LockParms) LID=%d", lid);
col_append_fstr(pinfo->cinfo, COL_INFO, " LID=%d", lid);
return offset;
}
static int
dissect_device_read_parms(tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree, void* data _U_)
{
int offset = 0;
uint32_t lid = tvb_get_ntohl(tvb, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lid, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_size, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_io_timeout, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lock_timeout, offset);
offset = dissect_flags(tvb, offset, tree);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_term_char, offset);
proto_item_append_text(tree, " (Device_ReadParms) LID=%d", lid);
col_append_fstr(pinfo->cinfo, COL_INFO, " LID=%d", lid);
return offset;
}
static int
dissect_device_read_resp(tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree, void* data _U_)
{
uint32_t error;
int offset = 0;
uint32_t datalength = 0;
offset = dissect_error(tvb, offset, pinfo, tree, "Device_ReadResp", &error);
offset = dissect_reason(tvb, offset, tree);
datalength = tvb_get_ntohl( tvb, offset);
if(MAX_DATA_SHOW_SIZE <=datalength)
datalength = MAX_DATA_SHOW_SIZE;
col_append_fstr( pinfo->cinfo, COL_INFO," %s",tvb_format_text(pinfo->pool, tvb, offset+4,(uint32_t) datalength));
offset = dissect_rpc_opaque_data(tvb, offset, tree, NULL, hf_vxi11_core_data, false, 0, false, NULL, NULL);
return offset;
}
static int
dissect_device_readstb_resp(tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree, void* data _U_)
{
uint32_t error, stb;
int offset = 0;
offset = dissect_error(tvb, offset, pinfo, tree, "Device_ReadStbResp", &error);
stb = tvb_get_ntohl(tvb, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_stb, offset);
if (error == VXI11_CORE_ERROR_NO_ERROR)
{
proto_item_append_text(tree, " STB=0x%02x", stb);
col_append_fstr(pinfo->cinfo, COL_INFO, " STB=0x%02x", stb);
}
return offset;
}
static int
dissect_device_remote_func(tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree, void* data _U_)
{
uint32_t port;
const char *addrstr;
int offset = 0;
addrstr = tvb_ip_to_str(pinfo->pool, tvb, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_host_addr, offset);
port = tvb_get_ntohl(tvb, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_host_port, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_prog_num, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_prog_vers, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_prog_family, offset);
proto_item_append_text(tree, " (Device_RemoteFunc) %s:%d", addrstr, port);
col_append_fstr(pinfo->cinfo, COL_INFO, " %s:%d", addrstr, port);
return offset;
}
static int
dissect_device_write_parms(tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree, void* data _U_)
{
uint32_t datalength = 0;
int offset = 0;
uint32_t lid = tvb_get_ntohl(tvb, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lid, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_io_timeout, offset);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_lock_timeout, offset);
offset = dissect_flags(tvb, offset, tree);
col_append_fstr(pinfo->cinfo, COL_INFO, " LID=%d", lid);
datalength = tvb_get_ntohl( tvb, offset);
if(MAX_DATA_SHOW_SIZE <=datalength)
datalength = MAX_DATA_SHOW_SIZE;
col_append_fstr( pinfo->cinfo, COL_INFO," %s",tvb_format_text(pinfo->pool, tvb, offset+4,(uint32_t) datalength));
offset = dissect_rpc_opaque_data(tvb, offset, tree, NULL, hf_vxi11_core_data, false, 0, false, NULL, NULL);
proto_item_append_text(tree, " (Device_WriteParms) LID=%d", lid);
return offset;
}
static int
dissect_device_write_resp(tvbuff_t *tvb,
packet_info *pinfo,
proto_tree *tree, void* data _U_)
{
uint32_t error;
int offset = 0;
offset = dissect_error(tvb, offset, pinfo, tree, "Device_WriteResp", &error);
offset = dissect_rpc_uint32(tvb, tree, hf_vxi11_core_size, offset);
return offset;
}
/* Initialization & registration. */
void
proto_register_vxi11_core(void)
{
static const value_string vxi11_core_v1_proc_vals[] = {
{ VXI11_CORE_PROC_NULL, "NULL" },
{ VXI11_CORE_PROC_CREATE_LINK, "CREATE_LINK" },
{ VXI11_CORE_PROC_DEVICE_WRITE, "DEVICE_WRITE" },
{ VXI11_CORE_PROC_DEVICE_READ, "DEVICE_READ" },
{ VXI11_CORE_PROC_DEVICE_READSTB, "DEVICE_READSTB" },
{ VXI11_CORE_PROC_DEVICE_TRIGGER, "DEVICE_TRIGGER" },
{ VXI11_CORE_PROC_DEVICE_CLEAR, "DEVICE_CLEAR" },
{ VXI11_CORE_PROC_DEVICE_REMOTE, "DEVICE_REMOTE" },
{ VXI11_CORE_PROC_DEVICE_LOCAL, "DEVICE_LOCAL" },
{ VXI11_CORE_PROC_DEVICE_LOCK, "DEVICE_LOCK" },
{ VXI11_CORE_PROC_DEVICE_UNLOCK, "DEVICE_UNLOCK" },
{ VXI11_CORE_PROC_DEVICE_ENABLE_SRQ, "DEVICE_ENABLE_SRQ" },
{ VXI11_CORE_PROC_DEVICE_DOCMD, "DEVICE_DOCMD" },
{ VXI11_CORE_PROC_DESTROY_LINK, "DESTROY_LINK" },
{ VXI11_CORE_PROC_CREATE_INTR_CHAN, "CREATE_INTR_CHAN" },
{ VXI11_CORE_PROC_DESTROY_INTR_CHAN, "DESTROY_INTR_CHAN" },
{ 0, NULL }
};
static const value_string vxi11_core_addr_family_vals[] = {
{ VXI11_CORE_ADDRESS_FAMILY_TCP, "TCP" },
{ VXI11_CORE_ADDRESS_FAMILY_UDP, "UDP" },
{ 0, NULL }
};
static hf_register_info vxi11_core_hf[] = {
{ &hf_vxi11_core_procedure_v1,
{
"V1 Procedure", "vxi11_core.procedure_v1", FT_UINT32, BASE_DEC,
VALS(vxi11_core_v1_proc_vals), 0, NULL, HFILL
}
},
{ &hf_vxi11_core_abort_port,
{
"Abort Port", "vxi11_core.abort_port", FT_UINT16, BASE_DEC,
NULL, 0, NULL, HFILL
}
},
{ &hf_vxi11_core_client_id,
{
"Client ID", "vxi11_core.client_id", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL
}
},
{ &hf_vxi11_core_cmd,
{
"Command", "vxi11_core.cmd", FT_UINT32, BASE_HEX,
VALS(vxi11_core_cmd_vals), 0, NULL, HFILL
}
},
{ &hf_vxi11_core_data,
{
"Data", "vxi11_core.data", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL
}
},
{ &hf_vxi11_core_device,
{
"Device Name", "vxi11_core.device", FT_STRING, BASE_NONE,
NULL, 0, NULL, HFILL
}
},
{ &hf_vxi11_core_enable,
{
"Enable", "vxi11_core.enable", FT_BOOLEAN, BASE_NONE,
TFS(&tfs_yes_no), 0, NULL, HFILL
}
},
{ &hf_vxi11_core_error,
{
"Error Code", "vxi11_core.error", FT_UINT32, BASE_DEC,
VALS(vxi11_core_error_vals), 0, NULL, HFILL
}
},
{ &hf_vxi11_core_flags,
{
"Flags", "vxi11_core.flags", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL
}
},
{ &hf_vxi11_core_flag_wait_lock,
{
"Wait Until Locked", "vxi11_core.flags.wait_lock", FT_BOOLEAN, 32,
NULL, VXI11_CORE_FLAG_WAITLOCK, NULL, HFILL
}
},
{ &hf_vxi11_core_flag_end,
{
"Set EOI", "vxi11_core.flags.end", FT_BOOLEAN, 32,
NULL, VXI11_CORE_FLAG_END, NULL, HFILL
}
},
{ &hf_vxi11_core_flag_term_chr_set,
{
"Termination Character Set", "vxi11_core.flags.term_chr_set", FT_BOOLEAN, 32,
NULL, VXI11_CORE_FLAG_TERMCHRSET, NULL, HFILL
}
},
{ &hf_vxi11_core_handle,
{
"Handle", "vxi11_core.handle", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL
}
},
{ &hf_vxi11_core_host_addr,
{
"Host Address", "vxi11_core.host_addr", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL
}
},
{ &hf_vxi11_core_host_port,
{
"Host Port", "vxi11_core.host_port", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL
}
},
{ &hf_vxi11_core_io_timeout,
{
"I/O Timeout", "vxi11_core.io_timeout", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL
}
},
{ &hf_vxi11_core_lid,
{
"Link ID", "vxi11_core.lid", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL
}
},
{ &hf_vxi11_core_lock_device,
{
"Lock Device", "vxi11_core.lock_device", FT_BOOLEAN, BASE_NONE,
TFS(&tfs_yes_no), 0, NULL, HFILL
}
},
{ &hf_vxi11_core_lock_timeout,
{
"Lock Timeout", "vxi11_core.lock_timeout", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL
}
},
{ &hf_vxi11_core_max_recv_size,
{
"Maximum Receive Size", "vxi11_core.max_recv_size", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL
}
},
{ &hf_vxi11_core_network_order,
{
"Network Byte Order", "vxi11_core.network_order", FT_BOOLEAN, BASE_NONE,
TFS(&tfs_yes_no), 0, NULL, HFILL
}
},
{ &hf_vxi11_core_prog_family,
{
"Address Family", "vxi11_core.prog_family", FT_UINT32, BASE_DEC,
VALS(vxi11_core_addr_family_vals), 0, NULL, HFILL
}
},
{ &hf_vxi11_core_prog_num,
{
"Program", "vxi11_core.prog_num", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL
}
},
{ &hf_vxi11_core_prog_vers,
{
"Version", "vxi11_core.prog_vers", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL
}
},
{ &hf_vxi11_core_reason,
{
"Reason", "vxi11_core.reason", FT_UINT32, BASE_HEX,
NULL, 0, NULL, HFILL
}
},
{ &hf_vxi11_core_reason_req_cnt,
{
"Requested Count Reached", "vxi11_core.reason.req_cnt", FT_BOOLEAN, 32,
NULL, VXI11_CORE_REASON_REQCNT, NULL, HFILL
}
},
{ &hf_vxi11_core_reason_chr,
{
"Termination Character Seen", "vxi11_core.reason.chr", FT_BOOLEAN, 32,
NULL, VXI11_CORE_REASON_CHR, NULL, HFILL
}
},
{ &hf_vxi11_core_reason_end,
{
"EOI Set", "vxi11_core.reason.end", FT_BOOLEAN, 32,
NULL, VXI11_CORE_REASON_END, NULL, HFILL
}
},
{ &hf_vxi11_core_size,
{
"Size", "vxi11_core.size", FT_UINT32, BASE_DEC,
NULL, 0, NULL, HFILL
}
},
{ &hf_vxi11_core_stb,
{
"Status Byte", "vxi11_core.stb", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL
}
},
{ &hf_vxi11_core_term_char,
{
"Termination Character", "vxi11_core.term_char", FT_UINT8, BASE_HEX,
NULL, 0, NULL, HFILL
}
}
};
static int *vxi11_core_ett[] = {
&ett_vxi11_core,
&ett_vxi11_core_flags,
&ett_vxi11_core_reason
};
proto_vxi11_core = proto_register_protocol("VXI-11 Core Protocol",
"VXI-11 Core",
"vxi11_core");
proto_register_field_array(proto_vxi11_core, vxi11_core_hf, array_length(vxi11_core_hf));
proto_register_subtree_array(vxi11_core_ett, array_length(vxi11_core_ett));
}
void
proto_reg_handoff_vxi11_core(void)
{
/* proc number, "proc name", dissect_request, dissect_reply */
static const vsff vxi111_core_proc[] = {
{ VXI11_CORE_PROC_NULL, "NULL",
dissect_rpc_void, dissect_rpc_void },
{ VXI11_CORE_PROC_CREATE_LINK, "CREATE_LINK",
dissect_create_link_parms, dissect_create_link_resp },
{ VXI11_CORE_PROC_DEVICE_WRITE, "DEVICE_WRITE",
dissect_device_write_parms, dissect_device_write_resp },
{ VXI11_CORE_PROC_DEVICE_READ, "DEVICE_READ",
dissect_device_read_parms, dissect_device_read_resp },
{ VXI11_CORE_PROC_DEVICE_READSTB, "DEVICE_READSTB",
dissect_device_generic_parms, dissect_device_readstb_resp },
{ VXI11_CORE_PROC_DEVICE_TRIGGER, "DEVICE_TRIGGER",
dissect_device_generic_parms, dissect_device_error },
{ VXI11_CORE_PROC_DEVICE_CLEAR, "DEVICE_CLEAR",
dissect_device_generic_parms, dissect_device_error },
{ VXI11_CORE_PROC_DEVICE_REMOTE, "DEVICE_REMOTE",
dissect_device_generic_parms, dissect_device_error },
{ VXI11_CORE_PROC_DEVICE_LOCAL, "DEVICE_LOCAL",
dissect_device_generic_parms, dissect_device_error },
{ VXI11_CORE_PROC_DEVICE_LOCK, "DEVICE_LOCK",
dissect_device_lock_parms, dissect_device_error },
{ VXI11_CORE_PROC_DEVICE_UNLOCK, "DEVICE_UNLOCK",
dissect_device_link, dissect_device_error },
{ VXI11_CORE_PROC_DEVICE_ENABLE_SRQ, "DEVICE_ENABLE_SRQ",
dissect_device_enable_SRQ_parms, dissect_device_error },
{ VXI11_CORE_PROC_DEVICE_DOCMD, "DEVICE_DOCMD",
dissect_device_docmd_parms, dissect_device_docmd_resp },
{ VXI11_CORE_PROC_DESTROY_LINK, "DESTROY_LINK",
dissect_device_link, dissect_device_error },
{ VXI11_CORE_PROC_CREATE_INTR_CHAN, "CREATE_INTR_CHAN",
dissect_device_remote_func, dissect_device_error },
{ VXI11_CORE_PROC_DESTROY_INTR_CHAN, "DESTROY_INTR_CHAN",
dissect_rpc_void, dissect_device_error },
{ 0, NULL, NULL, NULL }
};
static const rpc_prog_vers_info vxi11_core_vers_info[] = {
{ VXI11_CORE_VERSION, vxi111_core_proc, &hf_vxi11_core_procedure_v1 },
};
rpc_init_prog(proto_vxi11_core, VXI11_CORE_PROGRAM, ett_vxi11_core,
G_N_ELEMENTS(vxi11_core_vers_info), vxi11_core_vers_info);
}
void
proto_register_vxi11_async(void)
{
static const value_string vxi11_async_v1_proc_vals[] = {
{ VXI11_ASYNC_PROC_NULL, "NULL" },
{ VXI11_ASYNC_PROC_DEVICE_ABORT, "DEVICE_ABORT" },
{ 0, NULL }
};
static hf_register_info vxi11_async_hf[] = {
{ &hf_vxi11_async_procedure_v1,
{
"V1 Procedure", "vxi11_async.procedure_v1", FT_UINT32, BASE_DEC,
VALS(vxi11_async_v1_proc_vals), 0, NULL, HFILL
}
}
};
static int *vxi11_async_ett[] = {
&ett_vxi11_async,
};
proto_vxi11_async = proto_register_protocol("VXI-11 Asynchronous Abort",
"VXI-11 Async",
"vxi11_async");
proto_register_field_array(proto_vxi11_async, vxi11_async_hf, array_length(vxi11_async_hf));
proto_register_subtree_array(vxi11_async_ett, array_length(vxi11_async_ett));
}
void
proto_reg_handoff_vxi11_async(void)
{
static const vsff vxi111_async_proc[] = {
{ VXI11_ASYNC_PROC_NULL, "NULL",
dissect_rpc_void, dissect_rpc_void },
{ VXI11_ASYNC_PROC_DEVICE_ABORT, "DEVICE_ABORT",
dissect_device_link, dissect_device_error },
{ 0, NULL, NULL, NULL }
};
static const rpc_prog_vers_info vxi11_async_vers_info[] = {
{ VXI11_ASYNC_VERSION, vxi111_async_proc, &hf_vxi11_async_procedure_v1 },
};
rpc_init_prog(proto_vxi11_async, VXI11_ASYNC_PROGRAM, ett_vxi11_async,
G_N_ELEMENTS(vxi11_async_vers_info), vxi11_async_vers_info);
}
void
proto_register_vxi11_intr(void)
{
static const value_string vxi11_intr_v1_proc_vals[] = {
{ VXI11_INTR_PROC_NULL, "NULL" },
{ VXI11_INTR_PROC_DEVICE_INTR_SRQ, "DEVICE_INTR_SRQ" },
{ 0, NULL }
};
static hf_register_info vxi11_intr_hf[] = {
{ &hf_vxi11_intr_procedure_v1,
{
"V1 Procedure", "vxi11_intr.procedure_v1", FT_UINT32, BASE_DEC,
VALS(vxi11_intr_v1_proc_vals), 0, NULL, HFILL
}
},
{ &hf_vxi11_intr_handle,
{
"Handle", "vxi11_intr.handle", FT_BYTES, BASE_NONE,
NULL, 0, NULL, HFILL
}
}
};
static int *vxi11_intr_ett[] = {
&ett_vxi11_intr,
};
proto_vxi11_intr = proto_register_protocol("VXI-11 Interrupt",
"VXI-11 Intr",
"vxi11_intr");
proto_register_field_array(proto_vxi11_intr, vxi11_intr_hf, array_length(vxi11_intr_hf));
proto_register_subtree_array(vxi11_intr_ett, array_length(vxi11_intr_ett));
}
void
proto_reg_handoff_vxi11_intr(void)
{
static const vsff vxi111_intr_proc[] = {
{ VXI11_INTR_PROC_NULL, "NULL",
dissect_rpc_void, dissect_rpc_void },
{ VXI11_INTR_PROC_DEVICE_INTR_SRQ, "DEVICE_INTR_SRQ",
dissect_device_SRQ_parms, dissect_rpc_void },
{ 0, NULL, NULL, NULL }
};
static const rpc_prog_vers_info vxi11_intr_vers_info[] = {
{ VXI11_INTR_VERSION, vxi111_intr_proc, &hf_vxi11_intr_procedure_v1 },
};
rpc_init_prog(proto_vxi11_intr, VXI11_INTR_PROGRAM, ett_vxi11_intr,
G_N_ELEMENTS(vxi11_intr_vers_info), vxi11_intr_vers_info);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
|