Coverage Report

Created: 2025-08-04 07:15

/src/wireshark/epan/dissectors/packet-coseventcomm.c
Line
Count
Source (jump to first uncovered line)
1
/* packet-coseventcomm.c
2
 *
3
 * Routines for IDL dissection
4
 *
5
 * Autogenerated from idl2wrs
6
 * Copyright 2001 Frank Singleton <frank.singleton@ericsson.com>
7
 */
8
9
10
/*
11
 * Wireshark - Network traffic analyzer
12
 * By Gerald Combs <gerald@wireshark.org>
13
 * Copyright 1998 Gerald Combs
14
 */
15
16
/*
17
 * SPDX-License-Identifier: GPL-2.0-or-later
18
 */
19
20
21
#include "config.h"
22
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>
29
30
#include "ws_diag_control.h"
31
#include "ws_compiler_tests.h"
32
33
#ifdef _MSC_VER
34
/* disable warning: "unreference local variable" */
35
#pragma warning(disable:4101)
36
#endif
37
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
44
45
void proto_register_giop_coseventcomm(void);
46
void proto_reg_handoff_giop_coseventcomm(void);
47
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;
55
56
57
/* Initialise the initial Alignment */
58
static uint32_t boundary = GIOP_HEADER_SIZE;  /* initial value */
59
60
static int hf_operationrequest;/* Request_Operation field */
61
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;
69
70
71
static proto_tree *start_dissecting(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset);
72
73
74
/*  Begin Exception Helper Functions  */
75
76
77
78
/*  End Exception Helper Functions  */
79
80
/*
81
 * Main delegator for exception handling
82
 *
83
 */
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_)
86
0
{
87
0
    proto_tree *tree _U_;
88
89
0
    if (!header->exception_id)
90
0
        return false;
91
92
93
0
    return false;    /* user exception not found */
94
0
}
95
96
/*
97
 * IDL:omg.org/CosEventComm/PullConsumer/disconnect_pull_consumer:1.0
98
 */
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_)
101
0
{
102
0
    switch(header->message_type) {
103
0
    case Request:
104
0
        break;
105
0
    case Reply:
106
0
        switch(header->rep_status) {
107
0
        case NO_EXCEPTION:
108
            /* Function returns void */
109
110
0
            break;
111
0
        case USER_EXCEPTION:
112
0
            break;
113
0
        default:
114
            /* Unknown Exception */
115
0
            expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
116
0
            break;
117
0
        }   /* switch(header->rep_status) */
118
119
0
        break;
120
0
    default:
121
        /* Unknown GIOP Message */
122
0
        expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
123
0
        break;
124
0
    } /* switch(header->message_type) */
125
0
}
126
127
/*
128
 * IDL:omg.org/CosEventComm/PullSupplier/disconnect_pull_supplier:1.0
129
 */
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_)
132
0
{
133
0
    switch(header->message_type) {
134
0
    case Request:
135
0
        break;
136
0
    case Reply:
137
0
        switch(header->rep_status) {
138
0
        case NO_EXCEPTION:
139
            /* Function returns void */
140
141
0
            break;
142
0
        case USER_EXCEPTION:
143
0
            break;
144
0
        default:
145
            /* Unknown Exception */
146
0
            expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
147
0
            break;
148
0
        }   /* switch(header->rep_status) */
149
150
0
        break;
151
0
    default:
152
        /* Unknown GIOP Message */
153
0
        expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
154
0
        break;
155
0
    } /* switch(header->message_type) */
156
0
}
157
158
/*
159
 * IDL:omg.org/CosEventComm/PullSupplier/try_pull:1.0
160
 */
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_)
163
0
{
164
0
    switch(header->message_type) {
165
0
    case Request:
166
0
        break;
167
0
    case Reply:
168
0
        switch(header->rep_status) {
169
0
        case NO_EXCEPTION:
170
0
            get_CDR_any(tvb, pinfo, tree, item, offset, stream_is_big_endian, boundary, header);
171
172
0
            proto_tree_add_boolean(tree, hf_CosEventComm_PullSupplier_try_pull_has_event, tvb, *offset-1, 1, get_CDR_boolean(tvb,offset));
173
174
0
            break;
175
0
        case USER_EXCEPTION:
176
0
            break;
177
0
        default:
178
            /* Unknown Exception */
179
0
            expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
180
0
            break;
181
0
        }   /* switch(header->rep_status) */
182
183
0
        break;
184
0
    default:
185
        /* Unknown GIOP Message */
186
0
        expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
187
0
        break;
188
0
    } /* switch(header->message_type) */
189
0
}
190
191
/*
192
 * IDL:omg.org/CosEventComm/PullSupplier/pull:1.0
193
 */
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_)
196
0
{
197
0
    switch(header->message_type) {
198
0
    case Request:
199
0
        break;
200
0
    case Reply:
201
0
        switch(header->rep_status) {
202
0
        case NO_EXCEPTION:
203
0
            get_CDR_any(tvb, pinfo, tree, item, offset, stream_is_big_endian, boundary, header);
204
205
0
            break;
206
0
        case USER_EXCEPTION:
207
0
            break;
208
0
        default:
209
            /* Unknown Exception */
210
0
            expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
211
0
            break;
212
0
        }   /* switch(header->rep_status) */
213
214
0
        break;
215
0
    default:
216
        /* Unknown GIOP Message */
217
0
        expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
218
0
        break;
219
0
    } /* switch(header->message_type) */
220
0
}
221
222
/*
223
 * IDL:omg.org/CosEventComm/PushSupplier/disconnect_push_supplier:1.0
224
 */
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_)
227
0
{
228
0
    switch(header->message_type) {
229
0
    case Request:
230
0
        break;
231
0
    case Reply:
232
0
        switch(header->rep_status) {
233
0
        case NO_EXCEPTION:
234
            /* Function returns void */
235
236
0
            break;
237
0
        case USER_EXCEPTION:
238
0
            break;
239
0
        default:
240
            /* Unknown Exception */
241
0
            expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
242
0
            break;
243
0
        }   /* switch(header->rep_status) */
244
245
0
        break;
246
0
    default:
247
        /* Unknown GIOP Message */
248
0
        expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
249
0
        break;
250
0
    } /* switch(header->message_type) */
251
0
}
252
253
/*
254
 * IDL:omg.org/CosEventComm/PushConsumer/disconnect_push_consumer:1.0
255
 */
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_)
258
0
{
259
0
    switch(header->message_type) {
260
0
    case Request:
261
0
        break;
262
0
    case Reply:
263
0
        switch(header->rep_status) {
264
0
        case NO_EXCEPTION:
265
            /* Function returns void */
266
267
0
            break;
268
0
        case USER_EXCEPTION:
269
0
            break;
270
0
        default:
271
            /* Unknown Exception */
272
0
            expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
273
0
            break;
274
0
        }   /* switch(header->rep_status) */
275
276
0
        break;
277
0
    default:
278
        /* Unknown GIOP Message */
279
0
        expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
280
0
        break;
281
0
    } /* switch(header->message_type) */
282
0
}
283
284
/*
285
 * IDL:omg.org/CosEventComm/PushConsumer/push:1.0
286
 */
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_)
289
0
{
290
0
    switch(header->message_type) {
291
0
    case Request:
292
0
        get_CDR_any(tvb, pinfo, tree, item, offset, stream_is_big_endian, boundary, header);
293
294
0
        break;
295
0
    case Reply:
296
0
        switch(header->rep_status) {
297
0
        case NO_EXCEPTION:
298
            /* Function returns void */
299
300
0
            break;
301
0
        case USER_EXCEPTION:
302
0
            break;
303
0
        default:
304
            /* Unknown Exception */
305
0
            expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_exception, "Unknown exception %d", header->rep_status);
306
0
            break;
307
0
        }   /* switch(header->rep_status) */
308
309
0
        break;
310
0
    default:
311
        /* Unknown GIOP Message */
312
0
        expert_add_info_format(pinfo, item, &ei_coseventcomm_unknown_giop_msg, "Unknown GIOP message %d", header->message_type);
313
0
        break;
314
0
    } /* switch(header->message_type) */
315
0
}
316
317
/*
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.
321
 */
322
static proto_tree *
323
start_dissecting(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset)
324
0
{
325
326
0
    proto_item *ti = NULL;
327
0
    proto_tree *tree = NULL;            /* init later, inside if(tree) */
328
329
0
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "COSEVENTCOMM");
330
331
    /*
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);
336
     */
337
338
0
    if (ptree) {
339
0
        ti = proto_tree_add_item(ptree, proto_coseventcomm, tvb, *offset, tvb_reported_length_remaining(tvb, *offset), ENC_NA);
340
0
        tree = proto_item_add_subtree(ti, ett_coseventcomm);
341
0
    }
342
0
    return tree;
343
0
}
344
345
static proto_item*
346
process_RequestOperation(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, MessageHeader *header, const char *operation)
347
0
{
348
0
    proto_item *pi;
349
0
    if(header->message_type == Reply) {
350
        /* fill-up info column */
351
0
        col_append_fstr(pinfo->cinfo, COL_INFO, " op = %s",operation);
352
0
    }
353
    /* fill-up the field */
354
0
    pi=proto_tree_add_string(ptree, hf_operationrequest, tvb, 0, 0, operation);
355
0
    proto_item_set_generated(pi);
356
0
    return pi;
357
0
}
358
359
static bool
360
dissect_coseventcomm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset, MessageHeader *header, const char *operation, char *idlname)
361
66
{
362
66
    proto_item *item _U_;
363
66
    proto_tree *tree _U_;
364
66
    bool stream_is_big_endian = is_big_endian(header); /* get endianess */
365
366
    /* If we have a USER Exception, then decode it and return */
367
66
    if ((header->message_type == Reply) && (header->rep_status == USER_EXCEPTION)) {
368
0
       return decode_user_exception(tvb, pinfo, ptree, offset, header, operation, stream_is_big_endian);
369
0
    }
370
371
66
    switch(header->message_type) {
372
373
66
    case Request:
374
66
    case Reply:
375
376
66
        if (strcmp(operation, "disconnect_pull_consumer") == 0
377
66
            && (!idlname || strcmp(idlname, "CosEventComm/PullConsumer") == 0)) {
378
0
            item = process_RequestOperation(tvb, pinfo, ptree, header, operation);  /* fill-up Request_Operation field & info column */
379
0
            tree = start_dissecting(tvb, pinfo, ptree, offset);
380
0
            decode_CosEventComm_PullConsumer_disconnect_pull_consumer(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
381
0
            return true;
382
0
        }
383
384
66
        if (strcmp(operation, "disconnect_pull_supplier") == 0
385
66
            && (!idlname || strcmp(idlname, "CosEventComm/PullSupplier") == 0)) {
386
0
            item = process_RequestOperation(tvb, pinfo, ptree, header, operation);  /* fill-up Request_Operation field & info column */
387
0
            tree = start_dissecting(tvb, pinfo, ptree, offset);
388
0
            decode_CosEventComm_PullSupplier_disconnect_pull_supplier(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
389
0
            return true;
390
0
        }
391
392
66
        if (strcmp(operation, "try_pull") == 0
393
66
            && (!idlname || strcmp(idlname, "CosEventComm/PullSupplier") == 0)) {
394
0
            item = process_RequestOperation(tvb, pinfo, ptree, header, operation);  /* fill-up Request_Operation field & info column */
395
0
            tree = start_dissecting(tvb, pinfo, ptree, offset);
396
0
            decode_CosEventComm_PullSupplier_try_pull(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
397
0
            return true;
398
0
        }
399
400
66
        if (strcmp(operation, "pull") == 0
401
66
            && (!idlname || strcmp(idlname, "CosEventComm/PullSupplier") == 0)) {
402
0
            item = process_RequestOperation(tvb, pinfo, ptree, header, operation);  /* fill-up Request_Operation field & info column */
403
0
            tree = start_dissecting(tvb, pinfo, ptree, offset);
404
0
            decode_CosEventComm_PullSupplier_pull(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
405
0
            return true;
406
0
        }
407
408
66
        if (strcmp(operation, "disconnect_push_supplier") == 0
409
66
            && (!idlname || strcmp(idlname, "CosEventComm/PushSupplier") == 0)) {
410
0
            item = process_RequestOperation(tvb, pinfo, ptree, header, operation);  /* fill-up Request_Operation field & info column */
411
0
            tree = start_dissecting(tvb, pinfo, ptree, offset);
412
0
            decode_CosEventComm_PushSupplier_disconnect_push_supplier(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
413
0
            return true;
414
0
        }
415
416
66
        if (strcmp(operation, "disconnect_push_consumer") == 0
417
66
            && (!idlname || strcmp(idlname, "CosEventComm/PushConsumer") == 0)) {
418
0
            item = process_RequestOperation(tvb, pinfo, ptree, header, operation);  /* fill-up Request_Operation field & info column */
419
0
            tree = start_dissecting(tvb, pinfo, ptree, offset);
420
0
            decode_CosEventComm_PushConsumer_disconnect_push_consumer(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
421
0
            return true;
422
0
        }
423
424
66
        if (strcmp(operation, "push") == 0
425
66
            && (!idlname || strcmp(idlname, "CosEventComm/PushConsumer") == 0)) {
426
0
            item = process_RequestOperation(tvb, pinfo, ptree, header, operation);  /* fill-up Request_Operation field & info column */
427
0
            tree = start_dissecting(tvb, pinfo, ptree, offset);
428
0
            decode_CosEventComm_PushConsumer_push(tvb, pinfo, tree, item, offset, header, operation, stream_is_big_endian);
429
0
            return true;
430
0
        }
431
432
66
        break;
433
434
66
    case CancelRequest:
435
0
    case LocateRequest:
436
0
    case LocateReply:
437
0
    case CloseConnection:
438
0
    case MessageError:
439
0
    case Fragment:
440
0
       return false;      /* not handled yet */
441
442
0
    default:
443
0
       return false;      /* not handled yet */
444
445
66
    }   /* switch */
446
447
448
66
    return false;
449
450
66
}  /* End of main dissector  */
451
452
453
/* Register the protocol with Wireshark */
454
void proto_register_giop_coseventcomm(void)
455
14
{
456
    /* setup list of header fields */
457
14
    static hf_register_info hf[] = {
458
        /* field that indicates the currently ongoing request/reply exchange */
459
14
            {&hf_operationrequest, {"Request_Operation","giop-coseventcomm.Request_Operation",FT_STRING,BASE_NONE,NULL,0x0,NULL,HFILL}},
460
        /* Operation filters */
461
14
        {&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 */
466
467
14
    };
468
469
14
    static ei_register_info ei[] = {
470
14
        { &ei_coseventcomm_unknown_giop_msg, { "giop-coseventcomm.unknown_giop_msg", PI_PROTOCOL, PI_WARN, "Unknown GIOP message", EXPFILL }},
471
14
        { &ei_coseventcomm_unknown_exception, { "giop-coseventcomm.unknown_exception", PI_PROTOCOL, PI_WARN, "Unknown exception", EXPFILL }},
472
14
        { &ei_coseventcomm_unknown_reply_status, { "giop-coseventcomm.unknown_reply_status", PI_PROTOCOL, PI_WARN, "Unknown reply status", EXPFILL }},
473
14
    };
474
475
    /* setup protocol subtree array */
476
477
14
    static int *ett[] = {
478
14
        &ett_coseventcomm,
479
14
        &ett_giop_struct,
480
14
        &ett_giop_sequence,
481
14
        &ett_giop_array,
482
14
        &ett_giop_union,
483
14
    };
484
485
14
    expert_module_t* expert_coseventcomm;
486
487
488
    /* Register the protocol name and description */
489
14
    proto_coseventcomm = proto_register_protocol("Coseventcomm Dissector Using GIOP API" , "GIOP/COSEVENTCOMM", "giop-coseventcomm" );
490
14
    proto_register_field_array(proto_coseventcomm, hf, array_length(hf));
491
14
    proto_register_subtree_array(ett, array_length(ett));
492
493
14
    expert_coseventcomm = expert_register_protocol(proto_coseventcomm);
494
14
    expert_register_field_array(expert_coseventcomm, ei, array_length(ei));
495
14
}
496
497
/* register me as handler for these interfaces */
498
void proto_reg_handoff_giop_coseventcomm(void)
499
14
{
500
    /* Register for Explicit Dissection */
501
14
    register_giop_user_module(dissect_coseventcomm, "COSEVENTCOMM", "CosEventComm/PullConsumer", proto_coseventcomm );     /* explicit dissector */
502
503
    /* Register for Explicit Dissection */
504
14
    register_giop_user_module(dissect_coseventcomm, "COSEVENTCOMM", "CosEventComm/PullSupplier", proto_coseventcomm );     /* explicit dissector */
505
506
    /* Register for Explicit Dissection */
507
14
    register_giop_user_module(dissect_coseventcomm, "COSEVENTCOMM", "CosEventComm/PushConsumer", proto_coseventcomm );     /* explicit dissector */
508
509
    /* Register for Explicit Dissection */
510
14
    register_giop_user_module(dissect_coseventcomm, "COSEVENTCOMM", "CosEventComm/PushSupplier", proto_coseventcomm );     /* explicit dissector */
511
512
    /* Register for Heuristic Dissection */
513
14
    register_giop_user(dissect_coseventcomm, "COSEVENTCOMM" ,proto_coseventcomm);     /* heuristic dissector */
514
515
14
}
516
517
/*
518
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
519
 *
520
 * Local Variables:
521
 * c-basic-offset: 4
522
 * tab-width: 8
523
 * indent-tabs-mode: nil
524
 * End:
525
 *
526
 * ex: set shiftwidth=4 tabstop=8 expandtab:
527
 * :indentSize=4:tabSize=8:noTabs=true:
528
 */