2 * Routines for IBM WebSphere MQ PCF packet dissection
4 * metatech <metatech@flashmail.com>
6 * $Id: packet-mq-pcf.c,v 1.1 2004/05/01 21:18:09 guy Exp $
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@ethereal.com>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 /* MQ PCF in a nutshell
29 * The MQ Programmable Command Formats API allows remotely configuring a queue manager.
31 * MQ PCF documentation is called "WebSphere MQ Programmable Command Formats and Administration Interface"
41 #include <epan/packet.h>
42 #include <epan/conversation.h>
43 #include "packet-mq.h"
45 static int proto_mqpcf = -1;
46 static int hf_mqpcf_cfh_type = -1;
47 static int hf_mqpcf_cfh_length = -1;
48 static int hf_mqpcf_cfh_version = -1;
49 static int hf_mqpcf_cfh_command = -1;
50 static int hf_mqpcf_cfh_msgseqnumber = -1;
51 static int hf_mqpcf_cfh_control = -1;
52 static int hf_mqpcf_cfh_compcode = -1;
53 static int hf_mqpcf_cfh_reason = -1;
54 static int hf_mqpcf_cfh_paramcount = -1;
56 static gint ett_mqpcf = -1;
57 static gint ett_mqpcf_cfh = -1;
59 #define MQ_FMT_ADMIN "MQADMIN "
60 #define MQ_FMT_EVENT "MQEVENT "
61 #define MQ_FMT_PCF "MQPCF "
63 #define MQ_ENC_INTEGER_NORMAL 0x00000001
64 #define MQ_ENC_INTEGER_REVERSED 0x00000002
67 #define MQ_CMD_CHANGE_Q_MGR 1
68 #define MQ_CMD_INQUIRE_Q_MGR 2
69 #define MQ_CMD_CHANGE_PROCESS 3
70 #define MQ_CMD_COPY_PROCESS 4
71 #define MQ_CMD_CREATE_PROCESS 5
72 #define MQ_CMD_DELETE_PROCESS 6
73 #define MQ_CMD_INQUIRE_PROCESS 7
74 #define MQ_CMD_CHANGE_Q 8
75 #define MQ_CMD_CLEAR_Q 9
76 #define MQ_CMD_COPY_Q 10
77 #define MQ_CMD_CREATE_Q 11
78 #define MQ_CMD_DELETE_Q 12
79 #define MQ_CMD_INQUIRE_Q 13
80 #define MQ_CMD_RESET_Q_STATS 17
81 #define MQ_CMD_INQUIRE_Q_NAMES 18
82 #define MQ_CMD_INQUIRE_PROCESS_NAMES 19
83 #define MQ_CMD_INQUIRE_CHANNEL_NAMES 20
84 #define MQ_CMD_CHANGE_CHANNEL 21
85 #define MQ_CMD_COPY_CHANNEL 22
86 #define MQ_CMD_CREATE_CHANNEL 23
87 #define MQ_CMD_DELETE_CHANNEL 24
88 #define MQ_CMD_INQUIRE_CHANNEL 25
89 #define MQ_CMD_PING_CHANNEL 26
90 #define MQ_CMD_RESET_CHANNEL 27
91 #define MQ_CMD_START_CHANNEL 28
92 #define MQ_CMD_STOP_CHANNEL 29
93 #define MQ_CMD_START_CHANNEL_INIT 30
94 #define MQ_CMD_START_CHANNEL_LISTENER 31
95 #define MQ_CMD_CHANGE_NAMELIST 32
96 #define MQ_CMD_COPY_NAMELIST 33
97 #define MQ_CMD_CREATE_NAMELIST 34
98 #define MQ_CMD_DELETE_NAMELIST 35
99 #define MQ_CMD_INQUIRE_NAMELIST 36
100 #define MQ_CMD_INQUIRE_NAMELIST_NAMES 37
101 #define MQ_CMD_ESCAPE 38
102 #define MQ_CMD_RESOLVE_CHANNEL 39
103 #define MQ_CMD_PING_Q_MGR 40
104 #define MQ_CMD_INQUIRE_Q_STATUS 41
105 #define MQ_CMD_INQUIRE_CHANNEL_STATUS 42
106 #define MQ_CMD_CONFIG_EVENT 43
107 #define MQ_CMD_Q_MGR_EVENT 44
108 #define MQ_CMD_PERFM_EVENT 45
109 #define MQ_CMD_CHANNEL_EVENT 46
110 #define MQ_CMD_DELETE_PUBLICATION 60
111 #define MQ_CMD_DEREGISTER_PUBLISHER 61
112 #define MQ_CMD_DEREGISTER_SUBSCRIBER 62
113 #define MQ_CMD_PUBLISH 63
114 #define MQ_CMD_REGISTER_PUBLISHER 64
115 #define MQ_CMD_REGISTER_SUBSCRIBER 65
116 #define MQ_CMD_REQUEST_UPDATE 66
117 #define MQ_CMD_BROKER_INTERNAL 67
118 #define MQ_CMD_INQUIRE_CLUSTER_Q_MGR 70
119 #define MQ_CMD_RESUME_Q_MGR_CLUSTER 71
120 #define MQ_CMD_SUSPEND_Q_MGR_CLUSTER 72
121 #define MQ_CMD_REFRESH_CLUSTER 73
122 #define MQ_CMD_RESET_CLUSTER 74
123 #define MQ_CMD_REFRESH_SECURITY 78
124 #define MQ_CMD_CHANGE_AUTH_INFO 79
125 #define MQ_CMD_COPY_AUTH_INFO 80
126 #define MQ_CMD_CREATE_AUTH_INFO 81
127 #define MQ_CMD_DELETE_AUTH_INFO 82
128 #define MQ_CMD_INQUIRE_AUTH_INFO 83
129 #define MQ_CMD_INQUIRE_AUTH_INFO_NAMES 84
131 #define MQ_TEXT_CFH "MQ Command Format Header"
133 static const value_string mqpcf_opcode_vals[] = {
134 { MQ_CMD_NONE, "NONE" },
135 { MQ_CMD_CHANGE_Q_MGR, "CHANGE_Q_MGR" },
136 { MQ_CMD_INQUIRE_Q_MGR, "INQUIRE_Q_MGR" },
137 { MQ_CMD_CHANGE_PROCESS, "CHANGE_PROCESS" },
138 { MQ_CMD_COPY_PROCESS, "COPY_PROCESS" },
139 { MQ_CMD_CREATE_PROCESS, "CREATE_PROCESS" },
140 { MQ_CMD_DELETE_PROCESS, "DELETE_PROCESS" },
141 { MQ_CMD_INQUIRE_PROCESS, "INQUIRE_PROCESS" },
142 { MQ_CMD_CHANGE_Q, "CHANGE_Q" },
143 { MQ_CMD_CLEAR_Q, "CLEAR_Q" },
144 { MQ_CMD_COPY_Q, "COPY_Q" },
145 { MQ_CMD_CREATE_Q, "CREATE_Q" },
146 { MQ_CMD_DELETE_Q, "DELETE_Q" },
147 { MQ_CMD_INQUIRE_Q, "INQUIRE_Q" },
148 { MQ_CMD_RESET_Q_STATS, "RESET_Q_STATS" },
149 { MQ_CMD_INQUIRE_Q_NAMES, "INQUIRE_Q_NAMES" },
150 { MQ_CMD_INQUIRE_PROCESS_NAMES, "INQUIRE_PROCESS_NAMES" },
151 { MQ_CMD_INQUIRE_CHANNEL_NAMES, "INQUIRE_CHANNEL_NAMES" },
152 { MQ_CMD_CHANGE_CHANNEL, "CHANGE_CHANNEL" },
153 { MQ_CMD_COPY_CHANNEL, "COPY_CHANNEL" },
154 { MQ_CMD_CREATE_CHANNEL, "CREATE_CHANNEL" },
155 { MQ_CMD_DELETE_CHANNEL, "DELETE_CHANNEL" },
156 { MQ_CMD_INQUIRE_CHANNEL, "INQUIRE_CHANNEL" },
157 { MQ_CMD_PING_CHANNEL, "PING_CHANNEL" },
158 { MQ_CMD_RESET_CHANNEL, "RESET_CHANNEL" },
159 { MQ_CMD_START_CHANNEL, "START_CHANNEL" },
160 { MQ_CMD_STOP_CHANNEL, "STOP_CHANNEL" },
161 { MQ_CMD_START_CHANNEL_INIT, "START_CHANNEL_INIT" },
162 { MQ_CMD_START_CHANNEL_LISTENER, "START_CHANNEL_LISTENER" },
163 { MQ_CMD_CHANGE_NAMELIST, "CHANGE_NAMELIST" },
164 { MQ_CMD_CREATE_NAMELIST, "CREATE_NAMELIST" },
165 { MQ_CMD_DELETE_NAMELIST, "DELETE_NAMELIST" },
166 { MQ_CMD_INQUIRE_NAMELIST, "INQUIRE_NAMELIST" },
167 { MQ_CMD_INQUIRE_NAMELIST_NAMES, "INQUIRE_NAMELIST_NAMES" },
168 { MQ_CMD_ESCAPE, "ESCAPE" },
169 { MQ_CMD_RESOLVE_CHANNEL, "RESOLVE_CHANNEL" },
170 { MQ_CMD_PING_Q_MGR, "PING_Q_MGR" },
171 { MQ_CMD_INQUIRE_Q_STATUS, "INQUIRE_Q_STATUS" },
172 { MQ_CMD_INQUIRE_CHANNEL_STATUS, "INQUIRE_CHANNEL_STATUS" },
173 { MQ_CMD_CONFIG_EVENT, "CONFIG_EVENT" },
174 { MQ_CMD_Q_MGR_EVENT, "Q_MGR_EVENT" },
175 { MQ_CMD_PERFM_EVENT, "PERFM_EVENT" },
176 { MQ_CMD_CHANNEL_EVENT, "CHANNEL_EVENT" },
177 { MQ_CMD_DELETE_PUBLICATION, "DELETE_PUBLICATION" },
178 { MQ_CMD_DEREGISTER_PUBLISHER, "DEREGISTER_PUBLISHER" },
179 { MQ_CMD_DEREGISTER_SUBSCRIBER, "DEREGISTER_SUBSCRIBER" },
180 { MQ_CMD_PUBLISH, "PUBLISH" },
181 { MQ_CMD_REGISTER_PUBLISHER, "REGISTER_PUBLISHER" },
182 { MQ_CMD_REGISTER_SUBSCRIBER, "REGISTER_SUBSCRIBER" },
183 { MQ_CMD_REQUEST_UPDATE, "REQUEST_UPDATE" },
184 { MQ_CMD_BROKER_INTERNAL, "BROKER_INTERNAL" },
185 { MQ_CMD_INQUIRE_CLUSTER_Q_MGR, "INQUIRE_CLUSTER_Q_MGR" },
186 { MQ_CMD_RESUME_Q_MGR_CLUSTER, "RESUME_Q_MGR_CLUSTER" },
187 { MQ_CMD_SUSPEND_Q_MGR_CLUSTER, "SUSPEND_Q_MGR_CLUSTER" },
188 { MQ_CMD_REFRESH_CLUSTER, "REFRESH_CLUSTER" },
189 { MQ_CMD_REFRESH_SECURITY, "REFRESH_SECURITY" },
190 { MQ_CMD_CHANGE_AUTH_INFO, "CHANGE_AUTH_INFO" },
191 { MQ_CMD_COPY_AUTH_INFO, "COPY_AUTH_INFO" },
192 { MQ_CMD_CREATE_AUTH_INFO, "CREATE_AUTH_INFO" },
193 { MQ_CMD_DELETE_AUTH_INFO, "DELETE_AUTH_INFO" },
194 { MQ_CMD_INQUIRE_AUTH_INFO, "INQUIRE_AUTH_INFO" },
195 { MQ_CMD_INQUIRE_AUTH_INFO_NAMES, "INQUIRE_AUTH_INFO_NAMES" },
199 static guint32 tvb_get_guint32_endian(tvbuff_t *a_tvb, gint a_iOffset, gboolean a_bLittleEndian)
203 iResult = tvb_get_letohl(a_tvb, a_iOffset);
205 iResult = tvb_get_ntohl(a_tvb, a_iOffset);
210 dissect_mqpcf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
212 proto_tree *mq_tree = NULL;
213 proto_tree *mqroot_tree = NULL;
214 proto_item *ti = NULL;
216 struct mqinfo* mqinfo = pinfo->private_data;
217 gboolean bLittleEndian;
218 bLittleEndian = ((mqinfo->encoding & MQ_ENC_INTEGER_REVERSED) != 0) ? TRUE : FALSE;
220 if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "MQ PCF");
221 if (check_col(pinfo->cinfo, COL_INFO)) col_clear(pinfo->cinfo, COL_INFO);
222 if (tvb_length(tvb) >= 36)
224 gint iSizeMQCFH = 36;
225 guint32 iCommand = tvb_get_guint32_endian(tvb, offset + 12, bLittleEndian);
227 if (check_col(pinfo->cinfo, COL_INFO))
229 col_append_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str(iCommand, mqpcf_opcode_vals, "Unknown (0x%02x)"));
234 ti = proto_tree_add_item(tree, proto_mqpcf, tvb, offset, -1, FALSE);
235 proto_item_append_text(ti, " (%s)", val_to_str(iCommand, mqpcf_opcode_vals, "Unknown (0x%02x)"));
236 mqroot_tree = proto_item_add_subtree(ti, ett_mqpcf);
238 ti = proto_tree_add_text(mqroot_tree, tvb, offset, iSizeMQCFH, MQ_TEXT_CFH);
239 mq_tree = proto_item_add_subtree(ti, ett_mqpcf_cfh);
241 proto_tree_add_item(mq_tree, hf_mqpcf_cfh_type, tvb, offset + 0, 4, bLittleEndian);
242 proto_tree_add_item(mq_tree, hf_mqpcf_cfh_length, tvb, offset + 4, 4, bLittleEndian);
243 proto_tree_add_item(mq_tree, hf_mqpcf_cfh_version, tvb, offset + 8, 4, bLittleEndian);
244 proto_tree_add_item(mq_tree, hf_mqpcf_cfh_command, tvb, offset + 12, 4, bLittleEndian);
245 proto_tree_add_item(mq_tree, hf_mqpcf_cfh_msgseqnumber, tvb, offset + 16, 4, bLittleEndian);
246 proto_tree_add_item(mq_tree, hf_mqpcf_cfh_control, tvb, offset + 20, 4, bLittleEndian);
247 proto_tree_add_item(mq_tree, hf_mqpcf_cfh_compcode, tvb, offset + 24, 4, bLittleEndian);
248 proto_tree_add_item(mq_tree, hf_mqpcf_cfh_reason, tvb, offset + 28, 4, bLittleEndian);
249 proto_tree_add_item(mq_tree, hf_mqpcf_cfh_paramcount, tvb, offset + 32, 4, bLittleEndian);
251 offset += iSizeMQCFH;
256 dissect_mqpcf_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
258 if (tvb_length(tvb) >= 36)
260 struct mqinfo* mqinfo = pinfo->private_data;
261 if (strncmp((const char*)mqinfo->format, MQ_FMT_ADMIN, 8) == 0
262 || strncmp((const char*)mqinfo->format, MQ_FMT_EVENT, 8) == 0
263 || strncmp((const char*)mqinfo->format, MQ_FMT_PCF, 8) == 0)
265 /* Dissect the packet */
266 dissect_mqpcf(tvb, pinfo, tree);
274 proto_register_mqpcf(void)
276 static hf_register_info hf[] = {
277 { &hf_mqpcf_cfh_type,
278 { "Type", "mqpcf.cfh.type", FT_UINT32, BASE_DEC, NULL, 0x0, "CFH type", HFILL }},
280 { &hf_mqpcf_cfh_length,
281 { "Length", "mqpcf.cfh.length", FT_UINT32, BASE_DEC, NULL, 0x0, "CFH length", HFILL }},
283 { &hf_mqpcf_cfh_version,
284 { "Version", "mqpcf.cfh.version", FT_UINT32, BASE_DEC, NULL, 0x0, "CFH version", HFILL }},
286 { &hf_mqpcf_cfh_command,
287 { "Command", "mqpcf.cfh.command", FT_UINT32, BASE_DEC, NULL, 0x0, "CFH command", HFILL }},
289 { &hf_mqpcf_cfh_msgseqnumber,
290 { "Message sequence number", "mqpcf.cfh.msgseqnumber", FT_UINT32, BASE_DEC, NULL, 0x0, "CFH message sequence number", HFILL }},
292 { &hf_mqpcf_cfh_control,
293 { "Control", "mqpcf.cfh.control", FT_UINT32, BASE_DEC, NULL, 0x0, "CFH control", HFILL }},
295 { &hf_mqpcf_cfh_compcode,
296 { "Completion code", "mqpcf.cfh.compcode", FT_UINT32, BASE_DEC, NULL, 0x0, "CFH completion code", HFILL }},
298 { &hf_mqpcf_cfh_reason,
299 { "Reason code", "mqpcf.cfh.reasoncode", FT_UINT32, BASE_DEC, NULL, 0x0, "CFH reason code", HFILL }},
301 { &hf_mqpcf_cfh_paramcount,
302 { "Parameter count", "mqpcf.cfh.paramcount", FT_UINT32, BASE_DEC, NULL, 0x0, "CFH parameter count", HFILL }}
304 static gint *ett[] = {
309 proto_mqpcf = proto_register_protocol("WebSphere MQ Programmable Command Formats", "MQ PCF", "mqpcf");
310 proto_register_field_array(proto_mqpcf, hf, array_length(hf));
311 proto_register_subtree_array(ett, array_length(ett));
315 proto_reg_handoff_mqpcf(void)
317 heur_dissector_add("mq", dissect_mqpcf_heur, proto_mqpcf);