1 /* packet-coseventcomm.c
3 * Routines for IDL dissection
5 * Autogenerated from idl2wrs
6 * Copyright 2001 Frank Singleton <frank.singleton@ericsson.com>
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
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"
34 /* disable warning: "unreference local variable" */
35 #pragma warning(disable:4101)
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
)
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
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_
)
89 if (!header
->exception_id
)
93 return false; /* user exception not found */
97 * IDL:omg.org/CosEventComm/PullConsumer/disconnect_pull_consumer:1.0
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
) {
106 switch(header
->rep_status
) {
108 /* Function returns void */
114 /* Unknown Exception */
115 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_exception
, "Unknown exception %d", header
->rep_status
);
117 } /* switch(header->rep_status) */
121 /* Unknown GIOP Message */
122 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_giop_msg
, "Unknown GIOP message %d", header
->message_type
);
124 } /* switch(header->message_type) */
128 * IDL:omg.org/CosEventComm/PullSupplier/disconnect_pull_supplier:1.0
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
) {
137 switch(header
->rep_status
) {
139 /* Function returns void */
145 /* Unknown Exception */
146 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_exception
, "Unknown exception %d", header
->rep_status
);
148 } /* switch(header->rep_status) */
152 /* Unknown GIOP Message */
153 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_giop_msg
, "Unknown GIOP message %d", header
->message_type
);
155 } /* switch(header->message_type) */
159 * IDL:omg.org/CosEventComm/PullSupplier/try_pull:1.0
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
) {
168 switch(header
->rep_status
) {
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
));
178 /* Unknown Exception */
179 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_exception
, "Unknown exception %d", header
->rep_status
);
181 } /* switch(header->rep_status) */
185 /* Unknown GIOP Message */
186 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_giop_msg
, "Unknown GIOP message %d", header
->message_type
);
188 } /* switch(header->message_type) */
192 * IDL:omg.org/CosEventComm/PullSupplier/pull:1.0
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
) {
201 switch(header
->rep_status
) {
203 get_CDR_any(tvb
, pinfo
, tree
, item
, offset
, stream_is_big_endian
, boundary
, header
);
209 /* Unknown Exception */
210 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_exception
, "Unknown exception %d", header
->rep_status
);
212 } /* switch(header->rep_status) */
216 /* Unknown GIOP Message */
217 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_giop_msg
, "Unknown GIOP message %d", header
->message_type
);
219 } /* switch(header->message_type) */
223 * IDL:omg.org/CosEventComm/PushSupplier/disconnect_push_supplier:1.0
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
) {
232 switch(header
->rep_status
) {
234 /* Function returns void */
240 /* Unknown Exception */
241 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_exception
, "Unknown exception %d", header
->rep_status
);
243 } /* switch(header->rep_status) */
247 /* Unknown GIOP Message */
248 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_giop_msg
, "Unknown GIOP message %d", header
->message_type
);
250 } /* switch(header->message_type) */
254 * IDL:omg.org/CosEventComm/PushConsumer/disconnect_push_consumer:1.0
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
) {
263 switch(header
->rep_status
) {
265 /* Function returns void */
271 /* Unknown Exception */
272 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_exception
, "Unknown exception %d", header
->rep_status
);
274 } /* switch(header->rep_status) */
278 /* Unknown GIOP Message */
279 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_giop_msg
, "Unknown GIOP message %d", header
->message_type
);
281 } /* switch(header->message_type) */
285 * IDL:omg.org/CosEventComm/PushConsumer/push:1.0
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
) {
292 get_CDR_any(tvb
, pinfo
, tree
, item
, offset
, stream_is_big_endian
, boundary
, header
);
296 switch(header
->rep_status
) {
298 /* Function returns void */
304 /* Unknown Exception */
305 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_exception
, "Unknown exception %d", header
->rep_status
);
307 } /* switch(header->rep_status) */
311 /* Unknown GIOP Message */
312 expert_add_info_format(pinfo
, item
, &ei_coseventcomm_unknown_giop_msg
, "Unknown GIOP message %d", header
->message_type
);
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
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);
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
);
346 process_RequestOperation(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*ptree
, MessageHeader
*header
, const char *operation
)
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
);
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
) {
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
);
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
);
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
);
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
);
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
);
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
);
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
);
437 case CloseConnection
:
440 return false; /* not handled yet */
443 return false; /* not handled yet */
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 */
464 /* User exception 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
[] = {
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
523 * indent-tabs-mode: nil
526 * ex: set shiftwidth=4 tabstop=8 expandtab:
527 * :indentSize=4:tabSize=8:noTabs=true: