Regenerate GIOP dissector plugins (after change in generator !) for fix Warning found...
[obnox/wireshark/wip.git] / plugins / giop / packet-coseventcomm.c
1 /* packet-coseventcomm.c
2  *
3  * $Id$
4  *
5  * Routines for IDL dissection
6  *
7  * Autogenerated from idl2wrs
8  * Copyright 2001 Frank Singleton <frank.singleton@ericsson.com>
9  */
10
11
12 /*
13  * Wireshark - Network traffic analyzer
14  * By Gerald Combs
15  * Copyright 1999 - 2006 Gerald Combs
16  */
17
18
19 /*
20  * This program is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU General Public License
22  * as published by the Free Software Foundation; either version 2
23  * of the License, or (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28  * GNU General Public License for more details.
29  *
30  * You should have received a copy of the GNU General Public License
31  * along with this program; if not, write to the Free Software
32  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
33  */
34
35
36 #ifdef HAVE_CONFIG_H
37 # include "config.h"
38 #endif
39
40 #include <gmodule.h>
41
42 #include <string.h>
43 #include <glib.h>
44 #include <epan/packet.h>
45 #include <epan/proto.h>
46 #include <epan/dissectors/packet-giop.h>
47
48 #ifndef ENABLE_STATIC
49 G_MODULE_EXPORT const gchar version[] = "0.0.1";
50 #endif
51
52 #ifdef _MSC_VER
53 /* disable warning: "unreference local variable" */
54 #pragma warning(disable:4101)
55 #endif
56
57
58 static proto_tree *start_dissecting(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset);
59
60
61
62 /* Struct prototype declaration Start */
63
64
65 /* Struct prototype declaration End */
66
67
68 /* Union prototype declaration Start */
69
70
71 /* Union prototype declaration End */
72
73
74
75 /* Initialise the protocol and subtree pointers */
76
77 static int proto_coseventcomm = -1;
78
79 static gint ett_coseventcomm = -1;
80
81
82 /* Initialise the initial Alignment */
83
84 static guint32  boundary = GIOP_HEADER_SIZE;  /* initial value */
85
86
87
88 /* Initialise the Registered fields */
89
90 /* TODO - Use registered fields */
91
92 /*
93  * IDL Operations Start
94  */
95  
96 static const char CosEventComm_PushConsumer_push_op[] = "push" ;
97 static const char CosEventComm_PushConsumer_disconnect_push_consumer_op[] = "disconnect_push_consumer" ;
98 static const char CosEventComm_PushSupplier_disconnect_push_supplier_op[] = "disconnect_push_supplier" ;
99 static const char CosEventComm_PullSupplier_pull_op[] = "pull" ;
100 static const char CosEventComm_PullSupplier_try_pull_op[] = "try_pull" ;
101 static const char CosEventComm_PullSupplier_disconnect_pull_supplier_op[] = "disconnect_pull_supplier" ;
102 static const char CosEventComm_PullConsumer_disconnect_pull_consumer_op[] = "disconnect_pull_consumer" ;
103
104 /*
105  * IDL Operations End
106  */
107
108 /*  Begin Exception (containing members) String  Declare  */
109
110
111
112 /*  End Exception (containing members) String Declare  */
113
114 /*
115  * IDL Attributes Start
116  */
117  
118
119 /*
120  * IDL Attributes End
121  */
122
123 /*
124  * IDL Enums Start
125  */
126  
127 /*
128  * IDL Enums End
129  */
130  
131 /*  Begin Exception Helper Functions  */
132
133
134
135 /*  End Exception Helper Functions  */
136
137 /*
138  * Main delegator for exception handling
139  *
140  */
141
142 static gboolean decode_user_exception(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *ptree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_, gboolean stream_is_big_endian _U_) {
143
144     /*gboolean stream_is_big_endian _U_;*/                        /* big endianess */
145     proto_tree *tree _U_;
146
147     if (!header->exception_id)
148         return FALSE;
149
150
151
152     return FALSE;    /* user exception not found */
153
154 }
155
156 /*  Begin Attribute Helper Functions  */
157
158
159 /*  End Attribute Helper Functions  */
160
161 /*
162  * IDL:omg.org/CosEventComm/PushConsumer/push:1.0
163  */
164
165 static void decode_CosEventComm_PushConsumer_push(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_, gboolean stream_is_big_endian _U_) {
166
167     
168     /* Operation specific Variable declarations Begin */
169
170     
171     /* Operation specific Variable declarations End */
172
173     
174     switch(header->message_type) {
175
176     case Request:
177
178         get_CDR_any(tvb,tree,offset,stream_is_big_endian, boundary, header);
179
180         break;
181
182     case Reply:
183
184         switch(header->rep_status) {
185
186         case NO_EXCEPTION:
187
188             /* Function returns void */
189
190             break;
191
192         case USER_EXCEPTION:
193
194             break;
195
196         default:
197
198             /* Unknown Exception */
199
200             g_warning("Unknown Exception ");
201
202             break;
203
204         
205         }   /* switch(header->message_type) */
206
207         break;
208
209     default:
210
211         /* Unknown GIOP Message */
212
213         g_warning("Unknown GIOP Message");
214
215         break;
216
217     } /* switch(header->message_type) */
218
219 }
220
221 /*
222  * IDL:omg.org/CosEventComm/PushConsumer/disconnect_push_consumer:1.0
223  */
224
225 static void decode_CosEventComm_PushConsumer_disconnect_push_consumer(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_, gboolean stream_is_big_endian _U_) {
226
227     
228     /* Operation specific Variable declarations Begin */
229
230     
231     /* Operation specific Variable declarations End */
232
233     
234     switch(header->message_type) {
235
236     case Request:
237
238         break;
239
240     case Reply:
241
242         switch(header->rep_status) {
243
244         case NO_EXCEPTION:
245
246             /* Function returns void */
247
248             break;
249
250         case USER_EXCEPTION:
251
252             break;
253
254         default:
255
256             /* Unknown Exception */
257
258             g_warning("Unknown Exception ");
259
260             break;
261
262         
263         }   /* switch(header->message_type) */
264
265         break;
266
267     default:
268
269         /* Unknown GIOP Message */
270
271         g_warning("Unknown GIOP Message");
272
273         break;
274
275     } /* switch(header->message_type) */
276
277 }
278
279 /*
280  * IDL:omg.org/CosEventComm/PushSupplier/disconnect_push_supplier:1.0
281  */
282
283 static void decode_CosEventComm_PushSupplier_disconnect_push_supplier(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_, gboolean stream_is_big_endian _U_) {
284
285     
286     /* Operation specific Variable declarations Begin */
287
288     
289     /* Operation specific Variable declarations End */
290
291     
292     switch(header->message_type) {
293
294     case Request:
295
296         break;
297
298     case Reply:
299
300         switch(header->rep_status) {
301
302         case NO_EXCEPTION:
303
304             /* Function returns void */
305
306             break;
307
308         case USER_EXCEPTION:
309
310             break;
311
312         default:
313
314             /* Unknown Exception */
315
316             g_warning("Unknown Exception ");
317
318             break;
319
320         
321         }   /* switch(header->message_type) */
322
323         break;
324
325     default:
326
327         /* Unknown GIOP Message */
328
329         g_warning("Unknown GIOP Message");
330
331         break;
332
333     } /* switch(header->message_type) */
334
335 }
336
337 /*
338  * IDL:omg.org/CosEventComm/PullSupplier/pull:1.0
339  */
340
341 static void decode_CosEventComm_PullSupplier_pull(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_, gboolean stream_is_big_endian _U_) {
342
343     
344     /* Operation specific Variable declarations Begin */
345
346     
347     /* Operation specific Variable declarations End */
348
349     
350     switch(header->message_type) {
351
352     case Request:
353
354         break;
355
356     case Reply:
357
358         switch(header->rep_status) {
359
360         case NO_EXCEPTION:
361
362             get_CDR_any(tvb,tree,offset,stream_is_big_endian, boundary, header);
363
364             break;
365
366         case USER_EXCEPTION:
367
368             break;
369
370         default:
371
372             /* Unknown Exception */
373
374             g_warning("Unknown Exception ");
375
376             break;
377
378         
379         }   /* switch(header->message_type) */
380
381         break;
382
383     default:
384
385         /* Unknown GIOP Message */
386
387         g_warning("Unknown GIOP Message");
388
389         break;
390
391     } /* switch(header->message_type) */
392
393 }
394
395 /*
396  * IDL:omg.org/CosEventComm/PullSupplier/try_pull:1.0
397  */
398
399 static void decode_CosEventComm_PullSupplier_try_pull(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_, gboolean stream_is_big_endian _U_) {
400
401     
402     /* Operation specific Variable declarations Begin */
403
404     guint8    u_octet1;
405     
406     /* Operation specific Variable declarations End */
407
408     
409     switch(header->message_type) {
410
411     case Request:
412
413         break;
414
415     case Reply:
416
417         switch(header->rep_status) {
418
419         case NO_EXCEPTION:
420
421             get_CDR_any(tvb,tree,offset,stream_is_big_endian, boundary, header);
422
423             u_octet1 = get_CDR_boolean(tvb,offset);
424             if (tree) {
425                proto_tree_add_text(tree,tvb,*offset-1,1,"has_event = %u",u_octet1);
426             }
427
428             break;
429
430         case USER_EXCEPTION:
431
432             break;
433
434         default:
435
436             /* Unknown Exception */
437
438             g_warning("Unknown Exception ");
439
440             break;
441
442         
443         }   /* switch(header->message_type) */
444
445         break;
446
447     default:
448
449         /* Unknown GIOP Message */
450
451         g_warning("Unknown GIOP Message");
452
453         break;
454
455     } /* switch(header->message_type) */
456
457 }
458
459 /*
460  * IDL:omg.org/CosEventComm/PullSupplier/disconnect_pull_supplier:1.0
461  */
462
463 static void decode_CosEventComm_PullSupplier_disconnect_pull_supplier(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_, gboolean stream_is_big_endian _U_) {
464
465     
466     /* Operation specific Variable declarations Begin */
467
468     
469     /* Operation specific Variable declarations End */
470
471     
472     switch(header->message_type) {
473
474     case Request:
475
476         break;
477
478     case Reply:
479
480         switch(header->rep_status) {
481
482         case NO_EXCEPTION:
483
484             /* Function returns void */
485
486             break;
487
488         case USER_EXCEPTION:
489
490             break;
491
492         default:
493
494             /* Unknown Exception */
495
496             g_warning("Unknown Exception ");
497
498             break;
499
500         
501         }   /* switch(header->message_type) */
502
503         break;
504
505     default:
506
507         /* Unknown GIOP Message */
508
509         g_warning("Unknown GIOP Message");
510
511         break;
512
513     } /* switch(header->message_type) */
514
515 }
516
517 /*
518  * IDL:omg.org/CosEventComm/PullConsumer/disconnect_pull_consumer:1.0
519  */
520
521 static void decode_CosEventComm_PullConsumer_disconnect_pull_consumer(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int *offset _U_, MessageHeader *header, gchar *operation _U_, gboolean stream_is_big_endian _U_) {
522
523     
524     /* Operation specific Variable declarations Begin */
525
526     
527     /* Operation specific Variable declarations End */
528
529     
530     switch(header->message_type) {
531
532     case Request:
533
534         break;
535
536     case Reply:
537
538         switch(header->rep_status) {
539
540         case NO_EXCEPTION:
541
542             /* Function returns void */
543
544             break;
545
546         case USER_EXCEPTION:
547
548             break;
549
550         default:
551
552             /* Unknown Exception */
553
554             g_warning("Unknown Exception ");
555
556             break;
557
558         
559         }   /* switch(header->message_type) */
560
561         break;
562
563     default:
564
565         /* Unknown GIOP Message */
566
567         g_warning("Unknown GIOP Message");
568
569         break;
570
571     } /* switch(header->message_type) */
572
573 }
574
575 /*
576  * Called once we accept the packet as being for us; it sets the
577  * Protocol and Info columns and creates the top-level protocol
578  * tree item.
579  */
580 static proto_tree *start_dissecting(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset) {
581
582     proto_item *ti = NULL;
583     proto_tree *tree = NULL;            /* init later, inside if(tree) */
584
585     col_set_str(pinfo->cinfo, COL_PROTOCOL, "COSEVENTCOMM");
586
587     /*
588      * Do not clear COL_INFO, as nothing is being written there by
589      * this dissector yet. So leave it as is from the GIOP dissector.
590      * TODO: add something useful to COL_INFO
591      *     col_clear(pinfo->cinfo, COL_INFO);
592      */
593
594     if (ptree) {
595         ti = proto_tree_add_item(ptree, proto_coseventcomm, tvb, *offset, -1, ENC_NA);
596         tree = proto_item_add_subtree(ti, ett_coseventcomm);
597     }
598     return tree;
599 }
600
601 static gboolean dissect_coseventcomm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int *offset, MessageHeader *header, gchar *operation, gchar *idlname) {
602
603     gboolean stream_is_big_endian;                        /* big endianess */
604     proto_tree *tree _U_;
605
606     stream_is_big_endian = is_big_endian(header);         /* get endianess  */
607
608     /* If we have a USER Exception, then decode it and return */
609
610     if ((header->message_type == Reply) && (header->rep_status == USER_EXCEPTION)) {
611
612        return decode_user_exception(tvb, pinfo, ptree, offset, header, operation, stream_is_big_endian);
613
614     }
615
616     switch(header->message_type) {
617
618     case Request:
619     case Reply:
620
621         if (strcmp(operation, CosEventComm_PushConsumer_push_op) == 0
622             && (!idlname || strcmp(idlname, "CosEventComm/PushConsumer") == 0)) {
623            tree = start_dissecting(tvb, pinfo, ptree, offset);
624            decode_CosEventComm_PushConsumer_push(tvb, pinfo, tree, offset, header, operation, stream_is_big_endian);
625            return TRUE;
626         }
627
628         if (strcmp(operation, CosEventComm_PushConsumer_disconnect_push_consumer_op) == 0
629             && (!idlname || strcmp(idlname, "CosEventComm/PushConsumer") == 0)) {
630            tree = start_dissecting(tvb, pinfo, ptree, offset);
631            decode_CosEventComm_PushConsumer_disconnect_push_consumer(tvb, pinfo, tree, offset, header, operation, stream_is_big_endian);
632            return TRUE;
633         }
634
635         if (strcmp(operation, CosEventComm_PushSupplier_disconnect_push_supplier_op) == 0
636             && (!idlname || strcmp(idlname, "CosEventComm/PushSupplier") == 0)) {
637            tree = start_dissecting(tvb, pinfo, ptree, offset);
638            decode_CosEventComm_PushSupplier_disconnect_push_supplier(tvb, pinfo, tree, offset, header, operation, stream_is_big_endian);
639            return TRUE;
640         }
641
642         if (strcmp(operation, CosEventComm_PullSupplier_pull_op) == 0
643             && (!idlname || strcmp(idlname, "CosEventComm/PullSupplier") == 0)) {
644            tree = start_dissecting(tvb, pinfo, ptree, offset);
645            decode_CosEventComm_PullSupplier_pull(tvb, pinfo, tree, offset, header, operation, stream_is_big_endian);
646            return TRUE;
647         }
648
649         if (strcmp(operation, CosEventComm_PullSupplier_try_pull_op) == 0
650             && (!idlname || strcmp(idlname, "CosEventComm/PullSupplier") == 0)) {
651            tree = start_dissecting(tvb, pinfo, ptree, offset);
652            decode_CosEventComm_PullSupplier_try_pull(tvb, pinfo, tree, offset, header, operation, stream_is_big_endian);
653            return TRUE;
654         }
655
656         if (strcmp(operation, CosEventComm_PullSupplier_disconnect_pull_supplier_op) == 0
657             && (!idlname || strcmp(idlname, "CosEventComm/PullSupplier") == 0)) {
658            tree = start_dissecting(tvb, pinfo, ptree, offset);
659            decode_CosEventComm_PullSupplier_disconnect_pull_supplier(tvb, pinfo, tree, offset, header, operation, stream_is_big_endian);
660            return TRUE;
661         }
662
663         if (strcmp(operation, CosEventComm_PullConsumer_disconnect_pull_consumer_op) == 0
664             && (!idlname || strcmp(idlname, "CosEventComm/PullConsumer") == 0)) {
665            tree = start_dissecting(tvb, pinfo, ptree, offset);
666            decode_CosEventComm_PullConsumer_disconnect_pull_consumer(tvb, pinfo, tree, offset, header, operation, stream_is_big_endian);
667            return TRUE;
668         }
669
670         
671         break;
672
673     case CancelRequest:
674     case LocateRequest:
675     case LocateReply:
676     case CloseConnection:
677     case MessageError:
678     case Fragment:
679        return FALSE;      /* not handled yet */
680
681     default:
682        return FALSE;      /* not handled yet */
683
684     }   /* switch */
685
686
687     return FALSE;
688
689 }  /* End of main dissector  */
690
691
692
693 /* Register the protocol with Wireshark */
694
695 void proto_register_giop_coseventcomm(void) {
696
697    /* setup list of header fields */
698
699 #if 0
700    static hf_register_info hf[] = {
701
702       /* no fields yet */
703
704    };
705 #endif
706
707    /* setup protocol subtree array */
708
709    static gint *ett[] = {
710       &ett_coseventcomm,
711    };
712
713    /* Register the protocol name and description */
714
715    proto_coseventcomm = proto_register_protocol("Coseventcomm Dissector Using GIOP API" , "COSEVENTCOMM", "giop-coseventcomm" );
716
717 #if 0
718    proto_register_field_array(proto_coseventcomm, hf, array_length(hf));
719 #endif
720    proto_register_subtree_array(ett,array_length(ett));
721
722 }
723
724
725 /* register me as handler for these interfaces */
726
727 void proto_register_handoff_giop_coseventcomm(void) {
728
729
730     
731     /* Register for Explicit Dissection */
732
733     register_giop_user_module(dissect_coseventcomm, "COSEVENTCOMM", "CosEventComm/PullConsumer", proto_coseventcomm );     /* explicit dissector */
734
735     
736     /* Register for Explicit Dissection */
737
738     register_giop_user_module(dissect_coseventcomm, "COSEVENTCOMM", "CosEventComm/PullSupplier", proto_coseventcomm );     /* explicit dissector */
739
740     
741     /* Register for Explicit Dissection */
742
743     register_giop_user_module(dissect_coseventcomm, "COSEVENTCOMM", "CosEventComm/PushConsumer", proto_coseventcomm );     /* explicit dissector */
744
745     
746     /* Register for Explicit Dissection */
747
748     register_giop_user_module(dissect_coseventcomm, "COSEVENTCOMM", "CosEventComm/PushSupplier", proto_coseventcomm );     /* explicit dissector */
749
750     
751     /* Register for Heuristic Dissection */
752
753     register_giop_user(dissect_coseventcomm, "COSEVENTCOMM" ,proto_coseventcomm);     /* heuristic dissector */
754
755
756 }
757
758
759 #ifndef ENABLE_STATIC
760
761 G_MODULE_EXPORT void
762 plugin_register(void)
763 {
764    if (proto_coseventcomm == -1) {
765      proto_register_giop_coseventcomm();
766    }
767 }
768
769 G_MODULE_EXPORT void
770 plugin_reg_handoff(void){
771    proto_register_handoff_giop_coseventcomm();
772 }
773 #endif
774