1 /* packet-coseventcomm.c
5 * Routines for IDL dissection
7 * Autogenerated from idl2wrs
8 * Copyright 2001 Frank Singleton <frank.singleton@ericsson.com>
13 * Wireshark - Network traffic analyzer
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.
41 #include <epan/packet.h>
42 #include <epan/proto.h>
43 #include <epan/dissectors/packet-giop.h>
44 #include <epan/expert.h>
47 /* disable warning: "unreference local variable" */
48 #pragma warning(disable:4101)
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
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_
)
92 if (!header
->exception_id
)
96 return FALSE
; /* user exception not found */
100 * IDL:omg.org/CosEventComm/PushConsumer/push:1.0
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
) {
107 get_CDR_any(tvb
, pinfo
, tree
, item
, offset
, stream_is_big_endian
, boundary
, header
);
111 switch(header
->rep_status
) {
113 /* Function returns void */
119 /* Unknown Exception */
120 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_exception
, "Unknown exception %d", header
->rep_status
);
122 } /* switch(header->rep_status) */
126 /* Unknown GIOP Message */
127 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_giop_msg
, "Unknown GIOP message %d", header
->message_type
);
129 } /* switch(header->message_type) */
133 * IDL:omg.org/CosEventComm/PushConsumer/disconnect_push_consumer:1.0
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
) {
142 switch(header
->rep_status
) {
144 /* Function returns void */
150 /* Unknown Exception */
151 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_exception
, "Unknown exception %d", header
->rep_status
);
153 } /* switch(header->rep_status) */
157 /* Unknown GIOP Message */
158 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_giop_msg
, "Unknown GIOP message %d", header
->message_type
);
160 } /* switch(header->message_type) */
164 * IDL:omg.org/CosEventComm/PushSupplier/disconnect_push_supplier:1.0
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
) {
173 switch(header
->rep_status
) {
175 /* Function returns void */
181 /* Unknown Exception */
182 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_exception
, "Unknown exception %d", header
->rep_status
);
184 } /* switch(header->rep_status) */
188 /* Unknown GIOP Message */
189 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_giop_msg
, "Unknown GIOP message %d", header
->message_type
);
191 } /* switch(header->message_type) */
195 * IDL:omg.org/CosEventComm/PullSupplier/pull:1.0
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
) {
204 switch(header
->rep_status
) {
206 get_CDR_any(tvb
, pinfo
, tree
, item
, offset
, stream_is_big_endian
, boundary
, header
);
212 /* Unknown Exception */
213 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_exception
, "Unknown exception %d", header
->rep_status
);
215 } /* switch(header->rep_status) */
219 /* Unknown GIOP Message */
220 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_giop_msg
, "Unknown GIOP message %d", header
->message_type
);
222 } /* switch(header->message_type) */
226 * IDL:omg.org/CosEventComm/PullSupplier/try_pull:1.0
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
) {
235 switch(header
->rep_status
) {
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
));
245 /* Unknown Exception */
246 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_exception
, "Unknown exception %d", header
->rep_status
);
248 } /* switch(header->rep_status) */
252 /* Unknown GIOP Message */
253 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_giop_msg
, "Unknown GIOP message %d", header
->message_type
);
255 } /* switch(header->message_type) */
259 * IDL:omg.org/CosEventComm/PullSupplier/disconnect_pull_supplier:1.0
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
) {
268 switch(header
->rep_status
) {
270 /* Function returns void */
276 /* Unknown Exception */
277 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_exception
, "Unknown exception %d", header
->rep_status
);
279 } /* switch(header->rep_status) */
283 /* Unknown GIOP Message */
284 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_giop_msg
, "Unknown GIOP message %d", header
->message_type
);
286 } /* switch(header->message_type) */
290 * IDL:omg.org/CosEventComm/PullConsumer/disconnect_pull_consumer:1.0
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
) {
299 switch(header
->rep_status
) {
301 /* Function returns void */
307 /* Unknown Exception */
308 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_exception
, "Unknown exception %d", header
->rep_status
);
310 } /* switch(header->rep_status) */
314 /* Unknown GIOP Message */
315 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_giop_msg
, "Unknown GIOP message %d", header
->message_type
);
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
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);
342 ti
= proto_tree_add_item(ptree
, proto_coseventcomm
, tvb
, *offset
, -1, ENC_NA
);
343 tree
= proto_item_add_subtree(ti
, ett_coseventcomm
);
349 process_RequestOperation(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*ptree
, MessageHeader
*header
, const gchar
*operation
)
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
);
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
) {
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
);
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
);
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
);
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
);
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
);
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
);
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
);
440 case CloseConnection
:
443 return FALSE
; /* not handled yet */
446 return FALSE
; /* not handled yet */
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 */
467 /* User exception 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
[] = {
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 */