Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-coseventcomm.c
blob1b97602b35dabdd8111ac4d3570c2f1a0f2c90ef
1 /* packet-coseventcomm.c
3 * Routines for IDL dissection
5 * Autogenerated from idl2wrs
6 * Copyright 2001 Frank Singleton <frank.singleton@ericsson.com>
7 */
11 * Wireshark - Network traffic analyzer
12 * By Gerald Combs <gerald@wireshark.org>
13 * Copyright 1998 Gerald Combs
17 * SPDX-License-Identifier: GPL-2.0-or-later
21 #include "config.h"
23 #include <string.h>
24 #include <epan/packet.h>
25 #include <epan/proto.h>
26 #include "packet-giop.h"
27 #include <epan/expert.h>
28 #include <wsutil/array.h>
30 #include "ws_diag_control.h"
31 #include "ws_compiler_tests.h"
33 #ifdef _MSC_VER
34 /* disable warning: "unreference local variable" */
35 #pragma warning(disable:4101)
36 #endif
38 /* XXX this should be autogenerated, or the warnings fixed in the generator */
39 DIAG_OFF(unused-function)
40 DIAG_OFF(unused-variable)
41 #if WS_IS_AT_LEAST_GNUC_VERSION(6,0)
42 DIAG_OFF(unused-const-variable)
43 #endif
45 void proto_register_giop_coseventcomm(void);
46 void proto_reg_handoff_giop_coseventcomm(void);
48 /* Initialise the protocol and subtree pointers */
49 static int proto_coseventcomm;
50 static int ett_coseventcomm;
51 static int ett_giop_struct;
52 static int ett_giop_sequence;
53 static int ett_giop_array;
54 static int ett_giop_union;
57 /* Initialise the initial Alignment */
58 static uint32_t boundary = GIOP_HEADER_SIZE; /* initial value */
60 static int hf_operationrequest;/* Request_Operation field */
62 /* Operation filters */
63 static int hf_CosEventComm_PullSupplier_try_pull_has_event;
64 /* User exception filters */
65 /* Expert info filters */
66 static expert_field ei_coseventcomm_unknown_giop_msg;
67 static expert_field ei_coseventcomm_unknown_exception;
68 static expert_field ei_coseventcomm_unknown_reply_status;
71 static proto_tree *start_dissecting(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset);
74 /* Begin Exception Helper Functions */
78 /* End Exception Helper Functions */
81 * Main delegator for exception handling
84 static bool
85 decode_user_exception(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *ptree _U_, int *offset _U_, MessageHeader *header, const char *operation _U_, bool stream_is_big_endian _U_)
87 proto_tree *tree _U_;
89 if (!header->exception_id)
90 return false;
93 return false; /* user exception not found */
97 * IDL:omg.org/CosEventComm/PullConsumer/disconnect_pull_consumer:1.0
99 static void
100 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 char *operation _U_, bool stream_is_big_endian _U_)
102 switch(header->message_type) {
103 case Request:
104 break;
105 case Reply:
106 switch(header->rep_status) {
107 case NO_EXCEPTION:
108 /* Function returns void */
110 break;
111 case USER_EXCEPTION:
112 break;
113 default:
114 /* Unknown Exception */
115 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
116 break;
117 } /* switch(header->rep_status) */
119 break;
120 default:
121 /* Unknown GIOP Message */
122 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
123 break;
124 } /* switch(header->message_type) */
128 * IDL:omg.org/CosEventComm/PullSupplier/disconnect_pull_supplier:1.0
130 static void
131 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 char *operation _U_, bool stream_is_big_endian _U_)
133 switch(header->message_type) {
134 case Request:
135 break;
136 case Reply:
137 switch(header->rep_status) {
138 case NO_EXCEPTION:
139 /* Function returns void */
141 break;
142 case USER_EXCEPTION:
143 break;
144 default:
145 /* Unknown Exception */
146 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
147 break;
148 } /* switch(header->rep_status) */
150 break;
151 default:
152 /* Unknown GIOP Message */
153 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
154 break;
155 } /* switch(header->message_type) */
159 * IDL:omg.org/CosEventComm/PullSupplier/try_pull:1.0
161 static void
162 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 char *operation _U_, bool stream_is_big_endian _U_)
164 switch(header->message_type) {
165 case Request:
166 break;
167 case Reply:
168 switch(header->rep_status) {
169 case NO_EXCEPTION:
170 get_CDR_any(tvb, pinfo, tree, item, offset, stream_is_big_endian, boundary, header);
172 proto_tree_add_boolean(tree, hf_CosEventComm_PullSupplier_try_pull_has_event, tvb, *offset-1, 1, get_CDR_boolean(tvb,offset));
174 break;
175 case USER_EXCEPTION:
176 break;
177 default:
178 /* Unknown Exception */
179 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
180 break;
181 } /* switch(header->rep_status) */
183 break;
184 default:
185 /* Unknown GIOP Message */
186 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
187 break;
188 } /* switch(header->message_type) */
192 * IDL:omg.org/CosEventComm/PullSupplier/pull:1.0
194 static void
195 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 char *operation _U_, bool stream_is_big_endian _U_)
197 switch(header->message_type) {
198 case Request:
199 break;
200 case Reply:
201 switch(header->rep_status) {
202 case NO_EXCEPTION:
203 get_CDR_any(tvb, pinfo, tree, item, offset, stream_is_big_endian, boundary, header);
205 break;
206 case USER_EXCEPTION:
207 break;
208 default:
209 /* Unknown Exception */
210 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
211 break;
212 } /* switch(header->rep_status) */
214 break;
215 default:
216 /* Unknown GIOP Message */
217 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
218 break;
219 } /* switch(header->message_type) */
223 * IDL:omg.org/CosEventComm/PushSupplier/disconnect_push_supplier:1.0
225 static void
226 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 char *operation _U_, bool stream_is_big_endian _U_)
228 switch(header->message_type) {
229 case Request:
230 break;
231 case Reply:
232 switch(header->rep_status) {
233 case NO_EXCEPTION:
234 /* Function returns void */
236 break;
237 case USER_EXCEPTION:
238 break;
239 default:
240 /* Unknown Exception */
241 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
242 break;
243 } /* switch(header->rep_status) */
245 break;
246 default:
247 /* Unknown GIOP Message */
248 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
249 break;
250 } /* switch(header->message_type) */
254 * IDL:omg.org/CosEventComm/PushConsumer/disconnect_push_consumer:1.0
256 static void
257 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 char *operation _U_, bool stream_is_big_endian _U_)
259 switch(header->message_type) {
260 case Request:
261 break;
262 case Reply:
263 switch(header->rep_status) {
264 case NO_EXCEPTION:
265 /* Function returns void */
267 break;
268 case USER_EXCEPTION:
269 break;
270 default:
271 /* Unknown Exception */
272 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
273 break;
274 } /* switch(header->rep_status) */
276 break;
277 default:
278 /* Unknown GIOP Message */
279 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
280 break;
281 } /* switch(header->message_type) */
285 * IDL:omg.org/CosEventComm/PushConsumer/push:1.0
287 static void
288 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 char *operation _U_, bool stream_is_big_endian _U_)
290 switch(header->message_type) {
291 case Request:
292 get_CDR_any(tvb, pinfo, tree, item, offset, stream_is_big_endian, boundary, header);
294 break;
295 case Reply:
296 switch(header->rep_status) {
297 case NO_EXCEPTION:
298 /* Function returns void */
300 break;
301 case USER_EXCEPTION:
302 break;
303 default:
304 /* Unknown Exception */
305 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
306 break;
307 } /* switch(header->rep_status) */
309 break;
310 default:
311 /* Unknown GIOP Message */
312 expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
313 break;
314 } /* switch(header->message_type) */
318 * Called once we accept the packet as being for us; it sets the
319 * Protocol and Info columns and creates the top-level protocol
320 * tree item.
322 static proto_tree *
323 start_dissecting(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset)
326 proto_item *ti = NULL;
327 proto_tree *tree = NULL; /* init later, inside if(tree) */
329 col_set_str(pinfo->cinfo, COL_PROTOCOL, "COSEVENTCOMM");
332 * Do not clear COL_INFO, as nothing is being written there by
333 * this dissector yet. So leave it as is from the GIOP dissector.
334 * TODO: add something useful to COL_INFO
335 * col_clear(pinfo->cinfo, COL_INFO);
338 if (ptree) {
339 ti = proto_tree_add_item(ptree, proto_coseventcomm, tvb, *offset, tvb_reported_length_remaining(tvb, *offset), ENC_NA);
340 tree = proto_item_add_subtree(ti, ett_coseventcomm);
342 return tree;
345 static proto_item*
346 process_RequestOperation(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, MessageHeader *header, const char *operation)
348 proto_item *pi;
349 if(header->message_type == Reply) {
350 /* fill-up info column */
351 col_append_fstr(pinfo->cinfo, COL_INFO, " op = %s",operation);
353 /* fill-up the field */
354 pi=proto_tree_add_string(ptree, hf_operationrequest, tvb, 0, 0, operation);
355 proto_item_set_generated(pi);
356 return pi;
359 static bool
360 dissect_coseventcomm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset, MessageHeader *header, const char *operation, char *idlname)
362 proto_item *item _U_;
363 proto_tree *tree _U_;
364 bool stream_is_big_endian = is_big_endian(header); /* get endianess */
366 /* If we have a USER Exception, then decode it and return */
367 if ((header->message_type == Reply) && (header->rep_status == USER_EXCEPTION)) {
368 return decode_user_exception(tvb, pinfo, ptree, offset, header, operation, stream_is_big_endian);
371 switch(header->message_type) {
373 case Request:
374 case Reply:
376 if (strcmp(operation, "disconnect_pull_consumer") == 0
377 && (!idlname || strcmp(idlname, "CosEventComm/PullConsumer") == 0)) {
378 item = process_RequestOperation(tvb, pinfo, ptree, header, operation); /* fill-up Request_Operation field & info column */
379 tree = start_dissecting(tvb, pinfo, ptree, offset);
380 decode_CosEventComm_PullConsumer_disconnect_pull_consumer(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
381 return true;
384 if (strcmp(operation, "disconnect_pull_supplier") == 0
385 && (!idlname || strcmp(idlname, "CosEventComm/PullSupplier") == 0)) {
386 item = process_RequestOperation(tvb, pinfo, ptree, header, operation); /* fill-up Request_Operation field & info column */
387 tree = start_dissecting(tvb, pinfo, ptree, offset);
388 decode_CosEventComm_PullSupplier_disconnect_pull_supplier(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
389 return true;
392 if (strcmp(operation, "try_pull") == 0
393 && (!idlname || strcmp(idlname, "CosEventComm/PullSupplier") == 0)) {
394 item = process_RequestOperation(tvb, pinfo, ptree, header, operation); /* fill-up Request_Operation field & info column */
395 tree = start_dissecting(tvb, pinfo, ptree, offset);
396 decode_CosEventComm_PullSupplier_try_pull(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
397 return true;
400 if (strcmp(operation, "pull") == 0
401 && (!idlname || strcmp(idlname, "CosEventComm/PullSupplier") == 0)) {
402 item = process_RequestOperation(tvb, pinfo, ptree, header, operation); /* fill-up Request_Operation field & info column */
403 tree = start_dissecting(tvb, pinfo, ptree, offset);
404 decode_CosEventComm_PullSupplier_pull(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
405 return true;
408 if (strcmp(operation, "disconnect_push_supplier") == 0
409 && (!idlname || strcmp(idlname, "CosEventComm/PushSupplier") == 0)) {
410 item = process_RequestOperation(tvb, pinfo, ptree, header, operation); /* fill-up Request_Operation field & info column */
411 tree = start_dissecting(tvb, pinfo, ptree, offset);
412 decode_CosEventComm_PushSupplier_disconnect_push_supplier(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
413 return true;
416 if (strcmp(operation, "disconnect_push_consumer") == 0
417 && (!idlname || strcmp(idlname, "CosEventComm/PushConsumer") == 0)) {
418 item = process_RequestOperation(tvb, pinfo, ptree, header, operation); /* fill-up Request_Operation field & info column */
419 tree = start_dissecting(tvb, pinfo, ptree, offset);
420 decode_CosEventComm_PushConsumer_disconnect_push_consumer(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
421 return true;
424 if (strcmp(operation, "push") == 0
425 && (!idlname || strcmp(idlname, "CosEventComm/PushConsumer") == 0)) {
426 item = process_RequestOperation(tvb, pinfo, ptree, header, operation); /* fill-up Request_Operation field & info column */
427 tree = start_dissecting(tvb, pinfo, ptree, offset);
428 decode_CosEventComm_PushConsumer_push(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
429 return true;
432 break;
434 case CancelRequest:
435 case LocateRequest:
436 case LocateReply:
437 case CloseConnection:
438 case MessageError:
439 case Fragment:
440 return false; /* not handled yet */
442 default:
443 return false; /* not handled yet */
445 } /* switch */
448 return false;
450 } /* End of main dissector */
453 /* Register the protocol with Wireshark */
454 void proto_register_giop_coseventcomm(void)
456 /* setup list of header fields */
457 static hf_register_info hf[] = {
458 /* field that indicates the currently ongoing request/reply exchange */
459 {&hf_operationrequest, {"Request_Operation","giop-coseventcomm.Request_Operation",FT_STRING,BASE_NONE,NULL,0x0,NULL,HFILL}},
460 /* Operation filters */
461 {&hf_CosEventComm_PullSupplier_try_pull_has_event, {"has_event","giop-coseventcomm.PullSupplier.try_pull.has_event",FT_BOOLEAN,8,NULL,0x01,NULL,HFILL}},
462 /* Attribute filters */
463 /* Struct filters */
464 /* User exception filters */
465 /* Union filters */
469 static ei_register_info ei[] = {
470 { &ei_coseventcomm_unknown_giop_msg, { "giop-coseventcomm.unknown_giop_msg", PI_PROTOCOL, PI_WARN, "Unknown GIOP message", EXPFILL }},
471 { &ei_coseventcomm_unknown_exception, { "giop-coseventcomm.unknown_exception", PI_PROTOCOL, PI_WARN, "Unknown exception", EXPFILL }},
472 { &ei_coseventcomm_unknown_reply_status, { "giop-coseventcomm.unknown_reply_status", PI_PROTOCOL, PI_WARN, "Unknown reply status", EXPFILL }},
475 /* setup protocol subtree array */
477 static int *ett[] = {
478 &ett_coseventcomm,
479 &ett_giop_struct,
480 &ett_giop_sequence,
481 &ett_giop_array,
482 &ett_giop_union,
485 expert_module_t* expert_coseventcomm;
488 /* Register the protocol name and description */
489 proto_coseventcomm = proto_register_protocol("Coseventcomm Dissector Using GIOP API" , "GIOP/COSEVENTCOMM", "giop-coseventcomm" );
490 proto_register_field_array(proto_coseventcomm, hf, array_length(hf));
491 proto_register_subtree_array(ett, array_length(ett));
493 expert_coseventcomm = expert_register_protocol(proto_coseventcomm);
494 expert_register_field_array(expert_coseventcomm, ei, array_length(ei));
497 /* register me as handler for these interfaces */
498 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 */
518 * Editor modelines - https://www.wireshark.org/tools/modelines.html
520 * Local Variables:
521 * c-basic-offset: 4
522 * tab-width: 8
523 * indent-tabs-mode: nil
524 * End:
526 * ex: set shiftwidth=4 tabstop=8 expandtab:
527 * :indentSize=4:tabSize=8:noTabs=true: