2 * Routines for Interbase dissection
4 * Erik Kunze <kunze@philosys.de>
5 * Uwe Girlich <Uwe.Girlich@philosys.de>
7 * $Id: packet-ib.c,v 1.2 2003/01/20 08:03:16 guy Exp $
9 * Ethereal - Network traffic analyzer
10 * By Gerald Combs <gerald@ethereal.com>
11 * Copyright 1998 Gerald Combs
13 * Copied from packet-x11.c
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #include <epan/packet.h>
36 /* Initialize the protocol and registered fields */
37 static int proto_ib = -1;
39 static int hf_ib_opcode = -1;
41 /* Initialize the subtree pointers */
42 static gint ett_ib = -1;
44 static dissector_handle_t data_handle;
46 #define TCP_PORT_IB 3050
49 * Round a length to a multiple of 4 bytes.
51 #define ROUND_LENGTH(n) ((((n) + 3)/4) * 4)
54 static const value_string names_opcode[] = {
63 { 8, "continuation" },
66 { 11, "create file" },
71 { 16, "convert lock" },
72 { 17, "release lock" },
79 { 24, "start and_send" },
84 { 29, "transaction" },
89 { 34, "create blob" },
91 { 36, "get segment" },
92 { 37, "put segment" },
93 { 38, "cancel blob" },
95 { 40, "info database" },
96 { 41, "info request" },
97 { 42, "info transaction" },
99 { 44, "batch segments" },
100 { 45, "mgr set_affinity" },
101 { 46, "mgr clear_affinity" },
102 { 47, "mgr report" },
103 { 48, "que events" },
104 { 49, "cancel events" },
105 { 50, "commit retaining" },
108 { 53, "connect request" },
109 { 54, "aux connect" },
111 { 56, "open blob2" },
112 { 57, "create blob2" },
117 { 62, "allocate statement" },
119 { 64, "exec immediate" },
121 { 66, "fetch response" },
122 { 67, "free statement" },
123 { 68, "prepare statement" },
124 { 69, "set cursor" },
127 { 72, "response piggyback" },
128 { 73, "start and_receive" },
129 { 74, "start send_and_receive" },
130 { 75, "exec immediate2" },
133 { 78, "sql response" },
135 { 80, "transact response" },
136 { 81, "drop database" },
137 { 82, "service attach" },
138 { 83, "service detach" },
139 { 84, "service info" },
140 { 85, "service start" },
141 { 86, "rollback retaining" },
146 dissect_ib(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
149 proto_item *ti = NULL;
150 proto_tree *ib_tree = NULL;
157 * Check that the opcode is one we recognize.
159 if (!tvb_bytes_exist(tvb, offset, 4)) {
161 * We don't have enough bytes for an opcode.
165 opcode = tvb_get_ntohl(tvb, offset + 0);
166 if (match_strval(opcode, names_opcode) == NULL) {
168 * This isn't an opcode we recognize.
173 if (check_col(pinfo->cinfo, COL_PROTOCOL))
174 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IB");
176 if (check_col(pinfo->cinfo, COL_INFO)) {
177 if (pinfo->match_port == pinfo->destport)
178 col_set_str(pinfo->cinfo, COL_INFO, "Request");
180 col_set_str(pinfo->cinfo, COL_INFO, "Reply");
184 ti = proto_tree_add_item(tree, proto_ib, tvb, 0, -1, FALSE);
187 ib_tree = proto_item_add_subtree(ti, ett_ib);
191 proto_tree_add_uint(ib_tree,
192 hf_ib_opcode, tvb, offset + 0, 4, opcode);
194 if (check_col(pinfo->cinfo, COL_INFO)) {
195 col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
196 val_to_str(opcode,names_opcode,"%u"));
200 next_tvb = tvb_new_subset(tvb, offset, -1, -1);
202 call_dissector(data_handle, next_tvb, pinfo, ib_tree);
203 return tvb_length(tvb);
206 /* Register the protocol with Ethereal */
207 void proto_register_ib(void)
210 /* Setup list of header fields */
211 static hf_register_info hf[] = {
213 { "Opcode", "ib.opcode",
214 FT_UINT32, BASE_DEC, VALS(names_opcode), 0x0,
215 "packet opcode", HFILL }},
218 /* Setup protocol subtree array */
219 static gint *ett[] = {
223 /* Register the protocol name and description */
224 proto_ib = proto_register_protocol("Interbase", "IB", "ib");
226 /* Required function calls to register the header fields and subtrees used */
227 proto_register_field_array(proto_ib, hf, array_length(hf));
228 proto_register_subtree_array(ett, array_length(ett));
232 proto_reg_handoff_ib(void)
234 dissector_handle_t ib_handle;
236 ib_handle = new_create_dissector_handle(dissect_ib, proto_ib);
237 dissector_add("tcp.port", TCP_PORT_IB, ib_handle);
238 data_handle = find_dissector("data");