HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-vicp.c
blob2fe44ed9f8e219e438fc7673f92144a7d54430cc
1 /* packet-vicp.c
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 * $Id$
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 #include "config.h"
30 #include <epan/packet.h>
31 #include <epan/ptvcursor.h>
33 /* registration object IDs */
34 static int proto_vicp = -1;
35 static int hf_vicp_operation = -1;
36 static int hf_vicp_version = -1;
37 static int hf_vicp_sequence = -1;
38 static int hf_vicp_unused = -1;
39 static int hf_vicp_length = -1;
40 static int hf_vicp_data = -1;
41 static gint ett_vicp = -1;
43 #define VICP_PORT 1861
45 static void dissect_vicp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
47 proto_item *ti;
48 proto_tree *vicp_tree;
49 ptvcursor_t* cursor;
51 guint len;
53 if (tvb_reported_length_remaining(tvb, 0) < 8)
55 /* Payload too small for VICP */
56 return;
59 col_set_str(pinfo->cinfo, COL_PROTOCOL, "VICP");
61 col_clear(pinfo->cinfo, COL_INFO);
63 ti = proto_tree_add_item(tree, proto_vicp, tvb, 0, -1, ENC_NA);
64 vicp_tree = proto_item_add_subtree(ti, ett_vicp);
65 cursor = ptvcursor_new(vicp_tree, tvb, 0);
67 ptvcursor_add(cursor, hf_vicp_operation, 1, ENC_BIG_ENDIAN);
68 ptvcursor_add(cursor, hf_vicp_version, 1, ENC_BIG_ENDIAN);
69 ptvcursor_add(cursor, hf_vicp_sequence, 1, ENC_BIG_ENDIAN);
70 ptvcursor_add(cursor, hf_vicp_unused, 1, ENC_BIG_ENDIAN);
72 len=tvb_get_ntohl(tvb, ptvcursor_current_offset(cursor));
73 ptvcursor_add(cursor, hf_vicp_length, 4, ENC_BIG_ENDIAN);
75 if(len==0)
76 proto_tree_add_text(vicp_tree, tvb, 0, 0, "No data");
77 else
78 ptvcursor_add(cursor, hf_vicp_data, len, ENC_NA);
80 ptvcursor_free(cursor);
83 void proto_register_vicp(void)
85 static hf_register_info hf[] =
87 { &hf_vicp_operation,
88 { "Operation","vicp.operation",FT_UINT8,BASE_HEX,NULL,0x0,NULL,HFILL }
90 { &hf_vicp_version,
91 { "Protocol version","vicp.version",FT_UINT8,BASE_DEC,NULL,0x0,NULL,HFILL }
93 { &hf_vicp_sequence,
94 { "Sequence number","vicp.sequence",FT_UINT8,BASE_DEC,NULL,0x0,NULL,HFILL }
96 { &hf_vicp_unused,
97 { "Unused","vicp.unused",FT_UINT8,BASE_HEX,NULL,0x0,NULL,HFILL }
99 { &hf_vicp_length,
100 { "Data length","vicp.length",FT_UINT32,BASE_DEC,NULL,0x0,NULL,HFILL }
102 { &hf_vicp_data,
103 { "Data","vicp.data",FT_BYTES,BASE_NONE,NULL,0x0,NULL,HFILL }
107 static gint *ett[] =
108 { &ett_vicp
111 proto_vicp = proto_register_protocol("LeCroy VICP", "VICP", "vicp");
112 proto_register_field_array(proto_vicp, hf, array_length(hf));
113 proto_register_subtree_array(ett, array_length(ett));
116 void proto_reg_handoff_vicp(void)
117 { dissector_handle_t vicp_handle;
119 vicp_handle = create_dissector_handle(dissect_vicp, proto_vicp);
120 dissector_add_uint("tcp.port", VICP_PORT, vicp_handle);