2 * LeCroy VICP (GPIB-over-Ethernet-but-lets-not-do-LXI) dissector
4 * Written by Frank Kingswood <frank.kingswood@artimi.com>
5 * Copyright 2008, Artimi Ltd.
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 #include <epan/packet.h>
29 #include <epan/ptvcursor.h>
31 /* registration object IDs */
32 static int proto_vicp = -1;
33 static int hf_vicp_operation = -1;
34 static int hf_vicp_version = -1;
35 static int hf_vicp_sequence = -1;
36 static int hf_vicp_unused = -1;
37 static int hf_vicp_length = -1;
38 static int hf_vicp_data = -1;
39 static gint ett_vicp = -1;
41 #define VICP_PORT 1861
43 void proto_register_vicp(void);
44 void proto_reg_handoff_vicp(void);
46 static void dissect_vicp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
49 proto_tree *vicp_tree;
54 if (tvb_reported_length_remaining(tvb, 0) < 8)
56 /* Payload too small for VICP */
60 col_set_str(pinfo->cinfo, COL_PROTOCOL, "VICP");
62 col_clear(pinfo->cinfo, COL_INFO);
64 ti = proto_tree_add_item(tree, proto_vicp, tvb, 0, -1, ENC_NA);
65 vicp_tree = proto_item_add_subtree(ti, ett_vicp);
66 cursor = ptvcursor_new(vicp_tree, tvb, 0);
68 ptvcursor_add(cursor, hf_vicp_operation, 1, ENC_BIG_ENDIAN);
69 ptvcursor_add(cursor, hf_vicp_version, 1, ENC_BIG_ENDIAN);
70 ptvcursor_add(cursor, hf_vicp_sequence, 1, ENC_BIG_ENDIAN);
71 ptvcursor_add(cursor, hf_vicp_unused, 1, ENC_BIG_ENDIAN);
73 len=tvb_get_ntohl(tvb, ptvcursor_current_offset(cursor));
74 ptvcursor_add(cursor, hf_vicp_length, 4, ENC_BIG_ENDIAN);
77 proto_tree_add_text(vicp_tree, tvb, 0, 0, "No data");
79 ptvcursor_add(cursor, hf_vicp_data, len, ENC_NA);
81 ptvcursor_free(cursor);
84 void proto_register_vicp(void)
86 static hf_register_info hf[] =
89 { "Operation","vicp.operation",FT_UINT8,BASE_HEX,NULL,0x0,NULL,HFILL }
92 { "Protocol version","vicp.version",FT_UINT8,BASE_DEC,NULL,0x0,NULL,HFILL }
95 { "Sequence number","vicp.sequence",FT_UINT8,BASE_DEC,NULL,0x0,NULL,HFILL }
98 { "Unused","vicp.unused",FT_UINT8,BASE_HEX,NULL,0x0,NULL,HFILL }
101 { "Data length","vicp.length",FT_UINT32,BASE_DEC,NULL,0x0,NULL,HFILL }
104 { "Data","vicp.data",FT_BYTES,BASE_NONE,NULL,0x0,NULL,HFILL }
112 proto_vicp = proto_register_protocol("LeCroy VICP", "VICP", "vicp");
113 proto_register_field_array(proto_vicp, hf, array_length(hf));
114 proto_register_subtree_array(ett, array_length(ett));
117 void proto_reg_handoff_vicp(void)
118 { dissector_handle_t vicp_handle;
120 vicp_handle = create_dissector_handle(dissect_vicp, proto_vicp);
121 dissector_add_uint("tcp.port", VICP_PORT, vicp_handle);