HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-coseventcomm.c
blobc784ea766dc66a4f5cfb4f7ac329bef3024cffa8
1 /* packet-coseventcomm.c
3 * $Id$
5 * Routines for IDL dissection
7 * Autogenerated from idl2wrs
8 * Copyright 2001 Frank Singleton <frank.singleton@ericsson.com>
9 */
13 * Wireshark - Network traffic analyzer
14 * By Gerald Combs
15 * Copyright 1999 - 2012 Gerald Combs
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version 2
22 * of the License, or (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
35 #include "config.h"
37 #include <gmodule.h>
39 #include <string.h>
40 #include <glib.h>
41 #include <epan/packet.h>
42 #include <epan/proto.h>
43 #include <epan/dissectors/packet-giop.h>
44 #include <epan/expert.h>
46 #ifdef _MSC_VER
47 /* disable warning: "unreference local variable" */
48 #pragma warning(disable:4101)
49 #endif
52 /* Initialise the protocol and subtree pointers */
53 static int proto_coseventcomm = -1;
54 static gint ett_coseventcomm = -1;
57 /* Initialise the initial Alignment */
58 static guint32 boundary = GIOP_HEADER_SIZE; /* initial value */
60 static int hf_operationrequest = -1;/* Request_Operation field */
62 /* Operation filters */
63 static int hf_CosEventComm_PushConsumer_push_data = -1;
64 static int hf_CosEventComm_PullSupplier_pull_return = -1;
65 static int hf_CosEventComm_PullSupplier_try_pull_return = -1;
66 static int hf_CosEventComm_PullSupplier_try_pull_has_event = -1;
67 /* User exception filters */
68 /* Expert info filters */
69 static expert_field ei_coseventcomm_unknown_giop_msg = EI_INIT;
70 static expert_field ei_coseventcomm_unknown_exception = EI_INIT;
71 static expert_field ei_coseventcomm_unknown_reply_status = EI_INIT;
74 static proto_tree *start_dissecting(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset);
77 /* Begin Exception Helper Functions */
81 /* End Exception Helper Functions */
84 * Main delegator for exception handling
87 static gboolean
88 decode_user_exception(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *ptree _U_, int *offset _U_, MessageHeader *header, const gchar *operation _U_, gboolean stream_is_big_endian _U_)
90 proto_tree *tree _U_;
92 if (!header->exception_id)
93 return FALSE;
96 return FALSE; /* user exception not found */
100 * IDL:omg.org/CosEventComm/PushConsumer/push:1.0
102 static void
103 decode_CosEventComm_PushConsumer_push(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, proto_item *item _U_, int *offset _U_, MessageHeader *header, const gchar *operation _U_, gboolean stream_is_big_endian _U_)
105 switch(header->message_type) {
106 case Request:
107 get_CDR_any(tvb, pinfo, tree, item, offset, stream_is_big_endian, boundary, header);
109 break;
110 case Reply:
111 switch(header->rep_status) {
112 case NO_EXCEPTION:
113 /* Function returns void */
115 break;
116 case USER_EXCEPTION:
117 break;
118 default:
119 /* Unknown Exception */
120 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
121 break;
122 } /* switch(header->rep_status) */
124 break;
125 default:
126 /* Unknown GIOP Message */
127 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
128 break;
129 } /* switch(header->message_type) */
133 * IDL:omg.org/CosEventComm/PushConsumer/disconnect_push_consumer:1.0
135 static void
136 decode_CosEventComm_PushConsumer_disconnect_push_consumer(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, proto_item *item _U_, int *offset _U_, MessageHeader *header, const gchar *operation _U_, gboolean stream_is_big_endian _U_)
138 switch(header->message_type) {
139 case Request:
140 break;
141 case Reply:
142 switch(header->rep_status) {
143 case NO_EXCEPTION:
144 /* Function returns void */
146 break;
147 case USER_EXCEPTION:
148 break;
149 default:
150 /* Unknown Exception */
151 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
152 break;
153 } /* switch(header->rep_status) */
155 break;
156 default:
157 /* Unknown GIOP Message */
158 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
159 break;
160 } /* switch(header->message_type) */
164 * IDL:omg.org/CosEventComm/PushSupplier/disconnect_push_supplier:1.0
166 static void
167 decode_CosEventComm_PushSupplier_disconnect_push_supplier(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, proto_item *item _U_, int *offset _U_, MessageHeader *header, const gchar *operation _U_, gboolean stream_is_big_endian _U_)
169 switch(header->message_type) {
170 case Request:
171 break;
172 case Reply:
173 switch(header->rep_status) {
174 case NO_EXCEPTION:
175 /* Function returns void */
177 break;
178 case USER_EXCEPTION:
179 break;
180 default:
181 /* Unknown Exception */
182 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
183 break;
184 } /* switch(header->rep_status) */
186 break;
187 default:
188 /* Unknown GIOP Message */
189 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
190 break;
191 } /* switch(header->message_type) */
195 * IDL:omg.org/CosEventComm/PullSupplier/pull:1.0
197 static void
198 decode_CosEventComm_PullSupplier_pull(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, proto_item *item _U_, int *offset _U_, MessageHeader *header, const gchar *operation _U_, gboolean stream_is_big_endian _U_)
200 switch(header->message_type) {
201 case Request:
202 break;
203 case Reply:
204 switch(header->rep_status) {
205 case NO_EXCEPTION:
206 get_CDR_any(tvb, pinfo, tree, item, offset, stream_is_big_endian, boundary, header);
208 break;
209 case USER_EXCEPTION:
210 break;
211 default:
212 /* Unknown Exception */
213 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
214 break;
215 } /* switch(header->rep_status) */
217 break;
218 default:
219 /* Unknown GIOP Message */
220 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
221 break;
222 } /* switch(header->message_type) */
226 * IDL:omg.org/CosEventComm/PullSupplier/try_pull:1.0
228 static void
229 decode_CosEventComm_PullSupplier_try_pull(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, proto_item *item _U_, int *offset _U_, MessageHeader *header, const gchar *operation _U_, gboolean stream_is_big_endian _U_)
231 switch(header->message_type) {
232 case Request:
233 break;
234 case Reply:
235 switch(header->rep_status) {
236 case NO_EXCEPTION:
237 get_CDR_any(tvb, pinfo, tree, item, offset, stream_is_big_endian, boundary, header);
239 proto_tree_add_boolean(tree, hf_CosEventComm_PullSupplier_try_pull_has_event, tvb, *offset-1, 1, get_CDR_boolean(tvb,offset));
241 break;
242 case USER_EXCEPTION:
243 break;
244 default:
245 /* Unknown Exception */
246 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
247 break;
248 } /* switch(header->rep_status) */
250 break;
251 default:
252 /* Unknown GIOP Message */
253 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
254 break;
255 } /* switch(header->message_type) */
259 * IDL:omg.org/CosEventComm/PullSupplier/disconnect_pull_supplier:1.0
261 static void
262 decode_CosEventComm_PullSupplier_disconnect_pull_supplier(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, proto_item *item _U_, int *offset _U_, MessageHeader *header, const gchar *operation _U_, gboolean stream_is_big_endian _U_)
264 switch(header->message_type) {
265 case Request:
266 break;
267 case Reply:
268 switch(header->rep_status) {
269 case NO_EXCEPTION:
270 /* Function returns void */
272 break;
273 case USER_EXCEPTION:
274 break;
275 default:
276 /* Unknown Exception */
277 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
278 break;
279 } /* switch(header->rep_status) */
281 break;
282 default:
283 /* Unknown GIOP Message */
284 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
285 break;
286 } /* switch(header->message_type) */
290 * IDL:omg.org/CosEventComm/PullConsumer/disconnect_pull_consumer:1.0
292 static void
293 decode_CosEventComm_PullConsumer_disconnect_pull_consumer(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, proto_item *item _U_, int *offset _U_, MessageHeader *header, const gchar *operation _U_, gboolean stream_is_big_endian _U_)
295 switch(header->message_type) {
296 case Request:
297 break;
298 case Reply:
299 switch(header->rep_status) {
300 case NO_EXCEPTION:
301 /* Function returns void */
303 break;
304 case USER_EXCEPTION:
305 break;
306 default:
307 /* Unknown Exception */
308 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
309 break;
310 } /* switch(header->rep_status) */
312 break;
313 default:
314 /* Unknown GIOP Message */
315 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
316 break;
317 } /* switch(header->message_type) */
321 * Called once we accept the packet as being for us; it sets the
322 * Protocol and Info columns and creates the top-level protocol
323 * tree item.
325 static proto_tree *
326 start_dissecting(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset)
329 proto_item *ti = NULL;
330 proto_tree *tree = NULL; /* init later, inside if(tree) */
332 col_set_str(pinfo->cinfo, COL_PROTOCOL, "COSEVENTCOMM");
335 * Do not clear COL_INFO, as nothing is being written there by
336 * this dissector yet. So leave it as is from the GIOP dissector.
337 * TODO: add something useful to COL_INFO
338 * col_clear(pinfo->cinfo, COL_INFO);
341 if (ptree) {
342 ti = proto_tree_add_item(ptree, proto_coseventcomm, tvb, *offset, -1, ENC_NA);
343 tree = proto_item_add_subtree(ti, ett_coseventcomm);
345 return tree;
348 static proto_item*
349 process_RequestOperation(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, MessageHeader *header, const gchar *operation)
351 proto_item *pi;
352 if(header->message_type == Reply) {
353 /* fill-up info column */
354 col_append_fstr(pinfo->cinfo, COL_INFO, " op = %s",operation);
356 /* fill-up the field */
357 pi=proto_tree_add_string(ptree, hf_operationrequest, tvb, 0, 0, operation);
358 PROTO_ITEM_SET_GENERATED(pi);
359 return pi;
362 static gboolean
363 dissect_coseventcomm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset, MessageHeader *header, const gchar *operation, gchar *idlname)
365 proto_item *item _U_;
366 proto_tree *tree _U_;
367 gboolean stream_is_big_endian = is_big_endian(header); /* get endianess */
369 /* If we have a USER Exception, then decode it and return */
370 if ((header->message_type == Reply) && (header->rep_status == USER_EXCEPTION)) {
371 return decode_user_exception(tvb, pinfo, ptree, offset, header, operation, stream_is_big_endian);
374 switch(header->message_type) {
376 case Request:
377 case Reply:
379 if (strcmp(operation, "push") == 0
380 && (!idlname || strcmp(idlname, "CosEventComm/PushConsumer") == 0)) {
381 item = process_RequestOperation(tvb, pinfo, ptree, header, operation); /* fill-up Request_Operation field & info column */
382 tree = start_dissecting(tvb, pinfo, ptree, offset);
383 decode_CosEventComm_PushConsumer_push(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
384 return TRUE;
387 if (strcmp(operation, "disconnect_push_consumer") == 0
388 && (!idlname || strcmp(idlname, "CosEventComm/PushConsumer") == 0)) {
389 item = process_RequestOperation(tvb, pinfo, ptree, header, operation); /* fill-up Request_Operation field & info column */
390 tree = start_dissecting(tvb, pinfo, ptree, offset);
391 decode_CosEventComm_PushConsumer_disconnect_push_consumer(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
392 return TRUE;
395 if (strcmp(operation, "disconnect_push_supplier") == 0
396 && (!idlname || strcmp(idlname, "CosEventComm/PushSupplier") == 0)) {
397 item = process_RequestOperation(tvb, pinfo, ptree, header, operation); /* fill-up Request_Operation field & info column */
398 tree = start_dissecting(tvb, pinfo, ptree, offset);
399 decode_CosEventComm_PushSupplier_disconnect_push_supplier(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
400 return TRUE;
403 if (strcmp(operation, "pull") == 0
404 && (!idlname || strcmp(idlname, "CosEventComm/PullSupplier") == 0)) {
405 item = process_RequestOperation(tvb, pinfo, ptree, header, operation); /* fill-up Request_Operation field & info column */
406 tree = start_dissecting(tvb, pinfo, ptree, offset);
407 decode_CosEventComm_PullSupplier_pull(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
408 return TRUE;
411 if (strcmp(operation, "try_pull") == 0
412 && (!idlname || strcmp(idlname, "CosEventComm/PullSupplier") == 0)) {
413 item = process_RequestOperation(tvb, pinfo, ptree, header, operation); /* fill-up Request_Operation field & info column */
414 tree = start_dissecting(tvb, pinfo, ptree, offset);
415 decode_CosEventComm_PullSupplier_try_pull(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
416 return TRUE;
419 if (strcmp(operation, "disconnect_pull_supplier") == 0
420 && (!idlname || strcmp(idlname, "CosEventComm/PullSupplier") == 0)) {
421 item = process_RequestOperation(tvb, pinfo, ptree, header, operation); /* fill-up Request_Operation field & info column */
422 tree = start_dissecting(tvb, pinfo, ptree, offset);
423 decode_CosEventComm_PullSupplier_disconnect_pull_supplier(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
424 return TRUE;
427 if (strcmp(operation, "disconnect_pull_consumer") == 0
428 && (!idlname || strcmp(idlname, "CosEventComm/PullConsumer") == 0)) {
429 item = process_RequestOperation(tvb, pinfo, ptree, header, operation); /* fill-up Request_Operation field & info column */
430 tree = start_dissecting(tvb, pinfo, ptree, offset);
431 decode_CosEventComm_PullConsumer_disconnect_pull_consumer(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
432 return TRUE;
435 break;
437 case CancelRequest:
438 case LocateRequest:
439 case LocateReply:
440 case CloseConnection:
441 case MessageError:
442 case Fragment:
443 return FALSE; /* not handled yet */
445 default:
446 return FALSE; /* not handled yet */
448 } /* switch */
451 return FALSE;
453 } /* End of main dissector */
456 /* Register the protocol with Wireshark */
457 void proto_register_giop_coseventcomm(void)
459 /* setup list of header fields */
460 static hf_register_info hf[] = {
461 /* field that indicates the currently ongoing request/reply exchange */
462 {&hf_operationrequest, {"Request_Operation","giop-coseventcomm.Request_Operation",FT_STRING,BASE_NONE,NULL,0x0,NULL,HFILL}},
463 /* Operation filters */
464 {&hf_CosEventComm_PullSupplier_try_pull_has_event, {"has_event","giop-coseventcomm.PullSupplier.try_pull.has_event",FT_BOOLEAN,8,NULL,0x01,NULL,HFILL}},
465 /* Attribute filters */
466 /* Struct filters */
467 /* User exception filters */
468 /* Union filters */
472 static ei_register_info ei[] = {
473 { &ei_coseventcomm_unknown_giop_msg, { "giop-coseventcomm.unknown_giop_msg", PI_PROTOCOL, PI_WARN, "Unknown GIOP message", EXPFILL }},
474 { &ei_coseventcomm_unknown_exception, { "giop-coseventcomm.unknown_exception", PI_PROTOCOL, PI_WARN, "Unknown exception", EXPFILL }},
475 { &ei_coseventcomm_unknown_reply_status, { "giop-coseventcomm.unknown_reply_status", PI_PROTOCOL, PI_WARN, "Unknown reply status", EXPFILL }},
478 /* setup protocol subtree array */
480 static gint *ett[] = {
481 &ett_coseventcomm,
484 expert_module_t* expert_coseventcomm;
487 /* Register the protocol name and description */
488 proto_coseventcomm = proto_register_protocol("Coseventcomm Dissector Using GIOP API" , "COSEVENTCOMM", "giop-coseventcomm" );
489 proto_register_field_array(proto_coseventcomm, hf, array_length(hf));
490 proto_register_subtree_array(ett, array_length(ett));
492 expert_coseventcomm = expert_register_protocol(proto_coseventcomm);
493 expert_register_field_array(expert_coseventcomm, ei, array_length(ei));
496 /* register me as handler for these interfaces */
497 void proto_reg_handoff_giop_coseventcomm(void)
500 /* Register for Explicit Dissection */
501 register_giop_user_module(dissect_coseventcomm, "COSEVENTCOMM", "CosEventComm/PullConsumer", proto_coseventcomm ); /* explicit dissector */
503 /* Register for Explicit Dissection */
504 register_giop_user_module(dissect_coseventcomm, "COSEVENTCOMM", "CosEventComm/PullSupplier", proto_coseventcomm ); /* explicit dissector */
506 /* Register for Explicit Dissection */
507 register_giop_user_module(dissect_coseventcomm, "COSEVENTCOMM", "CosEventComm/PushConsumer", proto_coseventcomm ); /* explicit dissector */
509 /* Register for Explicit Dissection */
510 register_giop_user_module(dissect_coseventcomm, "COSEVENTCOMM", "CosEventComm/PushSupplier", proto_coseventcomm ); /* explicit dissector */
512 /* Register for Heuristic Dissection */
513 register_giop_user(dissect_coseventcomm, "COSEVENTCOMM" ,proto_coseventcomm); /* heuristic dissector */